Jena-OSGi integration test updated, removed Xerces as embedded dependency
Project: http://git-wip-us.apache.org/repos/asf/jena/repo Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/0ff9beb1 Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/0ff9beb1 Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/0ff9beb1 Branch: refs/heads/master Commit: 0ff9beb1122ffc1f2e5812972a81107f037c9e12 Parents: 2462447 Author: Jaroslav Pullmann <[email protected]> Authored: Mon Apr 4 16:23:36 2016 +0200 Committer: Jaroslav Pullmann <[email protected]> Committed: Mon Apr 4 16:23:36 2016 +0200 ---------------------------------------------------------------------- apache-jena-osgi/jena-osgi-test/pom.xml | 292 ++++++------------- .../org/apache/jena/osgi/test/JenaOSGITest.java | 118 ++++---- apache-jena-osgi/jena-osgi/pom.xml | 27 +- 3 files changed, 158 insertions(+), 279 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/jena/blob/0ff9beb1/apache-jena-osgi/jena-osgi-test/pom.xml ---------------------------------------------------------------------- diff --git a/apache-jena-osgi/jena-osgi-test/pom.xml b/apache-jena-osgi/jena-osgi-test/pom.xml index 2e63b54..b28d877 100644 --- a/apache-jena-osgi/jena-osgi-test/pom.xml +++ b/apache-jena-osgi/jena-osgi-test/pom.xml @@ -1,205 +1,93 @@ <?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.jena</groupId> - <artifactId>jena-parent</artifactId> - <version>15-SNAPSHOT</version> - <relativePath>../../jena-parent</relativePath> - </parent> - - <artifactId>jena-osgi-test</artifactId> - <version>3.0.1-SNAPSHOT</version> - <name>Apache Jena - OSGi integration tests</name> - <description>Tests for jena-osgi as a bundle</description> - <packaging>bundle</packaging> - - <properties> - <felix.version>4.6.0</felix.version> - <pax.exam.version>4.4.0</pax.exam.version> - <pax.url.version>1.6.0</pax.url.version> - <pax.logging.version>1.8.1</pax.logging.version> - </properties> - - <repositories> - <repository> - <id>apache.snapshots</id> - <name>Apache Snapshot Repository</name> - <url>http://repository.apache.org/snapshots</url> - <releases> - <enabled>false</enabled> - </releases> - </repository> - </repositories> - - <dependencies> - <dependency> - <groupId>org.apache.jena</groupId> - <artifactId>jena-osgi</artifactId> - <version>${project.version}</version> - <type>bundle</type> - <scope>test</scope> - </dependency> - - <dependency> - <groupId>org.osgi</groupId> - <artifactId>org.osgi.core</artifactId> - <version>5.0.0</version> - <scope>provided</scope> - </dependency> - - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <scope>test</scope> - </dependency> - - <!-- needed to get a org.slf4j bundle for PAX - as we exclude slf4j-log4j due to - "Fragment bundle" warning --> - <dependency> - <groupId>org.ops4j.pax.logging</groupId> - <artifactId>pax-logging-log4j2</artifactId> - <version>${pax.logging.version}</version> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.ops4j.pax.logging</groupId> - <artifactId>pax-logging-api</artifactId> - <version>${pax.logging.version}</version> - <scope>test</scope> - </dependency> - - <dependency> - <groupId>org.ops4j.pax.exam</groupId> - <artifactId>pax-exam-container-native</artifactId> - <version>${pax.exam.version}</version> - <scope>test</scope> - </dependency> - - <dependency> - <groupId>org.ops4j.pax.exam</groupId> - <artifactId>pax-exam-junit4</artifactId> - <version>${pax.exam.version}</version> - <scope>test</scope> - </dependency> - - <dependency> - <groupId>org.ops4j.pax.exam</groupId> - <artifactId>pax-exam-link-mvn</artifactId> - <version>${pax.exam.version}</version> - <scope>test</scope> - </dependency> - - <dependency> - <groupId>org.ops4j.pax.url</groupId> - <artifactId>pax-url-aether</artifactId> - <version>${pax.url.version}</version> - <scope>test</scope> - </dependency> - - <!-- OSGi Frameworks --> - <dependency> - <groupId>org.eclipse</groupId> - <artifactId>osgi</artifactId> - <version>3.9.1-v20140110-1610</version> - <scope>test</scope> - </dependency> - <!-- NOTE: Make sure eclipse-osgi (equinox) is first --> - <dependency> - <groupId>org.apache.felix</groupId> - <artifactId>org.apache.felix.framework</artifactId> - <version>${felix.version}</version> - <scope>test</scope> - </dependency> - - </dependencies> - - <build> - <plugins> - <plugin> - <groupId>org.apache.felix</groupId> - <artifactId>maven-bundle-plugin</artifactId> - <!-- re-enable extensions here for older Mavens --> - <extensions>true</extensions> - </plugin> - <plugin> - <!-- generate target/pax-exam-links --> - <groupId>org.ops4j.pax.exam</groupId> - <artifactId>exam-maven-plugin</artifactId> - <version>${pax.exam.version}</version> - <executions> - <execution> - <id>generate-link-files</id> - <goals> - <goal>generate-link-files</goal> - </goals> - <phase>generate-test-resources</phase> - </execution> - </executions> - </plugin> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-compiler-plugin</artifactId> - <executions> - <execution> - <!-- delay test compilation until pre-integration-test phase --> - <id>default-testCompile</id> - <goals> - <goal>testCompile</goal> - </goals> - <phase>pre-integration-test</phase> - </execution> - </executions> - <configuration> - </configuration> - - </plugin> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-surefire-plugin</artifactId> - <configuration> - <classpathDependencyExcludes> - <classpathDependencyExclude>org.slf4j:slf4j-log4j12</classpathDependencyExclude> - </classpathDependencyExcludes> - <systemPropertyVariables> - <!-- So the test can find the current version of jena-osgi --> - <jena-osgi.version>${project.version}</jena-osgi.version> - <!-- not so noisy OSGi logging --> - <org.ops4j.pax.logging.DefaultServiceLog.level>WARN</org.ops4j.pax.logging.DefaultServiceLog.level> - </systemPropertyVariables> - </configuration> - <!-- Explicit execution to run in a phase after the OSGi bundle - has been created --> - <executions> - <execution> - <id>default-test</id> - <goals> - <goal>test</goal> - </goals> - <!-- delay until integration-test phase --> - <phase>integration-test</phase> - </execution> - </executions> - </plugin> - </plugins> - </build> +<!-- 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.jena</groupId> + <artifactId>jena-parent</artifactId> + <version>16-SNAPSHOT</version> + </parent> + + <artifactId>jena-osgi-test</artifactId> + <!-- Same as jena-osgi --> + <version>3.1.0-SNAPSHOT</version> + <name>Apache Jena - OSGi integration tests</name> + <description>Tests for jena-osgi as a bundle</description> + <packaging>bundle</packaging> + + <properties> + <pax.exam.version>4.4.0</pax.exam.version> + </properties> + + <repositories> + <repository> + <id>apache.snapshots</id> + <name>Apache Snapshot Repository</name> + <url>http://repository.apache.org/snapshots</url> + <releases> + <enabled>false</enabled> + </releases> + </repository> + </repositories> + + <dependencies> + <dependency> + <groupId>org.apache.jena</groupId> + <artifactId>jena-osgi</artifactId> + <version>3.1.0-SNAPSHOT</version> + <type>bundle</type> + <scope>test</scope> + </dependency> + + <dependency> + <groupId>org.ops4j.pax.exam</groupId> + <artifactId>pax-exam-container-karaf</artifactId> + <version>${pax.exam.version}</version> + <scope>test</scope> + </dependency> + + <dependency> + <groupId>org.ops4j.pax.exam</groupId> + <artifactId>pax-exam-junit4</artifactId> + <version>${pax.exam.version}</version> + <scope>test</scope> + </dependency> + + <dependency> + <groupId>org.ops4j.pax.exam</groupId> + <artifactId>pax-exam-link-mvn</artifactId> + <version>${pax.exam.version}</version> + <scope>test</scope> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-failsafe-plugin</artifactId> + <executions> + <execution> + <id>verify</id> + <goals> + <goal>integration-test</goal> + <goal>verify</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + </build> </project> http://git-wip-us.apache.org/repos/asf/jena/blob/0ff9beb1/apache-jena-osgi/jena-osgi-test/src/test/java/org/apache/jena/osgi/test/JenaOSGITest.java ---------------------------------------------------------------------- diff --git a/apache-jena-osgi/jena-osgi-test/src/test/java/org/apache/jena/osgi/test/JenaOSGITest.java b/apache-jena-osgi/jena-osgi-test/src/test/java/org/apache/jena/osgi/test/JenaOSGITest.java index ef0d85e..8dcb8c0 100644 --- a/apache-jena-osgi/jena-osgi-test/src/test/java/org/apache/jena/osgi/test/JenaOSGITest.java +++ b/apache-jena-osgi/jena-osgi-test/src/test/java/org/apache/jena/osgi/test/JenaOSGITest.java @@ -20,10 +20,10 @@ package org.apache.jena.osgi.test; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; -import static org.ops4j.pax.exam.CoreOptions.junitBundles; -import static org.ops4j.pax.exam.CoreOptions.linkBundle; +import static org.ops4j.pax.exam.CoreOptions.maven; import static org.ops4j.pax.exam.CoreOptions.mavenBundle; import static org.ops4j.pax.exam.CoreOptions.options; +import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.karafDistributionConfiguration; import java.io.OutputStream; import java.io.StringWriter; @@ -31,22 +31,8 @@ import java.io.Writer; import java.nio.file.Files; import java.nio.file.Path; -import javax.inject.Inject; - 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 org.junit.runner.RunWith; -import org.ops4j.pax.exam.Configuration; -import org.ops4j.pax.exam.CoreOptions; -import org.ops4j.pax.exam.Option; -import org.ops4j.pax.exam.junit.PaxExam; -import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy; -import org.ops4j.pax.exam.spi.reactors.PerClass; -import org.osgi.framework.BundleContext; - import org.apache.jena.ontology.Individual; import org.apache.jena.ontology.ObjectProperty; import org.apache.jena.ontology.OntModel; @@ -61,12 +47,19 @@ import org.apache.jena.query.QuerySolution; import org.apache.jena.query.ReadWrite; import org.apache.jena.query.ResultSet; import org.apache.jena.rdf.model.Model; -import org.apache.jena.ontology.OntModel ; -import org.apache.jena.ontology.OntModelSpec ; import org.apache.jena.rdf.model.ModelFactory; import org.apache.jena.rdf.model.Property; import org.apache.jena.rdf.model.Resource; +import org.apache.jena.riot.Lang; +import org.apache.jena.riot.RDFDataMgr; import org.apache.jena.tdb.TDBFactory; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.ops4j.pax.exam.Configuration; +import org.ops4j.pax.exam.Option; +import org.ops4j.pax.exam.junit.PaxExam; +import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy; +import org.ops4j.pax.exam.spi.reactors.PerClass; /** * Brief tests of the Jena modules covered by jena-osgi @@ -76,35 +69,40 @@ import org.apache.jena.tdb.TDBFactory; @ExamReactorStrategy(PerClass.class) public class JenaOSGITest { - @Inject - private BundleContext bc; - @Configuration public Option[] config() { + return options( - // bundle with org.slf4j implementation - linkBundle("org.ops4j.pax.logging.pax-logging-log4j2"), - linkBundle("org.ops4j.pax.logging.pax-logging-api"), - - // jena-osgi - mavenBundle("org.apache.jena", "jena-osgi", - System.getProperty("jena-osgi.version", "LATEST")), - - // dependencies of jena-osgi - linkBundle("org.apache.httpcomponents.httpclient"), - linkBundle("org.apache.httpcomponents.httpcore"), - linkBundle("com.github.jsonld-java"), - linkBundle("org.apache.commons.csv"), - linkBundle("org.apache.thrift"), - linkBundle("jcl.over.slf4j"), + // OSGi container configuration + karafDistributionConfiguration().frameworkUrl( + maven().groupId("org.apache.karaf") + .artifactId("apache-karaf").type("zip") + .version("3.0.6")).useDeployFolder(false), - linkBundle("com.fasterxml.jackson.core.jackson-core"), - linkBundle("com.fasterxml.jackson.core.jackson-databind"), - linkBundle("com.fasterxml.jackson.core.jackson-annotations"), - linkBundle("org.apache.commons.lang3"), - - junitBundles() - ); + mavenBundle("org.apache.aries.spifly", + "org.apache.aries.spifly.dynamic.bundle", "1.0.8"), + + mavenBundle("org.apache.jena", "jena-osgi", "3.1.0-SNAPSHOT"), + mavenBundle("com.github.andrewoma.dexx", "collection", "0.4.0"), + mavenBundle("com.github.jsonld-java", "jsonld-java", "0.8.0"), + mavenBundle("org.apache.httpcomponents", "httpcore-osgi", + "4.4.4"), + mavenBundle("org.apache.httpcomponents", "httpclient-osgi", + "4.5.1"), + mavenBundle("commons-cli", "commons-cli", "1.3.1"), + mavenBundle("org.apache.commons", "commons-csv", "1.2"), + mavenBundle("org.apache.commons", "commons-lang3", "3.4"), + mavenBundle("org.apache.thrift", "libthrift", "0.9.3"), + + mavenBundle("com.fasterxml.jackson.core", "jackson-core", + "2.6.3"), + mavenBundle("com.fasterxml.jackson.core", "jackson-databind", + "2.6.3"), + mavenBundle("com.fasterxml.jackson.core", + "jackson-annotations", "2.6.3") + + ); + } private static final String EXAMPLE_COM_GRAPH = "http://example.com/graph"; @@ -115,19 +113,13 @@ public class JenaOSGITest { @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 + model.write(writer, "N-Triples"); + 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 @@ -142,15 +134,6 @@ public class JenaOSGITest { 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(); @@ -209,11 +192,12 @@ public class JenaOSGITest { dataset.end(); } - /* - @Test - public void createOntModel() - { - final OntModel model = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM); + 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; } - */ } http://git-wip-us.apache.org/repos/asf/jena/blob/0ff9beb1/apache-jena-osgi/jena-osgi/pom.xml ---------------------------------------------------------------------- diff --git a/apache-jena-osgi/jena-osgi/pom.xml b/apache-jena-osgi/jena-osgi/pom.xml index aaa0fa8..6225f31 100644 --- a/apache-jena-osgi/jena-osgi/pom.xml +++ b/apache-jena-osgi/jena-osgi/pom.xml @@ -26,7 +26,7 @@ <artifactId>apache-jena-osgi</artifactId> <version>3.1.0-SNAPSHOT</version> </parent> - <artifactId>jena-osgi</artifactId> + <artifactId>jena-osgi</artifactId> <packaging>bundle</packaging> <name>Apache Jena - OSGi bundle</name> <description> @@ -236,22 +236,29 @@ <configuration> <instructions> <Export-Package>org.apache.jena.*,!org.apache.jena.ext.*</Export-Package> + <Embed-Dependency>artifactId=jena*;inline=true</Embed-Dependency> + <!-- <Embed-Dependency>artifactId=jena*;inline=true,artifactId=xercesImpl;inline=true,artifactId=xml-apis;inline=true</Embed-Dependency> + --> <Embed-Transitive>true</Embed-Transitive> + <!-- Do not embed but import Xerces classes via OSGi --> + <Import-Package>org.osgi.framework.*,org.apache.xml.*,org.apache.xerces.*,!sun.io,!org.apache.avalon.framework.logger,!com.ibm.uvm.tools,!com.sun.jdmk.comm,!org.apache.log,!org.apache.jena.ext.*,sun.misc;resolution:=optional,*</Import-Package> + <!-- <Import-Package>org.osgi.framework.*,!sun.io,!org.apache.avalon.framework.logger,!com.ibm.uvm.tools,!com.sun.jdmk.comm,!org.apache.log,!org.apache.xml.*,!org.apache.xerces.*,!org.apache.jena.ext.*,sun.misc;resolution:=optional,*</Import-Package> + --> <Private-Package>org.apache.jena.ext.*</Private-Package> <Bundle-Activator>org.apache.jena.osgi.Activator</Bundle-Activator> <!-- Standard headers according to OSGi 133 Service Loader Mediator Specification --> - <Require-Capability> - osgi.extender; filter:="(|(osgi.extender=osgi.serviceloader.registrar)(osgi.extender=osgi.serviceloader.processor))", - osgi.serviceloader; filter:="(osgi.serviceloader=org.apache.jena.system.JenaSubsystemLifecycle)";cardinality:=multiple - </Require-Capability> - <Provide-Capability>osgi.serviceloader; osgi.serviceloader=org.apache.jena.system.JenaSubsystemLifecycle</Provide-Capability> - <!-- SPI-* headers work only with Apache Aries SPI Fly --> + <Require-Capability> + osgi.extender; filter:="(|(osgi.extender=osgi.serviceloader.registrar)(osgi.extender=osgi.serviceloader.processor))", + osgi.serviceloader; filter:="(osgi.serviceloader=org.apache.jena.system.JenaSubsystemLifecycle)";cardinality:=multiple + </Require-Capability> + <Provide-Capability>osgi.serviceloader; osgi.serviceloader=org.apache.jena.system.JenaSubsystemLifecycle</Provide-Capability> + <!-- SPI-* headers work only with Apache Aries SPI Fly --> <!-- - <SPI-Consumer>*</SPI-Consumer> - <SPI-Provider>*</SPI-Provider> - --> + <SPI-Consumer>*</SPI-Consumer> + <SPI-Provider>*</SPI-Provider> + --> </instructions> </configuration> </plugin>
