aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mnutt...@apache.org
Subject svn commit: r1358121 - in /aries/trunk/subsystem/subsystem-itests: ./ src/test/bundles/dynamicImport/ src/test/bundles/dynamicImport/META-INF/ src/test/bundles/dynamicImport/org/ src/test/bundles/dynamicImport/org/apache/ src/test/bundles/dynamicImport...
Date Fri, 06 Jul 2012 11:06:34 GMT
Author: mnuttall
Date: Fri Jul  6 11:06:34 2012
New Revision: 1358121

URL: http://svn.apache.org/viewvc?rev=1358121&view=rev
Log:
Aries-868: First test to prove that something needs to be done :)

Added:
    aries/trunk/subsystem/subsystem-itests/src/test/bundles/dynamicImport/
    aries/trunk/subsystem/subsystem-itests/src/test/bundles/dynamicImport/META-INF/
    aries/trunk/subsystem/subsystem-itests/src/test/bundles/dynamicImport/META-INF/MANIFEST.MF
    aries/trunk/subsystem/subsystem-itests/src/test/bundles/dynamicImport/org/
    aries/trunk/subsystem/subsystem-itests/src/test/bundles/dynamicImport/org/apache/
    aries/trunk/subsystem/subsystem-itests/src/test/bundles/dynamicImport/org/apache/aries/
    aries/trunk/subsystem/subsystem-itests/src/test/bundles/dynamicImport/org/apache/aries/subsystem/
    aries/trunk/subsystem/subsystem-itests/src/test/bundles/dynamicImport/org/apache/aries/subsystem/itests/
    aries/trunk/subsystem/subsystem-itests/src/test/bundles/dynamicImport/org/apache/aries/subsystem/itests/dynamicImport/
    aries/trunk/subsystem/subsystem-itests/src/test/bundles/dynamicImport/org/apache/aries/subsystem/itests/dynamicImport/Activator.java
    aries/trunk/subsystem/subsystem-itests/src/test/bundles/dynamicImport/org/apache/aries/subsystem/itests/dynamicImport/DynamicImportHelloImpl.java
    aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/DynamicImportTest.java
    aries/trunk/subsystem/subsystem-itests/src/test/resources/dynamicImport/
    aries/trunk/subsystem/subsystem-itests/src/test/resources/dynamicImport/OSGI-INF/
    aries/trunk/subsystem/subsystem-itests/src/test/resources/dynamicImport/OSGI-INF/SUBSYSTEM.MF
Modified:
    aries/trunk/subsystem/subsystem-itests/pom.xml

Modified: aries/trunk/subsystem/subsystem-itests/pom.xml
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-itests/pom.xml?rev=1358121&r1=1358120&r2=1358121&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-itests/pom.xml (original)
+++ aries/trunk/subsystem/subsystem-itests/pom.xml Fri Jul  6 11:06:34 2012
@@ -368,7 +368,7 @@
 						<phase>process-test-classes</phase>
 					</execution>
 					
-					<!-- New pom for hello tests, part 1 -->
+					<!-- New pom for hello + related tests, part 1 -->
 					
 					<execution>
 						<id>hello-impl</id>
@@ -389,6 +389,25 @@
 						<phase>process-test-classes</phase>
 					</execution>
 					
+					<execution>
+						<id>dynamic-import-impl</id>
+						<goals>
+							<goal>jar</goal>
+						</goals>
+						<configuration>
+							<archive>
+								<manifestFile>src/test/bundles/dynamicImport/META-INF/MANIFEST.MF</manifestFile>
+							</archive>
+							<classesDirectory>${project.build.directory}/test-classes</classesDirectory>
+							<includes>
+								<include>org/apache/aries/subsystem/itests/dynamicImport/**</include>
+							</includes>
+							<outputDirectory>src/test/resources/dynamicImport</outputDirectory>
+							<finalName>dynamicImport</finalName>
+						</configuration>
+						<phase>process-test-classes</phase>
+					</execution>
+					
 					<!-- End of new pom for hello tests, part 1 -->
 					
 					
@@ -451,6 +470,19 @@
 						</configuration>
 					</execution>
 					
+					<execution>
+						<id>add-source-dynamicImport</id>
+						<phase>generate-sources</phase>
+						<goals>
+							<goal>add-test-source</goal>
+						</goals>
+						<configuration>
+							<sources>
+								<source>src/test/bundles/dynamicImport</source>
+							</sources>
+						</configuration>
+					</execution>
+					
 					<!-- End of new pom for hello tests, part 2 -->
 					
 				</executions>

Added: aries/trunk/subsystem/subsystem-itests/src/test/bundles/dynamicImport/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-itests/src/test/bundles/dynamicImport/META-INF/MANIFEST.MF?rev=1358121&view=auto
==============================================================================
--- aries/trunk/subsystem/subsystem-itests/src/test/bundles/dynamicImport/META-INF/MANIFEST.MF
(added)
+++ aries/trunk/subsystem/subsystem-itests/src/test/bundles/dynamicImport/META-INF/MANIFEST.MF
Fri Jul  6 11:06:34 2012
@@ -0,0 +1,10 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: dynamic-import package test bundle
+Bundle-SymbolicName: org.apache.aries.subsystem.itests.dynamicImport
+Bundle-Version: 1.0.0
+Import-Package: org.apache.aries.subsystem.itests.hello.api
+Bundle-Activator: org.apache.aries.subsystem.itests.dynamicImport.Activator
+Provide-Capability: osgi.ee;osgi.ee=JavaSE;version=1.5
+DynamicImport-Package: org.osgi.framework
+

Added: aries/trunk/subsystem/subsystem-itests/src/test/bundles/dynamicImport/org/apache/aries/subsystem/itests/dynamicImport/Activator.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-itests/src/test/bundles/dynamicImport/org/apache/aries/subsystem/itests/dynamicImport/Activator.java?rev=1358121&view=auto
==============================================================================
--- aries/trunk/subsystem/subsystem-itests/src/test/bundles/dynamicImport/org/apache/aries/subsystem/itests/dynamicImport/Activator.java
(added)
+++ aries/trunk/subsystem/subsystem-itests/src/test/bundles/dynamicImport/org/apache/aries/subsystem/itests/dynamicImport/Activator.java
Fri Jul  6 11:06:34 2012
@@ -0,0 +1,32 @@
+package org.apache.aries.subsystem.itests.dynamicImport;
+
+import org.apache.aries.subsystem.itests.hello.api.Hello;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceRegistration;
+
+public class Activator implements BundleActivator 
+{
+
+	ServiceRegistration _sr = null;
+	
+	@Override
+	public void start(BundleContext bc) throws Exception 
+	{
+		System.out.println ("into " + this.getClass().getCanonicalName() + ".start()");
+		
+		Hello helloService = new DynamicImportHelloImpl();
+		
+		_sr = bc.registerService(Hello.class, helloService, null);
+		
+		System.out.println ("exiting " + this.getClass().getCanonicalName() + ".start()");
+	}
+
+	@Override
+	public void stop(BundleContext bc) throws Exception 
+	{
+		if (_sr != null) { 
+			_sr.unregister();
+		}
+	}
+}

Added: aries/trunk/subsystem/subsystem-itests/src/test/bundles/dynamicImport/org/apache/aries/subsystem/itests/dynamicImport/DynamicImportHelloImpl.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-itests/src/test/bundles/dynamicImport/org/apache/aries/subsystem/itests/dynamicImport/DynamicImportHelloImpl.java?rev=1358121&view=auto
==============================================================================
--- aries/trunk/subsystem/subsystem-itests/src/test/bundles/dynamicImport/org/apache/aries/subsystem/itests/dynamicImport/DynamicImportHelloImpl.java
(added)
+++ aries/trunk/subsystem/subsystem-itests/src/test/bundles/dynamicImport/org/apache/aries/subsystem/itests/dynamicImport/DynamicImportHelloImpl.java
Fri Jul  6 11:06:34 2012
@@ -0,0 +1,17 @@
+package org.apache.aries.subsystem.itests.dynamicImport;
+
+import org.apache.aries.subsystem.itests.hello.api.Hello;
+
+public class DynamicImportHelloImpl implements Hello {
+
+	public DynamicImportHelloImpl() 
+	{ 
+		System.out.println ("DynamicImportHelloImpl constructed");
+	}
+	
+	@Override
+	public String saySomething() {
+		return "Hello, this is something";
+	}
+
+}

Added: aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/DynamicImportTest.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/DynamicImportTest.java?rev=1358121&view=auto
==============================================================================
--- aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/DynamicImportTest.java
(added)
+++ aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/DynamicImportTest.java
Fri Jul  6 11:06:34 2012
@@ -0,0 +1,90 @@
+package org.apache.aries.subsystem.itests;
+
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+import static org.ops4j.pax.exam.CoreOptions.options;
+import static org.ops4j.pax.exam.OptionUtils.combine;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.junit.JUnit4TestRunner;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleException;
+import org.osgi.service.subsystem.Subsystem;
+import org.osgi.service.subsystem.SubsystemException;
+
+/*
+ * Simple iTest for dynamic imports. In the first instance we'll use a 
+ * DynamicImport-Package header because it's the simplest to set up. 
+ * _Hopefully_ if this works, then packages added by WeavingProxy services
+ * will also work. If not, we'll need extra tests :-/ 
+ */
+@RunWith(JUnit4TestRunner.class)
+public class DynamicImportTest extends SubsystemTest 
+{
+	private static boolean _testAppCreated = false;
+	
+	@Before
+	public void setUp() throws Exception 
+	{
+		super.setUp();
+		if (!_testAppCreated) { 
+			createApplication("dynamicImport", new String[]{"dynamicImport.jar"});
+			_testAppCreated = true;
+		}
+	}
+
+	/*
+	 * Install an .esa containing a bundle with a BundleActivator, and a 
+	 * DynamicImport-Package on org.osgi.framework. This app should fail to 
+	 * start unless we do something to stop the SubsystemResolverHook 
+	 * from preventing this package from wiring. 
+	 */
+	@Test
+	public void verifyThatDynamicImportNeedsHandling() throws Exception
+	{
+		
+		System.out.println ("Into verifyThatDynamicImportNeedsHandling");
+		
+		Subsystem subsystem = installSubsystemFromFile ("dynamicImport.esa");
+		try { 
+			startSubsystem(subsystem);
+			Bundle[] bundles = subsystem.getBundleContext().getBundles();
+			for (Bundle b : bundles) { 
+				System.out.println (b.getSymbolicName() + " -> " + b.getState());
+			}
+			fail ("dynamicImport.esa started when we didn't expect it to");
+		} catch (SubsystemException sx) { 
+			Throwable cause = sx.getCause();
+			assertTrue("BundleException expected", cause instanceof BundleException);
+		}
+	}
+/*	
+	@Test
+	public void testHello() throws Exception 
+	{
+		Subsystem subsystem = installSubsystemFromFile("hello.esa");
+		try {
+			subsystem.start();
+			BundleContext bc = subsystem.getBundleContext();
+			Hello h = getOsgiService(bc, Hello.class, null, DEFAULT_TIMEOUT);
+			String message = h.saySomething();
+			assertEquals ("Wrong message back", "something", message);
+			subsystem.stop();
+		}
+		finally {
+			uninstallSubsystemSilently(subsystem);
+		}
+	} */
+	
+	protected static Option[] updateOptions(Option[] options) 
+	{
+		Option[] helloOptions = options(
+				mavenBundle("org.apache.aries.subsystem", "org.apache.aries.subsystem.itest.interfaces")
+//				org.ops4j.pax.exam.container.def.PaxRunnerOptions.vmOption("-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005"),
+		);
+		return combine(helloOptions, options);
+	}
+}

Added: aries/trunk/subsystem/subsystem-itests/src/test/resources/dynamicImport/OSGI-INF/SUBSYSTEM.MF
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-itests/src/test/resources/dynamicImport/OSGI-INF/SUBSYSTEM.MF?rev=1358121&view=auto
==============================================================================
--- aries/trunk/subsystem/subsystem-itests/src/test/resources/dynamicImport/OSGI-INF/SUBSYSTEM.MF
(added)
+++ aries/trunk/subsystem/subsystem-itests/src/test/resources/dynamicImport/OSGI-INF/SUBSYSTEM.MF
Fri Jul  6 11:06:34 2012
@@ -0,0 +1,3 @@
+Subsystem-SymbolicName: org.apache.aries.subsystem.itests.dynamicImport.esa
+Subsystem-Type: osgi.subsystem.application
+Subsystem-Content: org.apache.aries.subsystem.itests.dynamicImport



Mime
View raw message