marmotta-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sschaff...@apache.org
Subject [1/2] git commit: try reproducting MARMOTTA-283
Date Mon, 09 Sep 2013 15:46:42 GMT
Updated Branches:
  refs/heads/develop 71d76587c -> d34df1dcc


try reproducting MARMOTTA-283


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

Branch: refs/heads/develop
Commit: 9117321a5434daf8a2d738dbd6613f402d9288ad
Parents: 28a108f
Author: Sebastian Schaffert <sschaffert@apache.org>
Authored: Mon Sep 9 17:46:18 2013 +0200
Committer: Sebastian Schaffert <sschaffert@apache.org>
Committed: Mon Sep 9 17:46:18 2013 +0200

----------------------------------------------------------------------
 .../marmotta/kiwi/test/RepositoryTest.java      | 55 ++++++++++++++++++--
 1 file changed, 51 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/9117321a/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 f8817b7..fba985a 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
@@ -66,7 +66,7 @@ import com.google.common.collect.Iterables;
 
 /**
  * Test the Sesame repository functionality backed by the KiWi triple store. 
- * 
+ *
  * @author Sebastian Schaffert (sschaffert@apache.org)
  */
 @RunWith(KiWiDatabaseRunner.class)
@@ -76,7 +76,7 @@ public class RepositoryTest {
 
     private Repository repository;
 
-	private KiWiStore store;
+    private KiWiStore store;
 
     private final KiWiConfiguration kiwiConfiguration;
 
@@ -85,10 +85,10 @@ public class RepositoryTest {
 
     }
 
-	@Before
+    @Before
     public void initDatabase() throws RepositoryException {
         store = new KiWiStore(kiwiConfiguration);
-		repository = new SailRepository(store);
+        repository = new SailRepository(store);
         repository.initialize();
     }
 
@@ -622,4 +622,51 @@ 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. See https://issues.apache.org/jira/browse/MARMOTTA-283
+     */
+    @Test
+    public void testMARMOTTA283() throws RepositoryException, RDFParseException, IOException,
MalformedQueryException, UpdateExecutionException {
+
+        InputStream rdfXML = this.getClass().getResourceAsStream("demo-data.foaf");
+        assumeThat("Could not load test-data: demo-data.foaf", rdfXML, notNullValue(InputStream.class));
+
+        RepositoryConnection connectionRDF = repository.getConnection();
+        try {
+            connectionRDF.add(rdfXML, "http://localhost/foaf/", RDFFormat.RDFXML);
+            connectionRDF.commit();
+        } finally {
+            connectionRDF.close();
+        }
+
+
+        String update = "DELETE { ?s ?p ?o } INSERT { <http://localhost:8080/LMF/resource/hans_meier>
<http://xmlns.com/foaf/0.1/name> \"Hans Meier\" . <http://localhost:8080/LMF/resource/hans_meier>
<http://xmlns.com/foaf/0.1/based_near> <http://dbpedia.org/resource/Traunstein>
} WHERE { ?s ?p ?o . FILTER ( ?s = <http://localhost:8080/LMF/resource/hans_meier> )
}";
+
+        RepositoryConnection connectionUpdate = repository.getConnection();
+        try {
+            Update u = connectionUpdate.prepareUpdate(QueryLanguage.SPARQL, update);
+            u.execute();
+            connectionUpdate.commit();
+        } finally {
+            connectionUpdate.close();
+        }
+
+        // now there should be two triples
+        RepositoryConnection connectionVerify = repository.getConnection();
+        try {
+            URI hans_meier = repository.getValueFactory().createURI("http://localhost:8080/LMF/resource/hans_meier");
+            URI foaf_name  = repository.getValueFactory().createURI("http://xmlns.com/foaf/0.1/name");
+            URI foaf_based_near = repository.getValueFactory().createURI("http://xmlns.com/foaf/0.1/based_near");
+            URI traunstein = repository.getValueFactory().createURI("http://dbpedia.org/resource/Traunstein");
+
+            Assert.assertTrue(connectionVerify.hasStatement(hans_meier,foaf_name,null, true));
+            Assert.assertTrue(connectionVerify.hasStatement(hans_meier,foaf_based_near,traunstein,
true));
+
+            connectionVerify.commit();
+        } finally {
+            connectionVerify.close();
+        }
+    }
+
 }


Mime
View raw message