You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by dj...@apache.org on 2014/06/15 03:09:32 UTC

svn commit: r1602633 [4/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...

Modified: felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/ServiceBindTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/ServiceBindTest.java?rev=1602633&r1=1602632&r2=1602633&view=diff
==============================================================================
--- felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/ServiceBindTest.java (original)
+++ felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/ServiceBindTest.java Sun Jun 15 01:09:31 2014
@@ -35,6 +35,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 +56,10 @@ public class ServiceBindTest extends Com
     @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" );
 
-        // async enabling
-        component.enable();
-        delay();
-
-        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 +68,6 @@ public class ServiceBindTest extends Com
         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 +76,22 @@ public class ServiceBindTest extends Com
         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.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" );
 
         // 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 );
@@ -109,7 +101,7 @@ public class ServiceBindTest extends Com
         // 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 +111,7 @@ public class ServiceBindTest extends Com
         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.assertEquals( srv3, comp22.m_singleRef );
@@ -129,14 +121,14 @@ public class ServiceBindTest extends Com
         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 +136,10 @@ public class ServiceBindTest extends Com
         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 +149,7 @@ public class ServiceBindTest extends Com
         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( srv6, comp31.m_singleRef );
@@ -167,7 +159,7 @@ public class ServiceBindTest extends Com
         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 +170,11 @@ public class ServiceBindTest extends Com
     @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" );
 
-        // 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 +183,31 @@ public class ServiceBindTest extends Com
         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" );
         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 );
@@ -230,7 +217,7 @@ public class ServiceBindTest extends Com
         // 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 +227,7 @@ public class ServiceBindTest extends Com
         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.assertEquals( srv3, comp22.m_singleRef );
@@ -250,14 +237,14 @@ public class ServiceBindTest extends Com
         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 +252,10 @@ public class ServiceBindTest extends Com
         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 +265,7 @@ public class ServiceBindTest extends Com
         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( srv6, comp31.m_singleRef );
@@ -288,7 +275,7 @@ public class ServiceBindTest extends Com
         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 +286,11 @@ public class ServiceBindTest extends Com
     @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 +299,7 @@ public class ServiceBindTest extends Com
         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 +308,23 @@ public class ServiceBindTest extends Com
         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 +334,7 @@ public class ServiceBindTest extends Com
 
         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 +345,7 @@ public class ServiceBindTest extends Com
         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 +357,7 @@ public class ServiceBindTest extends Com
         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 +366,7 @@ public class ServiceBindTest extends Com
         TestCase.assertFalse( comp23.m_multiRef.contains( srv4 ) );
 
         // "reset"
-        component.disable();
+        disableAndCheck(cc);
         srv3.drop();
         delay();
 
@@ -393,10 +374,10 @@ public class ServiceBindTest extends Com
         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 +388,8 @@ public class ServiceBindTest extends Com
         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 +401,8 @@ public class ServiceBindTest extends Com
         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 +415,11 @@ public class ServiceBindTest extends Com
     @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 +428,32 @@ public class ServiceBindTest extends Com
         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 +463,8 @@ public class ServiceBindTest extends Com
 
         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 +475,8 @@ public class ServiceBindTest extends Com
         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 +488,8 @@ public class ServiceBindTest extends Com
         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 +498,7 @@ public class ServiceBindTest extends Com
         TestCase.assertFalse( comp23.m_multiRef.contains( srv4 ) );
 
         // "reset"
-        component.disable();
+        disableAndCheck(cc);
         srv3.drop();
         delay();
 
@@ -524,10 +506,11 @@ public class ServiceBindTest extends Com
         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 +521,8 @@ public class ServiceBindTest extends Com
         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 +534,8 @@ public class ServiceBindTest extends Com
         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 +548,24 @@ public class ServiceBindTest extends Com
     @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 +588,29 @@ public class ServiceBindTest extends Com
         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 +622,7 @@ public class ServiceBindTest extends Com
         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 +631,69 @@ public class ServiceBindTest extends Com
         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 +702,8 @@ public class ServiceBindTest extends Com
         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 +713,26 @@ public class ServiceBindTest extends Com
         delay(); // async binding
 
         // static reference does not rebind unless component is cycled for other reasons !!
-        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
+        findComponentConfigurationByName(name, ComponentConfigurationDTO.ACTIVE);
+
         final SimpleComponent comp12 = SimpleComponent.INSTANCE;
         TestCase.assertNotSame( comp10, comp12 );
         TestCase.assertSame( comp11, comp12 );
         TestCase.assertNull( 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 +743,8 @@ public class ServiceBindTest extends Com
         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 +754,8 @@ public class ServiceBindTest extends Com
         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 );
@@ -777,7 +766,8 @@ public class ServiceBindTest extends Com
         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 +776,7 @@ public class ServiceBindTest extends Com
         TestCase.assertTrue( comp23.m_multiRef.isEmpty() );
 
         // "reset"
-        component.disable();
+        disableAndCheck(cc);
         srv3.drop();
         delay();
 
@@ -794,10 +784,11 @@ public class ServiceBindTest extends Com
         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 +798,8 @@ public class ServiceBindTest extends Com
         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( srv6, comp31.m_singleRef );
@@ -817,7 +809,8 @@ public class ServiceBindTest extends Com
         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 );
@@ -829,17 +822,11 @@ public class ServiceBindTest extends Com
     @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 +835,32 @@ public class ServiceBindTest extends Com
         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 +871,8 @@ public class ServiceBindTest extends Com
         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 +882,8 @@ public class ServiceBindTest extends Com
         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 +894,8 @@ public class ServiceBindTest extends Com
         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 +904,7 @@ public class ServiceBindTest extends Com
         TestCase.assertTrue( comp23.m_multiRef.isEmpty() );
 
         // "reset"
-        component.disable();
+        disableAndCheck(cc);
         srv3.drop();
         delay();
 
@@ -920,10 +912,11 @@ public class ServiceBindTest extends Com
         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 +926,8 @@ public class ServiceBindTest extends Com
         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( srv6, comp31.m_singleRef );
@@ -943,7 +937,8 @@ public class ServiceBindTest extends Com
         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 );
@@ -955,17 +950,11 @@ public class ServiceBindTest extends Com
     @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 +963,8 @@ public class ServiceBindTest extends Com
         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 +973,26 @@ public class ServiceBindTest extends Com
         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.assertSame( comp11, comp12 );
         TestCase.assertNull( 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 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 +1005,8 @@ public class ServiceBindTest extends Com
         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 +1017,8 @@ public class ServiceBindTest extends Com
         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 );
@@ -1037,7 +1031,8 @@ public class ServiceBindTest extends Com
         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 );
@@ -1048,7 +1043,7 @@ public class ServiceBindTest extends Com
         TestCase.assertFalse( comp23.m_multiRef.contains( srv4 ) );
 
         // "reset"
-        component.disable();
+        disableAndCheck(cc);
         srv3.drop();
         delay();
 
@@ -1056,10 +1051,11 @@ public class ServiceBindTest extends Com
         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 +1066,8 @@ public class ServiceBindTest extends Com
         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 );
@@ -1082,7 +1079,8 @@ public class ServiceBindTest extends Com
         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 +1094,11 @@ public class ServiceBindTest extends Com
     @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 +1107,32 @@ public class ServiceBindTest extends Com
         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 +1144,8 @@ public class ServiceBindTest extends Com
         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 +1156,8 @@ public class ServiceBindTest extends Com
         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 );
@@ -1174,7 +1170,8 @@ public class ServiceBindTest extends Com
         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 );
@@ -1185,7 +1182,7 @@ public class ServiceBindTest extends Com
         TestCase.assertFalse( comp23.m_multiRef.contains( srv4 ) );
 
         // "reset"
-        component.disable();
+        disableAndCheck(cc);
         srv3.drop();
         delay();
 
@@ -1193,10 +1190,11 @@ public class ServiceBindTest extends Com
         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 +1205,8 @@ public class ServiceBindTest extends Com
         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 );
@@ -1219,7 +1218,8 @@ public class ServiceBindTest extends Com
         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 +1232,19 @@ public class ServiceBindTest extends Com
     @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() );

Modified: felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/ServiceChangedTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/ServiceChangedTest.java?rev=1602633&r1=1602632&r2=1602633&view=diff
==============================================================================
--- felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/ServiceChangedTest.java (original)
+++ felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/ServiceChangedTest.java Sun Jun 15 01:09:31 2014
@@ -21,12 +21,12 @@ package org.apache.felix.scr.integration
 
 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.SimpleServiceImpl;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.ops4j.pax.exam.junit.JUnit4TestRunner;
+import org.osgi.service.component.runtime.dto.ComponentConfigurationDTO;
 
 
 @RunWith(JUnit4TestRunner.class)
@@ -44,17 +44,10 @@ public class ServiceChangedTest extends 
     @Test
     public void test_optional_single_dynamic()
     {
-        final Component component = findComponentByName( "test_optional_single_dynamic_target" );
-        TestCase.assertNotNull( component );
-        TestCase.assertEquals( Component.STATE_DISABLED, component.getState() );
-
         final SimpleServiceImpl srv1 = SimpleServiceImpl.create( bundleContext, "srv1" );
+        String name = "test_optional_single_dynamic_target";
+		getDisabledConfigurationAndEnable(name, ComponentConfigurationDTO.ACTIVE);
 
-        // async enabling
-        component.enable();
-        delay();
-
-        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
         final SimpleComponent comp10 = SimpleComponent.INSTANCE;
         TestCase.assertNotNull( comp10 );
         TestCase.assertEquals( srv1, comp10.m_singleRef );
@@ -74,7 +67,7 @@ public class ServiceChangedTest extends 
         // set target to not match any more
         srv1.setFilterProperty( "don't match" );
 
-        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 );
@@ -85,7 +78,7 @@ public class ServiceChangedTest extends 
         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.assertEquals( srv2, comp12.m_singleRef );
@@ -112,17 +105,10 @@ public class ServiceChangedTest extends 
     @Test
     public void test_required_single_dynamic()
     {
-        final Component component = findComponentByName( "test_required_single_dynamic_target" );
-        TestCase.assertNotNull( component );
-        TestCase.assertEquals( Component.STATE_DISABLED, component.getState() );
-
         final SimpleServiceImpl srv1 = SimpleServiceImpl.create( bundleContext, "srv1" );
-
-        // async enabling
-        component.enable();
-        delay();
-
-        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
+        String name = "test_required_single_dynamic_target";
+		getDisabledConfigurationAndEnable(name, ComponentConfigurationDTO.ACTIVE);
+		
         final SimpleComponent comp10 = SimpleComponent.INSTANCE;
         TestCase.assertNotNull( comp10 );
         TestCase.assertEquals( srv1, comp10.m_singleRef );
@@ -141,7 +127,7 @@ public class ServiceChangedTest extends 
 
         // set target to not match any more -> deactivate this component
         srv1.setFilterProperty( "don't match" );
-        TestCase.assertEquals( Component.STATE_UNSATISFIED, component.getState() );
+        findComponentConfigurationByName(name, ComponentConfigurationDTO.UNSATISFIED);
         TestCase.assertNull( SimpleComponent.INSTANCE );
         TestCase.assertNull( comp10.m_singleRef );
         TestCase.assertTrue( comp10.m_multiRef.isEmpty() );
@@ -151,7 +137,7 @@ public class ServiceChangedTest extends 
         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 );
@@ -178,17 +164,9 @@ public class ServiceChangedTest extends 
     @Test
     public void test_optional_multiple_dynamic()
     {
-        final Component component = findComponentByName( "test_optional_multiple_dynamic_target" );
-        TestCase.assertNotNull( component );
-        TestCase.assertEquals( Component.STATE_DISABLED, component.getState() );
-
         final SimpleServiceImpl srv1 = SimpleServiceImpl.create( bundleContext, "srv1" );
-
-        // async enabling
-        component.enable();
-        delay();
-
-        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
+        String name = "test_optional_multiple_dynamic_target";
+		getDisabledConfigurationAndEnable(name, ComponentConfigurationDTO.ACTIVE);
         final SimpleComponent comp10 = SimpleComponent.INSTANCE;
         TestCase.assertNotNull( comp10 );
         TestCase.assertNull( comp10.m_singleRef );
@@ -208,7 +186,7 @@ public class ServiceChangedTest extends 
         // set target to not match any more
         srv1.setFilterProperty( "don't match" );
 
-        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
+        findComponentConfigurationByName(name, ComponentConfigurationDTO.ACTIVE);
         final SimpleComponent comp11 = SimpleComponent.INSTANCE;
         TestCase.assertSame( comp10, comp11 );
         TestCase.assertNull( comp10.m_singleRef );
@@ -219,7 +197,7 @@ public class ServiceChangedTest extends 
         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( comp10.m_singleRef );
@@ -249,17 +227,9 @@ public class ServiceChangedTest extends 
     @Test
     public void test_required_multiple_dynamic()
     {
-        final Component component = findComponentByName( "test_required_multiple_dynamic_target" );
-        TestCase.assertNotNull( component );
-        TestCase.assertEquals( Component.STATE_DISABLED, component.getState() );
-
         final SimpleServiceImpl srv1 = SimpleServiceImpl.create( bundleContext, "srv1" );
-
-        // async enabling
-        component.enable();
-        delay();
-
-        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
+        String name = "test_required_multiple_dynamic_target";
+		getDisabledConfigurationAndEnable(name, ComponentConfigurationDTO.ACTIVE);
         final SimpleComponent comp10 = SimpleComponent.INSTANCE;
         TestCase.assertNotNull( comp10 );
         TestCase.assertNull( comp10.m_singleRef );
@@ -279,7 +249,7 @@ public class ServiceChangedTest extends 
         // set target to not match any more
         srv1.setFilterProperty( "don't match" );
 
-        TestCase.assertEquals( Component.STATE_UNSATISFIED, component.getState() );
+        findComponentConfigurationByName(name, ComponentConfigurationDTO.UNSATISFIED);
         final SimpleComponent comp11 = SimpleComponent.INSTANCE;
         TestCase.assertNull( comp11 );
         TestCase.assertNull( comp10.m_singleRef );
@@ -290,7 +260,7 @@ public class ServiceChangedTest extends 
         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 );
@@ -320,17 +290,9 @@ public class ServiceChangedTest extends 
     @Test
     public void test_optional_single_static()
     {
-        final Component component = findComponentByName( "test_optional_single_static_target" );
-        TestCase.assertNotNull( component );
-        TestCase.assertEquals( Component.STATE_DISABLED, component.getState() );
-
         final SimpleServiceImpl srv1 = SimpleServiceImpl.create( bundleContext, "srv1" );
-
-        // async enabling
-        component.enable();
-        delay();
-
-        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
+        String name = "test_optional_single_static_target";
+		getDisabledConfigurationAndEnable(name, ComponentConfigurationDTO.ACTIVE);
         final SimpleComponent comp10 = SimpleComponent.INSTANCE;
         TestCase.assertNotNull( comp10 );
         TestCase.assertEquals( srv1, comp10.m_singleRef );
@@ -351,7 +313,7 @@ public class ServiceChangedTest extends 
         srv1.setFilterProperty( "don't match" );
         delay(); // async reactivation
 
-        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 );
@@ -362,7 +324,7 @@ public class ServiceChangedTest extends 
         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.assertSame( comp11, comp12 );
@@ -399,17 +361,9 @@ public class ServiceChangedTest extends 
     @Test
     public void test_required_single_static()
     {
-        final Component component = findComponentByName( "test_required_single_static_target" );
-        TestCase.assertNotNull( component );
-        TestCase.assertEquals( Component.STATE_DISABLED, component.getState() );
-
         final SimpleServiceImpl srv1 = SimpleServiceImpl.create( bundleContext, "srv1" );
-
-        // async enabling
-        component.enable();
-        delay();
-
-        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
+        String name = "test_required_single_static_target";
+		getDisabledConfigurationAndEnable(name, ComponentConfigurationDTO.ACTIVE);
         final SimpleComponent comp10 = SimpleComponent.INSTANCE;
         TestCase.assertNotNull( comp10 );
         TestCase.assertEquals( srv1, comp10.m_singleRef );
@@ -428,7 +382,7 @@ public class ServiceChangedTest extends 
 
         // set target to not match any more -> deactivate this component
         srv1.setFilterProperty( "don't match" );
-        TestCase.assertEquals( Component.STATE_UNSATISFIED, component.getState() );
+        findComponentConfigurationByName(name, ComponentConfigurationDTO.UNSATISFIED);
         TestCase.assertNull( SimpleComponent.INSTANCE );
         TestCase.assertNull( comp10.m_singleRef );
         TestCase.assertTrue( comp10.m_multiRef.isEmpty() );
@@ -438,7 +392,7 @@ public class ServiceChangedTest extends 
         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 );
@@ -473,17 +427,9 @@ public class ServiceChangedTest extends 
     @Test
     public void test_optional_multiple_static()
     {
-        final Component component = findComponentByName( "test_optional_multiple_static_target" );
-        TestCase.assertNotNull( component );
-        TestCase.assertEquals( Component.STATE_DISABLED, component.getState() );
-
         final SimpleServiceImpl srv1 = SimpleServiceImpl.create( bundleContext, "srv1" );
-
-        // async enabling
-        component.enable();
-        delay();
-
-        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
+        String name = "test_optional_multiple_static_target";
+		getDisabledConfigurationAndEnable(name, ComponentConfigurationDTO.ACTIVE);
         final SimpleComponent comp10 = SimpleComponent.INSTANCE;
         TestCase.assertNotNull( comp10 );
         TestCase.assertNull( comp10.m_singleRef );
@@ -504,7 +450,7 @@ public class ServiceChangedTest extends 
         srv1.setFilterProperty( "don't match" );
         delay(); // async reactivation (for unbind)
 
-        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
+        findComponentConfigurationByName(name, ComponentConfigurationDTO.ACTIVE);
         final SimpleComponent comp11 = SimpleComponent.INSTANCE;
         TestCase.assertNotSame( comp10, comp11 );
         TestCase.assertNull( comp10.m_singleRef );
@@ -519,7 +465,7 @@ public class ServiceChangedTest extends 
         final SimpleServiceImpl srv2 = SimpleServiceImpl.create( bundleContext, "srv2" );
         delay(); // async binding (not expected for an optional static ref)
 
-        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
+        findComponentConfigurationByName(name, ComponentConfigurationDTO.ACTIVE);
         final SimpleComponent comp12 = SimpleComponent.INSTANCE;
         TestCase.assertNotSame( comp10, comp12 );
         TestCase.assertSame( comp11, comp12 );
@@ -541,7 +487,7 @@ public class ServiceChangedTest extends 
         srv2.setFilterProperty( "don't match" );
         delay(); // allow reactivation delay (for unbind/bind)
 
-        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
+        findComponentConfigurationByName(name, ComponentConfigurationDTO.ACTIVE);
         final SimpleComponent comp13 = SimpleComponent.INSTANCE;
         TestCase.assertNotSame( comp10, comp13 );
         TestCase.assertSame( comp11, comp13 );
@@ -557,17 +503,9 @@ public class ServiceChangedTest extends 
     @Test
     public void test_required_multiple_static()
     {
-        final Component component = findComponentByName( "test_required_multiple_static_target" );
-        TestCase.assertNotNull( component );
-        TestCase.assertEquals( Component.STATE_DISABLED, component.getState() );
-
         final SimpleServiceImpl srv1 = SimpleServiceImpl.create( bundleContext, "srv1" );
-
-        // async enabling
-        component.enable();
-        delay();
-
-        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
+        String name = "test_required_multiple_static_target";
+		getDisabledConfigurationAndEnable(name, ComponentConfigurationDTO.ACTIVE);
         final SimpleComponent comp10 = SimpleComponent.INSTANCE;
         TestCase.assertNotNull( comp10 );
         TestCase.assertNull( comp10.m_singleRef );
@@ -587,7 +525,7 @@ public class ServiceChangedTest extends 
         // set target to not match any more
         srv1.setFilterProperty( "don't match" );
 
-        TestCase.assertEquals( Component.STATE_UNSATISFIED, component.getState() );
+        findComponentConfigurationByName(name, ComponentConfigurationDTO.UNSATISFIED);
         final SimpleComponent comp11 = SimpleComponent.INSTANCE;
         TestCase.assertNull( comp11 );
         TestCase.assertNull( comp10.m_singleRef );
@@ -598,7 +536,7 @@ public class ServiceChangedTest extends 
         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 );
@@ -619,7 +557,7 @@ public class ServiceChangedTest extends 
         srv2.setFilterProperty( "don't match" );
         delay(); // allow reactivation/rebinding
 
-        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
+        findComponentConfigurationByName(name, ComponentConfigurationDTO.ACTIVE);
         final SimpleComponent comp13 = SimpleComponent.INSTANCE;
         TestCase.assertNotSame( comp10, comp13 );
         TestCase.assertNotSame( comp11, comp13 );

Modified: felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/ServiceComponentTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/ServiceComponentTest.java?rev=1602633&r1=1602632&r2=1602633&view=diff
==============================================================================
--- felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/ServiceComponentTest.java (original)
+++ felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/ServiceComponentTest.java Sun Jun 15 01:09:31 2014
@@ -20,20 +20,16 @@ package org.apache.felix.scr.integration
 
 
 import java.io.IOException;
-import java.util.Dictionary;
-import java.util.Hashtable;
 
 import junit.framework.TestCase;
 
-import org.apache.felix.scr.Component;
-import org.apache.felix.scr.impl.config.ScrConfiguration;
 import org.apache.felix.scr.integration.components.SimpleComponent;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.ops4j.pax.exam.junit.JUnit4TestRunner;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.ServiceReference;
-import org.osgi.service.cm.Configuration;
+import org.osgi.service.component.runtime.dto.ComponentConfigurationDTO;
 
 
 @RunWith(JUnit4TestRunner.class)
@@ -52,15 +48,8 @@ public class ServiceComponentTest extend
         final String pid = "ServiceComponent";
 
         // one single component exists without configuration
-        final Component component = findComponentByName( pid );
-        TestCase.assertNotNull( component );
-        TestCase.assertEquals( Component.STATE_DISABLED, component.getState() );
-
-        component.enable();
-        delay();
-
+		getDisabledConfigurationAndEnable(pid, ComponentConfigurationDTO.ACTIVE);
         final SimpleComponent instance = SimpleComponent.INSTANCE;
-        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
         TestCase.assertNotNull( instance );
 
         // assert component properties (all !)
@@ -99,15 +88,7 @@ public class ServiceComponentTest extend
         final String pid = "DelayedServiceComponent";
 
         // one single component exists without configuration
-        final Component component = findComponentByName( pid );
-        TestCase.assertNotNull( component );
-        TestCase.assertEquals( Component.STATE_DISABLED, component.getState() );
-
-        component.enable();
-        delay();
-
-        // the delayed service is expected to only be registered before use
-        TestCase.assertEquals( Component.STATE_REGISTERED, component.getState() );
+		getDisabledConfigurationAndEnable(pid, ComponentConfigurationDTO.SATISFIED);
         TestCase.assertNull( SimpleComponent.INSTANCE );
 
         // get the service
@@ -118,7 +99,7 @@ public class ServiceComponentTest extend
             final Object theService = bundleContext.getService( reference );
 
             // service must now be active
-            TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
+            findComponentConfigurationByName(pid, ComponentConfigurationDTO.ACTIVE);
 
             // and of course we expect the instance
             TestCase.assertEquals( SimpleComponent.INSTANCE, theService );
@@ -129,7 +110,7 @@ public class ServiceComponentTest extend
         }
 
         // service is not used anymore, ensure REGISTERED state and INSTANCE==null
-        TestCase.assertEquals( Component.STATE_REGISTERED, component.getState() );
+        findComponentConfigurationByName(pid, ComponentConfigurationDTO.SATISFIED);
         TestCase.assertNull( SimpleComponent.INSTANCE );
     }
 
@@ -140,22 +121,15 @@ public class ServiceComponentTest extend
         final String pid = "DelayedServiceComponent";
 
         // one single component exists without configuration
-        final Component component = findComponentByName( pid );
-        TestCase.assertNotNull( component );
-        TestCase.assertEquals( Component.STATE_DISABLED, component.getState() );
-
-        component.enable();
-        delay();
-
         // the delayed service is expected to only be registered before use
-        TestCase.assertEquals( Component.STATE_REGISTERED, component.getState() );
+		getDisabledConfigurationAndEnable(pid, ComponentConfigurationDTO.SATISFIED);
         TestCase.assertNull( SimpleComponent.INSTANCE );
 
         // get the service once
         final ServiceReference reference1 = bundleContext.getServiceReference( "java.lang.Object" );
         TestCase.assertNotNull( reference1 );
         bundleContext.getService( reference1 );
-        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
+        findComponentConfigurationByName(pid, ComponentConfigurationDTO.ACTIVE);
         TestCase.assertNotNull( SimpleComponent.INSTANCE );
 
         // get the service a second time
@@ -163,17 +137,17 @@ public class ServiceComponentTest extend
         final ServiceReference reference2 = bundleContext2.getServiceReference( "java.lang.Object" );
         TestCase.assertNotNull( reference2 );
         bundleContext2.getService( reference2 );
-        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
+        findComponentConfigurationByName(pid, ComponentConfigurationDTO.ACTIVE);
         TestCase.assertNotNull( SimpleComponent.INSTANCE );
 
         // unget the service once -- must still be active !
         bundleContext2.ungetService( reference2 );
-        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
+        findComponentConfigurationByName(pid, ComponentConfigurationDTO.ACTIVE);
         TestCase.assertNotNull( SimpleComponent.INSTANCE );
 
         // unget the service second time -- must be registered and null now
         bundleContext.ungetService( reference1 );
-        TestCase.assertEquals( Component.STATE_REGISTERED, component.getState() );
+        findComponentConfigurationByName(pid, ComponentConfigurationDTO.SATISFIED);
         TestCase.assertNull( SimpleComponent.INSTANCE );
     }
 
@@ -194,15 +168,8 @@ public class ServiceComponentTest extend
         final String pid = "DelayedKeepInstancesServiceComponent";
 
         // one single component exists without configuration
-        final Component component = findComponentByName( pid );
-        TestCase.assertNotNull( component );
-        TestCase.assertEquals( Component.STATE_DISABLED, component.getState() );
-
-        component.enable();
-        delay();
-
         // the delayed service is expected to only be registered before use
-        TestCase.assertEquals( Component.STATE_REGISTERED, component.getState() );
+		getDisabledConfigurationAndEnable(pid, ComponentConfigurationDTO.SATISFIED);
         TestCase.assertNull( SimpleComponent.INSTANCE );
 
         // get the service
@@ -213,7 +180,7 @@ public class ServiceComponentTest extend
             final Object theService = bundleContext.getService( reference );
 
             // service must now be active
-            TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
+            findComponentConfigurationByName(pid, ComponentConfigurationDTO.ACTIVE);
 
             // and of course we expect the instance
             TestCase.assertEquals( SimpleComponent.INSTANCE, theService );
@@ -224,7 +191,7 @@ public class ServiceComponentTest extend
         }
 
         // component instance must not be disposed off (due to config)
-        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
+        findComponentConfigurationByName(pid, ComponentConfigurationDTO.ACTIVE);
         TestCase.assertNotNull( SimpleComponent.INSTANCE );
 
         // delete the SCR configuration again