testJenaIRI() and testJenaCore()
Project: http://git-wip-us.apache.org/repos/asf/jena/repo Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/0e568edd Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/0e568edd Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/0e568edd Branch: refs/heads/master Commit: 0e568edd336716f942dfcf63fec18aca5baaa5bf Parents: b504678 Author: Stian Soiland-Reyes <[email protected]> Authored: Sun Jan 11 22:44:08 2015 +0000 Committer: Stian Soiland-Reyes <[email protected]> Committed: Mon Jan 12 01:19:17 2015 +0000 ---------------------------------------------------------------------- .../apache/jena/osgi/test/JenaOSGITestImpl.java | 26 +++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/jena/blob/0e568edd/jena-osgi-test/src/main/java/org/apache/jena/osgi/test/JenaOSGITestImpl.java ---------------------------------------------------------------------- diff --git a/jena-osgi-test/src/main/java/org/apache/jena/osgi/test/JenaOSGITestImpl.java b/jena-osgi-test/src/main/java/org/apache/jena/osgi/test/JenaOSGITestImpl.java index 26a8747..763855e 100644 --- a/jena-osgi-test/src/main/java/org/apache/jena/osgi/test/JenaOSGITestImpl.java +++ b/jena-osgi-test/src/main/java/org/apache/jena/osgi/test/JenaOSGITestImpl.java @@ -1,16 +1,24 @@ package org.apache.jena.osgi.test; -import static org.junit.Assert.assertEquals; +import static org.junit.Assert.*; import java.io.StringWriter; import java.io.Writer; import org.apache.jena.iri.IRI; import org.apache.jena.iri.IRIFactory; +import org.apache.jena.iri.impl.IRIFactoryImpl; +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.ontology.SymmetricProperty; 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.RDFNode; +import com.hp.hpl.jena.rdf.model.ReifiedStatement; import com.hp.hpl.jena.rdf.model.Resource; public class JenaOSGITestImpl implements JenaOSGITest { @@ -23,11 +31,24 @@ public class JenaOSGITestImpl implements JenaOSGITest { Resource bob = model.createResource("http://example.com/bob"); model.add(model.createStatement(alice, knows, bob)); + // 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)); } @Override @@ -40,6 +61,9 @@ public class JenaOSGITestImpl implements JenaOSGITest { IRIFactory iriFactory = IRIFactory.jenaImplementation(); IRI iri = iriFactory.create("http://example.com/"); assertEquals("http://example.com/", iri.toASCIIString()); + + // This should not work within OSGi + //assertTrue(iriFactory instanceof IRIFactoryImpl); } @Override
