aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cummi...@apache.org
Subject svn commit: r1381245 - in /aries/trunk/samples/blueprint/helloworld: helloworld-client/src/main/resources/OSGI-INF/blueprint/config.xml helloworld-itests/src/test/java/org/apache/aries/samples/blueprint/helloworld/itests/HelloworldSampleTest.java
Date Wed, 05 Sep 2012 16:59:42 GMT
Author: cumminsh
Date: Wed Sep  5 16:59:41 2012
New Revision: 1381245

URL: http://svn.apache.org/viewvc?rev=1381245&view=rev
Log:
[ARIES-919] Reversing accidentally committed changes to blueprint helloworld sample blueprint.xml
and adding test with more robust checks.

Modified:
    aries/trunk/samples/blueprint/helloworld/helloworld-client/src/main/resources/OSGI-INF/blueprint/config.xml
    aries/trunk/samples/blueprint/helloworld/helloworld-itests/src/test/java/org/apache/aries/samples/blueprint/helloworld/itests/HelloworldSampleTest.java

Modified: aries/trunk/samples/blueprint/helloworld/helloworld-client/src/main/resources/OSGI-INF/blueprint/config.xml
URL: http://svn.apache.org/viewvc/aries/trunk/samples/blueprint/helloworld/helloworld-client/src/main/resources/OSGI-INF/blueprint/config.xml?rev=1381245&r1=1381244&r2=1381245&view=diff
==============================================================================
--- aries/trunk/samples/blueprint/helloworld/helloworld-client/src/main/resources/OSGI-INF/blueprint/config.xml
(original)
+++ aries/trunk/samples/blueprint/helloworld/helloworld-client/src/main/resources/OSGI-INF/blueprint/config.xml
Wed Sep  5 16:59:41 2012
@@ -15,13 +15,13 @@
                 License.
         -->
 <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
-    <!--
+    
         <reference id="helloservice"
                 interface="org.apache.aries.samples.blueprint.helloworld.api.HelloWorldService"
/>
-                <property name="helloWorldService" ref="helloservice" />
-                -->
+                
 
         <bean id="helloclient" class="org.apache.aries.samples.blueprint.helloworld.client.HelloWorldClient"
                 init-method="startUp">
+                <property name="helloWorldService" ref="helloservice" />
         </bean>
 </blueprint>

Modified: aries/trunk/samples/blueprint/helloworld/helloworld-itests/src/test/java/org/apache/aries/samples/blueprint/helloworld/itests/HelloworldSampleTest.java
URL: http://svn.apache.org/viewvc/aries/trunk/samples/blueprint/helloworld/helloworld-itests/src/test/java/org/apache/aries/samples/blueprint/helloworld/itests/HelloworldSampleTest.java?rev=1381245&r1=1381244&r2=1381245&view=diff
==============================================================================
--- aries/trunk/samples/blueprint/helloworld/helloworld-itests/src/test/java/org/apache/aries/samples/blueprint/helloworld/itests/HelloworldSampleTest.java
(original)
+++ aries/trunk/samples/blueprint/helloworld/helloworld-itests/src/test/java/org/apache/aries/samples/blueprint/helloworld/itests/HelloworldSampleTest.java
Wed Sep  5 16:59:41 2012
@@ -20,22 +20,26 @@ package org.apache.aries.samples.bluepri
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
 import static org.ops4j.pax.exam.CoreOptions.bootDelegationPackages;
 import static org.ops4j.pax.exam.CoreOptions.equinox;
 import static org.ops4j.pax.exam.CoreOptions.options;
 import static org.ops4j.pax.exam.CoreOptions.systemProperty;
 import static org.ops4j.pax.exam.container.def.PaxRunnerOptions.vmOption;
 
+import org.osgi.service.blueprint.container.BlueprintContainer;
+
 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;
+
 @RunWith(JUnit4TestRunner.class)
 public class HelloworldSampleTest extends AbstractIntegrationTest {
 
     @Test
-    public void test() throws Exception {
+    public void testBundlesStart() throws Exception {
 
         /* Check that the HelloWorld Sample bundles are present an started */
         Bundle bapi = getInstalledBundle("org.apache.aries.samples.blueprint.helloworld.api");
@@ -46,12 +50,91 @@ public class HelloworldSampleTest extend
 
         Bundle bcli = getInstalledBundle("org.apache.aries.samples.blueprint.helloworld.client");
         assertNotNull(bcli);
-        failInBundleNotActiveInFiveSeconds(bapi);
+        failInBundleNotActiveInFiveSeconds(bcli);
 
         Bundle bser = getInstalledBundle("org.apache.aries.samples.blueprint.helloworld.server");
         assertNotNull(bser);
-        failInBundleNotActiveInFiveSeconds(bapi);
+        failInBundleNotActiveInFiveSeconds(bser);
+    }
+    
+    @Test
+    public void testClientBlueprintContainerOnlyStartsWhenServiceStarted() throws Exception
+    {
+       // Stop everything before we start
+       Bundle bcli = getInstalledBundle("org.apache.aries.samples.blueprint.helloworld.client");
+       assertNotNull(bcli);
+       bcli.stop();
+
+       Bundle bser = getInstalledBundle("org.apache.aries.samples.blueprint.helloworld.server");
+       assertNotNull(bser);
+       bser.stop();
+
+       // Wait for everything to shut down 
+       Thread.sleep(1000);
+       
+       // When everything is stopped, there should be no blueprint container for either the
client or the server 
+       
+       assertClientBlueprintContainerNull();
+       assertServerBlueprintContainerNull();
+
+       // If we start the client first, it shouldn't have a blueprint container
+       bcli.start();
+
+       // Wait for everything to get started 
+       Thread.sleep(1000);
+       assertClientBlueprintContainerNull();
+       
+       // Then when we start the server both it and the client should have blueprint containers
+       bser.start();
+       // Wait for everything to get started 
+       Thread.sleep(1000);
+       assertClientBlueprintContainerNotNull();
+       assertServerBlueprintContainerNotNull();
+
+    }
+    
+    private BlueprintContainer getBlueprintContainer(String bundleName)
+    {       
+       BlueprintContainer container = null;
+       try {
+       container = getOsgiService(BlueprintContainer.class, "(osgi.blueprint.container.symbolicname="
+ bundleName + ")", 500);
+       } catch (RuntimeException e)
+       {
+          // Just return null if we couldn't get the container
+       }
+       return container;
+    }
+    
+    private BlueprintContainer getClientBlueprintContainer()
+    {
+       return getBlueprintContainer("org.apache.aries.samples.blueprint.helloworld.client");
+    }
+  
+    private BlueprintContainer getServerBlueprintContainer()
+    {
+       return getBlueprintContainer("org.apache.aries.samples.blueprint.helloworld.server");
     }
+    
+    private void assertClientBlueprintContainerNotNull()
+    {
+       assertNotNull("There was no blueprint container for the client bundle.", getClientBlueprintContainer());
+    }
+
+    private void assertClientBlueprintContainerNull()
+    {
+       assertNull("There was a blueprint container for the client bundle when we didn't expect
one.", getClientBlueprintContainer());
+    }
+
+    private void assertServerBlueprintContainerNotNull()
+    {
+       assertNotNull("There was no blueprint container for the server bundle.", getServerBlueprintContainer());
+    }
+
+    private void assertServerBlueprintContainerNull()
+    {
+       assertNull("There was a blueprint container for the server bundle when we didn't expect
one.", getServerBlueprintContainer());
+    }
+
 
     private void failInBundleNotActiveInFiveSeconds(Bundle bapi)
     {



Mime
View raw message