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 2015/02/01 14:12:35 UTC

[26/35] jena git commit: jena-osgi-tests

jena-osgi-tests


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

Branch: refs/heads/master
Commit: b504678ed08f78ed04fb7c6ec05cb5c9eea6cfc4
Parents: b7e65a6
Author: Stian Soiland-Reyes <so...@cs.manchester.ac.uk>
Authored: Sun Jan 11 22:22:32 2015 +0000
Committer: Stian Soiland-Reyes <st...@apache.org>
Committed: Mon Jan 12 01:19:17 2015 +0000

----------------------------------------------------------------------
 jena-osgi-test/pom.xml                          | 69 +++++++-------------
 .../org/apache/jena/osgi/test/JenaCoreTest.java | 32 ---------
 .../apache/jena/osgi/test/JenaCoreTestImpl.java | 28 --------
 .../org/apache/jena/osgi/test/JenaOSGITest.java | 29 ++++++++
 .../jena/osgi/test/JenaOSGITestActivator.java   | 24 +++++++
 .../apache/jena/osgi/test/JenaOSGITestImpl.java | 50 ++++++++++++++
 6 files changed, 125 insertions(+), 107 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jena/blob/b504678e/jena-osgi-test/pom.xml
----------------------------------------------------------------------
diff --git a/jena-osgi-test/pom.xml b/jena-osgi-test/pom.xml
index 938f364..fc3d79e 100644
--- a/jena-osgi-test/pom.xml
+++ b/jena-osgi-test/pom.xml
@@ -28,26 +28,13 @@
 	<packaging>bundle</packaging>
 
 	<dependencies>
-	<!-- 
+
 		<dependency>
 			<groupId>org.apache.jena</groupId>
 			<artifactId>jena-osgi</artifactId>
 			<version>${project.version}</version>
 			<type>bundle</type>
 		</dependency>
-		<dependency>
-			<groupId>org.apache.jena</groupId>
-			<artifactId>jena-core</artifactId>
-			<version>${project.version}</version>
-			<type>test-jar</type>
-		</dependency>
-		<dependency>
-			<groupId>org.apache.jena</groupId>
-			<artifactId>jena-arq</artifactId>
-			<version>${project.version}</version>
-			<type>test-jar</type>
-		</dependency>
-	 -->
 
 		<dependency>
 			<groupId>junit</groupId>
@@ -55,19 +42,19 @@
 			<scope>compile</scope>
 		</dependency>
 		<dependency>
-			<groupId>org.apache.felix</groupId>
-			<artifactId>org.apache.felix.scr.annotations</artifactId>
-			<version>1.9.8</version>
-			<type>bundle</type>
-			<scope>provided</scope>
-		</dependency>
-		<dependency>
 			<groupId>org.everit.osgi.dev</groupId>
 			<artifactId>org.everit.osgi.dev.testrunner.junit4</artifactId>
-			<version>3.0.3</version>
-			<type>bundle</type>
+			<version>3.0.4</version>
+			<scope>test</scope>
 		</dependency>
+			<!--  NOTE: LGPL -->			
 
+		<dependency>
+			<groupId>org.osgi</groupId>
+			<artifactId>org.osgi.core</artifactId>
+			<version>4.3.1</version>
+			<scope>provided</scope>
+		</dependency>
 	</dependencies>
 
 	<build>
@@ -78,30 +65,16 @@
 				<extensions>true</extensions>
 				<configuration>
 					<instructions>
-						<!-- 
-						<Embed-Dependency>artifactId=jena-core;inline=true</Embed-Dependency>
-						<Import-Package>com.hp.hpl.jena,org.apache.jena</Import-Package>
-						 -->
-						<!--  Update according to expected number of *Test classes -->
-						<EOSGi-TestNum>1</EOSGi-TestNum>
+						<Bundle-Activator>org.apache.jena.osgi.test.JenaOSGITestActivator</Bundle-Activator>
+						<!-- <Import-Package>com.hp.hpl.jena</Import-Package> -->
+						<!-- <Embed-Dependency>artifactId=jena-core;inline=true</Embed-Dependency> -->
+						
+						<!-- Update according to expected number of @Test methods -->						     
+						<EOSGi-TestNum>4</EOSGi-TestNum>
 					</instructions>
 				</configuration>
 			</plugin>
 			<plugin>
-				<groupId>org.apache.felix</groupId>
-				<artifactId>maven-scr-plugin</artifactId>
-				<version>1.20.0</version>
-				<executions>
-					<execution>
-						<id>generate-scr-scrdescriptor</id>
-						<goals>
-							<goal>scr</goal>
-						</goals>
-					</execution>
-				</executions>
-
-			</plugin>
-			<plugin>
 				<groupId>org.everit.osgi.dev</groupId>
 				<artifactId>eosgi-maven-plugin</artifactId>
 				<version>3.1.0</version>
@@ -117,12 +90,14 @@
 				<configuration>
 					<environments>
 						<environment>
-							<id>equinox</id>
-							<framework>equinox</framework>
-						</environment>
-						<environment>
 							<id>felix</id>
 							<framework>felix</framework>
+							<timeout>150000</timeout><!-- 15000ms = 15s -->
+						</environment>
+						<environment>
+							<id>equinox</id>
+							<framework>equinox</framework>
+							<timeout>150000</timeout> <!-- 15000ms = 15s -->
 						</environment>
 					</environments>
 				</configuration>

http://git-wip-us.apache.org/repos/asf/jena/blob/b504678e/jena-osgi-test/src/main/java/org/apache/jena/osgi/test/JenaCoreTest.java
----------------------------------------------------------------------
diff --git a/jena-osgi-test/src/main/java/org/apache/jena/osgi/test/JenaCoreTest.java b/jena-osgi-test/src/main/java/org/apache/jena/osgi/test/JenaCoreTest.java
deleted file mode 100644
index f687f28..0000000
--- a/jena-osgi-test/src/main/java/org/apache/jena/osgi/test/JenaCoreTest.java
+++ /dev/null
@@ -1,32 +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 org.apache.felix.scr.annotations.Component;
-import org.apache.felix.scr.annotations.Properties;
-import org.apache.felix.scr.annotations.Property;
-import org.apache.felix.scr.annotations.Service;
-
-@Component
-@Properties({
-        @Property(name = "eosgi.testEngine", value = "junit4"),
-        @Property(name = "eosgi.testId", value = "JenaCoreTest")
-})
-public interface JenaCoreTest {
-
-}

http://git-wip-us.apache.org/repos/asf/jena/blob/b504678e/jena-osgi-test/src/main/java/org/apache/jena/osgi/test/JenaCoreTestImpl.java
----------------------------------------------------------------------
diff --git a/jena-osgi-test/src/main/java/org/apache/jena/osgi/test/JenaCoreTestImpl.java b/jena-osgi-test/src/main/java/org/apache/jena/osgi/test/JenaCoreTestImpl.java
deleted file mode 100644
index 4a1c153..0000000
--- a/jena-osgi-test/src/main/java/org/apache/jena/osgi/test/JenaCoreTestImpl.java
+++ /dev/null
@@ -1,28 +0,0 @@
-package org.apache.jena.osgi.test;
-
-import org.apache.felix.scr.annotations.Component;
-import org.apache.felix.scr.annotations.Service;
-import org.junit.Test;
-
-@Component
-@Service(JenaCoreTest.class)
-public class JenaCoreTestImpl implements JenaCoreTest {
-	@Test
-	public void coreTests() {
-		System.out.println("Testing stuff");
-		// Ideally we would run everything in com.hp.hpl.jena.test.TestPackage
-		// directly, but currently it relies heavily on the folder testing/ being
-		// on the current path. We'll cheat and set that at the user.dir..
-//		Path jenaCoreFolder = Paths.get("..", "jena-core");
-//		if (! Files.isDirectory(jenaCoreFolder.resolve("testing"))) { 
-//			throw new RuntimeException("Can't find ../jena-core/testing");
-//		}
-//		System.setProperty("user.dir", jenaCoreFolder.toAbsolutePath().toString());		
-		
-//		TestSuite suite = TestPackage.suite();
-//		junit.textui.TestRunner.run(suite) ;
-//        //SimpleTestRunner.runAndReport(suite) ;
-	}
-	
-
-}

http://git-wip-us.apache.org/repos/asf/jena/blob/b504678e/jena-osgi-test/src/main/java/org/apache/jena/osgi/test/JenaOSGITest.java
----------------------------------------------------------------------
diff --git a/jena-osgi-test/src/main/java/org/apache/jena/osgi/test/JenaOSGITest.java b/jena-osgi-test/src/main/java/org/apache/jena/osgi/test/JenaOSGITest.java
new file mode 100644
index 0000000..f19ee5f
--- /dev/null
+++ b/jena-osgi-test/src/main/java/org/apache/jena/osgi/test/JenaOSGITest.java
@@ -0,0 +1,29 @@
+package org.apache.jena.osgi.test;
+
+import org.junit.Test;
+
+/** 
+ * OSGi service interface for test using osgi-testrunner-junit4 
+ * <p>
+ * Junit annotations like @Test must be made here.
+ * The implementation is in JenaOSGITestImpl, which is registered
+ * with OSGi by JenaOSGIActiviator.
+ * 
+ * @author stain
+ *
+ */
+public interface JenaOSGITest {
+
+	@Test
+	public void testJenaIRI() throws Exception;
+
+	@Test
+	public void testJenaCore() throws Exception;
+	
+	@Test
+	public void testJenaArq() throws Exception;
+	
+	@Test
+	public void testJenaTdb() throws Exception;
+	
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/b504678e/jena-osgi-test/src/main/java/org/apache/jena/osgi/test/JenaOSGITestActivator.java
----------------------------------------------------------------------
diff --git a/jena-osgi-test/src/main/java/org/apache/jena/osgi/test/JenaOSGITestActivator.java b/jena-osgi-test/src/main/java/org/apache/jena/osgi/test/JenaOSGITestActivator.java
new file mode 100644
index 0000000..c57bb90
--- /dev/null
+++ b/jena-osgi-test/src/main/java/org/apache/jena/osgi/test/JenaOSGITestActivator.java
@@ -0,0 +1,24 @@
+package org.apache.jena.osgi.test;
+
+import java.util.Dictionary;
+import java.util.Hashtable;
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+
+public class JenaOSGITestActivator implements BundleActivator {
+
+	@Override
+	public void start(BundleContext context) throws Exception {
+		System.out.println("Starting ");
+		Dictionary<String, String> properties = new Hashtable<>();
+		properties.put("eosgi.testId", "JenaOSGITest");
+		properties.put("eosgi.testEngine", "junit4");		
+		context.registerService(JenaOSGITest.class, new JenaOSGITestImpl(), properties);
+	}
+
+	@Override
+	public void stop(BundleContext context) throws Exception {
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/b504678e/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
new file mode 100644
index 0000000..26a8747
--- /dev/null
+++ b/jena-osgi-test/src/main/java/org/apache/jena/osgi/test/JenaOSGITestImpl.java
@@ -0,0 +1,50 @@
+package org.apache.jena.osgi.test;
+
+import static org.junit.Assert.assertEquals;
+
+import java.io.StringWriter;
+import java.io.Writer;
+
+import org.apache.jena.iri.IRI;
+import org.apache.jena.iri.IRIFactory;
+
+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;
+
+public class JenaOSGITestImpl implements JenaOSGITest {
+
+	@Override
+	public void testJenaCore() throws Exception {
+		Model model = ModelFactory.createDefaultModel();
+		Resource alice = model.createResource("http://example.com/alice");		
+		Property knows = model.createProperty("http://xmlns.com/foaf/0.1/knows");
+		Resource bob = model.createResource("http://example.com/bob");
+		model.add(model.createStatement(alice, knows, bob));
+		
+		model.setWriterClassName("someWriter", "com.hp.hpl.jena.rdf.model.impl.NTripleWriter");
+		Writer writer = new StringWriter();
+		model.write(writer, "someWriter");
+		assertEquals("<http://example.com/alice> <http://xmlns.com/foaf/0.1/knows> <http://example.com/bob> .", 
+				writer.toString().trim());
+	}
+
+	@Override
+	public void testJenaArq() throws Exception {
+		//fail("Not quite");
+	}
+
+	@Override
+	public void testJenaIRI()throws Exception {
+		IRIFactory iriFactory = IRIFactory.jenaImplementation();
+		IRI iri = iriFactory.create("http://example.com/");
+		assertEquals("http://example.com/", iri.toASCIIString());
+	}
+
+	@Override
+	public void testJenaTdb() throws Exception {
+		//assertEquals(1,1);
+		
+	}
+}