You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@marmotta.apache.org by wi...@apache.org on 2016/07/01 12:16:36 UTC
[16/25] marmotta git commit: MARMOTTA-640: reorganized test
infrastrcuture, and added new query reported by user
MARMOTTA-640: reorganized test infrastrcuture, and added new query reported by user
Project: http://git-wip-us.apache.org/repos/asf/marmotta/repo
Commit: http://git-wip-us.apache.org/repos/asf/marmotta/commit/05ecd8a8
Tree: http://git-wip-us.apache.org/repos/asf/marmotta/tree/05ecd8a8
Diff: http://git-wip-us.apache.org/repos/asf/marmotta/diff/05ecd8a8
Branch: refs/heads/MARMOTTA-584
Commit: 05ecd8a8b827a04a5ed142427b3a2d93ba408e77
Parents: 7df4029
Author: Sergio Fern�ndez <wi...@apache.org>
Authored: Mon Jun 20 09:10:07 2016 +0200
Committer: Sergio Fern�ndez <wi...@apache.org>
Committed: Mon Jun 20 09:10:07 2016 +0200
----------------------------------------------------------------------
.../kiwi/sparql/builder/SQLBuilder.java | 2 +-
.../kiwi/sparql/test/KiWiSparqlTest.java | 36 +++++++-------
.../kiwi/sparql/test/MARMOTTA-640.sparql | 33 -------------
.../kiwi/sparql/test/MARMOTTA-640_1.sparql | 33 +++++++++++++
.../kiwi/sparql/test/MARMOTTA-640_2.sparql | 51 ++++++++++++++++++++
5 files changed, 103 insertions(+), 52 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/marmotta/blob/05ecd8a8/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/builder/SQLBuilder.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/builder/SQLBuilder.java b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/builder/SQLBuilder.java
index e706a7a..9ae8927 100644
--- a/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/builder/SQLBuilder.java
+++ b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/builder/SQLBuilder.java
@@ -615,7 +615,7 @@ public class SQLBuilder {
for(SQLVariable v : vars) {
if(v.getProjectionType() != ValueType.NONE && (projectedVars.isEmpty() || projectedVars.contains(v.getSparqlName()))) {
- String projectedName = v.getName();
+ final String projectedName = v.getName();
if (v.getExpressions() != null && v.getExpressions().size() > 0) {
String fromName = v.getExpressions().get(0);
http://git-wip-us.apache.org/repos/asf/marmotta/blob/05ecd8a8/libraries/kiwi/kiwi-sparql/src/test/java/org/apache/marmotta/kiwi/sparql/test/KiWiSparqlTest.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-sparql/src/test/java/org/apache/marmotta/kiwi/sparql/test/KiWiSparqlTest.java b/libraries/kiwi/kiwi-sparql/src/test/java/org/apache/marmotta/kiwi/sparql/test/KiWiSparqlTest.java
index aa52bde..9ab8d3d 100644
--- a/libraries/kiwi/kiwi-sparql/src/test/java/org/apache/marmotta/kiwi/sparql/test/KiWiSparqlTest.java
+++ b/libraries/kiwi/kiwi-sparql/src/test/java/org/apache/marmotta/kiwi/sparql/test/KiWiSparqlTest.java
@@ -56,7 +56,6 @@ import java.util.Set;
* @author Sergio Fern�mdez
*/
@RunWith(KiWiDatabaseRunner.class)
-@KiWiDatabaseRunner.ForDialects(PostgreSQLDialect.class)
public class KiWiSparqlTest {
final Logger log = LoggerFactory.getLogger(this.getClass());
@@ -131,12 +130,12 @@ public class KiWiSparqlTest {
*/
@Test
public void testMarmotta578() throws Exception {
- testQuery("MARMOTTA-578.sparql");
+ testQueryCompareResults("MARMOTTA-578.sparql");
}
//TODO: generalize this infrastructure code also used by KiWiSparqlJoinTest
- private void testQuery(String filename) throws Exception {
+ private void testQueryCompareResults(String filename) throws Exception {
String queryString = IOUtils.toString(this.getClass().getResourceAsStream(filename), "UTF-8");
RepositoryConnection conn1 = repository.getConnection();
@@ -184,7 +183,6 @@ public class KiWiSparqlTest {
Assert.assertTrue("binding " + p + " from reference set not found in result set", set1.contains(p));
}
-
Assert.assertTrue(CollectionUtils.isEqualCollection(set1, set2));
}
@@ -328,33 +326,35 @@ public class KiWiSparqlTest {
testMarmotta627("SELECT ( 2.00*4.00 as ?c ) WHERE {}", 8.00);
}
- @Test
- public void testMarmotta640() throws Exception {
+ private void testQueryEvaluation(String queryString) throws RepositoryException, MalformedQueryException, QueryEvaluationException {
RepositoryConnection conn = repository.getConnection();
try {
conn.begin();
- String queryString = IOUtils.toString(this.getClass().getResourceAsStream("MARMOTTA-640.sparql"), "UTF-8");
TupleQuery query = conn.prepareTupleQuery(QueryLanguage.SPARQL, queryString);
TupleQueryResult results = query.evaluate();
- //TODO: if we get some sample data, we could improve the test
results.close();
+ conn.commit();
} finally {
conn.close();
}
}
@Test
+ public void testMarmotta640_1() throws Exception {
+ final String queryString = IOUtils.toString(this.getClass().getResourceAsStream("MARMOTTA-640_1.sparql"), "UTF-8");
+ testQueryEvaluation(queryString);
+ }
+
+ @Test
+ public void testMarmotta640_2() throws Exception {
+ final String queryString = IOUtils.toString(this.getClass().getResourceAsStream("MARMOTTA-640_2.sparql"), "UTF-8");
+ testQueryEvaluation(queryString);
+ }
+
+ @Test
public void testMarmotta640Regresion() throws Exception {
- RepositoryConnection conn = repository.getConnection();
- try {
- conn.begin();
- String queryString = "SELECT * WHERE { { ?x ?y ?z } UNION { ?x ?y2 ?z2 } }";
- TupleQuery query = conn.prepareTupleQuery(QueryLanguage.SPARQL, queryString);
- TupleQueryResult results = query.evaluate();
- results.close();
- } finally {
- conn.close();
- }
+ final String queryString = "SELECT * WHERE { { ?x ?y ?z } UNION { ?x ?y2 ?z2 } }";
+ testQueryEvaluation(queryString);
}
}
http://git-wip-us.apache.org/repos/asf/marmotta/blob/05ecd8a8/libraries/kiwi/kiwi-sparql/src/test/resources/org/apache/marmotta/kiwi/sparql/test/MARMOTTA-640.sparql
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-sparql/src/test/resources/org/apache/marmotta/kiwi/sparql/test/MARMOTTA-640.sparql b/libraries/kiwi/kiwi-sparql/src/test/resources/org/apache/marmotta/kiwi/sparql/test/MARMOTTA-640.sparql
deleted file mode 100644
index d2c2a42..0000000
--- a/libraries/kiwi/kiwi-sparql/src/test/resources/org/apache/marmotta/kiwi/sparql/test/MARMOTTA-640.sparql
+++ /dev/null
@@ -1,33 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
-PREFIX void: <http://rdfs.org/ns/void#>
-PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
-
-SELECT *
-WHERE {
- {
- <http://resources.opengeospatial.org/def/voc/examples/mdg> rdf:type ?___0
- OPTIONAL { ?___0 rdfs:label ?___1 }
- } UNION {
- <http://resources.opengeospatial.org/def/voc/examples/mdg> rdfs:label ?___2
- } UNION {
- <http://resources.opengeospatial.org/def/voc/examples/mdg> void:sparqlendpoint ?___10
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/marmotta/blob/05ecd8a8/libraries/kiwi/kiwi-sparql/src/test/resources/org/apache/marmotta/kiwi/sparql/test/MARMOTTA-640_1.sparql
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-sparql/src/test/resources/org/apache/marmotta/kiwi/sparql/test/MARMOTTA-640_1.sparql b/libraries/kiwi/kiwi-sparql/src/test/resources/org/apache/marmotta/kiwi/sparql/test/MARMOTTA-640_1.sparql
new file mode 100644
index 0000000..d2c2a42
--- /dev/null
+++ b/libraries/kiwi/kiwi-sparql/src/test/resources/org/apache/marmotta/kiwi/sparql/test/MARMOTTA-640_1.sparql
@@ -0,0 +1,33 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
+PREFIX void: <http://rdfs.org/ns/void#>
+PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
+
+SELECT *
+WHERE {
+ {
+ <http://resources.opengeospatial.org/def/voc/examples/mdg> rdf:type ?___0
+ OPTIONAL { ?___0 rdfs:label ?___1 }
+ } UNION {
+ <http://resources.opengeospatial.org/def/voc/examples/mdg> rdfs:label ?___2
+ } UNION {
+ <http://resources.opengeospatial.org/def/voc/examples/mdg> void:sparqlendpoint ?___10
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/marmotta/blob/05ecd8a8/libraries/kiwi/kiwi-sparql/src/test/resources/org/apache/marmotta/kiwi/sparql/test/MARMOTTA-640_2.sparql
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-sparql/src/test/resources/org/apache/marmotta/kiwi/sparql/test/MARMOTTA-640_2.sparql b/libraries/kiwi/kiwi-sparql/src/test/resources/org/apache/marmotta/kiwi/sparql/test/MARMOTTA-640_2.sparql
new file mode 100644
index 0000000..69f5aa9
--- /dev/null
+++ b/libraries/kiwi/kiwi-sparql/src/test/resources/org/apache/marmotta/kiwi/sparql/test/MARMOTTA-640_2.sparql
@@ -0,0 +1,51 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+PREFIX dcterms: <http://purl.org/dc/terms/>
+PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
+PREFIX void: <http://rdfs.org/ns/void#>
+PREFIX lid: <http://lid.foo>
+
+SELECT *
+WHERE
+ { { { <http://resources.opengeospatial.org/def/voc/examples/mdg> rdf:type ?___0 }
+ OPTIONAL
+ { { ?___0 rdfs:label ?___1 } }
+ }
+ UNION
+ { <http://resources.opengeospatial.org/def/voc/examples/mdg> rdfs:label ?___2 }
+ UNION
+ { { <http://resources.opengeospatial.org/def/voc/examples/mdg> void:feature ?___3 }
+ OPTIONAL
+ { { ?___3 rdfs:label ?___4 }
+ UNION
+ { ?___3 lid:viewType ?___5 }
+ UNION
+ { { ?___3 dcterms:hasFormat ?___6 }
+ OPTIONAL
+ { { ?___6 lid:ldatoken ?___7 } }
+ }
+ UNION
+ { ?___3 lid:featurescope ?___8 }
+ UNION
+ { ?___3 lid:viewName ?___9 }
+ }
+ }
+ UNION
+ { <http://resources.opengeospatial.org/def/voc/examples/mdg> void:sparqlendpoint ?___10 }
+ }