felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fmesc...@apache.org
Subject svn commit: r1409819 - in /felix/trunk/scr/src/test: java/org/apache/felix/scr/integration/ComponentActivationTest.java resources/integration_test_activation_components.xml
Date Thu, 15 Nov 2012 14:57:47 GMT
Author: fmeschbe
Date: Thu Nov 15 14:57:46 2012
New Revision: 1409819

URL: http://svn.apache.org/viewvc?rev=1409819&view=rev
Log:
FELIX-3754 Add tests for delayed and service factory service components

Modified:
    felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/ComponentActivationTest.java
    felix/trunk/scr/src/test/resources/integration_test_activation_components.xml

Modified: felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/ComponentActivationTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/ComponentActivationTest.java?rev=1409819&r1=1409818&r2=1409819&view=diff
==============================================================================
--- felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/ComponentActivationTest.java
(original)
+++ felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/ComponentActivationTest.java
Thu Nov 15 14:57:46 2012
@@ -26,6 +26,7 @@ import org.apache.felix.scr.integration.
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.ops4j.pax.exam.junit.JUnit4TestRunner;
+import org.osgi.framework.ServiceReference;
 
 
 @RunWith(JUnit4TestRunner.class)
@@ -213,4 +214,62 @@ public class ComponentActivationTest ext
         delay();
         TestCase.assertEquals( Component.STATE_DISABLED, component.getState() );
     }
+
+
+    @Test
+    public void test_activate_register_service_delayed()
+    {
+        final String componentname = "ActivatorComponent.activate.delayed.with.bind";
+
+        final Component component = findComponentByName( componentname );
+
+        TestCase.assertNotNull( component );
+        TestCase.assertFalse( component.isDefaultEnabled() );
+
+        TestCase.assertEquals( Component.STATE_DISABLED, component.getState() );
+
+        component.enable();
+        delay();
+
+        TestCase.assertEquals( Component.STATE_REGISTERED, component.getState() );
+
+        ServiceReference<ActivatorComponent> ref = bundleContext.getServiceReference(
ActivatorComponent.class );
+        ActivatorComponent ac = bundleContext.getService( ref );
+        TestCase.assertNotNull( ac.getSimpleService() );
+
+        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
+
+        component.disable();
+
+        delay();
+        TestCase.assertEquals( Component.STATE_DISABLED, component.getState() );
+    }
+    @Test
+    public void test_activate_service_factory_register_service()
+    {
+        final String componentname = "ActivatorComponent.activate.service.factory.with.bind";
+
+        final Component component = findComponentByName( componentname );
+
+        TestCase.assertNotNull( component );
+        TestCase.assertFalse( component.isDefaultEnabled() );
+
+        TestCase.assertEquals( Component.STATE_DISABLED, component.getState() );
+
+        component.enable();
+        delay();
+
+        TestCase.assertEquals( Component.STATE_REGISTERED, component.getState() );
+
+        ServiceReference<ActivatorComponent> ref = bundleContext.getServiceReference(
ActivatorComponent.class );
+        ActivatorComponent ac = bundleContext.getService( ref );
+        TestCase.assertNotNull( ac.getSimpleService() );
+
+        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
+
+        component.disable();
+
+        delay();
+        TestCase.assertEquals( Component.STATE_DISABLED, component.getState() );
+    }
 }

Modified: felix/trunk/scr/src/test/resources/integration_test_activation_components.xml
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/test/resources/integration_test_activation_components.xml?rev=1409819&r1=1409818&r2=1409819&view=diff
==============================================================================
--- felix/trunk/scr/src/test/resources/integration_test_activation_components.xml (original)
+++ felix/trunk/scr/src/test/resources/integration_test_activation_components.xml Thu Nov
15 14:57:46 2012
@@ -87,4 +87,44 @@
             cardinality="0..n"
         />
     </scr:component>
+
+    <!-- bind service during activate -->
+    <scr:component name="ActivatorComponent.activate.delayed.with.bind"
+        enabled="false"
+        activate="myActivate"
+        deactivate="myDeactivate">
+        <implementation class="org.apache.felix.scr.integration.components.ActivatorComponent"
/>
+        <service factory="false">
+            <provide interface="org.apache.felix.scr.integration.components.ActivatorComponent"/>
+        </service>
+        <property name="registerService" value="true" />
+        <reference
+            name="service"
+            interface="org.apache.felix.scr.integration.components.SimpleService"
+            bind="bindSimpleService"
+            unbind="unbindSimpleService"
+            policy="dynamic"
+            cardinality="0..n"
+        />
+    </scr:component>
+
+    <!-- bind service during activate -->
+    <scr:component name="ActivatorComponent.activate.service.factory.with.bind"
+        enabled="false"
+        activate="myActivate"
+        deactivate="myDeactivate">
+        <implementation class="org.apache.felix.scr.integration.components.ActivatorComponent"
/>
+        <service factory="true">
+            <provide interface="org.apache.felix.scr.integration.components.ActivatorComponent"/>
+        </service>
+        <property name="registerService" value="true" />
+        <reference
+            name="service"
+            interface="org.apache.felix.scr.integration.components.SimpleService"
+            bind="bindSimpleService"
+            unbind="unbindSimpleService"
+            policy="dynamic"
+            cardinality="0..n"
+        />
+    </scr:component>
 </components>



Mime
View raw message