felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r1602633 [3/5] - in /felix/trunk/scr: ./ src/test/java/org/apache/felix/scr/integration/ src/test/java/org/apache/felix/scr/integration/components/ src/test/java/org/apache/felix/scr/integration/components/activatesignature/ src/test/resour...
Date Sun, 15 Jun 2014 01:09:32 GMT
Modified: felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/ServiceBindGreedyTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/ServiceBindGreedyTest.java?rev=1602633&r1=1602632&r2=1602633&view=diff
==============================================================================
--- felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/ServiceBindGreedyTest.java (original)
+++ felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/ServiceBindGreedyTest.java Sun Jun 15 01:09:31 2014
@@ -20,9 +20,8 @@ package org.apache.felix.scr.integration
 
 
 import java.util.Hashtable;
-
 import junit.framework.TestCase;
-import org.apache.felix.scr.Component;
+
 import org.apache.felix.scr.integration.components.SimpleComponent;
 import org.apache.felix.scr.integration.components.SimpleComponent2;
 import org.apache.felix.scr.integration.components.SimpleService2Impl;
@@ -35,6 +34,7 @@ import org.osgi.framework.ServiceReferen
 import org.osgi.service.component.ComponentConstants;
 import org.osgi.service.component.ComponentFactory;
 import org.osgi.service.component.ComponentInstance;
+import org.osgi.service.component.runtime.dto.ComponentConfigurationDTO;
 
 
 @RunWith(JUnit4TestRunner.class)
@@ -55,17 +55,10 @@ public class ServiceBindGreedyTest exten
     @Test
     public void test_optional_single_dynamic()
     {
-        final Component component = findComponentByName( "test_optional_single_dynamic" );
-        TestCase.assertNotNull( component );
-        TestCase.assertEquals( Component.STATE_DISABLED, component.getState() );
-
-        final SimpleServiceImpl srv1 = SimpleServiceImpl.create( bundleContext, "srv1", 1 );
-
-        // async enabling
-        component.enable();
-        delay();
+        final SimpleServiceImpl srv1 = SimpleServiceImpl.create( bundleContext, "srv1" );
 
-        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
+        String name ="test_optional_single_dynamic";
+        ComponentConfigurationDTO cc = getDisabledConfigurationAndEnable(name, ComponentConfigurationDTO.ACTIVE);
         final SimpleComponent comp10 = SimpleComponent.INSTANCE;
         TestCase.assertNotNull( comp10 );
         TestCase.assertEquals( srv1, comp10.m_singleRef );
@@ -74,7 +67,6 @@ public class ServiceBindGreedyTest exten
         srv1.drop();
         // no delay, should be immediate
 
-        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
         final SimpleComponent comp11 = SimpleComponent.INSTANCE;
         TestCase.assertSame( comp10, comp11 );
         TestCase.assertNull( comp11.m_singleRef );
@@ -83,23 +75,22 @@ public class ServiceBindGreedyTest exten
         final SimpleServiceImpl srv2 = SimpleServiceImpl.create( bundleContext, "srv2", 2 );
         delay(); // async binding
 
-        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
+        findComponentConfigurationByName(name, ComponentConfigurationDTO.ACTIVE);
         final SimpleComponent comp12 = SimpleComponent.INSTANCE;
         TestCase.assertSame( comp10, comp12 );
         TestCase.assertEquals( srv2, comp12.m_singleRef );
         TestCase.assertTrue( comp12.m_multiRef.isEmpty() );
 
-        component.disable();
-        delay(); // async disabling
+        disableAndCheck(cc);
 
         final SimpleServiceImpl srv3 = SimpleServiceImpl.create( bundleContext, "srv3", 2 );
 
         // enable component with two services available of same ranking, expect srv2 bind
         // async enabling
-        component.enable();
+        enableAndCheck(cc.description);
         delay();
 
-        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
+        findComponentConfigurationByName(name, ComponentConfigurationDTO.ACTIVE);
         final SimpleComponent comp20 = SimpleComponent.INSTANCE;
         TestCase.assertNotNull( comp20 );
         TestCase.assertNotSame( comp10, comp20 );
@@ -109,7 +100,7 @@ public class ServiceBindGreedyTest exten
         // drop srv2, expect rebind to srv3 (synchronously)
         srv2.drop();
 
-        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
+        findComponentConfigurationByName(name, ComponentConfigurationDTO.ACTIVE);
         final SimpleComponent comp21 = SimpleComponent.INSTANCE;
         TestCase.assertSame( comp20, comp21 );
         TestCase.assertEquals( srv3, comp21.m_singleRef );
@@ -119,7 +110,7 @@ public class ServiceBindGreedyTest exten
         final SimpleServiceImpl srv4 = SimpleServiceImpl.create( bundleContext, "srv4", 4 );
         delay();
 
-        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
+        findComponentConfigurationByName(name, ComponentConfigurationDTO.ACTIVE);
         final SimpleComponent comp22 = SimpleComponent.INSTANCE;
         TestCase.assertSame( comp20, comp22 );
         TestCase.assertEquals( srv4, comp22.m_singleRef );
@@ -129,14 +120,14 @@ public class ServiceBindGreedyTest exten
         srv4.drop();
         delay();
 
-        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
+        findComponentConfigurationByName(name, ComponentConfigurationDTO.ACTIVE);
         final SimpleComponent comp23 = SimpleComponent.INSTANCE;
         TestCase.assertSame( comp20, comp23 );
         TestCase.assertEquals( srv3, comp23.m_singleRef );
         TestCase.assertTrue( comp23.m_multiRef.isEmpty() );
 
         // "reset"
-        component.disable();
+        disableAndCheck(cc);
         srv3.drop();
         delay();
 
@@ -144,10 +135,10 @@ public class ServiceBindGreedyTest exten
         final SimpleServiceImpl srv5 = SimpleServiceImpl.create( bundleContext, "srv5", 10 );
         final SimpleServiceImpl srv6 = SimpleServiceImpl.create( bundleContext, "srv6", 20 );
 
-        component.enable();
+        enableAndCheck(cc.description);
         delay();
 
-        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
+        findComponentConfigurationByName(name, ComponentConfigurationDTO.ACTIVE);
         final SimpleComponent comp30 = SimpleComponent.INSTANCE;
         TestCase.assertNotSame( comp20, comp30 );
         TestCase.assertEquals( srv6, comp30.m_singleRef );
@@ -157,7 +148,7 @@ public class ServiceBindGreedyTest exten
         final SimpleServiceImpl srv7 = SimpleServiceImpl.create( bundleContext, "srv7", 30 );
         delay();
 
-        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
+        findComponentConfigurationByName(name, ComponentConfigurationDTO.ACTIVE);
         final SimpleComponent comp31 = SimpleComponent.INSTANCE;
         TestCase.assertSame( comp30, comp31 );
         TestCase.assertEquals( srv7, comp31.m_singleRef );
@@ -167,7 +158,7 @@ public class ServiceBindGreedyTest exten
         srv6.drop();
         delay();
 
-        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
+        findComponentConfigurationByName(name, ComponentConfigurationDTO.ACTIVE);
         final SimpleComponent comp32 = SimpleComponent.INSTANCE;
         TestCase.assertSame( comp30, comp32 );
         TestCase.assertEquals( srv7, comp32.m_singleRef );
@@ -178,17 +169,11 @@ public class ServiceBindGreedyTest exten
     @Test
     public void test_required_single_dynamic()
     {
-        final Component component = findComponentByName( "test_required_single_dynamic" );
-        TestCase.assertNotNull( component );
-        TestCase.assertEquals( Component.STATE_DISABLED, component.getState() );
-
         final SimpleServiceImpl srv1 = SimpleServiceImpl.create( bundleContext, "srv1", 1 );
 
-        // async enabling
-        component.enable();
-        delay();
+        String name ="test_required_single_dynamic";
+        ComponentConfigurationDTO cc = getDisabledConfigurationAndEnable(name, ComponentConfigurationDTO.ACTIVE);
 
-        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
         final SimpleComponent comp10 = SimpleComponent.INSTANCE;
         TestCase.assertNotNull( comp10 );
         TestCase.assertEquals( srv1, comp10.m_singleRef );
@@ -197,30 +182,31 @@ public class ServiceBindGreedyTest exten
         srv1.drop();
         // no delay, should be immediate
 
-        TestCase.assertEquals( Component.STATE_UNSATISFIED, component.getState() );
+        findComponentConfigurationByName(name, ComponentConfigurationDTO.UNSATISFIED);
+//        findComponentConfigurationByName(name, ComponentConfigurationDTO.UNSATISFIED);
         final SimpleComponent comp11 = SimpleComponent.INSTANCE;
         TestCase.assertNull( comp11 );
 
         final SimpleServiceImpl srv2 = SimpleServiceImpl.create( bundleContext, "srv2", 2 );
         delay(); // async binding
 
-        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
+        findComponentConfigurationByName(name, ComponentConfigurationDTO.ACTIVE);
         final SimpleComponent comp12 = SimpleComponent.INSTANCE;
         TestCase.assertNotSame( comp10, comp12 );
         TestCase.assertEquals( srv2, comp12.m_singleRef );
         TestCase.assertTrue( comp12.m_multiRef.isEmpty() );
 
-        component.disable();
+        disableAndCheck(cc);
         delay(); // async disabling
 
         final SimpleServiceImpl srv3 = SimpleServiceImpl.create( bundleContext, "srv3", 2 );
 
         // enable component with two services available of same ranking, expect srv2 bind
         // async enabling
-        component.enable();
+        enableAndCheck(cc.description);
         delay();
 
-        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
+        findComponentConfigurationByName(name, ComponentConfigurationDTO.ACTIVE);
         final SimpleComponent comp20 = SimpleComponent.INSTANCE;
         TestCase.assertNotNull( comp20 );
         TestCase.assertNotSame( comp10, comp20 );
@@ -230,7 +216,7 @@ public class ServiceBindGreedyTest exten
         // drop srv2, expect rebind to srv3 (synchronously)
         srv2.drop();
 
-        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
+        findComponentConfigurationByName(name, ComponentConfigurationDTO.ACTIVE);
         final SimpleComponent comp21 = SimpleComponent.INSTANCE;
         TestCase.assertSame( comp20, comp21 );
         TestCase.assertEquals( srv3, comp21.m_singleRef );
@@ -240,7 +226,7 @@ public class ServiceBindGreedyTest exten
         final SimpleServiceImpl srv4 = SimpleServiceImpl.create( bundleContext, "srv4", 2 );
         delay();
 
-        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
+        findComponentConfigurationByName(name, ComponentConfigurationDTO.ACTIVE);
         final SimpleComponent comp22 = SimpleComponent.INSTANCE;
         TestCase.assertSame( comp20, comp22 );
         TestCase.assertEquals( srv3, comp22.m_singleRef );
@@ -250,14 +236,14 @@ public class ServiceBindGreedyTest exten
         srv4.drop();
         delay();
 
-        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
+        findComponentConfigurationByName(name, ComponentConfigurationDTO.ACTIVE);
         final SimpleComponent comp23 = SimpleComponent.INSTANCE;
         TestCase.assertSame( comp20, comp23 );
         TestCase.assertEquals( srv3, comp23.m_singleRef );
         TestCase.assertTrue( comp23.m_multiRef.isEmpty() );
 
         // "reset"
-        component.disable();
+        disableAndCheck(cc);
         srv3.drop();
         delay();
 
@@ -265,10 +251,10 @@ public class ServiceBindGreedyTest exten
         final SimpleServiceImpl srv5 = SimpleServiceImpl.create( bundleContext, "srv5", 10 );
         final SimpleServiceImpl srv6 = SimpleServiceImpl.create( bundleContext, "srv6", 20 );
 
-        component.enable();
+        enableAndCheck(cc.description);
         delay();
 
-        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
+        findComponentConfigurationByName(name, ComponentConfigurationDTO.ACTIVE);
         final SimpleComponent comp30 = SimpleComponent.INSTANCE;
         TestCase.assertNotSame( comp20, comp30 );
         TestCase.assertEquals( srv6, comp30.m_singleRef );
@@ -278,7 +264,7 @@ public class ServiceBindGreedyTest exten
         final SimpleServiceImpl srv7 = SimpleServiceImpl.create( bundleContext, "srv7", 30 );
         delay();
 
-        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
+        findComponentConfigurationByName(name, ComponentConfigurationDTO.ACTIVE);
         final SimpleComponent comp31 = SimpleComponent.INSTANCE;
         TestCase.assertSame( comp30, comp31 );
         TestCase.assertEquals( srv7, comp31.m_singleRef );
@@ -288,7 +274,7 @@ public class ServiceBindGreedyTest exten
         srv6.drop();
         delay();
 
-        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
+        findComponentConfigurationByName(name, ComponentConfigurationDTO.ACTIVE);
         final SimpleComponent comp32 = SimpleComponent.INSTANCE;
         TestCase.assertSame( comp30, comp32 );
         TestCase.assertEquals( srv7, comp32.m_singleRef );
@@ -299,17 +285,11 @@ public class ServiceBindGreedyTest exten
     @Test
     public void test_optional_multiple_dynamic()
     {
-        final Component component = findComponentByName( "test_optional_multiple_dynamic" );
-        TestCase.assertNotNull( component );
-        TestCase.assertEquals( Component.STATE_DISABLED, component.getState() );
-
         final SimpleServiceImpl srv1 = SimpleServiceImpl.create( bundleContext, "srv1" );
 
-        // async enabling
-        component.enable();
-        delay();
+        String name ="test_optional_multiple_dynamic";
+        ComponentConfigurationDTO cc = getDisabledConfigurationAndEnable(name, ComponentConfigurationDTO.ACTIVE);
 
-        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
         final SimpleComponent comp10 = SimpleComponent.INSTANCE;
         TestCase.assertNotNull( comp10 );
         TestCase.assertNull( comp10.m_singleRef );
@@ -318,7 +298,7 @@ public class ServiceBindGreedyTest exten
         srv1.drop();
         // no delay, should be immediate
 
-        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
+        findComponentConfigurationByName(name, ComponentConfigurationDTO.ACTIVE);
         final SimpleComponent comp11 = SimpleComponent.INSTANCE;
         TestCase.assertSame( comp10, comp11 );
         TestCase.assertNull( comp11.m_singleRef );
@@ -327,23 +307,23 @@ public class ServiceBindGreedyTest exten
         final SimpleServiceImpl srv2 = SimpleServiceImpl.create( bundleContext, "srv2" );
         delay(); // async binding
 
-        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
+        findComponentConfigurationByName(name, ComponentConfigurationDTO.ACTIVE);
         final SimpleComponent comp12 = SimpleComponent.INSTANCE;
         TestCase.assertSame( comp10, comp12 );
         TestCase.assertNull( comp12.m_singleRef );
         TestCase.assertTrue( comp12.m_multiRef.contains( srv2 ) );
 
-        component.disable();
+        disableAndCheck(cc);
         delay(); // async disabling
 
         final SimpleServiceImpl srv3 = SimpleServiceImpl.create( bundleContext, "srv3" );
 
         // enable component with two services available, expect both bind
         // async enabling
-        component.enable();
+        enableAndCheck(cc.description);
         delay();
 
-        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
+        findComponentConfigurationByName(name, ComponentConfigurationDTO.ACTIVE);
         final SimpleComponent comp20 = SimpleComponent.INSTANCE;
         TestCase.assertNotNull( comp20 );
         TestCase.assertNotSame( comp10, comp20 );
@@ -353,7 +333,7 @@ public class ServiceBindGreedyTest exten
 
         srv2.drop();
 
-        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
+        findComponentConfigurationByName(name, ComponentConfigurationDTO.ACTIVE);
         final SimpleComponent comp21 = SimpleComponent.INSTANCE;
         TestCase.assertSame( comp20, comp21 );
         TestCase.assertNull( comp21.m_singleRef );
@@ -364,7 +344,7 @@ public class ServiceBindGreedyTest exten
         final SimpleServiceImpl srv4 = SimpleServiceImpl.create( bundleContext, "srv4" );
         delay();
 
-        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
+        findComponentConfigurationByName(name, ComponentConfigurationDTO.ACTIVE);
         final SimpleComponent comp22 = SimpleComponent.INSTANCE;
         TestCase.assertSame( comp20, comp22 );
         TestCase.assertNull( comp22.m_singleRef );
@@ -376,7 +356,7 @@ public class ServiceBindGreedyTest exten
         srv4.drop();
         delay();
 
-        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
+        findComponentConfigurationByName(name, ComponentConfigurationDTO.ACTIVE);
         final SimpleComponent comp23 = SimpleComponent.INSTANCE;
         TestCase.assertSame( comp20, comp23 );
         TestCase.assertNull( comp23.m_singleRef );
@@ -385,7 +365,7 @@ public class ServiceBindGreedyTest exten
         TestCase.assertFalse( comp23.m_multiRef.contains( srv4 ) );
 
         // "reset"
-        component.disable();
+        disableAndCheck(cc);
         srv3.drop();
         delay();
 
@@ -393,10 +373,10 @@ public class ServiceBindGreedyTest exten
         final SimpleServiceImpl srv5 = SimpleServiceImpl.create( bundleContext, "srv5", 10 );
         final SimpleServiceImpl srv6 = SimpleServiceImpl.create( bundleContext, "srv6", 20 );
 
-        component.enable();
+        enableAndCheck(cc.description);
         delay();
 
-        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
+        findComponentConfigurationByName(name, ComponentConfigurationDTO.ACTIVE);
         final SimpleComponent comp30 = SimpleComponent.INSTANCE;
         TestCase.assertNotSame( comp20, comp30 );
         TestCase.assertNull( comp30.m_singleRef );
@@ -407,7 +387,8 @@ public class ServiceBindGreedyTest exten
         final SimpleServiceImpl srv7 = SimpleServiceImpl.create( bundleContext, "srv7", 30 );
         delay();
 
-        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
+        findComponentConfigurationByName(name, ComponentConfigurationDTO.ACTIVE);
+
         final SimpleComponent comp31 = SimpleComponent.INSTANCE;
         TestCase.assertSame( comp30, comp31 );
         TestCase.assertNull( comp31.m_singleRef );
@@ -419,7 +400,8 @@ public class ServiceBindGreedyTest exten
         srv6.drop();
         delay();
 
-        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
+        findComponentConfigurationByName(name, ComponentConfigurationDTO.ACTIVE);
+
         final SimpleComponent comp32 = SimpleComponent.INSTANCE;
         TestCase.assertSame( comp30, comp32 );
         TestCase.assertNull( comp32.m_singleRef );
@@ -432,17 +414,11 @@ public class ServiceBindGreedyTest exten
     @Test
     public void test_required_multiple_dynamic()
     {
-        final Component component = findComponentByName( "test_required_multiple_dynamic" );
-        TestCase.assertNotNull( component );
-        TestCase.assertEquals( Component.STATE_DISABLED, component.getState() );
-
         final SimpleServiceImpl srv1 = SimpleServiceImpl.create( bundleContext, "srv1" );
 
-        // async enabling
-        component.enable();
-        delay();
+        String name ="test_required_multiple_dynamic";
+        ComponentConfigurationDTO cc = getDisabledConfigurationAndEnable(name, ComponentConfigurationDTO.ACTIVE);
 
-        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
         final SimpleComponent comp10 = SimpleComponent.INSTANCE;
         TestCase.assertNotNull( comp10 );
         TestCase.assertNull( comp10.m_singleRef );
@@ -451,30 +427,32 @@ public class ServiceBindGreedyTest exten
         srv1.drop();
         // no delay, should be immediate
 
-        TestCase.assertEquals( Component.STATE_UNSATISFIED, component.getState() );
+        findComponentConfigurationByName(name, ComponentConfigurationDTO.UNSATISFIED);
         final SimpleComponent comp11 = SimpleComponent.INSTANCE;
         TestCase.assertNull( comp11 );
 
         final SimpleServiceImpl srv2 = SimpleServiceImpl.create( bundleContext, "srv2" );
         delay(); // async binding
 
-        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
+        findComponentConfigurationByName(name, ComponentConfigurationDTO.ACTIVE);
+
         final SimpleComponent comp12 = SimpleComponent.INSTANCE;
         TestCase.assertNotSame( comp10, comp12 );
         TestCase.assertNull( comp12.m_singleRef );
         TestCase.assertTrue( comp12.m_multiRef.contains( srv2 ) );
 
-        component.disable();
+        disableAndCheck(cc);
         delay(); // async disabling
 
         final SimpleServiceImpl srv3 = SimpleServiceImpl.create( bundleContext, "srv3" );
 
         // enable component with two services available, expect both bind
         // async enabling
-        component.enable();
+        enableAndCheck(cc.description);
         delay();
 
-        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
+        findComponentConfigurationByName(name, ComponentConfigurationDTO.ACTIVE);
+
         final SimpleComponent comp20 = SimpleComponent.INSTANCE;
         TestCase.assertNotNull( comp20 );
         TestCase.assertNotSame( comp10, comp20 );
@@ -484,7 +462,8 @@ public class ServiceBindGreedyTest exten
 
         srv2.drop();
 
-        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
+        findComponentConfigurationByName(name, ComponentConfigurationDTO.ACTIVE);
+
         final SimpleComponent comp21 = SimpleComponent.INSTANCE;
         TestCase.assertSame( comp20, comp21 );
         TestCase.assertNull( comp21.m_singleRef );
@@ -495,7 +474,8 @@ public class ServiceBindGreedyTest exten
         final SimpleServiceImpl srv4 = SimpleServiceImpl.create( bundleContext, "srv4" );
         delay();
 
-        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
+        findComponentConfigurationByName(name, ComponentConfigurationDTO.ACTIVE);
+
         final SimpleComponent comp22 = SimpleComponent.INSTANCE;
         TestCase.assertSame( comp20, comp22 );
         TestCase.assertNull( comp22.m_singleRef );
@@ -507,7 +487,8 @@ public class ServiceBindGreedyTest exten
         srv4.drop();
         delay();
 
-        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
+        findComponentConfigurationByName(name, ComponentConfigurationDTO.ACTIVE);
+
         final SimpleComponent comp23 = SimpleComponent.INSTANCE;
         TestCase.assertSame( comp20, comp23 );
         TestCase.assertNull( comp23.m_singleRef );
@@ -516,7 +497,7 @@ public class ServiceBindGreedyTest exten
         TestCase.assertFalse( comp23.m_multiRef.contains( srv4 ) );
 
         // "reset"
-        component.disable();
+        disableAndCheck(cc);
         srv3.drop();
         delay();
 
@@ -524,10 +505,11 @@ public class ServiceBindGreedyTest exten
         final SimpleServiceImpl srv5 = SimpleServiceImpl.create( bundleContext, "srv5", 10 );
         final SimpleServiceImpl srv6 = SimpleServiceImpl.create( bundleContext, "srv6", 20 );
 
-        component.enable();
+        enableAndCheck(cc.description);
         delay();
 
-        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
+        findComponentConfigurationByName(name, ComponentConfigurationDTO.ACTIVE);
+
         final SimpleComponent comp30 = SimpleComponent.INSTANCE;
         TestCase.assertNotSame( comp20, comp30 );
         TestCase.assertNull( comp30.m_singleRef );
@@ -538,7 +520,8 @@ public class ServiceBindGreedyTest exten
         final SimpleServiceImpl srv7 = SimpleServiceImpl.create( bundleContext, "srv7", 30 );
         delay();
 
-        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
+        findComponentConfigurationByName(name, ComponentConfigurationDTO.ACTIVE);
+
         final SimpleComponent comp31 = SimpleComponent.INSTANCE;
         TestCase.assertSame( comp30, comp31 );
         TestCase.assertNull( comp31.m_singleRef );
@@ -550,7 +533,8 @@ public class ServiceBindGreedyTest exten
         srv6.drop();
         delay();
 
-        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
+        findComponentConfigurationByName(name, ComponentConfigurationDTO.ACTIVE);
+
         final SimpleComponent comp32 = SimpleComponent.INSTANCE;
         TestCase.assertSame( comp30, comp32 );
         TestCase.assertNull( comp32.m_singleRef );
@@ -563,22 +547,24 @@ public class ServiceBindGreedyTest exten
     @Test
     public void test_required_multiple_dynamic_factory() throws InvalidSyntaxException
     {
-        final String pid = "test_required_multiple_dynamic_factory";
-        final String factoryPid = "factory_" + pid;
-
-        final Component component = findComponentByName( pid );
-        TestCase.assertNotNull( component );
-        TestCase.assertEquals( Component.STATE_DISABLED, component.getState() );
-
-        // async enabling (unsatisfied)
-        component.enable();
-        delay();
-        TestCase.assertEquals( Component.STATE_UNSATISFIED, component.getState() );
+        String name ="test_required_multiple_dynamic_factory"; //also pid
+        final String factoryPid = "factory_" + name;
+        getConfigurationsDisabledThenEnable(name, 0, ComponentConfigurationDTO.UNSATISFIED);
+//        final String pid = "test_required_multiple_dynamic_factory";
+//
+//        final Component component = findComponentDescriptorByName( pid );
+//        TestCase.assertNotNull( component );
+//        TestCase.assertEquals( Component.STATE_DISABLED, component.getState() );
+//
+//        // async enabling (unsatisfied)
+//        enableAndCheck(cc.description);
+//        delay();
+//        findComponentConfigurationByName(name, ComponentConfigurationDTO.UNSATISFIED);
 
         // register service, satisfying
         final SimpleServiceImpl srv1 = SimpleServiceImpl.create( bundleContext, "srv1" );
         delay();
-        TestCase.assertEquals( Component.STATE_FACTORY, component.getState() );
+//        TestCase.assertEquals( Component.STATE_FACTORY, component.getState() );
 
         // create a component instance
         final ServiceReference[] refs = bundleContext.getServiceReferences( ComponentFactory.class.getName(), "("
@@ -601,28 +587,29 @@ public class ServiceBindGreedyTest exten
         TestCase.assertTrue( sc.m_multiRef.contains( srv1 ) );
 
         // ensure factory is not bound
-        TestCase.assertNull( component.getReferences()[0].getServiceReferences() );
+//        TestCase.assertNull( component.getReferences()[0].getServiceReferences() );
 
         // assert two components managed
-        final Component[] allFactoryComponents = findComponentsByName( pid );
-        TestCase.assertNotNull( allFactoryComponents );
-        TestCase.assertEquals( 2, allFactoryComponents.length );
-        for ( int i = 0; i < allFactoryComponents.length; i++ )
-        {
-            final Component c = allFactoryComponents[i];
-            if ( c.getId() == component.getId() )
-            {
-                TestCase.assertEquals( Component.STATE_FACTORY, c.getState() );
-            }
-            else if ( c.getId() == SimpleComponent.INSTANCE.m_id )
-            {
-                TestCase.assertEquals( Component.STATE_ACTIVE, c.getState() );
-            }
-            else
-            {
-                TestCase.fail( "Unexpected Component " + c );
-            }
-        }
+        checkConfigurationCount(name, 1, ComponentConfigurationDTO.ACTIVE);
+//        final Component[] allFactoryComponents = findComponentConfigurationsByName( pid, -1 );
+//        TestCase.assertNotNull( allFactoryComponents );
+//        TestCase.assertEquals( 2, allFactoryComponents.length );
+//        for ( int i = 0; i < allFactoryComponents.length; i++ )
+//        {
+//            final Component c = allFactoryComponents[i];
+//            if ( c.getId() == component.getId() )
+//            {
+//                TestCase.assertEquals( Component.STATE_FACTORY, c.getState() );
+//            }
+//            else if ( c.getId() == SimpleComponent.INSTANCE.m_id )
+//            {
+//                TestCase.assertEquals( Component.STATE_ACTIVE, c.getState() );
+//            }
+//            else
+//            {
+//                TestCase.fail( "Unexpected Component " + c );
+//            }
+//        }
 
         // register second service
         final SimpleServiceImpl srv11 = SimpleServiceImpl.create( bundleContext, "srv11" );
@@ -634,7 +621,7 @@ public class ServiceBindGreedyTest exten
         TestCase.assertTrue( sc.m_multiRef.contains( srv11 ) );
 
         // ensure factory is not bound
-        TestCase.assertNull( component.getReferences()[0].getServiceReferences() );
+//        TestCase.assertNull( component.getReferences()[0].getServiceReferences() );
 
         // drop second service and ensure unbound (and active)
         srv11.drop();
@@ -643,73 +630,69 @@ public class ServiceBindGreedyTest exten
         TestCase.assertEquals( SimpleComponent.INSTANCE, instance.getInstance() );
         TestCase.assertEquals( 1, sc.m_multiRef.size() );
         TestCase.assertTrue( sc.m_multiRef.contains( srv1 ) );
-        TestCase.assertNull( component.getReferences()[0].getServiceReferences() );
+//        TestCase.assertNull( component.getReferences()[0].getServiceReferences() );
 
 
         // remove the service, expect factory to deactivate and instance to dispose
         srv1.drop();
         delay();
 
-        TestCase.assertEquals( Component.STATE_UNSATISFIED, component.getState() );
+        findComponentConfigurationByName(name, ComponentConfigurationDTO.UNSATISFIED);
         TestCase.assertNull( instance.getInstance() );
 
         // assert component factory only managed
-        final Component[] allFactoryComponents2 = findComponentsByName( pid );
-        TestCase.assertNotNull( allFactoryComponents2 );
-        TestCase.assertEquals( 1, allFactoryComponents2.length );
-        for ( int i = 0; i < allFactoryComponents2.length; i++ )
-        {
-            final Component c = allFactoryComponents2[i];
-            if ( c.getId() == component.getId() )
-            {
-                TestCase.assertEquals( Component.STATE_UNSATISFIED, c.getState() );
-            }
-            else
-            {
-                TestCase.fail( "Unexpected Component " + c );
-            }
-        }
+        //TODO this check should be whether the service is registered.
+//        final Component[] allFactoryComponents2 = findComponentConfigurationsByName( pid, -1 );
+//        TestCase.assertNotNull( allFactoryComponents2 );
+//        TestCase.assertEquals( 1, allFactoryComponents2.length );
+//        for ( int i = 0; i < allFactoryComponents2.length; i++ )
+//        {
+//            final Component c = allFactoryComponents2[i];
+//            if ( c.getId() == component.getId() )
+//            {
+//                TestCase.assertEquals( Component.STATE_UNSATISFIED, c.getState() );
+//            }
+//            else
+//            {
+//                TestCase.fail( "Unexpected Component " + c );
+//            }
+//        }
 
         // registeranother service, factory must come back, instance not
         final SimpleServiceImpl srv2 = SimpleServiceImpl.create( bundleContext, "srv2" );
         delay();
 
-        TestCase.assertEquals( Component.STATE_FACTORY, component.getState() );
+//        TestCase.assertEquals( Component.STATE_FACTORY, component.getState() );
         TestCase.assertNull( instance.getInstance() );
 
         // assert component factory only managed
-        final Component[] allFactoryComponents3 = findComponentsByName( pid );
-        TestCase.assertNotNull( allFactoryComponents3 );
-        TestCase.assertEquals( 1, allFactoryComponents3.length );
-        for ( int i = 0; i < allFactoryComponents3.length; i++ )
-        {
-            final Component c = allFactoryComponents3[i];
-            if ( c.getId() == component.getId() )
-            {
-                TestCase.assertEquals( Component.STATE_FACTORY, c.getState() );
-            }
-            else
-            {
-                TestCase.fail( "Unexpected Component " + c );
-            }
-        }
+        checkConfigurationCount(name, 0, -1);
+//        final Component[] allFactoryComponents3 = findComponentConfigurationsByName( pid, -1 );
+//        TestCase.assertNotNull( allFactoryComponents3 );
+//        TestCase.assertEquals( 1, allFactoryComponents3.length );
+//        for ( int i = 0; i < allFactoryComponents3.length; i++ )
+//        {
+//            final Component c = allFactoryComponents3[i];
+//            if ( c.getId() == component.getId() )
+//            {
+//                TestCase.assertEquals( Component.STATE_FACTORY, c.getState() );
+//            }
+//            else
+//            {
+//                TestCase.fail( "Unexpected Component " + c );
+//            }
+//        }
     }
 
 
     @Test
     public void test_optional_single_static()
     {
-        final Component component = findComponentByName( "test_optional_single_static" );
-        TestCase.assertNotNull( component );
-        TestCase.assertEquals( Component.STATE_DISABLED, component.getState() );
-
         final SimpleServiceImpl srv1 = SimpleServiceImpl.create( bundleContext, "srv1" );
 
-        // async enabling
-        component.enable();
-        delay();
+        String name ="test_optional_single_static";
+        ComponentConfigurationDTO cc = getDisabledConfigurationAndEnable(name, ComponentConfigurationDTO.ACTIVE);
 
-        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
         final SimpleComponent comp10 = SimpleComponent.INSTANCE;
         TestCase.assertNotNull( comp10 );
         TestCase.assertEquals( srv1, comp10.m_singleRef );
@@ -718,7 +701,8 @@ public class ServiceBindGreedyTest exten
         srv1.drop();
         delay(); // async reactivate
 
-        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
+        findComponentConfigurationByName(name, ComponentConfigurationDTO.ACTIVE);
+
         final SimpleComponent comp11 = SimpleComponent.INSTANCE;
         TestCase.assertNotSame( comp10, comp11 );
         TestCase.assertNull( comp11.m_singleRef );
@@ -728,24 +712,25 @@ public class ServiceBindGreedyTest exten
         delay(); // async binding
 
         // greedy static reference rebinds
-        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
+        findComponentConfigurationByName(name, ComponentConfigurationDTO.ACTIVE);
         final SimpleComponent comp12 = SimpleComponent.INSTANCE;
         TestCase.assertNotSame( comp10, comp12 );
         TestCase.assertNotSame( comp11, comp12 );
         TestCase.assertEquals( srv2, comp12.m_singleRef );
         TestCase.assertTrue( comp12.m_multiRef.isEmpty() );
 
-        component.disable();
+        disableAndCheck(cc);
         delay(); // async disabling
 
         final SimpleServiceImpl srv3 = SimpleServiceImpl.create( bundleContext, "srv3" );
 
         // enable component with two services available, expect srv2 bind
         // async enabling
-        component.enable();
+        enableAndCheck(cc.description);
         delay();
 
-        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
+        findComponentConfigurationByName(name, ComponentConfigurationDTO.ACTIVE);
+
         final SimpleComponent comp20 = SimpleComponent.INSTANCE;
         TestCase.assertNotNull( comp20 );
         TestCase.assertNotSame( comp10, comp20 );
@@ -756,7 +741,8 @@ public class ServiceBindGreedyTest exten
         srv2.drop();
         delay(); // async reactivate
 
-        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
+        findComponentConfigurationByName(name, ComponentConfigurationDTO.ACTIVE);
+
         final SimpleComponent comp21 = SimpleComponent.INSTANCE;
         TestCase.assertNotSame( comp20, comp21 );
         TestCase.assertEquals( srv3, comp21.m_singleRef );
@@ -766,7 +752,8 @@ public class ServiceBindGreedyTest exten
         final SimpleServiceImpl srv4 = SimpleServiceImpl.create( bundleContext, "srv4", -1 );
         delay();
 
-        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
+        findComponentConfigurationByName(name, ComponentConfigurationDTO.ACTIVE);
+
         final SimpleComponent comp22 = SimpleComponent.INSTANCE;
         TestCase.assertNotSame( comp20, comp22 );
         TestCase.assertSame( comp21, comp22 );
@@ -777,7 +764,8 @@ public class ServiceBindGreedyTest exten
         srv4.drop();
         delay();
 
-        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
+        findComponentConfigurationByName(name, ComponentConfigurationDTO.ACTIVE);
+
         final SimpleComponent comp23 = SimpleComponent.INSTANCE;
         TestCase.assertNotSame( comp20, comp23 );
         TestCase.assertSame( comp21, comp23 );
@@ -786,7 +774,7 @@ public class ServiceBindGreedyTest exten
         TestCase.assertTrue( comp23.m_multiRef.isEmpty() );
 
         // "reset"
-        component.disable();
+        disableAndCheck(cc);
         srv3.drop();
         delay();
 
@@ -794,10 +782,11 @@ public class ServiceBindGreedyTest exten
         final SimpleServiceImpl srv5 = SimpleServiceImpl.create( bundleContext, "srv5", 10 );
         final SimpleServiceImpl srv6 = SimpleServiceImpl.create( bundleContext, "srv6", 20 );
 
-        component.enable();
+        enableAndCheck(cc.description);
         delay();
 
-        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
+        findComponentConfigurationByName(name, ComponentConfigurationDTO.ACTIVE);
+
         final SimpleComponent comp30 = SimpleComponent.INSTANCE;
         TestCase.assertNotSame( comp23, comp30 );
         TestCase.assertEquals( srv6, comp30.m_singleRef );
@@ -807,7 +796,8 @@ public class ServiceBindGreedyTest exten
         final SimpleServiceImpl srv7 = SimpleServiceImpl.create( bundleContext, "srv7", 30 );
         delay();
 
-        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
+        findComponentConfigurationByName(name, ComponentConfigurationDTO.ACTIVE);
+
         final SimpleComponent comp31 = SimpleComponent.INSTANCE;
         TestCase.assertNotSame( comp30, comp31 );
         TestCase.assertEquals( srv7, comp31.m_singleRef );
@@ -817,7 +807,8 @@ public class ServiceBindGreedyTest exten
         srv6.drop();
         delay();
 
-        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
+        findComponentConfigurationByName(name, ComponentConfigurationDTO.ACTIVE);
+
         final SimpleComponent comp32 = SimpleComponent.INSTANCE;
         TestCase.assertNotSame( comp30, comp32 );
         TestCase.assertSame( comp31, comp32 );
@@ -829,17 +820,11 @@ public class ServiceBindGreedyTest exten
     @Test
     public void test_required_single_static()
     {
-        final Component component = findComponentByName( "test_required_single_static" );
-        TestCase.assertNotNull( component );
-        TestCase.assertEquals( Component.STATE_DISABLED, component.getState() );
-
         final SimpleServiceImpl srv1 = SimpleServiceImpl.create( bundleContext, "srv1" );
 
-        // async enabling
-        component.enable();
-        delay();
+        String name ="test_required_single_static";
+        ComponentConfigurationDTO cc = getDisabledConfigurationAndEnable(name, ComponentConfigurationDTO.ACTIVE);
 
-        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
         final SimpleComponent comp10 = SimpleComponent.INSTANCE;
         TestCase.assertNotNull( comp10 );
         TestCase.assertEquals( srv1, comp10.m_singleRef );
@@ -848,30 +833,32 @@ public class ServiceBindGreedyTest exten
         srv1.drop();
         delay(); // async reactivate
 
-        TestCase.assertEquals( Component.STATE_UNSATISFIED, component.getState() );
+        findComponentConfigurationByName(name, ComponentConfigurationDTO.UNSATISFIED);
         final SimpleComponent comp11 = SimpleComponent.INSTANCE;
         TestCase.assertNull( comp11 );
 
         final SimpleServiceImpl srv2 = SimpleServiceImpl.create( bundleContext, "srv2" );
         delay(); // async binding
 
-        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
+        findComponentConfigurationByName(name, ComponentConfigurationDTO.ACTIVE);
+
         final SimpleComponent comp12 = SimpleComponent.INSTANCE;
         TestCase.assertNotSame( comp10, comp12 );
         TestCase.assertEquals( srv2, comp12.m_singleRef );
         TestCase.assertTrue( comp12.m_multiRef.isEmpty() );
 
-        component.disable();
+        disableAndCheck(cc);
         delay(); // async disabling
 
         final SimpleServiceImpl srv3 = SimpleServiceImpl.create( bundleContext, "srv3" );
 
         // enable component with two services available, expect srv2 bind
         // async enabling
-        component.enable();
+        enableAndCheck(cc.description);
         delay();
 
-        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
+        findComponentConfigurationByName(name, ComponentConfigurationDTO.ACTIVE);
+
         final SimpleComponent comp20 = SimpleComponent.INSTANCE;
         TestCase.assertNotNull( comp20 );
         TestCase.assertNotSame( comp10, comp20 );
@@ -882,7 +869,8 @@ public class ServiceBindGreedyTest exten
         srv2.drop();
         delay(); // async reactivate
 
-        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
+        findComponentConfigurationByName(name, ComponentConfigurationDTO.ACTIVE);
+
         final SimpleComponent comp21 = SimpleComponent.INSTANCE;
         TestCase.assertNotSame( comp20, comp21 );
         TestCase.assertEquals( srv3, comp21.m_singleRef );
@@ -892,7 +880,8 @@ public class ServiceBindGreedyTest exten
         final SimpleServiceImpl srv4 = SimpleServiceImpl.create( bundleContext, "srv4" );
         delay();
 
-        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
+        findComponentConfigurationByName(name, ComponentConfigurationDTO.ACTIVE);
+
         final SimpleComponent comp22 = SimpleComponent.INSTANCE;
         TestCase.assertNotSame( comp20, comp22 );
         TestCase.assertSame( comp21, comp22 );
@@ -903,7 +892,8 @@ public class ServiceBindGreedyTest exten
         srv4.drop();
         delay();
 
-        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
+        findComponentConfigurationByName(name, ComponentConfigurationDTO.ACTIVE);
+
         final SimpleComponent comp23 = SimpleComponent.INSTANCE;
         TestCase.assertNotSame( comp20, comp23 );
         TestCase.assertSame( comp21, comp23 );
@@ -912,7 +902,7 @@ public class ServiceBindGreedyTest exten
         TestCase.assertTrue( comp23.m_multiRef.isEmpty() );
 
         // "reset"
-        component.disable();
+        disableAndCheck(cc);
         srv3.drop();
         delay();
 
@@ -920,10 +910,11 @@ public class ServiceBindGreedyTest exten
         final SimpleServiceImpl srv5 = SimpleServiceImpl.create( bundleContext, "srv5", 10 );
         final SimpleServiceImpl srv6 = SimpleServiceImpl.create( bundleContext, "srv6", 20 );
 
-        component.enable();
+        enableAndCheck(cc.description);
         delay();
 
-        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
+        findComponentConfigurationByName(name, ComponentConfigurationDTO.ACTIVE);
+
         final SimpleComponent comp30 = SimpleComponent.INSTANCE;
         TestCase.assertNotSame( comp23, comp30 );
         TestCase.assertEquals( srv6, comp30.m_singleRef );
@@ -933,7 +924,8 @@ public class ServiceBindGreedyTest exten
         final SimpleServiceImpl srv7 = SimpleServiceImpl.create( bundleContext, "srv7", 30 );
         delay();
 
-        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
+        findComponentConfigurationByName(name, ComponentConfigurationDTO.ACTIVE);
+
         final SimpleComponent comp31 = SimpleComponent.INSTANCE;
         TestCase.assertNotSame( comp30, comp31 );
         TestCase.assertEquals( srv7, comp31.m_singleRef );
@@ -943,7 +935,8 @@ public class ServiceBindGreedyTest exten
         srv6.drop();
         delay();
 
-        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
+        findComponentConfigurationByName(name, ComponentConfigurationDTO.ACTIVE);
+
         final SimpleComponent comp32 = SimpleComponent.INSTANCE;
         TestCase.assertNotSame( comp30, comp32 );
         TestCase.assertSame( comp31, comp32 );
@@ -955,17 +948,11 @@ public class ServiceBindGreedyTest exten
     @Test
     public void test_optional_multiple_static()
     {
-        final Component component = findComponentByName( "test_optional_multiple_static" );
-        TestCase.assertNotNull( component );
-        TestCase.assertEquals( Component.STATE_DISABLED, component.getState() );
-
         final SimpleServiceImpl srv1 = SimpleServiceImpl.create( bundleContext, "srv1" );
 
-        // async enabling
-        component.enable();
-        delay();
+        String name ="test_optional_multiple_static";
+        ComponentConfigurationDTO cc = getDisabledConfigurationAndEnable(name, ComponentConfigurationDTO.ACTIVE);
 
-        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
         final SimpleComponent comp10 = SimpleComponent.INSTANCE;
         TestCase.assertNotNull( comp10 );
         TestCase.assertNull( comp10.m_singleRef );
@@ -974,7 +961,8 @@ public class ServiceBindGreedyTest exten
         srv1.drop();
         delay(); // async reactivate
 
-        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
+        findComponentConfigurationByName(name, ComponentConfigurationDTO.ACTIVE);
+
         final SimpleComponent comp11 = SimpleComponent.INSTANCE;
         TestCase.assertNotSame( comp10, comp11 );
         TestCase.assertNull( comp11.m_singleRef );
@@ -983,24 +971,26 @@ public class ServiceBindGreedyTest exten
         final SimpleServiceImpl srv2 = SimpleServiceImpl.create( bundleContext, "srv2" );
         delay(); // async binding
 
-        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
+        findComponentConfigurationByName(name, ComponentConfigurationDTO.ACTIVE);
+
         final SimpleComponent comp12 = SimpleComponent.INSTANCE;
         TestCase.assertNotSame( comp10, comp12 );
         TestCase.assertNotSame( comp11, comp12 );
         TestCase.assertNull( comp12.m_singleRef );
         TestCase.assertTrue( comp12.m_multiRef.contains( srv2 ) );
 
-        component.disable();
+        disableAndCheck(cc);
         delay(); // async disabling
 
         final SimpleServiceImpl srv3 = SimpleServiceImpl.create( bundleContext, "srv3" );
 
         // enable component with two services available, expect both bind
         // async enabling
-        component.enable();
+        enableAndCheck(cc.description);
         delay();
 
-        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
+        findComponentConfigurationByName(name, ComponentConfigurationDTO.ACTIVE);
+
         final SimpleComponent comp20 = SimpleComponent.INSTANCE;
         TestCase.assertNotNull( comp20 );
         TestCase.assertNotSame( comp10, comp20 );
@@ -1013,7 +1003,8 @@ public class ServiceBindGreedyTest exten
         srv2.drop();
         delay(); // async reactivate
 
-        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
+        findComponentConfigurationByName(name, ComponentConfigurationDTO.ACTIVE);
+
         final SimpleComponent comp21 = SimpleComponent.INSTANCE;
         TestCase.assertNotSame( comp20, comp21 );
         TestCase.assertNull( comp21.m_singleRef );
@@ -1024,7 +1015,8 @@ public class ServiceBindGreedyTest exten
         final SimpleServiceImpl srv4 = SimpleServiceImpl.create( bundleContext, "srv4" );
         delay();
 
-        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
+        findComponentConfigurationByName(name, ComponentConfigurationDTO.ACTIVE);
+
         final SimpleComponent comp22 = SimpleComponent.INSTANCE;
         TestCase.assertNotSame( comp20, comp22 );
         TestCase.assertNotSame( comp21, comp22 );
@@ -1037,7 +1029,8 @@ public class ServiceBindGreedyTest exten
         srv4.drop();
         delay();
 
-        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
+        findComponentConfigurationByName(name, ComponentConfigurationDTO.ACTIVE);
+
         final SimpleComponent comp23 = SimpleComponent.INSTANCE;
         TestCase.assertNotSame( comp20, comp23 );
         TestCase.assertNotSame( comp21, comp23 );
@@ -1048,7 +1041,7 @@ public class ServiceBindGreedyTest exten
         TestCase.assertFalse( comp23.m_multiRef.contains( srv4 ) );
 
         // "reset"
-        component.disable();
+        disableAndCheck(cc);
         srv3.drop();
         delay();
 
@@ -1056,10 +1049,11 @@ public class ServiceBindGreedyTest exten
         final SimpleServiceImpl srv5 = SimpleServiceImpl.create( bundleContext, "srv5", 10 );
         final SimpleServiceImpl srv6 = SimpleServiceImpl.create( bundleContext, "srv6", 20 );
 
-        component.enable();
+        enableAndCheck(cc.description);
         delay();
 
-        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
+        findComponentConfigurationByName(name, ComponentConfigurationDTO.ACTIVE);
+
         final SimpleComponent comp30 = SimpleComponent.INSTANCE;
         TestCase.assertNotSame( comp23, comp30 );
         TestCase.assertNull( comp30.m_singleRef );
@@ -1070,7 +1064,8 @@ public class ServiceBindGreedyTest exten
         final SimpleServiceImpl srv7 = SimpleServiceImpl.create( bundleContext, "srv7", 30 );
         delay();
 
-        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
+        findComponentConfigurationByName(name, ComponentConfigurationDTO.ACTIVE);
+
         final SimpleComponent comp31 = SimpleComponent.INSTANCE;
         TestCase.assertNotSame( comp30, comp31 );
         TestCase.assertNull( comp31.m_singleRef );
@@ -1082,7 +1077,8 @@ public class ServiceBindGreedyTest exten
         srv6.drop();
         delay();
 
-        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
+        findComponentConfigurationByName(name, ComponentConfigurationDTO.ACTIVE);
+
         final SimpleComponent comp32 = SimpleComponent.INSTANCE;
         TestCase.assertNotSame( comp30, comp32 );
         TestCase.assertNotSame( comp31, comp32 );
@@ -1096,17 +1092,11 @@ public class ServiceBindGreedyTest exten
     @Test
     public void test_required_multiple_static()
     {
-        final Component component = findComponentByName( "test_required_multiple_static" );
-        TestCase.assertNotNull( component );
-        TestCase.assertEquals( Component.STATE_DISABLED, component.getState() );
-
         final SimpleServiceImpl srv1 = SimpleServiceImpl.create( bundleContext, "srv1" );
 
-        // async enabling
-        component.enable();
-        delay();
+        String name ="test_required_multiple_static";
+        ComponentConfigurationDTO cc = getDisabledConfigurationAndEnable(name, ComponentConfigurationDTO.ACTIVE);
 
-        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
         final SimpleComponent comp10 = SimpleComponent.INSTANCE;
         TestCase.assertNotNull( comp10 );
         TestCase.assertNull( comp10.m_singleRef );
@@ -1115,30 +1105,32 @@ public class ServiceBindGreedyTest exten
         srv1.drop();
         delay(); // async reactivate
 
-        TestCase.assertEquals( Component.STATE_UNSATISFIED, component.getState() );
+        findComponentConfigurationByName(name, ComponentConfigurationDTO.UNSATISFIED);
         final SimpleComponent comp11 = SimpleComponent.INSTANCE;
         TestCase.assertNull( comp11 );
 
         final SimpleServiceImpl srv2 = SimpleServiceImpl.create( bundleContext, "srv2" );
         delay(); // async binding
 
-        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
+        findComponentConfigurationByName(name, ComponentConfigurationDTO.ACTIVE);
+
         final SimpleComponent comp12 = SimpleComponent.INSTANCE;
         TestCase.assertNotSame( comp10, comp12 );
         TestCase.assertNull( comp12.m_singleRef );
         TestCase.assertTrue( comp12.m_multiRef.contains( srv2 ) );
 
-        component.disable();
+        disableAndCheck(cc);
         delay(); // async disabling
 
         final SimpleServiceImpl srv3 = SimpleServiceImpl.create( bundleContext, "srv3" );
 
         // enable component with two services available, expect both bind
         // async enabling
-        component.enable();
+        enableAndCheck(cc.description);
         delay();
 
-        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
+        findComponentConfigurationByName(name, ComponentConfigurationDTO.ACTIVE);
+
         final SimpleComponent comp20 = SimpleComponent.INSTANCE;
         TestCase.assertNotNull( comp20 );
         TestCase.assertNotSame( comp10, comp20 );
@@ -1150,7 +1142,8 @@ public class ServiceBindGreedyTest exten
         srv2.drop();
         delay(); // async reactivate
 
-        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
+        findComponentConfigurationByName(name, ComponentConfigurationDTO.ACTIVE);
+
         final SimpleComponent comp21 = SimpleComponent.INSTANCE;
         TestCase.assertNotSame( comp20, comp21 );
         TestCase.assertNull( comp21.m_singleRef );
@@ -1161,7 +1154,8 @@ public class ServiceBindGreedyTest exten
         final SimpleServiceImpl srv4 = SimpleServiceImpl.create( bundleContext, "srv4" );
         delay();
 
-        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
+        findComponentConfigurationByName(name, ComponentConfigurationDTO.ACTIVE);
+
         final SimpleComponent comp22 = SimpleComponent.INSTANCE;
         TestCase.assertNotSame( comp20, comp22 );
         TestCase.assertNotSame( comp21, comp22 );
@@ -1174,7 +1168,8 @@ public class ServiceBindGreedyTest exten
         srv4.drop();
         delay();
 
-        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
+        findComponentConfigurationByName(name, ComponentConfigurationDTO.ACTIVE);
+
         final SimpleComponent comp23 = SimpleComponent.INSTANCE;
         TestCase.assertNotSame( comp20, comp23 );
         TestCase.assertNotSame( comp21, comp23 );
@@ -1185,7 +1180,7 @@ public class ServiceBindGreedyTest exten
         TestCase.assertFalse( comp23.m_multiRef.contains( srv4 ) );
 
         // "reset"
-        component.disable();
+        disableAndCheck(cc);
         srv3.drop();
         delay();
 
@@ -1193,10 +1188,11 @@ public class ServiceBindGreedyTest exten
         final SimpleServiceImpl srv5 = SimpleServiceImpl.create( bundleContext, "srv5", 10 );
         final SimpleServiceImpl srv6 = SimpleServiceImpl.create( bundleContext, "srv6", 20 );
 
-        component.enable();
+        enableAndCheck(cc.description);
         delay();
 
-        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
+        findComponentConfigurationByName(name, ComponentConfigurationDTO.ACTIVE);
+
         final SimpleComponent comp30 = SimpleComponent.INSTANCE;
         TestCase.assertNotSame( comp23, comp30 );
         TestCase.assertNull( comp30.m_singleRef );
@@ -1207,7 +1203,8 @@ public class ServiceBindGreedyTest exten
         final SimpleServiceImpl srv7 = SimpleServiceImpl.create( bundleContext, "srv7", 30 );
         delay();
 
-        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
+        findComponentConfigurationByName(name, ComponentConfigurationDTO.ACTIVE);
+
         final SimpleComponent comp31 = SimpleComponent.INSTANCE;
         TestCase.assertNotSame( comp30, comp31 );
         TestCase.assertNull( comp31.m_singleRef );
@@ -1219,7 +1216,8 @@ public class ServiceBindGreedyTest exten
         srv6.drop();
         delay();
 
-        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
+        findComponentConfigurationByName(name, ComponentConfigurationDTO.ACTIVE);
+
         final SimpleComponent comp32 = SimpleComponent.INSTANCE;
         TestCase.assertNotSame( comp30, comp32 );
         TestCase.assertNotSame( comp31, comp32 );
@@ -1232,25 +1230,19 @@ public class ServiceBindGreedyTest exten
     @Test
     public void test_multi_service_bind_unbind_order()
     {
-        final Component component = findComponentByName( "test_multi_service_bind_unbind_order" );
-        TestCase.assertNotNull( component );
-        TestCase.assertEquals( Component.STATE_DISABLED, component.getState() );
-
         final SimpleServiceImpl srv1 = SimpleServiceImpl.create( bundleContext, "srv1" );
         final SimpleService2Impl srv2 = SimpleService2Impl.create( bundleContext, "srv2" );
 
-        // async enabling
-        component.enable();
-        delay();
+        String name ="test_multi_service_bind_unbind_order";
+        ComponentConfigurationDTO cc = getDisabledConfigurationAndEnable(name, ComponentConfigurationDTO.ACTIVE);
 
-        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
         final SimpleComponent2 comp10 = SimpleComponent2.INSTANCE;
         TestCase.assertNotNull( comp10 );
         TestCase.assertEquals( 2, comp10.getBindings().size() );
         TestCase.assertEquals( "bindSimpleService", comp10.getBindings().get( 0 ) );
         TestCase.assertEquals( "bindSimpleService2", comp10.getBindings().get( 1 ) );
 
-        component.disable();
+        disableAndCheck(cc);
         delay();
 
         TestCase.assertEquals( 4, comp10.getBindings().size() );



Mime
View raw message