You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@marmotta.apache.org by ss...@apache.org on 2013/09/30 18:44:49 UTC

[12/50] [abbrv] git commit: add an additional test to verity that the error described in MARMOTTA-283 does not happen anymore (or at least cannot reproduced)

add an additional test to verity that the error described in MARMOTTA-283 does not happen anymore (or at least cannot reproduced)


Project: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/commit/213495cc
Tree: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/tree/213495cc
Diff: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/diff/213495cc

Branch: refs/heads/master
Commit: 213495ccd5846b2c6a130bad9bb5eabb3d9cd1af
Parents: 58baf97
Author: tkurz <tk...@apache.org>
Authored: Wed Sep 11 11:12:54 2013 +0200
Committer: tkurz <tk...@apache.org>
Committed: Wed Sep 11 11:12:54 2013 +0200

----------------------------------------------------------------------
 .../marmotta/kiwi/test/RepositoryTest.java      | 80 ++++++++++++++++++++
 1 file changed, 80 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/213495cc/libraries/kiwi/kiwi-triplestore/src/test/java/org/apache/marmotta/kiwi/test/RepositoryTest.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-triplestore/src/test/java/org/apache/marmotta/kiwi/test/RepositoryTest.java b/libraries/kiwi/kiwi-triplestore/src/test/java/org/apache/marmotta/kiwi/test/RepositoryTest.java
index 9d2fd3d..f18413f 100644
--- a/libraries/kiwi/kiwi-triplestore/src/test/java/org/apache/marmotta/kiwi/test/RepositoryTest.java
+++ b/libraries/kiwi/kiwi-triplestore/src/test/java/org/apache/marmotta/kiwi/test/RepositoryTest.java
@@ -672,4 +672,84 @@ public class RepositoryTest {
         }
     }
 
+    /**
+     * This test is for a strange bug that happens when running SPARQL updates that delete and reinsert a triple in
+     * the same transaction. It is similar to #testMARMOTTA283, but simulates the issue in more detail.
+     * See https://issues.apache.org/jira/browse/MARMOTTA-283
+     */
+    @Test
+    public void testMARMOTTA283_2() throws RepositoryException, RDFParseException, IOException, MalformedQueryException, UpdateExecutionException {
+
+        //insert quadruples
+        String insert =
+                "WITH <http://resource.org/video>" +
+                "INSERT {" +
+                "   <http://resource.org/video> <http://ontology.org#hasFragment> <http://resource.org/fragment1>." +
+                "   <http://resource.org/annotation1> <http://ontology.org#hasTarget> <http://resource.org/fragment1>." +
+                "   <http://resource.org/annotation1> <http://ontology.org#hasBody> <http://resource.org/subject1>." +
+                "   <http://resource.org/fragment1> <http://ontology.org#shows> <http://resource.org/subject1>." +
+                "} WHERE {}";
+
+        RepositoryConnection connectionInsert = repository.getConnection();
+        try {
+            Update u = connectionInsert.prepareUpdate(QueryLanguage.SPARQL, insert);
+            u.execute();
+            connectionInsert.commit();
+        } finally {
+            connectionInsert.close();
+        }
+
+        //update quadruples
+        String update =
+                "WITH <http://resource.org/video>" +
+                "DELETE { " +
+                "   ?annotation ?p ?v." +
+                "   ?fragment ?r ?s." +
+                "   <http://resource.org/video> <http://ontology.org#hasFragment> ?fragment." +
+                "} INSERT {" +
+                "   <http://resource.org/video> <http://ontology.org#hasFragment> <http://resource.org/fragment1>." +
+                "   <http://resource.org/annotation1> <http://ontology.org#hasTarget> <http://resource.org/fragment1>." +
+                "   <http://resource.org/annotation1> <http://ontology.org#hasBody> <http://resource.org/subject1>." +
+                "   <http://resource.org/fragment1> <http://ontology.org#shows> <http://resource.org/subject1>." +
+                "} WHERE {" +
+                "   ?annotation <http://ontology.org#hasTarget> ?fragment." +
+                "   ?annotation ?p ?v." +
+                "   OPTIONAL {" +
+                "       ?fragment ?r ?s" +
+                "   }" +
+                "   FILTER (?fragment = <http://resource.org/fragment1>)" +
+                "} ";
+
+        RepositoryConnection connectionUpdate = repository.getConnection();
+        try {
+            Update u = connectionUpdate.prepareUpdate(QueryLanguage.SPARQL, update);
+            u.execute();
+            connectionUpdate.commit();
+        } finally {
+            connectionUpdate.close();
+        }
+
+        //check quadruples
+        RepositoryConnection connectionVerify = repository.getConnection();
+        try {
+            URI video = repository.getValueFactory().createURI("http://resource.org/video");
+            URI hasFragment  = repository.getValueFactory().createURI("http://ontology.org#hasFragment");
+            URI fragment = repository.getValueFactory().createURI("http://resource.org/fragment1");
+            URI annotation = repository.getValueFactory().createURI("http://resource.org/annotation1");
+            URI hasTarget = repository.getValueFactory().createURI("http://ontology.org#hasTarget");
+            URI hasBody = repository.getValueFactory().createURI("http://ontology.org#hasBody");
+            URI subject = repository.getValueFactory().createURI("http://resource.org/subject1");
+            URI shows = repository.getValueFactory().createURI("http://ontology.org#shows");
+
+            Assert.assertTrue(connectionVerify.hasStatement(video,hasFragment,fragment,true,video));
+            Assert.assertTrue(connectionVerify.hasStatement(annotation,hasTarget,fragment,true,video));
+            Assert.assertTrue(connectionVerify.hasStatement(annotation,hasBody,subject,true,video));
+            Assert.assertTrue(connectionVerify.hasStatement(fragment,shows,subject,true,video));
+
+            connectionVerify.commit();
+        } finally {
+            connectionVerify.close();
+        }
+    }
+
 }