MARMOTTA-584: reordered methods
Project: http://git-wip-us.apache.org/repos/asf/marmotta/repo Commit: http://git-wip-us.apache.org/repos/asf/marmotta/commit/b76a32c1 Tree: http://git-wip-us.apache.org/repos/asf/marmotta/tree/b76a32c1 Diff: http://git-wip-us.apache.org/repos/asf/marmotta/diff/b76a32c1 Branch: refs/heads/MARMOTTA-584 Commit: b76a32c1088c007494499b81c4283766a3c6949e Parents: d233388 Author: Sergio Fernández <[email protected]> Authored: Fri Sep 11 12:50:53 2015 +0200 Committer: Sergio Fernández <[email protected]> Committed: Fri Sep 11 12:50:53 2015 +0200 ---------------------------------------------------------------------- .../geosparql/GeoSPARQLFunctionsTest.java | 111 +++++++++---------- 1 file changed, 55 insertions(+), 56 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/marmotta/blob/b76a32c1/libraries/kiwi/kiwi-geosparql/src/test/java/org/apache/marmotta/kiwi/sparql/geosparql/GeoSPARQLFunctionsTest.java ---------------------------------------------------------------------- diff --git a/libraries/kiwi/kiwi-geosparql/src/test/java/org/apache/marmotta/kiwi/sparql/geosparql/GeoSPARQLFunctionsTest.java b/libraries/kiwi/kiwi-geosparql/src/test/java/org/apache/marmotta/kiwi/sparql/geosparql/GeoSPARQLFunctionsTest.java index ac6eb55..1c79d61 100644 --- a/libraries/kiwi/kiwi-geosparql/src/test/java/org/apache/marmotta/kiwi/sparql/geosparql/GeoSPARQLFunctionsTest.java +++ b/libraries/kiwi/kiwi-geosparql/src/test/java/org/apache/marmotta/kiwi/sparql/geosparql/GeoSPARQLFunctionsTest.java @@ -48,13 +48,13 @@ import java.sql.SQLException; import java.util.List; /** - * Test suite for all the functions of GeoSPARQL implemented. + * Test suite for all GeoSPARQL implemented functions. * * There is 35 test cases for each function: - * Simple Features Topological Relations (8) - * Egenhofer Topological Relations (8) - * RCC8 Topological Relations (8) - * Non-Topological Functions (11) + * - Simple Features Topological Relations (8) + * - Egenhofer Topological Relations (8) + * - RCC8 Topological Relations (8) + * - Non-Topological Functions (11) * * @author Xavier Sumba ([email protected]) * @author Sergio Fernández ([email protected]) @@ -81,7 +81,6 @@ public class GeoSPARQLFunctionsTest { public void initDatabase() throws RepositoryException, IOException, RDFParseException { Assume.assumeTrue(String.format("PostgreSQL not available! (using %s)", this.dbConfig.getDialect().getClass().getSimpleName()), PostgreSQLDialect.class.equals(this.dbConfig.getDialect().getClass())); - Assume.assumeTrue("PostGIS not available!", checkPostGIS(dbConfig)); store = new KiWiStore(dbConfig); @@ -160,6 +159,56 @@ public class GeoSPARQLFunctionsTest { } } + private void testQueryBoolean(String filename, String function) throws Exception { + String queryString = IOUtils.toString(this.getClass().getResourceAsStream("/" + filename), "UTF-8"); + + RepositoryConnection conn = repository.getConnection(); + try { + + conn.begin(); + + TupleQuery query1 = conn.prepareTupleQuery(QueryLanguage.SPARQL, queryString); + TupleQueryResult result1 = query1.evaluate(); + + conn.commit(); + + Assert.assertTrue(result1.hasNext()); + + List<BindingSet> results = Iterations.asList(result1); + + Assert.assertTrue(Boolean.parseBoolean(results.get(0).getValue(function).stringValue())); + } catch (RepositoryException ex) { + conn.rollback(); + } finally { + conn.close(); + } + } + + private void testQueryGeometry(String filename) throws Exception { + String queryString = IOUtils.toString(this.getClass().getResourceAsStream("/" + filename), "UTF-8"); + + RepositoryConnection conn = repository.getConnection(); + try { + + conn.begin(); + + TupleQuery query1 = conn.prepareTupleQuery(QueryLanguage.SPARQL, queryString); + TupleQueryResult result1 = query1.evaluate(); + + conn.commit(); + + Assert.assertTrue(result1.hasNext()); + + List<BindingSet> results = Iterations.asList(result1); + + Assert.assertEquals(1, results.size()); + } catch (RepositoryException ex) { + conn.rollback(); + } finally { + conn.close(); + } + } + @Test public void testSfContains() throws Exception { testQueryBoolean("sfContains.sparql", "contains"); @@ -335,54 +384,4 @@ public class GeoSPARQLFunctionsTest { testQueryBoolean("rcc8ntppi.sparql", "rcc8ntppi"); } - private void testQueryBoolean(String filename, String function) throws Exception { - String queryString = IOUtils.toString(this.getClass().getResourceAsStream("/" + filename), "UTF-8"); - - RepositoryConnection conn = repository.getConnection(); - try { - - conn.begin(); - - TupleQuery query1 = conn.prepareTupleQuery(QueryLanguage.SPARQL, queryString); - TupleQueryResult result1 = query1.evaluate(); - - conn.commit(); - - Assert.assertTrue(result1.hasNext()); - - List<BindingSet> results = Iterations.asList(result1); - - Assert.assertTrue(Boolean.parseBoolean(results.get(0).getValue(function).stringValue())); - } catch (RepositoryException ex) { - conn.rollback(); - } finally { - conn.close(); - } - } - - private void testQueryGeometry(String filename) throws Exception { - String queryString = IOUtils.toString(this.getClass().getResourceAsStream("/" + filename), "UTF-8"); - - RepositoryConnection conn = repository.getConnection(); - try { - - conn.begin(); - - TupleQuery query1 = conn.prepareTupleQuery(QueryLanguage.SPARQL, queryString); - TupleQueryResult result1 = query1.evaluate(); - - conn.commit(); - - Assert.assertTrue(result1.hasNext()); - - List<BindingSet> results = Iterations.asList(result1); - - Assert.assertEquals(1, results.size()); - } catch (RepositoryException ex) { - conn.rollback(); - } finally { - conn.close(); - } - } - }
