You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@marmotta.apache.org by ja...@apache.org on 2013/08/26 17:26:52 UTC
[3/8] git commit: MARMOTTA-287: Added
RDFSchemaRepositoryConnectionTest for kiwi-reasoner
MARMOTTA-287: Added RDFSchemaRepositoryConnectionTest for kiwi-reasoner
Project: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/commit/30d5e83d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/tree/30d5e83d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/diff/30d5e83d
Branch: refs/heads/develop
Commit: 30d5e83dae4478d97a765ad056292cf9562ee6f1
Parents: 3631605
Author: Jakob Frank <ja...@apache.org>
Authored: Mon Aug 26 15:54:54 2013 +0200
Committer: Jakob Frank <ja...@apache.org>
Committed: Mon Aug 26 15:55:07 2013 +0200
----------------------------------------------------------------------
libraries/kiwi/kiwi-reasoner/pom.xml | 6 +-
.../KiWiRDFSchemaRepositoryConnectionTest.java | 126 +++++++++++++++++++
.../kiwi/reasoner/test/sesame/rdfs.skwrl | 36 ++++++
3 files changed, 167 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/30d5e83d/libraries/kiwi/kiwi-reasoner/pom.xml
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-reasoner/pom.xml b/libraries/kiwi/kiwi-reasoner/pom.xml
index 67e9a97..cdc67aa 100644
--- a/libraries/kiwi/kiwi-reasoner/pom.xml
+++ b/libraries/kiwi/kiwi-reasoner/pom.xml
@@ -56,7 +56,6 @@
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
- <version>1.7</version>
<executions>
<execution>
<id>add-source</id>
@@ -208,6 +207,11 @@
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.openrdf.sesame</groupId>
+ <artifactId>sesame-store-testsuite</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
</project>
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/30d5e83d/libraries/kiwi/kiwi-reasoner/src/test/java/org/apache/marmotta/kiwi/reasoner/test/sesame/KiWiRDFSchemaRepositoryConnectionTest.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-reasoner/src/test/java/org/apache/marmotta/kiwi/reasoner/test/sesame/KiWiRDFSchemaRepositoryConnectionTest.java b/libraries/kiwi/kiwi-reasoner/src/test/java/org/apache/marmotta/kiwi/reasoner/test/sesame/KiWiRDFSchemaRepositoryConnectionTest.java
new file mode 100644
index 0000000..494e476
--- /dev/null
+++ b/libraries/kiwi/kiwi-reasoner/src/test/java/org/apache/marmotta/kiwi/reasoner/test/sesame/KiWiRDFSchemaRepositoryConnectionTest.java
@@ -0,0 +1,126 @@
+/*
+ * 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.
+ */
+package org.apache.marmotta.kiwi.reasoner.test.sesame;
+
+import org.apache.marmotta.kiwi.config.KiWiConfiguration;
+import org.apache.marmotta.kiwi.reasoner.engine.ReasoningConfiguration;
+import org.apache.marmotta.kiwi.reasoner.sail.KiWiReasoningSail;
+import org.apache.marmotta.kiwi.sail.KiWiStore;
+import org.apache.marmotta.kiwi.test.junit.KiWiDatabaseRunner;
+import org.apache.marmotta.kiwi.transactions.sail.KiWiTransactionalSail;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.openrdf.model.vocabulary.RDF;
+import org.openrdf.model.vocabulary.RDFS;
+import org.openrdf.repository.RDFSchemaRepositoryConnectionTest;
+import org.openrdf.repository.Repository;
+import org.openrdf.repository.RepositoryConnection;
+import org.openrdf.repository.RepositoryException;
+import org.openrdf.repository.base.RepositoryConnectionWrapper;
+import org.openrdf.repository.base.RepositoryWrapper;
+import org.openrdf.repository.sail.SailRepository;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Run the {@link KiWiRDFSchemaRepositoryConnectionTest}s.
+ * @author Jakob Frank <ja...@apache.org>
+ *
+ */
+@RunWith(KiWiDatabaseRunner.class)
+public class KiWiRDFSchemaRepositoryConnectionTest extends RDFSchemaRepositoryConnectionTest {
+
+ public Logger log = LoggerFactory.getLogger(this.getClass());
+
+ private final KiWiConfiguration config;
+ private KiWiReasoningSail rsail;
+
+ public KiWiRDFSchemaRepositoryConnectionTest(KiWiConfiguration config) {
+ this.config = config;
+ }
+
+ /* (non-Javadoc)
+ * @see org.openrdf.repository.RepositoryConnectionTest#createRepository()
+ */
+ @Override
+ protected Repository createRepository() throws Exception {
+ KiWiStore sail = new KiWiStore(config);
+ KiWiTransactionalSail tsail = new KiWiTransactionalSail(sail);
+ rsail = new KiWiReasoningSail(tsail, new ReasoningConfiguration());
+
+
+ return new RepositoryWrapper(new SailRepository(rsail)) {
+ @Override
+ public RepositoryConnection getConnection()
+ throws RepositoryException {
+ return new RepositoryConnectionWrapper(this, super.getConnection()) {
+ @Override
+ public void commit() throws RepositoryException {
+ super.commit();
+
+ // wait for the reasoner to finish
+ try {
+ while(rsail.getEngine().isRunning()) {
+ log.info("sleeping for 100ms to let engine finish processing ... ");
+ Thread.sleep(100);
+ }
+ Thread.sleep(100);
+ log.info("sleeping for 100ms to let engine finish processing ... ");
+ } catch (InterruptedException e) {
+ throw new RepositoryException("Could not finish reasoning", e);
+ }
+ }
+ };
+ }
+ };
+ }
+
+ @Override
+ @Before
+ public void setUp() throws Exception {
+ super.setUp();
+
+ log.info("Setting up reasoning for RDFS");
+ rsail.addProgram("rdfs", this.getClass().getResourceAsStream("rdfs.skwrl"));
+ }
+
+ @Override
+ @Test
+ public void testExplicitFlag() throws Exception {
+ // We need at least _some_ data to infer...
+ testCon.begin();
+ testCon.add(bob, RDF.TYPE, RDFS.RESOURCE);
+ testCon.commit();
+
+ super.testExplicitFlag();
+ }
+
+ @Override
+ @Test
+ @Ignore("in KiWi, inferencing is triggered on commit")
+ public void testInferencerQueryDuringTransaction() throws Exception {
+ }
+
+ @Override
+ @Test
+ @Ignore("in KiWi, inferencing is triggered on commit")
+ public void testInferencerTransactionIsolation() throws Exception {
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/30d5e83d/libraries/kiwi/kiwi-reasoner/src/test/resources/org/apache/marmotta/kiwi/reasoner/test/sesame/rdfs.skwrl
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-reasoner/src/test/resources/org/apache/marmotta/kiwi/reasoner/test/sesame/rdfs.skwrl b/libraries/kiwi/kiwi-reasoner/src/test/resources/org/apache/marmotta/kiwi/reasoner/test/sesame/rdfs.skwrl
new file mode 100644
index 0000000..75294d8
--- /dev/null
+++ b/libraries/kiwi/kiwi-reasoner/src/test/resources/org/apache/marmotta/kiwi/reasoner/test/sesame/rdfs.skwrl
@@ -0,0 +1,36 @@
+/*
+ * 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.
+ */
+/* rules taken from http://www.w3.org/TR/2004/REC-rdf-mt-20040210/#RDFRules */
+@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
+@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
+@prefix xsd: <http://www.w3.org/2001/XMLSchema#>
+@prefix foaf: <http://xmlns.com/foaf/0.1/>
+
+rdf1 : ($u $a $y) -> ($a rdf:type rdf:Property)
+rdfs2 : ($a rdfs:domain $x), ($u $a $y) -> ($u rdf:type $x)
+rdfs3 : ($a rdfs:range $x), ($u $a $v) -> ($v rdf:type $x)
+rdfs4a : ($u $a $x) -> ($u rdf:type rdfs:Resource)
+rdfs5 : ($u rdfs:subPropertyOf $v), ($v rdfs:subPropertyOf $x) -> ($u rdfs:subPropertyOf $x)
+rdfs6 : ($u rdf:type rdf:Property) -> ($u rdfs:subPropertyOf $u)
+rdfs7 : ($a rdfs:subPropertyOf $b), ($u $a $y) -> ($u $b $y)
+rdfs8 : ($u rdf:type rdfs:Class) -> ($u rdfs:subClassOf rdfs:Resource)
+rdfs9 : ($u rdfs:subClassOf $x), ($v rdf:type $u) -> ($v rdf:type $x)
+rdfs10 : ($u rdf:type rdfs:Class) -> ($u rdfs:subClassOf $u)
+rdfs11 : ($u rdfs:subClassOf $v), ($v rdfs:subClassOf $x) -> ($u rdfs:subClassOf $x)
+rdfs12 : ($u rdf:type rdfs:ContainerMembershipProperty) -> ($u rdfs:subPropertyOf rdfs:member)
+rdfs13 : ($u rdf:type rdfs:Datatype) -> ($u rdfs:subClassOf rdfs:Literal)