You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jena.apache.org by rv...@apache.org on 2015/02/17 13:42:22 UTC

[13/50] [abbrv] jena git commit: JENA-879: JenaOSGITestImpl renamed to JenaOSGITest

JENA-879: JenaOSGITestImpl renamed to JenaOSGITest

javadoc updated

Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/85354695
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/85354695
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/85354695

Branch: refs/heads/eliminate-assignments
Commit: 85354695ad87e949c1613a54529fff921451a7e9
Parents: 4d80d1f
Author: Stian Soiland-Reyes <st...@apache.org>
Authored: Mon Feb 2 23:47:19 2015 +0000
Committer: Stian Soiland-Reyes <st...@apache.org>
Committed: Mon Feb 9 10:02:07 2015 +0000

----------------------------------------------------------------------
 .../org/apache/jena/osgi/test/JenaOSGITest.java | 162 ++++++++++++++++++
 .../apache/jena/osgi/test/JenaOSGITestImpl.java | 166 -------------------
 2 files changed, 162 insertions(+), 166 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jena/blob/85354695/apache-jena-osgi/jena-osgi-test/src/main/java/org/apache/jena/osgi/test/JenaOSGITest.java
----------------------------------------------------------------------
diff --git a/apache-jena-osgi/jena-osgi-test/src/main/java/org/apache/jena/osgi/test/JenaOSGITest.java b/apache-jena-osgi/jena-osgi-test/src/main/java/org/apache/jena/osgi/test/JenaOSGITest.java
new file mode 100644
index 0000000..fd179eb
--- /dev/null
+++ b/apache-jena-osgi/jena-osgi-test/src/main/java/org/apache/jena/osgi/test/JenaOSGITest.java
@@ -0,0 +1,162 @@
+/*
+ * 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.jena.osgi.test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.io.OutputStream;
+import java.io.StringWriter;
+import java.io.Writer;
+import java.nio.file.Files;
+import java.nio.file.Path;
+
+import org.apache.jena.iri.IRI;
+import org.apache.jena.iri.IRIFactory;
+import org.apache.jena.riot.Lang;
+import org.apache.jena.riot.RDFDataMgr;
+import org.junit.Test;
+
+import com.hp.hpl.jena.ontology.Individual;
+import com.hp.hpl.jena.ontology.ObjectProperty;
+import com.hp.hpl.jena.ontology.OntModel;
+import com.hp.hpl.jena.ontology.OntModelSpec;
+import com.hp.hpl.jena.query.Dataset;
+import com.hp.hpl.jena.query.DatasetFactory;
+import com.hp.hpl.jena.query.Query;
+import com.hp.hpl.jena.query.QueryExecution;
+import com.hp.hpl.jena.query.QueryExecutionFactory;
+import com.hp.hpl.jena.query.QueryFactory;
+import com.hp.hpl.jena.query.QuerySolution;
+import com.hp.hpl.jena.query.ReadWrite;
+import com.hp.hpl.jena.query.ResultSet;
+import com.hp.hpl.jena.rdf.model.Model;
+import com.hp.hpl.jena.rdf.model.ModelFactory;
+import com.hp.hpl.jena.rdf.model.Property;
+import com.hp.hpl.jena.rdf.model.Resource;
+import com.hp.hpl.jena.tdb.TDBFactory;
+
+/**
+ * Brief tests of the Jena modules covered by jena-osgi
+ *  
+ */
+public class JenaOSGITest {
+
+	private static final String EXAMPLE_COM_GRAPH = "http://example.com/graph";
+	private Resource alice;
+	private Property knows;
+	private Resource bob;
+
+	@Test
+	public void testJenaCore() throws Exception {
+		Model model = makeModel();
+
+		// Does Model's Class.forName() still work?
+		model.setWriterClassName("someWriter",
+				"com.hp.hpl.jena.rdf.model.impl.NTripleWriter");
+		Writer writer = new StringWriter();
+		model.write(writer, "someWriter");
+		// yes, but only as long as that classname is accessible within
+		// jena-osgi bundle
+		assertEquals(
+				"<http://example.com/alice> <http://xmlns.com/foaf/0.1/knows> <http://example.com/bob> .",
+				writer.toString().trim());
+
+		// Let's also test com.hp.hpl.jena.ontology
+		OntModel ontModel = ModelFactory
+				.createOntologyModel(OntModelSpec.OWL_DL_MEM_RULE_INF);
+		ObjectProperty knowsObjProp = ontModel.createObjectProperty(knows
+				.getURI());
+		ObjectProperty hasFriend = ontModel
+				.createObjectProperty("http://example.com/has_friend");
+		hasFriend.addSuperProperty(knowsObjProp);
+
+		Individual aliceIndividual = ontModel.createIndividual(alice);
+		Individual bobIndividiual = ontModel.createIndividual(bob);
+		ontModel.add(aliceIndividual, hasFriend, bobIndividiual);
+		assertTrue(aliceIndividual.hasProperty(knowsObjProp, bobIndividiual));
+	}
+
+	private Model makeModel() {
+		Model model = ModelFactory.createDefaultModel();
+		alice = model.createResource("http://example.com/alice");
+		knows = model.createProperty("http://xmlns.com/foaf/0.1/knows");
+		bob = model.createResource("http://example.com/bob");
+		model.add(model.createStatement(alice, knows, bob));
+		return model;
+	}
+
+	@Test
+	public void testJenaArq() throws Exception {
+		Dataset dataset = DatasetFactory.createMem();
+		dataset.addNamedModel(EXAMPLE_COM_GRAPH, makeModel());
+
+		Path path = Files.createTempFile("example", ".jsonld");
+		// System.out.println(path);
+		path.toFile().deleteOnExit();
+
+		try (OutputStream output = Files.newOutputStream(path)) {
+			RDFDataMgr.write(output, dataset, Lang.JSONLD);
+		}
+		// We test JSON-LD as it involves multiple other bundles
+
+		Dataset dataset2 = RDFDataMgr.loadDataset(path.toUri().toString());
+		assertTrue(dataset2.containsNamedModel(EXAMPLE_COM_GRAPH));
+
+		runQuery(dataset2);
+
+	}
+
+	private void runQuery(Dataset dataset) {
+		Query query = QueryFactory.create(""
+				+ "PREFIX foaf: <http://xmlns.com/foaf/0.1/>"
+				+ "SELECT ?bob WHERE { "
+				+ "  GRAPH <http://example.com/graph> { "
+				+ "      ?alice foaf:knows ?bob . " + "  }" + "}");
+		try (QueryExecution qexec = QueryExecutionFactory.create(query,
+				dataset)) {
+			ResultSet results = qexec.execSelect();
+			assertTrue(results.hasNext());
+			QuerySolution r = results.next();
+			assertEquals(bob, r.get("bob").asResource());
+		}
+	}
+
+	@Test
+	public void testJenaIRI() throws Exception {
+		IRIFactory iriFactory = IRIFactory.jenaImplementation();
+		IRI iri = iriFactory.create("http://example.com/");
+		assertEquals("http://example.com/", iri.toASCIIString());
+	}
+
+	@Test
+	public void testJenaTdb() throws Exception {
+		Path tdbDir = Files.createTempDirectory("jena-tdb-test");
+		Dataset dataset = TDBFactory.createDataset(tdbDir.toString());
+		
+		dataset.begin(ReadWrite.WRITE) ;
+		dataset.addNamedModel(EXAMPLE_COM_GRAPH, makeModel());
+		dataset.commit();
+		dataset.end();
+		
+		dataset.begin(ReadWrite.READ);
+		runQuery(dataset);
+		dataset.end();
+	}
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/85354695/apache-jena-osgi/jena-osgi-test/src/main/java/org/apache/jena/osgi/test/JenaOSGITestImpl.java
----------------------------------------------------------------------
diff --git a/apache-jena-osgi/jena-osgi-test/src/main/java/org/apache/jena/osgi/test/JenaOSGITestImpl.java b/apache-jena-osgi/jena-osgi-test/src/main/java/org/apache/jena/osgi/test/JenaOSGITestImpl.java
deleted file mode 100644
index cbdb324..0000000
--- a/apache-jena-osgi/jena-osgi-test/src/main/java/org/apache/jena/osgi/test/JenaOSGITestImpl.java
+++ /dev/null
@@ -1,166 +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.
- */
-
-package org.apache.jena.osgi.test;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-import java.io.OutputStream;
-import java.io.StringWriter;
-import java.io.Writer;
-import java.nio.file.Files;
-import java.nio.file.Path;
-
-import org.apache.jena.iri.IRI;
-import org.apache.jena.iri.IRIFactory;
-import org.apache.jena.riot.Lang;
-import org.apache.jena.riot.RDFDataMgr;
-import org.junit.Test;
-
-import com.hp.hpl.jena.ontology.Individual;
-import com.hp.hpl.jena.ontology.ObjectProperty;
-import com.hp.hpl.jena.ontology.OntModel;
-import com.hp.hpl.jena.ontology.OntModelSpec;
-import com.hp.hpl.jena.query.Dataset;
-import com.hp.hpl.jena.query.DatasetFactory;
-import com.hp.hpl.jena.query.Query;
-import com.hp.hpl.jena.query.QueryExecution;
-import com.hp.hpl.jena.query.QueryExecutionFactory;
-import com.hp.hpl.jena.query.QueryFactory;
-import com.hp.hpl.jena.query.QuerySolution;
-import com.hp.hpl.jena.query.ReadWrite;
-import com.hp.hpl.jena.query.ResultSet;
-import com.hp.hpl.jena.rdf.model.Model;
-import com.hp.hpl.jena.rdf.model.ModelFactory;
-import com.hp.hpl.jena.rdf.model.Property;
-import com.hp.hpl.jena.rdf.model.Resource;
-import com.hp.hpl.jena.tdb.TDBFactory;
-
-/**
- * Brief tests of the Jena modules covered by jena-osgi
- * <p>
- * Do NOT add tests to this class without also adding a
- * \@Test-annotated method to the interface JenaOSGITest
- * -- otherwise it won't be picked up when testing inside OSGi
- *  
- */
-public class JenaOSGITestImpl {
-
-	private static final String EXAMPLE_COM_GRAPH = "http://example.com/graph";
-	private Resource alice;
-	private Property knows;
-	private Resource bob;
-
-	@Test
-	public void testJenaCore() throws Exception {
-		Model model = makeModel();
-
-		// Does Model's Class.forName() still work?
-		model.setWriterClassName("someWriter",
-				"com.hp.hpl.jena.rdf.model.impl.NTripleWriter");
-		Writer writer = new StringWriter();
-		model.write(writer, "someWriter");
-		// yes, but only as long as that classname is accessible within
-		// jena-osgi bundle
-		assertEquals(
-				"<http://example.com/alice> <http://xmlns.com/foaf/0.1/knows> <http://example.com/bob> .",
-				writer.toString().trim());
-
-		// Let's also test com.hp.hpl.jena.ontology
-		OntModel ontModel = ModelFactory
-				.createOntologyModel(OntModelSpec.OWL_DL_MEM_RULE_INF);
-		ObjectProperty knowsObjProp = ontModel.createObjectProperty(knows
-				.getURI());
-		ObjectProperty hasFriend = ontModel
-				.createObjectProperty("http://example.com/has_friend");
-		hasFriend.addSuperProperty(knowsObjProp);
-
-		Individual aliceIndividual = ontModel.createIndividual(alice);
-		Individual bobIndividiual = ontModel.createIndividual(bob);
-		ontModel.add(aliceIndividual, hasFriend, bobIndividiual);
-		assertTrue(aliceIndividual.hasProperty(knowsObjProp, bobIndividiual));
-	}
-
-	private Model makeModel() {
-		Model model = ModelFactory.createDefaultModel();
-		alice = model.createResource("http://example.com/alice");
-		knows = model.createProperty("http://xmlns.com/foaf/0.1/knows");
-		bob = model.createResource("http://example.com/bob");
-		model.add(model.createStatement(alice, knows, bob));
-		return model;
-	}
-
-	@Test
-	public void testJenaArq() throws Exception {
-		Dataset dataset = DatasetFactory.createMem();
-		dataset.addNamedModel(EXAMPLE_COM_GRAPH, makeModel());
-
-		Path path = Files.createTempFile("example", ".jsonld");
-		// System.out.println(path);
-		path.toFile().deleteOnExit();
-
-		try (OutputStream output = Files.newOutputStream(path)) {
-			RDFDataMgr.write(output, dataset, Lang.JSONLD);
-		}
-		// We test JSON-LD as it involves multiple other bundles
-
-		Dataset dataset2 = RDFDataMgr.loadDataset(path.toUri().toString());
-		assertTrue(dataset2.containsNamedModel(EXAMPLE_COM_GRAPH));
-
-		runQuery(dataset2);
-
-	}
-
-	private void runQuery(Dataset dataset) {
-		Query query = QueryFactory.create(""
-				+ "PREFIX foaf: <http://xmlns.com/foaf/0.1/>"
-				+ "SELECT ?bob WHERE { "
-				+ "  GRAPH <http://example.com/graph> { "
-				+ "      ?alice foaf:knows ?bob . " + "  }" + "}");
-		try (QueryExecution qexec = QueryExecutionFactory.create(query,
-				dataset)) {
-			ResultSet results = qexec.execSelect();
-			assertTrue(results.hasNext());
-			QuerySolution r = results.next();
-			assertEquals(bob, r.get("bob").asResource());
-		}
-	}
-
-	@Test
-	public void testJenaIRI() throws Exception {
-		IRIFactory iriFactory = IRIFactory.jenaImplementation();
-		IRI iri = iriFactory.create("http://example.com/");
-		assertEquals("http://example.com/", iri.toASCIIString());
-	}
-
-	@Test
-	public void testJenaTdb() throws Exception {
-		Path tdbDir = Files.createTempDirectory("jena-tdb-test");
-		Dataset dataset = TDBFactory.createDataset(tdbDir.toString());
-		
-		dataset.begin(ReadWrite.WRITE) ;
-		dataset.addNamedModel(EXAMPLE_COM_GRAPH, makeModel());
-		dataset.commit();
-		dataset.end();
-		
-		dataset.begin(ReadWrite.READ);
-		runQuery(dataset);
-		dataset.end();
-	}
-}