-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ issue #10 ] Added integration tests from Chapter 2 of
- Loading branch information
agazzarini
committed
Aug 25, 2014
1 parent
268e125
commit db78bf8
Showing
29 changed files
with
220 additions
and
83 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
...ests/src/test/java/org/gazzax/labs/jena/nosql/fwk/SparqlConstructIntegrationTestCase.java
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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package org.gazzax.labs.jena.nosql.fwk; | ||
|
||
import static org.gazzax.labs.jena.nosql.fwk.TestUtility.DUMMY_BASE_URI; | ||
import static org.junit.Assert.assertTrue; | ||
|
||
import java.io.File; | ||
|
||
import com.hp.hpl.jena.query.Query; | ||
import com.hp.hpl.jena.query.QueryExecution; | ||
import com.hp.hpl.jena.query.QueryExecutionFactory; | ||
import com.hp.hpl.jena.query.QueryFactory; | ||
import com.hp.hpl.jena.rdf.model.Model; | ||
import com.hp.hpl.jena.rdf.model.ModelFactory; | ||
|
||
/** | ||
* Supertype layer for all SPARQL integration tests. | ||
* | ||
* @author Andrea Gazzarini | ||
* @since 1.0 | ||
*/ | ||
public abstract class SparqlConstructIntegrationTestCase extends SparqlIntegrationTestCase { | ||
@Override | ||
protected void executeTestWithFile(final String filename) throws Exception { | ||
final Query query = QueryFactory.create(queryString(filename + ".rq")); | ||
final QueryExecution execution = QueryExecutionFactory.create(query, dataset); | ||
final Model rs = execution.execConstruct(); | ||
|
||
final Model model = ModelFactory.createDefaultModel().read(new File(EXAMPLES_DIR + File.separator + chapter() + File.separator, filename + ".rs").toURI().toString(), DUMMY_BASE_URI, "TTL"); | ||
|
||
assertTrue(rs.isIsomorphicWith(model)); | ||
} | ||
} |
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
45 changes: 45 additions & 0 deletions
45
...n-tests/src/test/java/org/gazzax/labs/jena/nosql/fwk/SparqlSelectIntegrationTestCase.java
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 |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package org.gazzax.labs.jena.nosql.fwk; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
import java.io.IOException; | ||
|
||
import com.hp.hpl.jena.query.Query; | ||
import com.hp.hpl.jena.query.QueryExecution; | ||
import com.hp.hpl.jena.query.QueryExecutionFactory; | ||
import com.hp.hpl.jena.query.QueryFactory; | ||
import com.hp.hpl.jena.query.ResultSet; | ||
import com.hp.hpl.jena.query.ResultSetFormatter; | ||
|
||
/** | ||
* Supertype layer for all SPARQL integration tests. | ||
* | ||
* @author Andrea Gazzarini | ||
* @since 1.0 | ||
*/ | ||
public abstract class SparqlSelectIntegrationTestCase extends SparqlIntegrationTestCase { | ||
@Override | ||
protected void executeTestWithFile(final String filename) throws Exception { | ||
final Query query = QueryFactory.create(queryString(filename + ".rq")); | ||
final QueryExecution execution = QueryExecutionFactory.create(query, dataset); | ||
final ResultSet rs = execution.execSelect(); | ||
|
||
final String s = ResultSetFormatter.asText(rs, query).trim(); | ||
|
||
assertEquals( | ||
results(filename + ".rs").trim(), | ||
s.trim()); | ||
execution.close(); | ||
} | ||
|
||
/** | ||
* Builds a string (from the file associated with this test) with the expected query results. | ||
* | ||
* @param resultsFileName the results filename. | ||
* @return a string (from the file associated with this test) with the expected query results. | ||
* @throws IOException in case of I/O failure while reading the file. | ||
*/ | ||
protected String results(final String resultsFileName) throws IOException { | ||
return readFile(resultsFileName); | ||
} | ||
} |
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
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
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
17 changes: 17 additions & 0 deletions
17
...t/java/org/gazzax/labs/jena/nosql/fwk/w3c/Ch2_5_CreatingValuesWithExpressions_ITCase.java
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package org.gazzax.labs.jena.nosql.fwk.w3c; | ||
|
||
import org.gazzax.labs.jena.nosql.fwk.SparqlSelectIntegrationTestCase; | ||
|
||
/** | ||
* SPARQL Integration test with examples taken from http://www.w3.org/TR/sparql11-query. | ||
* | ||
* @see http://www.w3.org/TR/sparql11-query/#CreatingValuesWithExpressions | ||
* @author Andrea Gazzarini | ||
* @since 1.0 | ||
*/ | ||
public class Ch2_5_CreatingValuesWithExpressions_ITCase extends SparqlSelectIntegrationTestCase { | ||
@Override | ||
protected String chapter() { | ||
return "2.5"; | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
...ests/src/test/java/org/gazzax/labs/jena/nosql/fwk/w3c/Ch2_6_BuildingRDFGraphs_ITCase.java
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package org.gazzax.labs.jena.nosql.fwk.w3c; | ||
|
||
import org.gazzax.labs.jena.nosql.fwk.SparqlConstructIntegrationTestCase; | ||
|
||
/** | ||
* SPARQL Integration test with examples taken from http://www.w3.org/TR/sparql11-query. | ||
* | ||
* @see http://www.w3.org/TR/sparql11-query/#constructGraph | ||
* @author Andrea Gazzarini | ||
* @since 1.0 | ||
*/ | ||
public class Ch2_6_BuildingRDFGraphs_ITCase extends SparqlConstructIntegrationTestCase { | ||
@Override | ||
protected String chapter() { | ||
return "2.6"; | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 6 additions & 0 deletions
6
jena-nosql-integration-tests/src/test/resources/w3c/2.3/ex3.rq
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
PREFIX dt: <http://example.org/datatype#> | ||
PREFIX ns: <http://example.org/ns#> | ||
PREFIX : <http://example.org/ns#> | ||
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> | ||
|
||
SELECT ?v WHERE { ?v ?p 42 } |
5 changes: 5 additions & 0 deletions
5
jena-nosql-integration-tests/src/test/resources/w3c/2.3/ex3.rs
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
------ | ||
| v | | ||
====== | ||
| :y | | ||
------ |
6 changes: 6 additions & 0 deletions
6
jena-nosql-integration-tests/src/test/resources/w3c/2.3/ex4.rq
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
PREFIX dt: <http://example.org/datatype#> | ||
PREFIX ns: <http://example.org/ns#> | ||
PREFIX : <http://example.org/ns#> | ||
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> | ||
|
||
SELECT ?v WHERE { ?v ?p "abc"^^<http://example.org/datatype#specialDatatype> } |
5 changes: 5 additions & 0 deletions
5
jena-nosql-integration-tests/src/test/resources/w3c/2.3/ex4.rs
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
------ | ||
| v | | ||
====== | ||
| :z | | ||
------ |
4 changes: 4 additions & 0 deletions
4
jena-nosql-integration-tests/src/test/resources/w3c/2.5/data.ttl
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
@prefix foaf: <http://xmlns.com/foaf/0.1/> . | ||
|
||
_:a foaf:givenName "John" . | ||
_:a foaf:surname "Doe" . |
Oops, something went wrong.