forked from LinkedDataFragments/Server.Java
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adapted the unit tests to the latest changes
- Loading branch information
Olaf Hartig
committed
Dec 25, 2015
1 parent
1232964
commit a66e354
Showing
3 changed files
with
56 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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; | ||
|
||
/** | ||
|
@@ -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. | ||
|
@@ -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 ); | ||
|
@@ -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(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
|
@@ -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 { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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; | ||
|
@@ -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 { | ||
|