aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cschnei...@apache.org
Subject svn commit: r1605339 - in /aries/trunk/blueprint: blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/ blueprint-sample/
Date Wed, 25 Jun 2014 11:18:10 GMT
Author: cschneider
Date: Wed Jun 25 11:18:10 2014
New Revision: 1605339

URL: http://svn.apache.org/r1605339
Log:
ARIES-1218 Fix for test failure in BlueprintContainerBTCustomizerTest and some other test
improvements

Modified:
    aries/trunk/blueprint/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/AbstractBlueprintIntegrationTest.java
    aries/trunk/blueprint/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/BaseBlueprintContainerBTCustomizerTest.java
    aries/trunk/blueprint/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/BlueprintContainer2BTCustomizerTest.java
    aries/trunk/blueprint/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/BlueprintContainer2Test.java
    aries/trunk/blueprint/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/BlueprintContainerBTCustomizerTest.java
    aries/trunk/blueprint/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/BlueprintContainerTest.java
    aries/trunk/blueprint/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/DeadLockTest.java
    aries/trunk/blueprint/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/TestRegistrationListener.java
    aries/trunk/blueprint/blueprint-sample/pom.xml

Modified: aries/trunk/blueprint/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/AbstractBlueprintIntegrationTest.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/AbstractBlueprintIntegrationTest.java?rev=1605339&r1=1605338&r2=1605339&view=diff
==============================================================================
--- aries/trunk/blueprint/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/AbstractBlueprintIntegrationTest.java
(original)
+++ aries/trunk/blueprint/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/AbstractBlueprintIntegrationTest.java
Wed Jun 25 11:18:10 2014
@@ -27,16 +27,23 @@ import static org.ops4j.pax.exam.CoreOpt
 import static org.ops4j.pax.exam.CoreOptions.when;
 
 import java.io.InputStream;
+import java.util.Hashtable;
 
 import org.apache.aries.itest.AbstractIntegrationTest;
+import org.apache.aries.itest.RichBundleContext;
 import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.CoreOptions;
 import org.ops4j.pax.exam.Option;
 import org.ops4j.pax.exam.junit.PaxExam;
+import org.ops4j.pax.exam.options.MavenArtifactProvisionOption;
 import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
 import org.ops4j.pax.exam.spi.reactors.PerClass;
 import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
 import org.osgi.framework.BundleException;
 import org.osgi.service.blueprint.container.BlueprintContainer;
+import org.osgi.service.cm.Configuration;
+import org.osgi.service.cm.ConfigurationAdmin;
 
 /**
  * Base class for Pax Exam 1.2.x based unit tests
@@ -78,4 +85,29 @@ public abstract class AbstractBlueprintI
     	}
     	return is;
     }
+
+	protected void applyCommonConfiguration(BundleContext ctx) throws Exception {
+	    ConfigurationAdmin ca = (new RichBundleContext(ctx)).getService(ConfigurationAdmin.class);
       
+	    Configuration cf = ca.getConfiguration("blueprint-sample-placeholder", null);
+	    Hashtable<String, String> props = new Hashtable<String, String>();
+	    props.put("key.b", "10");
+	    cf.update(props);
+	}
+
+	protected Bundle getSampleBundle() {
+		Bundle bundle = context().getBundleByName("org.apache.aries.blueprint.sample");
+		assertNotNull(bundle);
+		return bundle;
+	}
+
+	protected MavenArtifactProvisionOption sampleBundleOption() {
+		return CoreOptions.mavenBundle("org.apache.aries.blueprint", "org.apache.aries.blueprint.sample").version("1.0.1-SNAPSHOT");
+	}
+
+	protected void startBlueprintBundles() throws BundleException,
+			InterruptedException {
+			    context().getBundleByName("org.apache.aries.blueprint.core").start();
+			    context().getBundleByName("org.apache.aries.blueprint.cm").start();
+			    Thread.sleep(2000);
+			}
 }

Modified: aries/trunk/blueprint/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/BaseBlueprintContainerBTCustomizerTest.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/BaseBlueprintContainerBTCustomizerTest.java?rev=1605339&r1=1605338&r2=1605339&view=diff
==============================================================================
--- aries/trunk/blueprint/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/BaseBlueprintContainerBTCustomizerTest.java
(original)
+++ aries/trunk/blueprint/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/BaseBlueprintContainerBTCustomizerTest.java
Wed Jun 25 11:18:10 2014
@@ -23,12 +23,10 @@ import java.io.InputStream;
 import java.net.MalformedURLException;
 import java.net.URL;
 import java.util.HashMap;
-import java.util.Hashtable;
 import java.util.Map;
 
 import javax.inject.Inject;
 
-import org.apache.aries.itest.RichBundleContext;
 import org.junit.Assert;
 import org.ops4j.pax.exam.CoreOptions;
 import org.ops4j.pax.exam.options.MavenArtifactProvisionOption;
@@ -36,8 +34,6 @@ import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.BundleException;
 import org.osgi.framework.Constants;
-import org.osgi.service.cm.Configuration;
-import org.osgi.service.cm.ConfigurationAdmin;
 import org.osgi.service.framework.CompositeBundle;
 import org.osgi.service.framework.CompositeBundleFactory;
 
@@ -47,15 +43,24 @@ public abstract class BaseBlueprintConta
 	@Inject
 	CompositeBundleFactory cbf;
 
+	/**
+	 * Make sure to adapt the imports and exports to the imports and exports needed by the sample
+	 * bundle. If they are wrong then there might be an error like:
+	 * composite bundle could not be resolved: bundle was disabled:null
+	 * @return
+	 */
     protected Map<String, String> getCompositeManifest() {
         Map<String, String> compositeManifest = new HashMap<String, String>();
         compositeManifest.put(Constants.BUNDLE_SYMBOLICNAME, "test-composite");
         compositeManifest.put(Constants.BUNDLE_VERSION, "1.0.0");
         // this import-package is used by the blueprint.sample
-        compositeManifest.put(Constants.IMPORT_PACKAGE, "org.osgi.service.blueprint;version=\"[1.0.0,2.0.0)\",
org.osgi.service.blueprint.container;version=1.0, org.osgi.service.cm");
+        compositeManifest.put(Constants.IMPORT_PACKAGE, "org.osgi.framework;version=\"[1.6,2)\","
+        		+ "org.osgi.service.cm,"
+        		+ "org.osgi.service.blueprint;version=\"[1.0.0,2.0.0)\","
+        		+ "org.osgi.service.blueprint.container;version=\"[1.0,2)\"");
         // this export-package is used by pax junit runner as it needs to see the blueprint
sample package 
         // for the test after the blueprint sample is started.
-        compositeManifest.put(Constants.EXPORT_PACKAGE, "org.apache.aries.blueprint.sample");
+        compositeManifest.put(Constants.EXPORT_PACKAGE, "org.apache.aries.blueprint.sample;version=\"1.0.1\"");
         
         return compositeManifest;
     }
@@ -64,14 +69,6 @@ public abstract class BaseBlueprintConta
 		return CoreOptions.mavenBundle("org.apache.felix", "org.apache.felix.configadmin").versionAsInProject();
 	}
     
-    protected void applyCommonConfiguration(BundleContext ctx) throws Exception {
-        ConfigurationAdmin ca = (new RichBundleContext(ctx)).getService(ConfigurationAdmin.class);
       
-        Configuration cf = ca.getConfiguration("blueprint-sample-placeholder", null);
-        Hashtable<String, String> props = new Hashtable<String, String>();
-        props.put("key.b", "10");
-        cf.update(props);
-    }
-    
     protected Bundle installBundle(BundleContext bundleContext, String url) throws IOException,
MalformedURLException, BundleException {
         // let's use input stream to avoid invoking mvn url handler which isn't avail in
the child framework.
         InputStream is = new URL(url).openStream();
@@ -80,10 +77,6 @@ public abstract class BaseBlueprintConta
         return bundle;
     }
 
-	protected MavenArtifactProvisionOption testBundleOption() {
-		return CoreOptions.mavenBundle("org.apache.aries.blueprint", "org.apache.aries.blueprint.sample").versionAsInProject();
-	}
-
 	protected CompositeBundle createCompositeBundle() throws BundleException {
 		Map<String, String> frameworkConfig = new HashMap<String, String>();
 	    Map<String, String> compositeManifest = getCompositeManifest();

Modified: aries/trunk/blueprint/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/BlueprintContainer2BTCustomizerTest.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/BlueprintContainer2BTCustomizerTest.java?rev=1605339&r1=1605338&r2=1605339&view=diff
==============================================================================
--- aries/trunk/blueprint/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/BlueprintContainer2BTCustomizerTest.java
(original)
+++ aries/trunk/blueprint/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/BlueprintContainer2BTCustomizerTest.java
Wed Jun 25 11:18:10 2014
@@ -27,7 +27,6 @@ import org.ops4j.pax.exam.Option;
 import org.ops4j.pax.exam.junit.PaxExam;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
-import org.osgi.framework.BundleException;
 import org.osgi.service.framework.CompositeBundle;
 
 /**
@@ -45,7 +44,7 @@ public class BlueprintContainer2BTCustom
     public void test() throws Exception {
         CompositeBundle cb = createCompositeBundle();
         BundleContext compositeBundleContext = cb.getCompositeFramework().getBundleContext();
-        Bundle bundle = installBundle(compositeBundleContext, testBundleOption().getURL());
+        Bundle testBundle = installBundle(compositeBundleContext, sampleBundleOption().getURL());
         Bundle configAdminBundle = installBundle(compositeBundleContext, configAdminOption().getURL());
         
         // start the composite bundle, config admin then the blueprint sample
@@ -53,19 +52,12 @@ public class BlueprintContainer2BTCustom
         configAdminBundle.start();
         // create a config to check the property placeholder
         applyCommonConfiguration(compositeBundleContext);
-        bundle.start();
+        testBundle.start();
 
         startBlueprintBundles();
 
         // do the test
-        Helper.testBlueprintContainer(new RichBundleContext(compositeBundleContext), bundle);
-    }
-
-    // start the blueprint bundle and it should detect the previously started blueprint sample
-    private void startBlueprintBundles() throws BundleException, InterruptedException {
-        context().getBundleByName("org.apache.aries.blueprint.core").start();
-        context().getBundleByName("org.apache.aries.blueprint.cm").start();
-        Thread.sleep(2000);
+        Helper.testBlueprintContainer(new RichBundleContext(compositeBundleContext), testBundle);
     }
 
     @Configuration

Modified: aries/trunk/blueprint/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/BlueprintContainer2Test.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/BlueprintContainer2Test.java?rev=1605339&r1=1605338&r2=1605339&view=diff
==============================================================================
--- aries/trunk/blueprint/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/BlueprintContainer2Test.java
(original)
+++ aries/trunk/blueprint/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/BlueprintContainer2Test.java
Wed Jun 25 11:18:10 2014
@@ -20,15 +20,11 @@ package org.apache.aries.blueprint.itest
 
 import static org.apache.aries.blueprint.itests.Helper.mvnBundle;
 
-import java.util.Hashtable;
-
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.ops4j.pax.exam.Option;
 import org.ops4j.pax.exam.junit.PaxExam;
 import org.osgi.framework.Bundle;
-import org.osgi.service.cm.Configuration;
-import org.osgi.service.cm.ConfigurationAdmin;
 
 /**
  * this test is based on blueprint container test, but this test starts the
@@ -41,20 +37,11 @@ public class BlueprintContainer2Test ext
 
     @Test
     public void test() throws Exception {
-        // Create a config to check the property placeholder
-        ConfigurationAdmin ca = context().getService(ConfigurationAdmin.class);
-        Configuration cf = ca.getConfiguration("blueprint-sample-placeholder", null);
-        Hashtable<String, String> props = new Hashtable<String, String>();
-        props.put("key.b", "10");
-        cf.update(props);
-
-        Bundle bundle = context().getBundleByName("org.apache.aries.blueprint.sample");
-        Bundle blueprintBundle = context().getBundleByName("org.apache.aries.blueprint.core");
-        Bundle blueprintCMBundle = context().getBundleByName("org.apache.aries.blueprint.cm");
+    	applyCommonConfiguration(context());
 
+        Bundle bundle = getSampleBundle();
         bundle.start();
-        blueprintBundle.start();
-        blueprintCMBundle.start();
+        startBlueprintBundles();
         
         // do the test
         Helper.testBlueprintContainer(context(), bundle);

Modified: aries/trunk/blueprint/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/BlueprintContainerBTCustomizerTest.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/BlueprintContainerBTCustomizerTest.java?rev=1605339&r1=1605338&r2=1605339&view=diff
==============================================================================
--- aries/trunk/blueprint/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/BlueprintContainerBTCustomizerTest.java
(original)
+++ aries/trunk/blueprint/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/BlueprintContainerBTCustomizerTest.java
Wed Jun 25 11:18:10 2014
@@ -44,7 +44,7 @@ public class BlueprintContainerBTCustomi
         CompositeBundle cb = createCompositeBundle();
 
         BundleContext compositeBundleContext = cb.getCompositeFramework().getBundleContext();
-        Bundle testBundle = installBundle(compositeBundleContext, testBundleOption().getURL());
+        Bundle testBundle = installBundle(compositeBundleContext, sampleBundleOption().getURL());
         Bundle configAdminBundle = installBundle(compositeBundleContext, configAdminOption().getURL());
         // start the composite bundle, config admin then the blueprint sample
         cb.start();

Modified: aries/trunk/blueprint/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/BlueprintContainerTest.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/BlueprintContainerTest.java?rev=1605339&r1=1605338&r2=1605339&view=diff
==============================================================================
--- aries/trunk/blueprint/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/BlueprintContainerTest.java
(original)
+++ aries/trunk/blueprint/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/BlueprintContainerTest.java
Wed Jun 25 11:18:10 2014
@@ -21,28 +21,17 @@ package org.apache.aries.blueprint.itest
 import static org.apache.aries.blueprint.itests.Helper.mvnBundle;
 import static org.junit.Assert.assertNotNull;
 
-import java.util.Hashtable;
-
 import org.junit.Test;
 import org.ops4j.pax.exam.Option;
 import org.osgi.framework.Bundle;
-import org.osgi.service.cm.Configuration;
-import org.osgi.service.cm.ConfigurationAdmin;
 
 public class BlueprintContainerTest extends AbstractBlueprintIntegrationTest {
 
     @Test
     public void test() throws Exception {
-        // Create a config to check the property placeholder
-        ConfigurationAdmin ca = context().getService(ConfigurationAdmin.class);
-        Configuration cf = ca.getConfiguration("blueprint-sample-placeholder", null);
-        Hashtable<String, String> props = new Hashtable<String, String>();
-        props.put("key.b", "10");
-        cf.update(props);
-
+    	applyCommonConfiguration(context());
         Bundle bundle = context().getBundleByName("org.apache.aries.blueprint.sample");
         assertNotNull(bundle);
-
         bundle.start();
         
         // do the test

Modified: aries/trunk/blueprint/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/DeadLockTest.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/DeadLockTest.java?rev=1605339&r1=1605338&r2=1605339&view=diff
==============================================================================
--- aries/trunk/blueprint/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/DeadLockTest.java
(original)
+++ aries/trunk/blueprint/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/DeadLockTest.java
Wed Jun 25 11:18:10 2014
@@ -103,17 +103,15 @@ public class DeadLockTest extends Abstra
     public void testDeadlock() throws Exception {
       bundleContext.registerService("java.util.Set",new HashSet<Object>(), null);
       
-      Bundle bundle = context().getBundleByName("org.apache.aries.blueprint.sample");
-      assertNotNull(bundle);
-
+      Bundle bundle = getSampleBundle();
       bundle.start();
       
       Helper.getBlueprintContainerForBundle(context(), "org.apache.aries.blueprint.sample");
       
       // no actual assertions, we just don't want to deadlock
     }
-    
-    @org.ops4j.pax.exam.Configuration
+
+	@org.ops4j.pax.exam.Configuration
     public Option[] configuration() {
         return new Option[] {
             baseOptions(),

Modified: aries/trunk/blueprint/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/TestRegistrationListener.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/TestRegistrationListener.java?rev=1605339&r1=1605338&r2=1605339&view=diff
==============================================================================
--- aries/trunk/blueprint/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/TestRegistrationListener.java
(original)
+++ aries/trunk/blueprint/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/TestRegistrationListener.java
Wed Jun 25 11:18:10 2014
@@ -31,7 +31,6 @@ import org.apache.aries.blueprint.sample
 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.osgi.service.blueprint.container.BlueprintContainer;

Modified: aries/trunk/blueprint/blueprint-sample/pom.xml
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-sample/pom.xml?rev=1605339&r1=1605338&r2=1605339&view=diff
==============================================================================
--- aries/trunk/blueprint/blueprint-sample/pom.xml (original)
+++ aries/trunk/blueprint/blueprint-sample/pom.xml Wed Jun 25 11:18:10 2014
@@ -59,12 +59,11 @@
     </properties>
 
     <dependencies>
-        <dependency>
-            <groupId>org.eclipse</groupId>
-            <artifactId>osgi</artifactId>
-            <version>3.5.0.v20090520</version>
-            <scope>provided</scope>
-        </dependency>
+		<dependency>
+			<groupId>org.osgi</groupId>
+			<artifactId>org.osgi.core</artifactId>
+			<scope>provided</scope>
+		</dependency>
         <dependency>
             <groupId>org.apache.aries.blueprint</groupId>
             <artifactId>org.apache.aries.blueprint.api</artifactId>



Mime
View raw message