commonsrdf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject [6/6] incubator-commonsrdf git commit: Jena and RDF4j integratoin test
Date Mon, 05 Sep 2016 15:36:12 GMT
Jena and RDF4j integratoin test


Project: http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/commit/84c70320
Tree: http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/tree/84c70320
Diff: http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/diff/84c70320

Branch: refs/heads/rdf4j-jena-compat
Commit: 84c703204170f11b9b4410add47fa723744e7f80
Parents: d7b7c78
Author: Stian Soiland-Reyes <stain@apache.org>
Authored: Mon Sep 5 16:34:45 2016 +0100
Committer: Stian Soiland-Reyes <stain@apache.org>
Committed: Mon Sep 5 16:35:45 2016 +0100

----------------------------------------------------------------------
 integration-tests/pom.xml                       | 67 +++++++++++++++++
 .../rdf/integrationtests/JenaRDF4JTest.java     | 78 ++++++++++++++++++++
 pom.xml                                         |  1 +
 3 files changed, 146 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/84c70320/integration-tests/pom.xml
----------------------------------------------------------------------
diff --git a/integration-tests/pom.xml b/integration-tests/pom.xml
new file mode 100644
index 0000000..196f4d5
--- /dev/null
+++ b/integration-tests/pom.xml
@@ -0,0 +1,67 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    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.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+	<modelVersion>4.0.0</modelVersion>
+	<parent>
+		<groupId>org.apache.commons</groupId>
+		<artifactId>commons-rdf-parent</artifactId>
+		<version>0.3.0-incubating-SNAPSHOT</version>
+	</parent>
+	<artifactId>commons-rdf-integration-tests</artifactId>
+	<dependencies>
+	<dependency>
+		<groupId>${project.groupId}</groupId>
+		<artifactId>commons-rdf-api</artifactId>
+		<version>${project.version}</version>
+	</dependency>
+
+	<dependency>
+		<groupId>${project.groupId}</groupId>
+		<artifactId>commons-rdf-simple</artifactId>
+		<version>${project.version}</version>
+	</dependency>
+	<dependency>
+		<groupId>${project.groupId}</groupId>
+		<artifactId>commons-rdf-rdf4j</artifactId>
+		<version>${project.version}</version>
+	</dependency>
+	<dependency>
+		<groupId>${project.groupId}</groupId>
+		<artifactId>commons-rdf-jena</artifactId>
+		<version>${project.version}</version>
+	</dependency>
+	<dependency>
+		<groupId>${project.groupId}</groupId>
+		<artifactId>commons-rdf-api</artifactId>
+		<version>${project.version}</version>
+		<type>test-jar</type>
+		<scope>test</scope>
+	</dependency>	
+	<dependency>
+		<groupId>junit</groupId>
+		<artifactId>junit</artifactId>
+		<scope>test</scope>
+	</dependency>
+		
+</dependencies>
+	
+</project>

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/84c70320/integration-tests/src/test/java/org/apache/commons/rdf/integrationtests/JenaRDF4JTest.java
----------------------------------------------------------------------
diff --git a/integration-tests/src/test/java/org/apache/commons/rdf/integrationtests/JenaRDF4JTest.java
b/integration-tests/src/test/java/org/apache/commons/rdf/integrationtests/JenaRDF4JTest.java
new file mode 100644
index 0000000..50b5c68
--- /dev/null
+++ b/integration-tests/src/test/java/org/apache/commons/rdf/integrationtests/JenaRDF4JTest.java
@@ -0,0 +1,78 @@
+package org.apache.commons.rdf.integrationtests;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import org.apache.commons.rdf.api.BlankNode;
+import org.apache.commons.rdf.api.Graph;
+import org.apache.commons.rdf.api.IRI;
+import org.apache.commons.rdf.api.Literal;
+import org.apache.commons.rdf.api.RDFTermFactory;
+import org.apache.commons.rdf.api.Triple;
+import org.apache.commons.rdf.jena.RDFTermFactoryJena;
+import org.apache.commons.rdf.rdf4j.RDF4JTermFactory;
+import org.apache.commons.rdf.simple.SimpleRDFTermFactory;
+import org.junit.Test;
+
+public class JenaRDF4JTest {
+
+	private RDFTermFactory simpleFactory = new SimpleRDFTermFactory();
+	private RDFTermFactory jenaFactory = new RDFTermFactoryJena();
+	private RDFTermFactory rdf4jFactory = new RDF4JTermFactory();
+
+	@Test
+	public void jenaToRdf4j() throws Exception {
+		nodesIntoOther(jenaFactory, rdf4jFactory);
+	}
+
+	@Test
+	public void rdf4jToJena() throws Exception {
+		nodesIntoOther(rdf4jFactory, jenaFactory);
+	}
+
+	@Test
+	public void simpletoJena() throws Exception {
+		nodesIntoOther(simpleFactory, jenaFactory);
+	}
+
+	@Test
+	public void simpleToRdf4j() throws Exception {
+		nodesIntoOther(simpleFactory, rdf4jFactory);
+	}
+
+	public void nodesIntoOther(RDFTermFactory fromFactory, RDFTermFactory toFactory) throws
Exception {
+		Graph g = fromFactory.createGraph();
+		BlankNode s = toFactory.createBlankNode();
+		IRI p = toFactory.createIRI("http://example.com/p");
+		Literal o = toFactory.createLiteral("Hello");
+
+		g.add(s, p, o);
+
+		// blankNode should still work with g.contains()
+		assertTrue(g.contains(s, p, o));
+		Triple t1 = g.stream().findAny().get();
+
+		// Can't make assumptions about mappegetPredicated BlankNode equality
+		// assertEquals(s, t.getSubject());
+		assertEquals(p, t1.getPredicate());
+		assertEquals(o, t1.getObject());
+
+		IRI s2 = toFactory.createIRI("http://example.com/s2");
+		g.add(s2, p, s);
+		assertTrue(g.contains(s2, p, s));
+
+		// This should be mapped to the same BlankNode
+		// (even if it has a different identifier), e.g.
+		// we should be able to do:
+
+		Triple t2 = g.stream(s2, p, null).findAny().get();
+
+		BlankNode bnode = (BlankNode) t2.getObject();
+		// And that (possibly adapted) BlankNode object should
+		// match the subject of t1 statement
+		assertEquals(bnode, t1.getSubject());
+		// And can be used as a key:
+		Triple t3 = g.stream(bnode, p, null).findAny().get();
+		assertEquals(t1, t3);
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/84c70320/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 539204d..2f3abbf 100644
--- a/pom.xml
+++ b/pom.xml
@@ -222,6 +222,7 @@
         <module>simple</module>
         <module>rdf4j</module>
         <module>jena</module>
+        <module>integration-tests</module>
     </modules>
 
     <dependencyManagement>


Mime
View raw message