Skip to content

Commit

Permalink
adapted the unit tests to the latest changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Olaf Hartig committed Dec 25, 2015
1 parent 1232964 commit a66e354
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,18 @@
import org.linkeddatafragments.datasource.IDataSource;
import org.linkeddatafragments.datasource.IFragmentRequestProcessor;
import org.linkeddatafragments.fragments.LinkedDataFragment;
import org.linkeddatafragments.fragments.tpf.TriplePatternElement;
import org.linkeddatafragments.fragments.tpf.TriplePatternFragment;
import org.linkeddatafragments.fragments.tpf.TriplePatternFragmentRequest;
import org.linkeddatafragments.fragments.tpf.TriplePatternFragmentRequestImpl;
import org.linkeddatafragments.util.TriplePatternElementParser;


/**
*
* @author Bart Hanssens <[email protected]>
*/
public abstract class DataSourceTest {
public abstract class DataSourceTest<TermType,VarType> {
private static IDataSource ds;

/**
Expand All @@ -43,6 +46,9 @@ public static IDataSource getDatasource() {
public static void setDatasource(IDataSource ds) {
DataSourceTest.ds = ds;
}

protected abstract TriplePatternElementParser<TermType,VarType>
getTriplePatternElementParser();

/**
* Copy the demo triple in the jar to a temp file.
Expand Down Expand Up @@ -84,15 +90,18 @@ public static JsonObject createConfig(String title, String desc, String type) {
*/
@Test
public void testEmpty() {
TriplePatternFragmentRequest request = new TriplePatternFragmentRequest() {
public boolean isPageRequest() { return true; }
public long getPageNumber() { return 1L; }
public String getFragmentURL() { return "http://example.org/f"; }
public String getDatasetURL() { return "http://example.org/"; }
public String getSubject() { return "http://nothing.ldf.org"; }
public String getPredicate() { return null; }
public String getObject() { return null; }
};
final TriplePatternElementParser<TermType,VarType> tpeParser =
getTriplePatternElementParser();

final TriplePatternFragmentRequest<TermType,VarType> request =
new TriplePatternFragmentRequestImpl<TermType,VarType>(
"http://example.org/f", // fragmentURL
"http://example.org/", // datasetURL,
true, // pageNumberWasRequested,
1L, //pageNumber,
tpeParser.parseIntoTriplePatternElement("http://nothing.ldf.org"), // subject,
tpeParser.parseIntoTriplePatternElement(null), // predicate,
tpeParser.parseIntoTriplePatternElement(null) ); //object

final IFragmentRequestProcessor proc = getDatasource().getRequestProcessor();
final LinkedDataFragment ldf = proc.createRequestedFragment( request );
Expand All @@ -109,14 +118,25 @@ public void testEmpty() {
*/
@Test
public void testEstimate() {
TriplePatternFragmentRequest request = new TriplePatternFragmentRequest() {
final TriplePatternElementParser<TermType,VarType> tpeParser =
getTriplePatternElementParser();

final TriplePatternFragmentRequest<TermType,VarType> request =
new TriplePatternFragmentRequest<TermType,VarType>() {
public boolean isPageRequest() { return true; }
public long getPageNumber() { return 1L; }
public String getFragmentURL() { return "http://example.org/f"; }
public String getDatasetURL() { return "http://example.org/"; }
public String getSubject() { return "http://data.gov.be/catalog/ckanvl"; }
public String getPredicate() { return null; }
public String getObject() { return null; }

public TriplePatternElement<TermType,VarType> getSubject() {
return tpeParser.parseIntoTriplePatternElement("http://data.gov.be/catalog/ckanvl");
}
public TriplePatternElement<TermType,VarType> getPredicate() {
return tpeParser.parseIntoTriplePatternElement(null);
}
public TriplePatternElement<TermType,VarType> getObject() {
return tpeParser.parseIntoTriplePatternElement(null);
}
};

final IFragmentRequestProcessor proc = getDatasource().getRequestProcessor();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
package test.java.org.linkeddatafragments.datasource;

import com.google.gson.JsonObject;
import com.hp.hpl.jena.rdf.model.RDFNode;

import java.io.File;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.linkeddatafragments.datasource.DataSourceFactory;
import org.linkeddatafragments.datasource.hdt.HdtDataSourceType;
import org.linkeddatafragments.util.TriplePatternElementParser;
import org.linkeddatafragments.util.TriplePatternElementParserForJena;
import org.rdfhdt.hdt.enums.RDFNotation;
import org.rdfhdt.hdt.hdt.HDT;
import org.rdfhdt.hdt.hdt.HDTManager;
Expand All @@ -17,10 +21,16 @@
*
* @author Bart Hanssens <[email protected]>
*/
public class HdtDataSourceTest extends DataSourceTest {
public class HdtDataSourceTest extends DataSourceTest<RDFNode,String> {

private static File hdtfile;

@Override
protected TriplePatternElementParser<RDFNode,String>
getTriplePatternElementParser()
{
return TriplePatternElementParserForJena.getInstance();
}

@BeforeClass
public static void setUpClass() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import com.hp.hpl.jena.query.Dataset;
import com.hp.hpl.jena.rdf.model.Model;
import com.hp.hpl.jena.rdf.model.RDFNode;
import com.hp.hpl.jena.tdb.TDBFactory;

import java.io.File;
Expand All @@ -20,14 +21,23 @@

import org.linkeddatafragments.datasource.DataSourceFactory;
import org.linkeddatafragments.datasource.tdb.JenaTDBDataSourceType;
import org.linkeddatafragments.util.TriplePatternElementParser;
import org.linkeddatafragments.util.TriplePatternElementParserForJena;

/**
*
* @author Bart Hanssens <[email protected]>
*/
public class JenaTDBDataSourceTest extends DataSourceTest {
public class JenaTDBDataSourceTest extends DataSourceTest<RDFNode,String> {
private static File jena;
private static Dataset dataset;

@Override
protected TriplePatternElementParser<RDFNode,String>
getTriplePatternElementParser()
{
return TriplePatternElementParserForJena.getInstance();
}

@BeforeClass
public static void setUpClass() throws Exception {
Expand Down

0 comments on commit a66e354

Please sign in to comment.