You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jena.apache.org by an...@apache.org on 2016/04/15 18:49:47 UTC

[5/9] jena git commit: Added Apache Karaf feature definition for Jena, reused in integration testing

Added Apache Karaf feature definition for Jena, reused in integration testing


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

Branch: refs/heads/master
Commit: 18cddf63e4f8345941ecd4b9bf2066ee2996a988
Parents: cbf6695
Author: Jaroslav Pullmann <ja...@fit.fraunhofer.de>
Authored: Wed Apr 13 15:37:22 2016 +0200
Committer: Jaroslav Pullmann <ja...@fit.fraunhofer.de>
Committed: Wed Apr 13 15:37:22 2016 +0200

----------------------------------------------------------------------
 apache-jena-osgi/jena-osgi-features/pom.xml     | 102 +++++++++++++++++++
 .../src/main/resources/features.xml             |  46 +++++++++
 apache-jena-osgi/jena-osgi-test/pom.xml         |  34 +++++--
 .../org/apache/jena/osgi/test/JenaOSGITest.java |  42 ++++----
 apache-jena-osgi/jena-osgi/pom.xml              |  21 +---
 .../java/org/apache/jena/osgi/Activator.java    |  40 ++++----
 apache-jena-osgi/pom.xml                        |   2 +
 7 files changed, 215 insertions(+), 72 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jena/blob/18cddf63/apache-jena-osgi/jena-osgi-features/pom.xml
----------------------------------------------------------------------
diff --git a/apache-jena-osgi/jena-osgi-features/pom.xml b/apache-jena-osgi/jena-osgi-features/pom.xml
new file mode 100644
index 0000000..bdd43e1
--- /dev/null
+++ b/apache-jena-osgi/jena-osgi-features/pom.xml
@@ -0,0 +1,102 @@
+<?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>apache-jena-osgi</artifactId>
+		<version>3.1.0-SNAPSHOT</version>
+	</parent>
+	<artifactId>jena-osgi-features</artifactId>  
+	<packaging>bundle</packaging>
+	<name>Apache Jena - OSGi Karaf features</name>	
+	<description>Apache Karaf features (deplyoment configurations) for easy installation and integration testing.</description>
+	<build>
+		<pluginManagement>
+            <plugins>
+            	<plugin>
+                	<groupId>org.codehaus.mojo</groupId>
+                	<artifactId>build-helper-maven-plugin</artifactId>
+                	<version>1.8</version>
+            	</plugin>
+            </plugins>
+        </pluginManagement>
+        <resources>
+            <resource>
+                <directory>src/main/resources</directory>
+                <filtering>true</filtering>
+            </resource>
+        </resources>
+		<plugins>
+			<plugin>
+				<groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-resources-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>copy-resources</id>
+                        <phase>validate</phase>
+                        <goals>
+                            <goal>copy-resources</goal>
+                        </goals>
+                        <configuration>
+                            <outputDirectory>${basedir}/target</outputDirectory>
+                            <resources>
+                                <resource>
+                                    <directory>src/main/resources</directory>
+                                    <filtering>true</filtering>
+                                </resource>
+                            </resources>
+                        </configuration>
+                    </execution>
+                    <execution>
+                        <id>filter</id>
+                        <phase>generate-resources</phase>
+                        <goals>
+                            <goal>resources</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+			      <plugin>
+                <groupId>org.codehaus.mojo</groupId>
+                <artifactId>build-helper-maven-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>attach-artifacts</id>
+                        <phase>package</phase>
+                        <goals>
+                            <goal>attach-artifact</goal>
+                        </goals>
+                        <configuration>
+                            <artifacts>
+                                <artifact>
+                                    <file>target/features.xml</file>
+                                    <type>xml</type>
+                                    <classifier>features</classifier>
+                                </artifact>
+                            </artifacts>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+		</plugins>
+	</build>
+</project>

http://git-wip-us.apache.org/repos/asf/jena/blob/18cddf63/apache-jena-osgi/jena-osgi-features/src/main/resources/features.xml
----------------------------------------------------------------------
diff --git a/apache-jena-osgi/jena-osgi-features/src/main/resources/features.xml b/apache-jena-osgi/jena-osgi-features/src/main/resources/features.xml
new file mode 100644
index 0000000..f32bf43
--- /dev/null
+++ b/apache-jena-osgi/jena-osgi-features/src/main/resources/features.xml
@@ -0,0 +1,46 @@
+<?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.
+-->
+
+<features xmlns="http://karaf.apache.org/xmlns/features/v1.0.0">
+  
+	<feature name="jena" version="3">
+		<bundle>mvn:org.apache.jena/jena-osgi/3.1.0-SNAPSHOT</bundle>
+		<feature version="3">jena_osgi_dependencies</feature>
+		<!-- This is normally exposed by Apache Karaf via root classloader -->
+		<!--<feature version="2.11.0">xerces</feature>-->
+	</feature>
+
+	<feature name="jena_osgi_dependencies" version="3">
+		<bundle>mvn:com.github.andrewoma.dexx/collection/0.6</bundle>
+		<bundle>mvn:com.github.jsonld-java/jsonld-java/0.8.2</bundle>
+		<bundle>mvn:com.fasterxml.jackson.core/jackson-core/2.7.3</bundle>
+		<bundle>mvn:com.fasterxml.jackson.core/jackson-databind/2.7.3</bundle>
+		<bundle>mvn:com.fasterxml.jackson.core/jackson-annotations/2.7.3</bundle>
+		<bundle>mvn:org.apache.httpcomponents/httpcore-osgi/4.4.4</bundle>
+		<bundle>mvn:org.apache.httpcomponents/httpclient-osgi/4.5.2</bundle>
+		<bundle>mvn:org.apache.commons/commons-csv/1.2</bundle>
+		<bundle>mvn:org.apache.commons/commons-lang3/3.4</bundle>
+		<bundle>mvn:org.apache.thrift/libthrift/0.9.3</bundle>	
+	</feature>
+
+	<feature name="xerces" version="2.11.0">
+		<bundle>mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.xerces/2.11.0_1</bundle>
+		<bundle>mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.xmlresolver/1.2_5</bundle>
+	</feature>
+
+</features>

http://git-wip-us.apache.org/repos/asf/jena/blob/18cddf63/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 b28d877..c8e8cf2 100644
--- a/apache-jena-osgi/jena-osgi-test/pom.xml
+++ b/apache-jena-osgi/jena-osgi-test/pom.xml
@@ -1,14 +1,20 @@
 <?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. -->
+<!--
+   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">
@@ -44,6 +50,14 @@
 	<dependencies>
 		<dependency>
 			<groupId>org.apache.jena</groupId>
+			<artifactId>jena-osgi-features</artifactId>  
+			<version>3.1.0-SNAPSHOT</version>
+			<type>bundle</type>
+			<scope>test</scope>
+		</dependency>
+		
+		<dependency>
+			<groupId>org.apache.jena</groupId>
 			<artifactId>jena-osgi</artifactId>
 			<version>3.1.0-SNAPSHOT</version>
 			<type>bundle</type>

http://git-wip-us.apache.org/repos/asf/jena/blob/18cddf63/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 1d468f1..619d174 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
@@ -21,8 +21,8 @@ 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.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.features;
 import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.karafDistributionConfiguration;
 
 import java.io.OutputStream;
@@ -71,30 +71,24 @@ public class JenaOSGITest {
 
 	@Configuration
 	public Option[] config() {
-
 		return options(
-				// OSGi container configuration
+		// OSGi container configuration
 				karafDistributionConfiguration().frameworkUrl(
 						maven().groupId("org.apache.karaf")
 								.artifactId("apache-karaf").type("zip")
+								/*
+								 * Version 4.0.4 does not work at the moment:
+								 * Error: Could not find or load main class
+								 * org.apache.karaf.main.Main (layout of the
+								 * archive/file naming changed).
+								 */
 								.version("3.0.6")).useDeployFolder(false),
-				
-				//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.6.0-SNAPSHOT"),
-				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")
-
-		);
+				// Install core Jena feature
+				features(
+						maven().groupId("org.apache.jena")
+								.artifactId("jena-osgi-features").type("xml")
+								.classifier("features")
+								.version("3.1.0-SNAPSHOT"), "jena"));
 
 	}
 
@@ -107,12 +101,12 @@ public class JenaOSGITest {
 	public void testJenaCore() throws Exception {
 		Model model = makeModel();
 		Writer writer = new StringWriter();
-		model.write(writer, "N-Triples");		
+		model.write(writer, "N-Triples");
 
 		assertEquals(
 				"<http://example.com/alice> <http://xmlns.com/foaf/0.1/knows> <http://example.com/bob> .",
 				writer.toString().trim());
-		
+
 		OntModel ontModel = ModelFactory
 				.createOntologyModel(OntModelSpec.OWL_DL_MEM_RULE_INF);
 		ObjectProperty knowsObjProp = ontModel.createObjectProperty(knows
@@ -132,15 +126,13 @@ public class JenaOSGITest {
 		Dataset dataset = DatasetFactory.createMem();
 		dataset.addNamedModel(EXAMPLE_COM_GRAPH, makeModel());
 
+		// We test JSON-LD as it involves multiple other bundles
 		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));
 

http://git-wip-us.apache.org/repos/asf/jena/blob/18cddf63/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 ebf1ba4..b4d7ebe 100644
--- a/apache-jena-osgi/jena-osgi/pom.xml
+++ b/apache-jena-osgi/jena-osgi/pom.xml
@@ -233,34 +233,21 @@
         <artifactId>maven-bundle-plugin</artifactId>
         <!-- re-enable extensions here for older Mavens -->
         <extensions>true</extensions>
-        <configuration>		  
+        <configuration>
           <instructions>
-            <Export-Package>org.apache.jena.*,!org.apache.jena.ext.*</Export-Package>			
+            <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.*,org.apache.xml.*,org.apache.xerces.*;version="2.11.0",!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 -->
-			<!-- Not needed, if JenaSubsystemRegistryBasic (jena-core) uses an explicit classloader
-			<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>	
-			-->
+            <Bundle-Activator>org.apache.jena.osgi.Activator</Bundle-Activator>
           </instructions>
         </configuration>
       </plugin>

http://git-wip-us.apache.org/repos/asf/jena/blob/18cddf63/apache-jena-osgi/jena-osgi/src/main/java/org/apache/jena/osgi/Activator.java
----------------------------------------------------------------------
diff --git a/apache-jena-osgi/jena-osgi/src/main/java/org/apache/jena/osgi/Activator.java b/apache-jena-osgi/jena-osgi/src/main/java/org/apache/jena/osgi/Activator.java
index 90f8016..e3f721b 100644
--- a/apache-jena-osgi/jena-osgi/src/main/java/org/apache/jena/osgi/Activator.java
+++ b/apache-jena-osgi/jena-osgi/src/main/java/org/apache/jena/osgi/Activator.java
@@ -1,3 +1,21 @@
+/*
+ * 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;
 
 import org.apache.jena.system.JenaSubsystemRegistry;
@@ -6,28 +24,11 @@ import org.apache.jena.system.JenaSystem;
 import org.osgi.framework.BundleActivator;
 import org.osgi.framework.BundleContext;
 
+// Sample bundle activator explicitly calling the static Jena initialization.
 public class Activator implements BundleActivator {
-	
-	/* 
-	 * Based on http://svn.apache.org/repos/asf/aries/trunk/spi-fly/spi-fly-examples/spi-fly-example-provider-consumer-bundle/src/main/java/org/apache/aries/spifly/pc/bundle/Activator.java
-	 * the Activator#start() waits for bundle extension by Aries SPI Fly, configures JenaSystem logging and requests for initialization.     
-	 */
-	public void start(BundleContext context) throws Exception {
 
-		Thread t = new Thread(new Runnable() {
-			@Override
-			public void run() {
-				try {
-					Thread.sleep(500);
-				} catch (InterruptedException e) {
-				}				
-				setUpJena();
-			}
-		});
-		t.start();
-	}
+	public void start(BundleContext context) throws Exception {
 
-	private void setUpJena() {
 		JenaSubsystemRegistry r = new JenaSubsystemRegistryBasic() {
 			@Override
 			public void load() {
@@ -38,7 +39,6 @@ public class Activator implements BundleActivator {
 		JenaSystem.DEBUG_INIT = true;
 		JenaSystem.init();
 		System.out.println("Jena-OSGi bundle configuration done!");
-		
 	}
 
 	public void stop(BundleContext context) throws Exception {

http://git-wip-us.apache.org/repos/asf/jena/blob/18cddf63/apache-jena-osgi/pom.xml
----------------------------------------------------------------------
diff --git a/apache-jena-osgi/pom.xml b/apache-jena-osgi/pom.xml
index 9fea90b..c95165d 100644
--- a/apache-jena-osgi/pom.xml
+++ b/apache-jena-osgi/pom.xml
@@ -49,6 +49,8 @@
       See JENA-913 - this breaks a clean build unless "install" is used.
     <module>jena-osgi-test</module>
     -->
+    <module>jena-osgi-features</module>
+    <module>jena-osgi-test</module>
   </modules>
   
 </project>