felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r1602633 [1/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
Author: djencks
Date: Sun Jun 15 01:09:31 2014
New Revision: 1602633

URL: http://svn.apache.org/r1602633
Log:
FELIX-4401 Initial refactoring of integration tests to use ServiceComponentRuntime.  Does not include factory component tests which do not compile

Modified:
    felix/trunk/scr/pom.xml
    felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/ActivateSignatureTest.java
    felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/CircularReferenceTest.java
    felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/ComponentActivationTest.java
    felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/ComponentConcurrencyTest.java
    felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/ComponentConfigurationPidTest.java
    felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/ComponentConfigurationTest.java
    felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/ComponentDisposeTest.java
    felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/ComponentFactoryTest.java
    felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/ComponentTestBase.java
    felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/ConfigurationChangeTest.java
    felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/ConfigurationComponentFactoryTest.java
    felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/Felix3680Test.java
    felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/Felix3680_2Test.java
    felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/Felix4188Test.java
    felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/Felix4350Test.java
    felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/LocateTest.java
    felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/LocationTest.java
    felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/MutablePropertiesTest.java
    felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/PersistentComponentFactoryTest.java
    felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/ServiceBindGreedyTest.java
    felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/ServiceBindTest.java
    felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/ServiceChangedTest.java
    felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/ServiceComponentTest.java
    felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/TargetedPIDTest.java
    felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/components/ActivatorComponent.java
    felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/components/Felix4350Component.java
    felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/components/activatesignature/AbstractActivateSignatureTestComponent.java
    felix/trunk/scr/src/test/resources/integration_test_FELIX_4188_1.xml
    felix/trunk/scr/src/test/resources/integration_test_FELIX_4188_2.xml
    felix/trunk/scr/src/test/resources/integration_test_simple_components_location.xml

Modified: felix/trunk/scr/pom.xml
URL: http://svn.apache.org/viewvc/felix/trunk/scr/pom.xml?rev=1602633&r1=1602632&r2=1602633&view=diff
==============================================================================
--- felix/trunk/scr/pom.xml (original)
+++ felix/trunk/scr/pom.xml Sun Jun 15 01:09:31 2014
@@ -252,7 +252,10 @@
                             org.apache.felix.scr;version=1.8,
                             org.apache.felix.scr.component;version=1.0;
                                 mandatory:="status"; status="provisional",
-                            org.osgi.service.component
+                            org.osgi.service.component,
+                            org.osgi.service.component.runtime.*,
+                            org.osgi.dto,
+                            org.osgi.framework.dto
                         </Export-Package>
                         <Private-Package>
                             org.apache.felix.scr.impl.*,

Modified: felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/ActivateSignatureTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/ActivateSignatureTest.java?rev=1602633&r1=1602632&r2=1602633&view=diff
==============================================================================
--- felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/ActivateSignatureTest.java (original)
+++ felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/ActivateSignatureTest.java Sun Jun 15 01:09:31 2014
@@ -19,13 +19,16 @@
 package org.apache.felix.scr.integration;
 
 
+import java.util.Collection;
+
 import junit.framework.TestCase;
 
-import org.apache.felix.scr.Component;
 import org.apache.felix.scr.integration.components.activatesignature.AbstractActivateSignatureTestComponent;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.ops4j.pax.exam.junit.JUnit4TestRunner;
+import org.osgi.service.component.runtime.dto.ComponentConfigurationDTO;
+import org.osgi.service.component.runtime.dto.ComponentDescriptionDTO;
 
 
 /**
@@ -53,24 +56,20 @@ public class ActivateSignatureTest exten
         // wait for components to fire up in the background....
         delay();
 
-        final Component[] components = getComponents();
+        final Collection<ComponentDescriptionDTO> components = getComponentDescriptions();
         TestCase.assertNotNull( components );
 
-        for ( Component component : components )
+        for ( ComponentDescriptionDTO component : components )
         {
-            TestCase.assertTrue( "Expecting component " + component.getName() + " to be enabled", component
-                .isDefaultEnabled() );
-
-            TestCase.assertEquals( "Expecting component " + component.getName() + " to be active",
-                Component.STATE_ACTIVE, component.getState() );
+            TestCase.assertTrue( "Expecting component " + component.name + " to be enabled", component
+                .defaultEnabled );
 
-            final Object instance = component.getComponentInstance().getInstance();
-            TestCase.assertTrue( "Expecting component " + component.getName()
-                + " to be an AbstractActivateSignatureTestComponent",
-                instance instanceof AbstractActivateSignatureTestComponent );
+            ComponentConfigurationDTO cc = findComponentConfigurationByName(component.name, -1);
+            TestCase.assertEquals( "Expecting component " + component.name + " to be active",
+            		ComponentConfigurationDTO.ACTIVE, cc.state );
+            
+            TestCase.assertNotNull("Expect activate method to be called", AbstractActivateSignatureTestComponent.getInstance(component.name));
 
-            final AbstractActivateSignatureTestComponent aastc = ( AbstractActivateSignatureTestComponent ) instance;
-            TestCase.assertEquals( "Expect activate method to be called", component.getName(), aastc.getMethodCalled() );
         }
     }
 

Modified: felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/CircularReferenceTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/CircularReferenceTest.java?rev=1602633&r1=1602632&r2=1602633&view=diff
==============================================================================
--- felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/CircularReferenceTest.java (original)
+++ felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/CircularReferenceTest.java Sun Jun 15 01:09:31 2014
@@ -29,6 +29,7 @@ import org.junit.runner.RunWith;
 import org.ops4j.pax.exam.junit.JUnit4TestRunner;
 import org.osgi.framework.InvalidSyntaxException;
 import org.osgi.framework.ServiceReference;
+import org.osgi.service.component.runtime.dto.ComponentConfigurationDTO;
 
 import static junit.framework.Assert.assertEquals;
 import static junit.framework.Assert.assertNotNull;
@@ -57,56 +58,44 @@ public class CircularReferenceTest exten
     public void test_A11_B11()
     {
         String componentNameA = "1.A.1.1.dynamic";
-        final Component componentA = findComponentByName( componentNameA );
-        TestCase.assertNotNull( componentA );
-        TestCase.assertEquals( Component.STATE_UNSATISFIED, componentA.getState() );
+        final ComponentConfigurationDTO componentA = findComponentConfigurationByName( componentNameA, ComponentConfigurationDTO.UNSATISFIED );
 
         String componentNameB = "1.B.1.1.dynamic";
-        final Component componentB = findComponentByName( componentNameB );
-        TestCase.assertNotNull( componentB );
-        TestCase.assertEquals( Component.STATE_UNSATISFIED, componentB.getState() );
-
-
+        final ComponentConfigurationDTO componentB = findComponentConfigurationByName( componentNameB, ComponentConfigurationDTO.UNSATISFIED );
     }
 
     /**
      * A > 1.1 > B > 0..n > A Both should start (A first), but B should not have an A reference.
+     * @throws InvalidSyntaxException 
      */
     @Test
-    public void test_A11_B0n_immediate_A_first()
+    public void test_A11_B0n_immediate_A_first() throws InvalidSyntaxException
     {
         String componentNameA = "2.A.1.1.dynamic";
-        final Component componentA = findComponentByName( componentNameA );
-        TestCase.assertNotNull( componentA );
-        TestCase.assertEquals( Component.STATE_ACTIVE, componentA.getState() );
-        A a = ( A ) componentA.getComponentInstance().getInstance();
+        final ComponentConfigurationDTO componentA = findComponentConfigurationByName( componentNameA, ComponentConfigurationDTO.ACTIVE );
+        A a = getServiceFromConfiguration(componentA, A.class);
         assertEquals( 1, a.getBs().size());
 
         String componentNameB = "2.B.0.n.dynamic";
-        final Component componentB = findComponentByName( componentNameB );
-        TestCase.assertNotNull( componentB );
-        TestCase.assertEquals( Component.STATE_ACTIVE, componentB.getState() );
-        B b = ( B ) componentB.getComponentInstance().getInstance();
+        final ComponentConfigurationDTO componentB = findComponentConfigurationByName( componentNameB, ComponentConfigurationDTO.ACTIVE );
+        B b = getServiceFromConfiguration(componentB, B.class);
         assertEquals( 1, b.getAs().size() );
     }
     /**
      * A > 1.1 > B > 0..n > A Both should start (B first), and B should have an A reference.
+     * @throws InvalidSyntaxException 
      */
     @Test
-    public void test_A11_B0n_immediate_B_first()
+    public void test_A11_B0n_immediate_B_first() throws InvalidSyntaxException
     {
         String componentNameA = "3.A.1.1.dynamic";
-        final Component componentA = findComponentByName( componentNameA );
-        TestCase.assertNotNull( componentA );
-        TestCase.assertEquals( Component.STATE_ACTIVE, componentA.getState() );
-        A a = ( A ) componentA.getComponentInstance().getInstance();
+        final ComponentConfigurationDTO componentA = findComponentConfigurationByName( componentNameA, ComponentConfigurationDTO.ACTIVE );
+        A a = getServiceFromConfiguration(componentA, A.class);
         assertEquals( 1, a.getBs().size());
 
         String componentNameB = "3.B.0.n.dynamic";
-        final Component componentB = findComponentByName( componentNameB );
-        TestCase.assertNotNull( componentB );
-        TestCase.assertEquals( Component.STATE_ACTIVE, componentB.getState() );
-        B b = ( B ) componentB.getComponentInstance().getInstance();
+        final ComponentConfigurationDTO componentB = findComponentConfigurationByName( componentNameB, ComponentConfigurationDTO.ACTIVE );
+        B b = getServiceFromConfiguration(componentB, B.class);
         assertEquals( 1, b.getAs().size() );
     }
     /**
@@ -116,26 +105,22 @@ public class CircularReferenceTest exten
     public void test_A11_B0n_delayed_A_first() throws InvalidSyntaxException
     {
         String componentNameA = "4.A.1.1.dynamic";
-        final Component componentA = findComponentByName( componentNameA );
-        TestCase.assertNotNull( componentA );
-        TestCase.assertEquals( Component.STATE_REGISTERED, componentA.getState() );
+        final ComponentConfigurationDTO componentA = findComponentConfigurationByName( componentNameA, ComponentConfigurationDTO.SATISFIED );
 
         String componentNameB = "4.B.0.n.dynamic";
-        final Component componentB = findComponentByName( componentNameB );
-        TestCase.assertNotNull( componentB );
-        TestCase.assertEquals( Component.STATE_REGISTERED, componentB.getState() );
+        final ComponentConfigurationDTO componentB = findComponentConfigurationByName( componentNameB, ComponentConfigurationDTO.SATISFIED );
 
-        ServiceReference[] serviceReferences = bundleContext.getServiceReferences( A.class.getName(), "(service.pid=" + componentNameA + ")" );
-        TestCase.assertEquals( 1, serviceReferences.length );
-        ServiceReference serviceReference = serviceReferences[0];
-        Object service = bundleContext.getService( serviceReference );
-        assertNotNull( service );
+//        ServiceReference[] serviceReferences = bundleContext.getServiceReferences( A.class.getName(), "(service.pid=" + componentNameA + ")" );
+//        TestCase.assertEquals( 1, serviceReferences.length );
+//        ServiceReference serviceReference = serviceReferences[0];
+//        Object service = bundleContext.getService( serviceReference );
+//        assertNotNull( service );
 
         delay();
 
-        A a = ( A ) componentA.getComponentInstance().getInstance();
-        assertEquals( 1, a.getBs().size() );
-        B b = ( B ) componentB.getComponentInstance().getInstance();
+        A a = getServiceFromConfiguration(componentA, A.class);
+        assertEquals( 1, a.getBs().size());
+        B b = getServiceFromConfiguration(componentB, B.class);
         assertEquals( 1, b.getAs().size() );
     }
     /**
@@ -145,14 +130,10 @@ public class CircularReferenceTest exten
     public void test_A11_B0n_delayed_B_first() throws InvalidSyntaxException
     {
         String componentNameA = "4.A.1.1.dynamic";
-        final Component componentA = findComponentByName( componentNameA );
-        TestCase.assertNotNull( componentA );
-        TestCase.assertEquals( Component.STATE_REGISTERED, componentA.getState() );
+        final ComponentConfigurationDTO componentA = findComponentConfigurationByName( componentNameA, ComponentConfigurationDTO.SATISFIED );
 
         String componentNameB = "4.B.0.n.dynamic";
-        final Component componentB = findComponentByName( componentNameB );
-        TestCase.assertNotNull( componentB );
-        TestCase.assertEquals( Component.STATE_REGISTERED, componentB.getState() );
+        final ComponentConfigurationDTO componentB = findComponentConfigurationByName( componentNameB, ComponentConfigurationDTO.SATISFIED);
 
         ServiceReference[] serviceReferencesB = bundleContext.getServiceReferences( B.class.getName(), "(service.pid=" + componentNameB + ")" );
         TestCase.assertEquals( 1, serviceReferencesB.length );
@@ -167,68 +148,62 @@ public class CircularReferenceTest exten
         assertNotNull( serviceA );
 
         delay();
-        A a = ( A ) componentA.getComponentInstance().getInstance();
-        assertEquals( 1, a.getBs().size() );
-        B b = ( B ) componentB.getComponentInstance().getInstance();
+        A a = getServiceFromConfiguration(componentA, A.class);
+        assertEquals( 1, a.getBs().size());
+        B b = getServiceFromConfiguration(componentB, B.class);
         assertEquals( 1, b.getAs().size() );
 
 
         //disabling (removing the A service registration) and re-enabling will
         //result in a service event to B, so B will bind A.
-        componentA.disable();
+        disableAndCheck(componentA);
         delay();
-        componentA.enable();
+        enableAndCheck(componentA.description);
         delay();
-        ServiceReference[] serviceReferencesA1 = bundleContext.getServiceReferences( A.class.getName(), "(service.pid=" + componentNameA + ")" );
-        TestCase.assertEquals( 1, serviceReferencesA1.length );
-        ServiceReference serviceReferenceA1 = serviceReferencesA1[0];
-        Object serviceA1 = bundleContext.getService( serviceReferenceA1 );
-        assertNotNull( serviceA1 );
-
-        A a1 = ( A ) componentA.getComponentInstance().getInstance();
-        assertEquals( 1, a1.getBs().size() );
-        B b1 = ( B ) componentB.getComponentInstance().getInstance();
-        assertEquals( 1, b1.getAs().size() );
+//        ServiceReference[] serviceReferencesA1 = bundleContext.getServiceReferences( A.class.getName(), "(service.pid=" + componentNameA + ")" );
+//        TestCase.assertEquals( 1, serviceReferencesA1.length );
+//        ServiceReference serviceReferenceA1 = serviceReferencesA1[0];
+//        Object serviceA1 = bundleContext.getService( serviceReferenceA1 );
+//        assertNotNull( serviceA1 );
+
+        a = getServiceFromConfiguration(componentA, A.class);
+        assertEquals( 1, a.getBs().size());
+        b = getServiceFromConfiguration(componentB, B.class);
+        assertEquals( 1, b.getAs().size() );
 
     }
     /**
      * A > 1.1 > B > 0..1 > A Both should start (A first), but B should not have an A reference.
+     * @throws InvalidSyntaxException 
      */
     @Test
-    public void test_A11_B01_immediate_A_first()
+    public void test_A11_B01_immediate_A_first() throws InvalidSyntaxException
     {
         String componentNameA = "5.A.1.1.dynamic";
-        final Component componentA = findComponentByName( componentNameA );
-        TestCase.assertNotNull( componentA );
-        TestCase.assertEquals( Component.STATE_ACTIVE, componentA.getState() );
-        A a = ( A ) componentA.getComponentInstance().getInstance();
+        final ComponentConfigurationDTO componentA = findComponentConfigurationByName( componentNameA, ComponentConfigurationDTO.ACTIVE );
+        A a = getServiceFromConfiguration(componentA, A.class);
         assertEquals( 1, a.getBs().size());
 
         String componentNameB = "5.B.0.1.dynamic";
-        final Component componentB = findComponentByName( componentNameB );
-        TestCase.assertNotNull( componentB );
-        TestCase.assertEquals( Component.STATE_ACTIVE, componentB.getState() );
-        B b = ( B ) componentB.getComponentInstance().getInstance();
+        final ComponentConfigurationDTO componentB = findComponentConfigurationByName( componentNameB, ComponentConfigurationDTO.ACTIVE );
+        B b = getServiceFromConfiguration(componentB, B.class);
         assertEquals( 1, b.getAs().size() );
     }
     /**
      * A > 1.1 > B > 0..1 > A Both should start (B first), and B should have an A reference.
+     * @throws InvalidSyntaxException 
      */
     @Test
-    public void test_A11_B01_immediate_B_first()
+    public void test_A11_B01_immediate_B_first() throws InvalidSyntaxException
     {
         String componentNameA = "6.A.1.1.dynamic";
-        final Component componentA = findComponentByName( componentNameA );
-        TestCase.assertNotNull( componentA );
-        TestCase.assertEquals( Component.STATE_ACTIVE, componentA.getState() );
-        A a = ( A ) componentA.getComponentInstance().getInstance();
+        final ComponentConfigurationDTO componentA = findComponentConfigurationByName( componentNameA, ComponentConfigurationDTO.ACTIVE );
+        A a = getServiceFromConfiguration(componentA, A.class);
         assertEquals( 1, a.getBs().size());
 
         String componentNameB = "6.B.0.1.dynamic";
-        final Component componentB = findComponentByName( componentNameB );
-        TestCase.assertNotNull( componentB );
-        TestCase.assertEquals( Component.STATE_ACTIVE, componentB.getState() );
-        B b = ( B ) componentB.getComponentInstance().getInstance();
+        final ComponentConfigurationDTO componentB = findComponentConfigurationByName( componentNameB, ComponentConfigurationDTO.ACTIVE );
+        B b = getServiceFromConfiguration(componentB, B.class);
         assertEquals( 1, b.getAs().size() );
     }
     /**
@@ -238,14 +213,10 @@ public class CircularReferenceTest exten
     public void test_A11_B01_delayed_A_first() throws InvalidSyntaxException
     {
         String componentNameA = "7.A.1.1.dynamic";
-        final Component componentA = findComponentByName( componentNameA );
-        TestCase.assertNotNull( componentA );
-        TestCase.assertEquals( Component.STATE_REGISTERED, componentA.getState() );
+        final ComponentConfigurationDTO componentA = findComponentConfigurationByName( componentNameA, ComponentConfigurationDTO.SATISFIED );
 
         String componentNameB = "7.B.0.1.dynamic";
-        final Component componentB = findComponentByName( componentNameB );
-        TestCase.assertNotNull( componentB );
-        TestCase.assertEquals( Component.STATE_REGISTERED, componentB.getState() );
+        final ComponentConfigurationDTO componentB = findComponentConfigurationByName( componentNameB, ComponentConfigurationDTO.SATISFIED );
 
         ServiceReference[] serviceReferences = bundleContext.getServiceReferences( A.class.getName(), "(service.pid=" + componentNameA + ")" );
         TestCase.assertEquals( 1, serviceReferences.length );
@@ -254,9 +225,9 @@ public class CircularReferenceTest exten
         assertNotNull( service );
 
         delay();
-        A a = ( A ) componentA.getComponentInstance().getInstance();
-        assertEquals( 1, a.getBs().size() );
-        B b = ( B ) componentB.getComponentInstance().getInstance();
+        A a = getServiceFromConfiguration(componentA, A.class);
+        assertEquals( 1, a.getBs().size());
+        B b = getServiceFromConfiguration(componentB, B.class);
         assertEquals( 1, b.getAs().size() );
     }
     /**
@@ -266,14 +237,10 @@ public class CircularReferenceTest exten
     public void test_A11_B01_delayed_B_first() throws InvalidSyntaxException
     {
         String componentNameA = "7.A.1.1.dynamic";
-        final Component componentA = findComponentByName( componentNameA );
-        TestCase.assertNotNull( componentA );
-        TestCase.assertEquals( Component.STATE_REGISTERED, componentA.getState() );
+        final ComponentConfigurationDTO componentA = findComponentConfigurationByName( componentNameA, ComponentConfigurationDTO.SATISFIED );
 
         String componentNameB = "7.B.0.1.dynamic";
-        final Component componentB = findComponentByName( componentNameB );
-        TestCase.assertNotNull( componentB );
-        TestCase.assertEquals( Component.STATE_REGISTERED, componentB.getState() );
+        final ComponentConfigurationDTO componentB = findComponentConfigurationByName( componentNameB, ComponentConfigurationDTO.SATISFIED );
 
         ServiceReference[] serviceReferencesB = bundleContext.getServiceReferences( B.class.getName(), "(service.pid=" + componentNameB + ")" );
         TestCase.assertEquals( 1, serviceReferencesB.length );
@@ -289,28 +256,28 @@ public class CircularReferenceTest exten
 
 
         delay();
-        A a = ( A ) componentA.getComponentInstance().getInstance();
-        assertEquals( 1, a.getBs().size() );
-        B b = ( B ) componentB.getComponentInstance().getInstance();
+        A a = getServiceFromConfiguration(componentA, A.class);
+        assertEquals( 1, a.getBs().size());
+        B b = getServiceFromConfiguration(componentB, B.class);
         assertEquals( 1, b.getAs().size() );
 
 
         //disabling (removing the A service registration) and re-enabling will
         //result in a service event to B, so B will bind A.
-        componentA.disable();
+        disableAndCheck(componentA);
         delay();
-        componentA.enable();
+        enableAndCheck(componentA.description);
         delay();
-        ServiceReference[] serviceReferencesA1 = bundleContext.getServiceReferences( A.class.getName(), "(service.pid=" + componentNameA + ")" );
-        TestCase.assertEquals( 1, serviceReferencesA1.length );
-        ServiceReference serviceReferenceA1 = serviceReferencesA1[0];
-        Object serviceA1 = bundleContext.getService( serviceReferenceA1 );
-        assertNotNull( serviceA1 );
-
-        A a1 = ( A ) componentA.getComponentInstance().getInstance();
-        assertEquals( 1, a1.getBs().size() );
-        B b1 = ( B ) componentB.getComponentInstance().getInstance();
-        assertEquals( 1, b1.getAs().size() );
+//        ServiceReference[] serviceReferencesA1 = bundleContext.getServiceReferences( A.class.getName(), "(service.pid=" + componentNameA + ")" );
+//        TestCase.assertEquals( 1, serviceReferencesA1.length );
+//        ServiceReference serviceReferenceA1 = serviceReferencesA1[0];
+//        Object serviceA1 = bundleContext.getService( serviceReferenceA1 );
+//        assertNotNull( serviceA1 );
+
+        a = getServiceFromConfiguration(componentA, A.class);
+        assertEquals( 1, a.getBs().size());
+        b = getServiceFromConfiguration(componentB, B.class);
+        assertEquals( 1, b.getAs().size() );
 
     }
 }

Modified: felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/ComponentActivationTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/ComponentActivationTest.java?rev=1602633&r1=1602632&r2=1602633&view=diff
==============================================================================
--- felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/ComponentActivationTest.java (original)
+++ felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/ComponentActivationTest.java Sun Jun 15 01:09:31 2014
@@ -21,14 +21,13 @@ package org.apache.felix.scr.integration
 
 import junit.framework.TestCase;
 
-import org.apache.felix.scr.Component;
 import org.apache.felix.scr.integration.components.ActivatorComponent;
-import org.apache.felix.scr.integration.components.SimpleService;
 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.framework.ServiceReference;
+import org.osgi.service.component.runtime.dto.ComponentConfigurationDTO;
 
 
 @RunWith(JUnit4TestRunner.class)
@@ -50,47 +49,21 @@ public class ComponentActivationTest ext
     {
         final String componentname = "ActivatorComponent.no.decl";
 
-        final Component component = findComponentByName( componentname );
+        ComponentConfigurationDTO cc = getDisabledConfigurationAndEnable(componentname, ComponentConfigurationDTO.ACTIVE);
 
-        TestCase.assertNotNull( component );
-        TestCase.assertFalse( component.isDefaultEnabled() );
-
-        TestCase.assertEquals( Component.STATE_DISABLED, component.getState() );
-
-        component.enable();
-        delay();
-
-        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
-
-        component.disable();
-
-        delay();
-        TestCase.assertEquals( Component.STATE_DISABLED, component.getState() );
+        disableAndCheck( cc );
     }
 
 
-//    @Test  I think this test is wrong.  Failure to activate does not mean that the state changes from Registered.
+    @Test //Changed to expect SATISFIED rather than unsatisfied
     public void test_activate_missing()
     {
         final String componentname = "ActivatorComponent.activate.missing";
 
-        final Component component = findComponentByName( componentname );
-
-        TestCase.assertNotNull( component );
-        TestCase.assertFalse( component.isDefaultEnabled() );
-
-        TestCase.assertEquals( Component.STATE_DISABLED, component.getState() );
-
-        component.enable();
-        delay();
+        // activate must fail, so state remains SATISFIED
+        ComponentConfigurationDTO cc = getDisabledConfigurationAndEnable(componentname, ComponentConfigurationDTO.SATISFIED);
 
-        // activate must fail
-        TestCase.assertEquals( Component.STATE_UNSATISFIED, component.getState() );
-
-        component.disable();
-
-        delay();
-        TestCase.assertEquals( Component.STATE_DISABLED, component.getState() );
+        disableAndCheck( cc );
     }
 
 
@@ -99,22 +72,9 @@ public class ComponentActivationTest ext
     {
         final String componentname = "ActivatorComponent.deactivate.missing";
 
-        final Component component = findComponentByName( componentname );
-
-        TestCase.assertNotNull( component );
-        TestCase.assertFalse( component.isDefaultEnabled() );
-
-        TestCase.assertEquals( Component.STATE_DISABLED, component.getState() );
-
-        component.enable();
-        delay();
-
-        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
-
-        component.disable();
+        ComponentConfigurationDTO cc = getDisabledConfigurationAndEnable(componentname, ComponentConfigurationDTO.ACTIVE);
 
-        delay();
-        TestCase.assertEquals( Component.STATE_DISABLED, component.getState() );
+        disableAndCheck( cc );
     }
 
 
@@ -123,47 +83,21 @@ public class ComponentActivationTest ext
     {
         final String componentname = "ActivatorComponent.decl";
 
-        final Component component = findComponentByName( componentname );
+        ComponentConfigurationDTO cc = getDisabledConfigurationAndEnable(componentname, ComponentConfigurationDTO.ACTIVE);
 
-        TestCase.assertNotNull( component );
-        TestCase.assertFalse( component.isDefaultEnabled() );
-
-        TestCase.assertEquals( Component.STATE_DISABLED, component.getState() );
-
-        component.enable();
-        delay();
-
-        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
-
-        component.disable();
-
-        delay();
-        TestCase.assertEquals( Component.STATE_DISABLED, component.getState() );
+        disableAndCheck( cc );
     }
 
 
-//    @Test  Failure to activate does not mean the state should change to unsatisfied.
+    @Test // Failure to activate does not mean the state should change to unsatisfied.
     public void test_activate_fail()
     {
         final String componentname = "ActivatorComponent.activate.fail";
 
-        final Component component = findComponentByName( componentname );
-
-        TestCase.assertNotNull( component );
-        TestCase.assertFalse( component.isDefaultEnabled() );
-
-        TestCase.assertEquals( Component.STATE_DISABLED, component.getState() );
-
-        component.enable();
-        delay();
+        // activate must fail, so state remains SATISFIED
+        ComponentConfigurationDTO cc = getDisabledConfigurationAndEnable(componentname, ComponentConfigurationDTO.SATISFIED);
 
-        // activate has failed
-        TestCase.assertEquals( Component.STATE_UNSATISFIED, component.getState() );
-
-        component.disable();
-
-        delay();
-        TestCase.assertEquals( Component.STATE_DISABLED, component.getState() );
+        disableAndCheck( cc );
     }
 
 
@@ -172,22 +106,9 @@ public class ComponentActivationTest ext
     {
         final String componentname = "ActivatorComponent.deactivate.fail";
 
-        final Component component = findComponentByName( componentname );
-
-        TestCase.assertNotNull( component );
-        TestCase.assertFalse( component.isDefaultEnabled() );
-
-        TestCase.assertEquals( Component.STATE_DISABLED, component.getState() );
-
-        component.enable();
-        delay();
-
-        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
-
-        component.disable();
+        ComponentConfigurationDTO cc = getDisabledConfigurationAndEnable(componentname, ComponentConfigurationDTO.ACTIVE);
 
-        delay();
-        TestCase.assertEquals( Component.STATE_DISABLED, component.getState() );
+        disableAndCheck( cc );
     }
 
 
@@ -196,25 +117,14 @@ public class ComponentActivationTest ext
     {
         final String componentname = "ActivatorComponent.activate.with.bind";
 
-        final Component component = findComponentByName( componentname );
+        ComponentConfigurationDTO cc = getDisabledConfigurationAndEnable(componentname, ComponentConfigurationDTO.ACTIVE);
 
-        TestCase.assertNotNull( component );
-        TestCase.assertFalse( component.isDefaultEnabled() );
-
-        TestCase.assertEquals( Component.STATE_DISABLED, component.getState() );
-
-        component.enable();
-        delay();
-
-        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
-
-        ActivatorComponent ac = (ActivatorComponent) component.getComponentInstance().getInstance();
+        ActivatorComponent ac = ActivatorComponent.getInstance();
         TestCase.assertNotNull( ac.getSimpleService() );
-
-        component.disable();
-
-        delay();
-        TestCase.assertEquals( Component.STATE_DISABLED, component.getState() );
+        
+        disableAndCheck( cc );
+        
+        TestCase.assertNull( ac.getSimpleService() );
     }
 
 
@@ -223,28 +133,13 @@ public class ComponentActivationTest ext
     {
         final String componentname = "ActivatorComponent.activate.delayed.with.bind";
 
-        final Component component = findComponentByName( componentname );
+        ComponentConfigurationDTO cc = getDisabledConfigurationAndEnable(componentname, ComponentConfigurationDTO.SATISFIED);
 
-        TestCase.assertNotNull( component );
-        TestCase.assertFalse( component.isDefaultEnabled() );
-
-        TestCase.assertEquals( Component.STATE_DISABLED, component.getState() );
-
-        component.enable();
-        delay();
-
-        TestCase.assertEquals( Component.STATE_REGISTERED, component.getState() );
-
-        ServiceReference<ActivatorComponent> ref = bundleContext.getServiceReference( ActivatorComponent.class );
-        ActivatorComponent ac = bundleContext.getService( ref );
-        TestCase.assertNotNull( ac.getSimpleService() );
+        getServiceFromConfiguration(cc, ActivatorComponent.class);
 
-        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
+        findComponentConfigurationByName(componentname, ComponentConfigurationDTO.ACTIVE);
 
-        component.disable();
-
-        delay();
-        TestCase.assertEquals( Component.STATE_DISABLED, component.getState() );
+        disableAndCheck( cc );
     }
     
     @Test
@@ -252,28 +147,13 @@ public class ComponentActivationTest ext
     {
         final String componentname = "ActivatorComponent.activate.service.factory.with.bind";
 
-        final Component component = findComponentByName( componentname );
-
-        TestCase.assertNotNull( component );
-        TestCase.assertFalse( component.isDefaultEnabled() );
-
-        TestCase.assertEquals( Component.STATE_DISABLED, component.getState() );
-
-        component.enable();
-        delay();
-
-        TestCase.assertEquals( Component.STATE_REGISTERED, component.getState() );
-
-        ServiceReference<ActivatorComponent> ref = bundleContext.getServiceReference( ActivatorComponent.class );
-        ActivatorComponent ac = bundleContext.getService( ref );
-        TestCase.assertNotNull( ac.getSimpleService() );
+        ComponentConfigurationDTO cc = getDisabledConfigurationAndEnable(componentname, ComponentConfigurationDTO.SATISFIED);
 
-        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
+        getServiceFromConfiguration(cc, ActivatorComponent.class);
 
-        component.disable();
+        findComponentConfigurationByName(componentname, ComponentConfigurationDTO.ACTIVE);
 
-        delay();
-        TestCase.assertEquals( Component.STATE_DISABLED, component.getState() );
+        disableAndCheck( cc );
     }
     
     @Test
@@ -319,26 +199,17 @@ public class ComponentActivationTest ext
 
     private void testRequiredDependency(final String componentname)
     {
-        final Component component = findComponentByName( componentname );
-
-        TestCase.assertNotNull( component );
-        TestCase.assertFalse( component.isDefaultEnabled() );
-
-        TestCase.assertEquals( Component.STATE_DISABLED, component.getState() );
+        ComponentConfigurationDTO cc = getDisabledConfigurationAndEnable(componentname, ComponentConfigurationDTO.UNSATISFIED);
 
-        component.enable();
-        delay();
-
-        TestCase.assertEquals( Component.STATE_UNSATISFIED, component.getState() );
-        
         SimpleServiceImpl ss = SimpleServiceImpl.create( bundleContext, "foo" );
         
-        TestCase.assertEquals( Component.STATE_REGISTERED, component.getState() );
+        findComponentConfigurationByName(componentname, ComponentConfigurationDTO.SATISFIED);
 
         ServiceReference<ActivatorComponent> ref = bundleContext.getServiceReference( ActivatorComponent.class );
         
         ss.drop();
-        TestCase.assertEquals( Component.STATE_UNSATISFIED, component.getState() );
+        findComponentConfigurationByName(componentname, ComponentConfigurationDTO.UNSATISFIED);
+
         
         TestCase.assertNull(bundleContext.getServiceReference( ActivatorComponent.class ));
         ss = SimpleServiceImpl.create( bundleContext, "foo" );
@@ -346,12 +217,10 @@ public class ComponentActivationTest ext
         ActivatorComponent ac = bundleContext.getService( ref );
         TestCase.assertNotNull( ac.getSimpleService() );
 
-        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
+        findComponentConfigurationByName(componentname, ComponentConfigurationDTO.ACTIVE);
 
-        component.disable();
 
-        delay();
-        TestCase.assertEquals( Component.STATE_DISABLED, component.getState() );
+        disableAndCheck( cc );
     }
 
 }

Modified: felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/ComponentConcurrencyTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/ComponentConcurrencyTest.java?rev=1602633&r1=1602632&r2=1602633&view=diff
==============================================================================
--- felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/ComponentConcurrencyTest.java (original)
+++ felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/ComponentConcurrencyTest.java Sun Jun 15 01:09:31 2014
@@ -16,11 +16,11 @@ import javax.inject.Inject;
 
 import junit.framework.TestCase;
 
-import org.apache.felix.scr.Component;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.ops4j.pax.exam.junit.JUnit4TestRunner;
 import org.osgi.framework.BundleContext;
+import org.osgi.service.component.runtime.dto.ComponentConfigurationDTO;
 
 @RunWith(JUnit4TestRunner.class)
 public class ComponentConcurrencyTest extends ComponentTestBase
@@ -52,15 +52,8 @@ public class ComponentConcurrencyTest ex
     {
 
 
-        final Component AFactory =
-                findComponentByName( "org.apache.felix.scr.integration.components.concurrency.AFactory" );
-        TestCase.assertNotNull( AFactory );
-        AFactory.enable();
-
-        final Component CFactory =
-                findComponentByName( "org.apache.felix.scr.integration.components.concurrency.CFactory" );
-        TestCase.assertNotNull( CFactory );
-        CFactory.enable();
+    	ComponentConfigurationDTO ccA = getDisabledConfigurationAndEnable( "org.apache.felix.scr.integration.components.concurrency.AFactory", ComponentConfigurationDTO.ACTIVE );
+    	ComponentConfigurationDTO ccC = getDisabledConfigurationAndEnable( "org.apache.felix.scr.integration.components.concurrency.CFactory", ComponentConfigurationDTO.ACTIVE );
 
         delay( 30 );
         for ( Iterator it = log.foundWarnings().iterator(); it.hasNext();)

Modified: felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/ComponentConfigurationPidTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/ComponentConfigurationPidTest.java?rev=1602633&r1=1602632&r2=1602633&view=diff
==============================================================================
--- felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/ComponentConfigurationPidTest.java (original)
+++ felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/ComponentConfigurationPidTest.java Sun Jun 15 01:09:31 2014
@@ -21,11 +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.junit.Test;
 import org.junit.runner.RunWith;
 import org.ops4j.pax.exam.junit.JUnit4TestRunner;
+import org.osgi.service.component.runtime.dto.ComponentConfigurationDTO;
+import org.osgi.service.component.runtime.dto.ComponentDescriptionDTO;
 
 
 @RunWith(JUnit4TestRunner.class)
@@ -43,40 +44,28 @@ public class ComponentConfigurationPidTe
     {
         final String pid = "ConfigurationPid.otherPid";
         final String name = "ConfigurationPid.componentName";
-        final Component component = findComponentByName( name );
-
         deleteConfig( pid );
         delay();
-
-        TestCase.assertNotNull( component );
-        TestCase.assertFalse( component.isDefaultEnabled() );
-
-        TestCase.assertEquals( Component.STATE_DISABLED, component.getState() );
         TestCase.assertNull( SimpleComponent.INSTANCE );
 
-        component.enable();
-        delay();
+        getConfigurationsDisabledThenEnable(name, 0, ComponentConfigurationDTO.UNSATISFIED);
 
-        TestCase.assertEquals( Component.STATE_UNSATISFIED, component.getState() );
         TestCase.assertNull( SimpleComponent.INSTANCE );
 
         configure( pid );
         delay();
 
-        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
+        findComponentConfigurationByName( name, ComponentConfigurationDTO.ACTIVE);
         TestCase.assertNotNull( SimpleComponent.INSTANCE );
         TestCase.assertEquals( PROP_NAME, SimpleComponent.INSTANCE.getProperty( PROP_NAME ) );
 
         deleteConfig( pid );
         delay();
 
-        TestCase.assertEquals( Component.STATE_UNSATISFIED, component.getState() );
+        ComponentDescriptionDTO cd = checkConfigurationCount(name, 0, -1);
         TestCase.assertNull( SimpleComponent.INSTANCE );
 
-        component.disable();
-        delay();
-
-        TestCase.assertEquals( Component.STATE_DISABLED, component.getState() );
+        disableAndCheck( cd );
         TestCase.assertNull( SimpleComponent.INSTANCE );
     }
     
@@ -85,29 +74,21 @@ public class ComponentConfigurationPidTe
     {
         final String name = "ConfigurationPid.componentName";
         final String pid = name;
-        final Component component = findComponentByName( name );
-
         deleteConfig( pid );
         delay();
 
-        TestCase.assertNotNull( component );
-        TestCase.assertFalse( component.isDefaultEnabled() );
-
-        TestCase.assertEquals( Component.STATE_DISABLED, component.getState() );
-        TestCase.assertNull( SimpleComponent.INSTANCE );
-
-        component.enable();
-        delay();
-
-        TestCase.assertEquals( Component.STATE_UNSATISFIED, component.getState() );
+        getConfigurationsDisabledThenEnable(name, 0, ComponentConfigurationDTO.UNSATISFIED);
         TestCase.assertNull( SimpleComponent.INSTANCE );
 
         configure( pid );
         delay();
 
-        TestCase.assertEquals( Component.STATE_UNSATISFIED, component.getState() );
+        ComponentDescriptionDTO cd = checkConfigurationCount(name, 0, -1);
+        TestCase.assertNull( SimpleComponent.INSTANCE );
 
         deleteConfig( pid );
         delay();
+        
+        disableAndCheck( cd );
     }
 }

Modified: felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/ComponentConfigurationTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/ComponentConfigurationTest.java?rev=1602633&r1=1602632&r2=1602633&view=diff
==============================================================================
--- felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/ComponentConfigurationTest.java (original)
+++ felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/ComponentConfigurationTest.java Sun Jun 15 01:09:31 2014
@@ -19,6 +19,9 @@
 package org.apache.felix.scr.integration;
 
 
+import java.util.Collection;
+
+import junit.framework.Assert;
 import junit.framework.TestCase;
 
 import org.apache.felix.scr.Component;
@@ -28,6 +31,7 @@ import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.ops4j.pax.exam.junit.JUnit4TestRunner;
 import org.osgi.framework.Constants;
+import org.osgi.service.component.runtime.dto.ComponentConfigurationDTO;
 
 
 @RunWith(JUnit4TestRunner.class)
@@ -44,42 +48,31 @@ public class ComponentConfigurationTest 
     public void test_SimpleComponent_configuration_ignore()
     {
         final String pid = "SimpleComponent.configuration.ignore";
-        final Component component = findComponentByName( pid );
-
-        deleteConfig( pid );
-        delay();
-
-        TestCase.assertNotNull( component );
-        TestCase.assertFalse( component.isDefaultEnabled() );
-
-        TestCase.assertEquals( Component.STATE_DISABLED, component.getState() );
         TestCase.assertNull( SimpleComponent.INSTANCE );
 
-        component.enable();
+        deleteConfig( pid );
         delay();
 
-        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
+        ComponentConfigurationDTO cc = getDisabledConfigurationAndEnable(pid, ComponentConfigurationDTO.ACTIVE);
+        
         TestCase.assertNotNull( SimpleComponent.INSTANCE );
         TestCase.assertNull( SimpleComponent.INSTANCE.getProperty( PROP_NAME ) );
 
         configure( pid );
         delay();
 
-        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
+        findComponentConfigurationByName(pid, ComponentConfigurationDTO.ACTIVE);
         TestCase.assertNotNull( SimpleComponent.INSTANCE );
         TestCase.assertNull( SimpleComponent.INSTANCE.getProperty( PROP_NAME ) );
 
         deleteConfig( pid );
         delay();
 
-        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
+        findComponentConfigurationByName(pid, ComponentConfigurationDTO.ACTIVE);
         TestCase.assertNotNull( SimpleComponent.INSTANCE );
         TestCase.assertNull( SimpleComponent.INSTANCE.getProperty( PROP_NAME ) );
 
-        component.disable();
-        delay();
-
-        TestCase.assertEquals( Component.STATE_DISABLED, component.getState() );
+        disableAndCheck( cc );
         TestCase.assertNull( SimpleComponent.INSTANCE );
     }
 
@@ -88,22 +81,9 @@ public class ComponentConfigurationTest 
     public void test_SimpleComponent_configuration_optional()
     {
         final String pid = "SimpleComponent.configuration.optional";
-        final Component component = findComponentByName( pid );
-
-        deleteConfig( pid );
-        delay();
-
-        TestCase.assertNotNull( component );
-        TestCase.assertFalse( component.isDefaultEnabled() );
-
-        TestCase.assertEquals( Component.STATE_DISABLED, component.getState() );
-        TestCase.assertNull( SimpleComponent.INSTANCE );
-
-        component.enable();
-        delay();
+        ComponentConfigurationDTO cc = getDisabledConfigurationAndEnable(pid, ComponentConfigurationDTO.ACTIVE);
 
         final SimpleComponent firstInstance = SimpleComponent.INSTANCE;
-        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
         TestCase.assertNotNull( firstInstance );
         TestCase.assertNull( firstInstance.getProperty( PROP_NAME ) );
 
@@ -111,7 +91,7 @@ public class ComponentConfigurationTest 
         delay();
 
         final SimpleComponent secondInstance = SimpleComponent.INSTANCE;
-        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
+        findComponentConfigurationByName(pid, ComponentConfigurationDTO.ACTIVE);
         TestCase.assertNotNull( secondInstance );
         TestCase.assertEquals( PROP_NAME, secondInstance.getProperty( PROP_NAME ) );
 
@@ -119,7 +99,7 @@ public class ComponentConfigurationTest 
         delay();
 
         final SimpleComponent thirdInstance = SimpleComponent.INSTANCE;
-        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
+        findComponentConfigurationByName(pid, ComponentConfigurationDTO.ACTIVE);
         TestCase.assertNotNull( thirdInstance );
         TestCase.assertNull( thirdInstance.getProperty( PROP_NAME ) );
 
@@ -129,10 +109,7 @@ public class ComponentConfigurationTest 
         TestCase.assertNotSame( "Expect new instance object after configuration deletion (2)", secondInstance,
             thirdInstance );
 
-        component.disable();
-        delay();
-
-        TestCase.assertEquals( Component.STATE_DISABLED, component.getState() );
+        disableAndCheck( cc );
         TestCase.assertNull( SimpleComponent.INSTANCE );
     }
 
@@ -141,40 +118,29 @@ public class ComponentConfigurationTest 
     public void test_SimpleComponent_configuration_require()
     {
         final String pid = "SimpleComponent.configuration.require";
-        final Component component = findComponentByName( pid );
 
         deleteConfig( pid );
         delay();
-
-        TestCase.assertNotNull( component );
-        TestCase.assertFalse( component.isDefaultEnabled() );
-
-        TestCase.assertEquals( Component.STATE_DISABLED, component.getState() );
+        
         TestCase.assertNull( SimpleComponent.INSTANCE );
 
-        component.enable();
-        delay();
-
-        TestCase.assertEquals( Component.STATE_UNSATISFIED, component.getState() );
+        getConfigurationsDisabledThenEnable(pid, 0, ComponentConfigurationDTO.UNSATISFIED);
         TestCase.assertNull( SimpleComponent.INSTANCE );
 
         configure( pid );
         delay();
 
-        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
+        ComponentConfigurationDTO cc = findComponentConfigurationByName(pid, ComponentConfigurationDTO.ACTIVE);
         TestCase.assertNotNull( SimpleComponent.INSTANCE );
         TestCase.assertEquals( PROP_NAME, SimpleComponent.INSTANCE.getProperty( PROP_NAME ) );
 
         deleteConfig( pid );
         delay();
 
-        TestCase.assertEquals( Component.STATE_UNSATISFIED, component.getState() );
+        checkConfigurationCount(pid, 0, -1);
         TestCase.assertNull( SimpleComponent.INSTANCE );
 
-        component.disable();
-        delay();
-
-        TestCase.assertEquals( Component.STATE_DISABLED, component.getState() );
+        disableAndCheck( cc );
         TestCase.assertNull( SimpleComponent.INSTANCE );
     }
 
@@ -205,21 +171,11 @@ public class ComponentConfigurationTest 
 
 
 	private void dynamicConfigTest(final String pid, boolean pre13) {
-		final Component component = findComponentByName( pid );
-
         deleteConfig( pid );
         delay();
 
-        TestCase.assertNotNull( component );
-        TestCase.assertFalse( component.isDefaultEnabled() );
-
-        TestCase.assertEquals( Component.STATE_DISABLED, component.getState() );
-        TestCase.assertNull( SimpleComponent.INSTANCE );
-
-        component.enable();
-        delay();
+        ComponentConfigurationDTO cc = getDisabledConfigurationAndEnable(pid, ComponentConfigurationDTO.ACTIVE);
 
-        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
         TestCase.assertNotNull( SimpleComponent.INSTANCE );
         TestCase.assertNull( SimpleComponent.INSTANCE.getProperty( PROP_NAME ) );
         TestCase.assertEquals( pid, SimpleComponent.INSTANCE.getProperty( Constants.SERVICE_PID ) );
@@ -229,7 +185,7 @@ public class ComponentConfigurationTest 
         configure( pid );
         delay();
 
-        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
+        findComponentConfigurationByName(pid, ComponentConfigurationDTO.ACTIVE);
         TestCase.assertEquals( instance, SimpleComponent.INSTANCE );
         TestCase.assertEquals( PROP_NAME, SimpleComponent.INSTANCE.getProperty( PROP_NAME ) );
         TestCase.assertEquals( pid, SimpleComponent.INSTANCE.getProperty( Constants.SERVICE_PID ) );
@@ -237,7 +193,7 @@ public class ComponentConfigurationTest 
         deleteConfig( pid );
         delay();
 
-        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
+        findComponentConfigurationByName(pid, ComponentConfigurationDTO.ACTIVE);
         if (pre13)
         {
             TestCase.assertNotSame( instance, SimpleComponent.INSTANCE );
@@ -249,16 +205,13 @@ public class ComponentConfigurationTest 
         TestCase.assertNull( SimpleComponent.INSTANCE.getProperty( PROP_NAME ) );
         TestCase.assertEquals( pid, SimpleComponent.INSTANCE.getProperty( Constants.SERVICE_PID ) );
 
-        component.disable();
-        delay();
-
-        TestCase.assertEquals( Component.STATE_DISABLED, component.getState() );
+        disableAndCheck( cc );
         TestCase.assertNull( SimpleComponent.INSTANCE );
 	}
 
 
     @Test
-    public void test_SimpleComponent_dynamic_configuration_with_required_service()
+    public void test_SimpleComponent_dynamic_optional_configuration_with_required_service()
     {
         final String targetProp = "ref.target";
         final String filterProp = "required";
@@ -266,36 +219,25 @@ public class ComponentConfigurationTest 
         try
         {
             final String pid = "DynamicConfigurationComponentWithRequiredReference";
-            final Component component = findComponentByName( pid );
-
             deleteConfig( pid );
             delay();
 
-            TestCase.assertNotNull( component );
-            TestCase.assertFalse( component.isDefaultEnabled() );
-
-            TestCase.assertEquals( Component.STATE_DISABLED, component.getState() );
-            TestCase.assertNull( SimpleComponent.INSTANCE );
-
-            component.enable();
-            delay();
-
             // mandatory ref missing --> component unsatisfied
-            TestCase.assertEquals( Component.STATE_UNSATISFIED, component.getState() );
+            ComponentConfigurationDTO cc = getDisabledConfigurationAndEnable(pid, ComponentConfigurationDTO.UNSATISFIED);
 
             // dynamically configure without the correct target
             configure( pid );
             delay();
 
             // mandatory ref missing --> component unsatisfied
-            TestCase.assertEquals( Component.STATE_UNSATISFIED, component.getState() );
+            findComponentConfigurationByName(pid, ComponentConfigurationDTO.UNSATISFIED);
 
             // dynamically configure with correct target
             theConfig.put( targetProp, "(filterprop=" + filterProp + ")" );
             configure( pid );
             delay();
 
-            TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
+            findComponentConfigurationByName(pid, ComponentConfigurationDTO.ACTIVE);
             TestCase.assertNotNull( SimpleComponent.INSTANCE );
             TestCase.assertEquals( PROP_NAME, SimpleComponent.INSTANCE.getProperty( PROP_NAME ) );
             TestCase.assertEquals( pid, SimpleComponent.INSTANCE.getProperty( Constants.SERVICE_PID ) );
@@ -306,7 +248,7 @@ public class ComponentConfigurationTest 
             delay();
 
             // same instance after reconfiguration
-            TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
+            findComponentConfigurationByName(pid, ComponentConfigurationDTO.ACTIVE);
             TestCase.assertEquals( instance, SimpleComponent.INSTANCE );
             TestCase.assertEquals( PROP_NAME, SimpleComponent.INSTANCE.getProperty( PROP_NAME ) );
             TestCase.assertEquals( pid, SimpleComponent.INSTANCE.getProperty( Constants.SERVICE_PID ) );
@@ -318,18 +260,15 @@ public class ComponentConfigurationTest 
             delay();
 
             // mandatory ref missing --> component unsatisfied
-            TestCase.assertEquals( Component.STATE_UNSATISFIED, component.getState() );
+            findComponentConfigurationByName(pid, ComponentConfigurationDTO.UNSATISFIED);
 
             deleteConfig( pid );
             delay();
 
             // mandatory ref missing --> component unsatisfied
-            TestCase.assertEquals( Component.STATE_UNSATISFIED, component.getState() );
+            findComponentConfigurationByName(pid, ComponentConfigurationDTO.UNSATISFIED);
 
-            component.disable();
-            delay();
-
-            TestCase.assertEquals( Component.STATE_DISABLED, component.getState() );
+            disableAndCheck(cc);
             TestCase.assertNull( SimpleComponent.INSTANCE );
         }
         finally
@@ -347,7 +286,7 @@ public class ComponentConfigurationTest 
      * to (still) match the other one.  2nd service should remain bound.
      */
     @Test
-    public void test_SimpleComponent_dynamic_configuration_with_required_service2()
+    public void test_SimpleComponent_dynamic_optional_configuration_with_required_service2()
     {
         final String targetProp = "ref.target";
         final String filterProp1 = "one";
@@ -357,36 +296,25 @@ public class ComponentConfigurationTest 
         try
         {
             final String pid = "DynamicConfigurationComponentWithRequiredReference";
-            final Component component = findComponentByName( pid );
-
             deleteConfig( pid );
             delay();
 
-            TestCase.assertNotNull( component );
-            TestCase.assertFalse( component.isDefaultEnabled() );
-
-            TestCase.assertEquals( Component.STATE_DISABLED, component.getState() );
-            TestCase.assertNull( SimpleComponent.INSTANCE );
-
-            component.enable();
-            delay();
-
             // mandatory ref missing --> component unsatisfied
-            TestCase.assertEquals( Component.STATE_UNSATISFIED, component.getState() );
+            ComponentConfigurationDTO cc = getDisabledConfigurationAndEnable(pid, ComponentConfigurationDTO.UNSATISFIED);
 
             // dynamically configure without the correct target
             configure( pid );
             delay();
 
             // mandatory ref missing --> component unsatisfied
-            TestCase.assertEquals( Component.STATE_UNSATISFIED, component.getState() );
+            findComponentConfigurationByName(pid, ComponentConfigurationDTO.UNSATISFIED);
 
             // dynamically configure with correct target
             theConfig.put( targetProp, "(|(filterprop=" + filterProp1 + ")(filterprop=" + filterProp2 + "))" );
             configure( pid );
             delay();
 
-            TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
+            findComponentConfigurationByName(pid, ComponentConfigurationDTO.ACTIVE);
             TestCase.assertNotNull( SimpleComponent.INSTANCE );
             TestCase.assertEquals( PROP_NAME, SimpleComponent.INSTANCE.getProperty( PROP_NAME ) );
             TestCase.assertEquals( pid, SimpleComponent.INSTANCE.getProperty( Constants.SERVICE_PID ) );
@@ -402,7 +330,7 @@ public class ComponentConfigurationTest 
                 service2.drop();
             }
              // same instance after reconfiguration
-            TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
+            findComponentConfigurationByName(pid, ComponentConfigurationDTO.ACTIVE);
             TestCase.assertEquals( instance, SimpleComponent.INSTANCE );
             TestCase.assertEquals( PROP_NAME, SimpleComponent.INSTANCE.getProperty( PROP_NAME ) );
             TestCase.assertEquals( pid, SimpleComponent.INSTANCE.getProperty( Constants.SERVICE_PID ) );
@@ -414,7 +342,7 @@ public class ComponentConfigurationTest 
             delay();
 
             // same instance after reconfiguration
-            TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
+            findComponentConfigurationByName(pid, ComponentConfigurationDTO.ACTIVE);
             TestCase.assertEquals( instance, SimpleComponent.INSTANCE );
             TestCase.assertEquals( PROP_NAME, SimpleComponent.INSTANCE.getProperty( PROP_NAME ) );
             TestCase.assertEquals( pid, SimpleComponent.INSTANCE.getProperty( Constants.SERVICE_PID ) );
@@ -424,12 +352,9 @@ public class ComponentConfigurationTest 
             delay();
 
             // mandatory ref missing --> component unsatisfied
-            TestCase.assertEquals( Component.STATE_UNSATISFIED, component.getState() );
-
-            component.disable();
-            delay();
+            findComponentConfigurationByName(pid, ComponentConfigurationDTO.UNSATISFIED);
 
-            TestCase.assertEquals( Component.STATE_DISABLED, component.getState() );
+            disableAndCheck(cc);
             TestCase.assertNull( SimpleComponent.INSTANCE );
         }
         finally
@@ -443,7 +368,7 @@ public class ComponentConfigurationTest 
     }
 
     @Test
-    public void test_SimpleComponent_dynamic_configuration_with_optional_service() throws Exception
+    public void test_SimpleComponent_dynamic_optional_configuration_with_optional_service() throws Exception
     {
         final String targetProp = "ref.target";
         final String filterProp = "required";
@@ -451,22 +376,12 @@ public class ComponentConfigurationTest 
         try
         {
             final String pid = "DynamicConfigurationComponentWithOptionalReference";
-            final Component component = findComponentByName( pid );
-
             deleteConfig( pid );
             delay();
 
-            TestCase.assertNotNull( component );
-            TestCase.assertFalse( component.isDefaultEnabled() );
-
-            TestCase.assertEquals( Component.STATE_DISABLED, component.getState() );
-            TestCase.assertNull( SimpleComponent.INSTANCE );
-
-            component.enable();
-            delay();
-
             // optional ref missing --> component active
-            TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
+            ComponentConfigurationDTO cc = getDisabledConfigurationAndEnable(pid, ComponentConfigurationDTO.ACTIVE);
+
             TestCase.assertNotNull( SimpleComponent.INSTANCE );
             final SimpleComponent instance = SimpleComponent.INSTANCE;
 
@@ -475,7 +390,7 @@ public class ComponentConfigurationTest 
             delay();
 
             // optional ref missing --> component active
-            TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
+            findComponentConfigurationByName(pid, ComponentConfigurationDTO.ACTIVE);
             TestCase.assertEquals( instance, SimpleComponent.INSTANCE );
             TestCase.assertNull( SimpleComponent.INSTANCE.m_singleRef );
 
@@ -484,7 +399,7 @@ public class ComponentConfigurationTest 
             configure( pid );
             delay();
 
-            TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
+            findComponentConfigurationByName(pid, ComponentConfigurationDTO.ACTIVE);
             TestCase.assertEquals( instance, SimpleComponent.INSTANCE );
             TestCase.assertEquals( PROP_NAME, SimpleComponent.INSTANCE.getProperty( PROP_NAME ) );
             TestCase.assertEquals( pid, SimpleComponent.INSTANCE.getProperty( Constants.SERVICE_PID ) );
@@ -494,7 +409,7 @@ public class ComponentConfigurationTest 
             delay();
 
             // same instance after reconfiguration
-            TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
+            findComponentConfigurationByName(pid, ComponentConfigurationDTO.ACTIVE);
             TestCase.assertEquals( instance, SimpleComponent.INSTANCE );
             TestCase.assertEquals( PROP_NAME, SimpleComponent.INSTANCE.getProperty( PROP_NAME ) );
             TestCase.assertEquals( pid, SimpleComponent.INSTANCE.getProperty( Constants.SERVICE_PID ) );
@@ -506,7 +421,7 @@ public class ComponentConfigurationTest 
             delay();
 
             // optional ref missing --> component active
-            TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
+            findComponentConfigurationByName(pid, ComponentConfigurationDTO.ACTIVE);
             TestCase.assertEquals( instance, SimpleComponent.INSTANCE );
             TestCase.assertNull( SimpleComponent.INSTANCE.m_singleRef );
 
@@ -514,14 +429,11 @@ public class ComponentConfigurationTest 
             delay();
 
             // optional ref missing --> component active
-            TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
+            findComponentConfigurationByName(pid, ComponentConfigurationDTO.ACTIVE);
             TestCase.assertNotSame( instance, SimpleComponent.INSTANCE );
             TestCase.assertNull( SimpleComponent.INSTANCE.m_singleRef );
 
-            component.disable();
-            delay();
-
-            TestCase.assertEquals( Component.STATE_DISABLED, component.getState() );
+            disableAndCheck(cc);
             TestCase.assertNull( SimpleComponent.INSTANCE );
         }
         finally
@@ -544,21 +456,7 @@ public class ComponentConfigurationTest 
         deleteFactoryConfigurations( factoryPid );
         delay();
 
-        // one single component exists without configuration
-        final Component[] noConfigurations = findComponentsByName( factoryPid );
-        TestCase.assertNotNull( noConfigurations );
-        TestCase.assertEquals( 1, noConfigurations.length );
-        TestCase.assertEquals( Component.STATE_DISABLED, noConfigurations[0].getState() );
-        TestCase.assertTrue( SimpleComponent.INSTANCES.isEmpty() );
-
-        // enable the component, configuration required, hence unsatisfied
-        noConfigurations[0].enable();
-        delay();
-
-        final Component[] enabledNoConfigs = findComponentsByName( factoryPid );
-        TestCase.assertNotNull( enabledNoConfigs );
-        TestCase.assertEquals( 1, enabledNoConfigs.length );
-        TestCase.assertEquals( Component.STATE_UNSATISFIED, enabledNoConfigs[0].getState() );
+        getConfigurationsDisabledThenEnable(factoryPid, 0, -1);
         TestCase.assertTrue( SimpleComponent.INSTANCES.isEmpty() );
 
         // create two factory configurations expecting two components
@@ -566,71 +464,85 @@ public class ComponentConfigurationTest 
         final String pid1 = createFactoryConfiguration( factoryPid );
         delay();
 
-        // expect two components, only first is active, second is disabled
-        final Component[] twoConfigs = findComponentsByName( factoryPid );
-        TestCase.assertNotNull( twoConfigs );
-        TestCase.assertEquals( 2, twoConfigs.length );
-
-        // find the active and inactive configs, fail if none
-        int activeConfig;
-        int inactiveConfig;
-        if ( twoConfigs[0].getState() == Component.STATE_ACTIVE )
-        {
-            // [0] is active, [1] expected disabled
-            activeConfig = 0;
-            inactiveConfig = 1;
-        }
-        else if ( twoConfigs[1].getState() == Component.STATE_ACTIVE )
-        {
-            // [1] is active, [0] expected disabled
-            activeConfig = 1;
-            inactiveConfig = 0;
-        }
-        else
-        {
-            TestCase.fail( "One of two components expected active" );
-            return; // eases the compiler...
-        }
-
-        TestCase.assertEquals( Component.STATE_ACTIVE, twoConfigs[activeConfig].getState() );
-        TestCase.assertEquals( Component.STATE_DISABLED, twoConfigs[inactiveConfig].getState() );
-        TestCase.assertEquals( 1, SimpleComponent.INSTANCES.size() );
-        TestCase.assertTrue( SimpleComponent.INSTANCES.containsKey( twoConfigs[activeConfig].getId() ) );
-        TestCase.assertFalse( SimpleComponent.INSTANCES.containsKey( twoConfigs[inactiveConfig].getId() ) );
-
-        // enable second component
-        twoConfigs[inactiveConfig].enable();
-        delay();
-
-        // ensure both components active
-        TestCase.assertEquals( Component.STATE_ACTIVE, twoConfigs[0].getState() );
-        TestCase.assertEquals( Component.STATE_ACTIVE, twoConfigs[1].getState() );
-        TestCase.assertEquals( 2, SimpleComponent.INSTANCES.size() );
-        TestCase.assertTrue( SimpleComponent.INSTANCES.containsKey( twoConfigs[0].getId() ) );
-        TestCase.assertTrue( SimpleComponent.INSTANCES.containsKey( twoConfigs[1].getId() ) );
+        // expect two active components, //TODO WTF?? only first is active, second is disabled
+        checkConfigurationCount(factoryPid, 2, ComponentConfigurationDTO.ACTIVE);
+//        Collection<ComponentConfigurationDTO> ccs = findComponentConfigurationsByName(factoryPid);
+//        Assert.assertEquals(2, ccs.size());
+//        
+//        ComponentConfigurationDTO activ e= null;
+//        ComponentConfigurationDTO inactive = null;
+//        
+//        for (ComponentConfigurationDTO cc: ccs)
+//        {
+//        	if (ComponentConfigurationDTO.ACTIVE == cc.state)
+//        	{
+//        		if 
+//        	}
+//        }
+//
+//        // find the active and inactive configs, fail if none
+//        int activeConfig;
+//        int inactiveConfig;
+//        if ( twoConfigs[0].getState() == Component.STATE_ACTIVE )
+//        {
+//            // [0] is active, [1] expected disabled
+//            activeConfig = 0;
+//            inactiveConfig = 1;
+//        }
+//        else if ( twoConfigs[1].getState() == Component.STATE_ACTIVE )
+//        {
+//            // [1] is active, [0] expected disabled
+//            activeConfig = 1;
+//            inactiveConfig = 0;
+//        }
+//        else
+//        {
+//            TestCase.fail( "One of two components expected active" );
+//            return; // eases the compiler...
+//        }
+//
+//        TestCase.assertEquals( Component.STATE_ACTIVE, twoConfigs[activeConfig].getState() );
+//        TestCase.assertEquals( Component.STATE_DISABLED, twoConfigs[inactiveConfig].getState() );
+//        TestCase.assertEquals( 1, SimpleComponent.INSTANCES.size() );
+//        TestCase.assertTrue( SimpleComponent.INSTANCES.containsKey( twoConfigs[activeConfig].getId() ) );
+//        TestCase.assertFalse( SimpleComponent.INSTANCES.containsKey( twoConfigs[inactiveConfig].getId() ) );
+//
+//        // enable second component
+//        twoConfigs[inactiveConfig].enable();
+//        delay();
+//
+//        // ensure both components active
+//        TestCase.assertEquals( Component.STATE_ACTIVE, twoConfigs[0].getState() );
+//        TestCase.assertEquals( Component.STATE_ACTIVE, twoConfigs[1].getState() );
+//        TestCase.assertEquals( 2, SimpleComponent.INSTANCES.size() );
+//        TestCase.assertTrue( SimpleComponent.INSTANCES.containsKey( twoConfigs[0].getId() ) );
+//        TestCase.assertTrue( SimpleComponent.INSTANCES.containsKey( twoConfigs[1].getId() ) );
 
         // delete a configuration
         deleteConfig( pid0 );
         delay();
 
         // expect one component
-        final Component[] oneConfig = findComponentsByName( factoryPid );
-        TestCase.assertNotNull( oneConfig );
-        TestCase.assertEquals( 1, oneConfig.length );
-        TestCase.assertEquals( Component.STATE_ACTIVE, oneConfig[0].getState() );
-        TestCase.assertEquals( 1, SimpleComponent.INSTANCES.size() );
-        TestCase.assertTrue( SimpleComponent.INSTANCES.containsKey( oneConfig[0].getId() ) );
+        checkConfigurationCount(factoryPid, 1, ComponentConfigurationDTO.ACTIVE);
+//        final Component[] oneConfig = findComponentConfigurationsByName( factoryPid );
+//        TestCase.assertNotNull( oneConfig );
+//        TestCase.assertEquals( 1, oneConfig.length );
+//        TestCase.assertEquals( Component.STATE_ACTIVE, oneConfig[0].getState() );
+//        TestCase.assertEquals( 1, SimpleComponent.INSTANCES.size() );
+//        TestCase.assertTrue( SimpleComponent.INSTANCES.containsKey( oneConfig[0].getId() ) );
 
         // delete second configuration
         deleteConfig( pid1 );
         delay();
 
+        checkConfigurationCount(factoryPid, 0, ComponentConfigurationDTO.ACTIVE);
         // expect a single unsatisfied component
-        final Component[] configsDeleted = findComponentsByName( factoryPid );
-        TestCase.assertNotNull( configsDeleted );
-        TestCase.assertEquals( 1, configsDeleted.length );
-        TestCase.assertEquals( Component.STATE_UNSATISFIED, configsDeleted[0].getState() );
-        TestCase.assertEquals( 0, SimpleComponent.INSTANCES.size() );
+//        final Component[] configsDeleted = findComponentConfigurationsByName( factoryPid );
+//        TestCase.assertNotNull( configsDeleted );
+//        TestCase.assertEquals( 1, configsDeleted.length );
+//        TestCase.assertEquals( Component.STATE_UNSATISFIED, configsDeleted[0].getState() );
+//        TestCase.assertEquals( 0, SimpleComponent.INSTANCES.size() );
+//        disableAndCheck(cd); //TODO needed??
     }
 
     @Test
@@ -641,12 +553,8 @@ public class ComponentConfigurationTest 
         deleteFactoryConfigurations( factoryPid );
         delay();
 
-        // one single component exists without configuration
-        final Component[] enabledNoConfigs = findComponentsByName( factoryPid );
-        TestCase.assertNotNull( enabledNoConfigs );
-        TestCase.assertEquals( 1, enabledNoConfigs.length );
-        TestCase.assertEquals( Component.STATE_UNSATISFIED, enabledNoConfigs[0].getState() );
-        TestCase.assertTrue( SimpleComponent.INSTANCES.isEmpty() );
+        checkConfigurationCount(factoryPid, 0, ComponentConfigurationDTO.ACTIVE);
+        // no component config exists without configuration
 
         // create two factory configurations expecting two components
         final String pid0 = createFactoryConfiguration( factoryPid );
@@ -654,76 +562,74 @@ public class ComponentConfigurationTest 
         delay();
 
         // expect two components, all active
-        final Component[] twoConfigs = findComponentsByName( factoryPid );
-        TestCase.assertNotNull( twoConfigs );
-        TestCase.assertEquals( 2, twoConfigs.length );
-        TestCase.assertEquals( Component.STATE_ACTIVE, twoConfigs[0].getState() );
-        TestCase.assertEquals( Component.STATE_ACTIVE, twoConfigs[1].getState() );
-        TestCase.assertEquals( 2, SimpleComponent.INSTANCES.size() );
-        TestCase.assertTrue( SimpleComponent.INSTANCES.containsKey( twoConfigs[0].getId() ) );
-        TestCase.assertTrue( SimpleComponent.INSTANCES.containsKey( twoConfigs[1].getId() ) );
+        checkConfigurationCount(factoryPid, 2, ComponentConfigurationDTO.ACTIVE);
 
         // disable the name component
-        SimpleComponent.INSTANCES.values().iterator().next().m_activateContext.disableComponent( factoryPid );
+        disableAndCheck( factoryPid );
         delay();
 
-        // expect two disabled components
-        final Component[] twoConfigsDisabled = findComponentsByName( factoryPid );
-        TestCase.assertNotNull( twoConfigsDisabled );
-        TestCase.assertEquals( 2, twoConfigsDisabled.length );
-        TestCase.assertEquals( Component.STATE_DISABLED, twoConfigsDisabled[0].getState() );
-        TestCase.assertEquals( Component.STATE_DISABLED, twoConfigsDisabled[1].getState() );
-        TestCase.assertEquals( 0, SimpleComponent.INSTANCES.size() );
-        TestCase.assertFalse( SimpleComponent.INSTANCES.containsKey( twoConfigs[0].getId() ) );
-        TestCase.assertFalse( SimpleComponent.INSTANCES.containsKey( twoConfigs[1].getId() ) );
+        // expect no XXtwo disabled components
+//        checkConfigurationCount(factoryPid, 0, ComponentConfigurationDTO.ACTIVE);
+//        final Component[] twoConfigsDisabled = findComponentConfigurationsByName( factoryPid );
+//        TestCase.assertNotNull( twoConfigsDisabled );
+//        TestCase.assertEquals( 2, twoConfigsDisabled.length );
+//        TestCase.assertEquals( Component.STATE_DISABLED, twoConfigsDisabled[0].getState() );
+//        TestCase.assertEquals( Component.STATE_DISABLED, twoConfigsDisabled[1].getState() );
+//        TestCase.assertEquals( 0, SimpleComponent.INSTANCES.size() );
+//        TestCase.assertFalse( SimpleComponent.INSTANCES.containsKey( twoConfigs[0].getId() ) );
+//        TestCase.assertFalse( SimpleComponent.INSTANCES.containsKey( twoConfigs[1].getId() ) );
 
         // create a configuration
         final String pid3 = createFactoryConfiguration( factoryPid );
         delay();
 
         // expect three disabled components
-        final Component[] threeConfigsDisabled = findComponentsByName( factoryPid );
-        TestCase.assertNotNull( threeConfigsDisabled );
-        TestCase.assertEquals( 3, threeConfigsDisabled.length );
-        TestCase.assertEquals( Component.STATE_DISABLED, threeConfigsDisabled[0].getState() );
-        TestCase.assertEquals( Component.STATE_DISABLED, threeConfigsDisabled[1].getState() );
-        TestCase.assertEquals( Component.STATE_DISABLED, threeConfigsDisabled[2].getState() );
-        TestCase.assertEquals( 0, SimpleComponent.INSTANCES.size() );
-        TestCase.assertFalse( SimpleComponent.INSTANCES.containsKey( threeConfigsDisabled[0].getId() ) );
-        TestCase.assertFalse( SimpleComponent.INSTANCES.containsKey( threeConfigsDisabled[1].getId() ) );
-        TestCase.assertFalse( SimpleComponent.INSTANCES.containsKey( threeConfigsDisabled[2].getId() ) );
-
-        // enable a single component (to get ComponentContext later)
-        threeConfigsDisabled[0].enable();
-        delay();
-
-        // expect one enabled and two disabled components
-        final Component[] threeConfigs21 = findComponentsByName( factoryPid );
-        TestCase.assertNotNull( threeConfigs21 );
-        TestCase.assertEquals( 3, threeConfigs21.length );
-        TestCase.assertEquals( 1, SimpleComponent.INSTANCES.size() );
-        TestCase.assertEquals( Component.STATE_ACTIVE, threeConfigs21[0].getState() );
-        TestCase.assertEquals( Component.STATE_DISABLED, threeConfigs21[1].getState() );
-        TestCase.assertEquals( Component.STATE_DISABLED, threeConfigs21[2].getState() );
-        TestCase.assertTrue( SimpleComponent.INSTANCES.containsKey( threeConfigs21[0].getId() ) );
-        TestCase.assertFalse( SimpleComponent.INSTANCES.containsKey( threeConfigs21[1].getId() ) );
-        TestCase.assertFalse( SimpleComponent.INSTANCES.containsKey( threeConfigs21[2].getId() ) );
-
-        // enable all components now
-        SimpleComponent.INSTANCES.values().iterator().next().m_activateContext.enableComponent( factoryPid );
-        delay();
-
-        // expect all enabled
-        final Component[] threeConfigsEnabled = findComponentsByName( factoryPid );
-        TestCase.assertNotNull( threeConfigsEnabled );
-        TestCase.assertEquals( 3, threeConfigsEnabled.length );
-        TestCase.assertEquals( Component.STATE_ACTIVE, threeConfigsEnabled[0].getState() );
-        TestCase.assertEquals( Component.STATE_ACTIVE, threeConfigsEnabled[1].getState() );
-        TestCase.assertEquals( Component.STATE_ACTIVE, threeConfigsEnabled[2].getState() );
-        TestCase.assertEquals( 3, SimpleComponent.INSTANCES.size() );
-        TestCase.assertTrue( SimpleComponent.INSTANCES.containsKey( threeConfigsEnabled[0].getId() ) );
-        TestCase.assertTrue( SimpleComponent.INSTANCES.containsKey( threeConfigsEnabled[1].getId() ) );
-        TestCase.assertTrue( SimpleComponent.INSTANCES.containsKey( threeConfigsEnabled[2].getId() ) );
+//        checkConfigurationCount(factoryPid, 0, ComponentConfigurationDTO.ACTIVE);
+//        final Component[] threeConfigsDisabled = findComponentConfigurationsByName( factoryPid );
+//        TestCase.assertNotNull( threeConfigsDisabled );
+//        TestCase.assertEquals( 3, threeConfigsDisabled.length );
+//        TestCase.assertEquals( Component.STATE_DISABLED, threeConfigsDisabled[0].getState() );
+//        TestCase.assertEquals( Component.STATE_DISABLED, threeConfigsDisabled[1].getState() );
+//        TestCase.assertEquals( Component.STATE_DISABLED, threeConfigsDisabled[2].getState() );
+//        TestCase.assertEquals( 0, SimpleComponent.INSTANCES.size() );
+//        TestCase.assertFalse( SimpleComponent.INSTANCES.containsKey( threeConfigsDisabled[0].getId() ) );
+//        TestCase.assertFalse( SimpleComponent.INSTANCES.containsKey( threeConfigsDisabled[1].getId() ) );
+//        TestCase.assertFalse( SimpleComponent.INSTANCES.containsKey( threeConfigsDisabled[2].getId() ) );
+//disabled, no configurations.
+        getConfigurationsDisabledThenEnable(factoryPid, 0, ComponentConfigurationDTO.ACTIVE);
+        
+//        // enable a single component (to get ComponentContext later)
+//        threeConfigsDisabled[0].enable();
+//        delay();
+//
+//        // expect one enabled and two disabled components
+//        final Component[] threeConfigs21 = findComponentConfigurationsByName( factoryPid );
+//        TestCase.assertNotNull( threeConfigs21 );
+//        TestCase.assertEquals( 3, threeConfigs21.length );
+//        TestCase.assertEquals( 1, SimpleComponent.INSTANCES.size() );
+//        TestCase.assertEquals( Component.STATE_ACTIVE, threeConfigs21[0].getState() );
+//        TestCase.assertEquals( Component.STATE_DISABLED, threeConfigs21[1].getState() );
+//        TestCase.assertEquals( Component.STATE_DISABLED, threeConfigs21[2].getState() );
+//        TestCase.assertTrue( SimpleComponent.INSTANCES.containsKey( threeConfigs21[0].getId() ) );
+//        TestCase.assertFalse( SimpleComponent.INSTANCES.containsKey( threeConfigs21[1].getId() ) );
+//        TestCase.assertFalse( SimpleComponent.INSTANCES.containsKey( threeConfigs21[2].getId() ) );
+//
+//        // enable all components now
+//        SimpleComponent.INSTANCES.values().iterator().next().m_activateContext.enableComponent( factoryPid );
+//        delay();
+//
+//        // expect all enabled
+//        final Component[] threeConfigsEnabled = findComponentConfigurationsByName( factoryPid );
+//        TestCase.assertNotNull( threeConfigsEnabled );
+//        TestCase.assertEquals( 3, threeConfigsEnabled.length );
+//        TestCase.assertEquals( Component.STATE_ACTIVE, threeConfigsEnabled[0].getState() );
+//        TestCase.assertEquals( Component.STATE_ACTIVE, threeConfigsEnabled[1].getState() );
+//        TestCase.assertEquals( Component.STATE_ACTIVE, threeConfigsEnabled[2].getState() );
+//        TestCase.assertEquals( 3, SimpleComponent.INSTANCES.size() );
+//        TestCase.assertTrue( SimpleComponent.INSTANCES.containsKey( threeConfigsEnabled[0].getId() ) );
+//        TestCase.assertTrue( SimpleComponent.INSTANCES.containsKey( threeConfigsEnabled[1].getId() ) );
+//        TestCase.assertTrue( SimpleComponent.INSTANCES.containsKey( threeConfigsEnabled[2].getId() ) );
     }
 
+
 }



Mime
View raw message