felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r1602633 [2/5] - in /felix/trunk/scr: ./ src/test/java/org/apache/felix/scr/integration/ src/test/java/org/apache/felix/scr/integration/components/ src/test/java/org/apache/felix/scr/integration/components/activatesignature/ src/test/resour...
Date Sun, 15 Jun 2014 01:09:32 GMT
Modified: felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/ComponentDisposeTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/ComponentDisposeTest.java?rev=1602633&r1=1602632&r2=1602633&view=diff
==============================================================================
--- felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/ComponentDisposeTest.java (original)
+++ felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/ComponentDisposeTest.java Sun Jun 15 01:09:31 2014
@@ -20,16 +20,18 @@ package org.apache.felix.scr.integration
 
 
 import java.lang.reflect.Field;
+import java.util.Collection;
 import java.util.Map;
 
+import junit.framework.Assert;
 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.ComponentContext;
+import org.osgi.service.component.runtime.dto.ComponentConfigurationDTO;
 
 
 @RunWith(JUnit4TestRunner.class)
@@ -50,70 +52,77 @@ public class ComponentDisposeTest extend
         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() );
-        TestCase.assertTrue( SimpleComponent.INSTANCES.isEmpty() );
+        getConfigurationsDisabledThenEnable(factoryPid, 0, ComponentConfigurationDTO.ACTIVE);//there should be none
+//        // one single component exists without configuration
+//        final Component[] noConfigurations = findComponentConfigurationsByName( factoryPid, -1 );
+//        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 = findComponentConfigurationsByName( factoryPid, -1 );
+//        TestCase.assertNotNull( enabledNoConfigs );
+//        TestCase.assertEquals( 1, enabledNoConfigs.length );
+//        TestCase.assertEquals( Component.STATE_UNSATISFIED, enabledNoConfigs[0].getState() );
+//        TestCase.assertTrue( SimpleComponent.INSTANCES.isEmpty() );
 
         // create two factory configurations expecting two components
         final String pid0 = createFactoryConfiguration( factoryPid );
         final String pid1 = createFactoryConfiguration( factoryPid );
         delay();
 
+        Collection<ComponentConfigurationDTO> ccs = findComponentConfigurationsByName(factoryPid, ComponentConfigurationDTO.ACTIVE);
+		Assert.assertEquals(2, ccs.size());
         // 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
+//        final Component[] twoConfigs = findComponentConfigurationsByName( factoryPid, -1 );
+//        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( 2, SimpleComponent.INSTANCES.size() );
+        for (ComponentConfigurationDTO cc: ccs)
         {
-            TestCase.fail( "One of two components expected active" );
-            return; // eases the compiler...
+        	TestCase.assertTrue(SimpleComponent.INSTANCES.containsKey(cc.id));
         }
-
-        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() ) );
+//        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() ) );
+//        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() ) );
 
         // dispose an instance
         final SimpleComponent anInstance = SimpleComponent.INSTANCE;
@@ -123,12 +132,15 @@ public class ComponentDisposeTest extend
         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() );
+        ComponentConfigurationDTO cc = findComponentConfigurationByName(factoryPid, ComponentConfigurationDTO.ACTIVE);
+
+//        final Component[] oneConfig = findComponentConfigurationsByName( factoryPid, -1 );
+//        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() ) );
+    	TestCase.assertTrue(SimpleComponent.INSTANCES.containsKey(cc.id));
+//        TestCase.assertTrue( SimpleComponent.INSTANCES.containsKey( oneConfig[0].getId() ) );
 
         final SimpleComponent instance = SimpleComponent.INSTANCES.values().iterator().next();
 

Modified: felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/ComponentFactoryTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/ComponentFactoryTest.java?rev=1602633&r1=1602632&r2=1602633&view=diff
==============================================================================
--- felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/ComponentFactoryTest.java (original)
+++ felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/ComponentFactoryTest.java Sun Jun 15 01:09:31 2014
@@ -62,7 +62,7 @@ public class ComponentFactoryTest extend
         final String componentname = "factory.component";
         final String componentfactory = "factory.component.factory";
 
-        final Component component = findComponentByName( componentname );
+        final Component component = findComponentDescriptorByName( componentname );
 
         TestCase.assertNotNull( component );
         TestCase.assertFalse( component.isDefaultEnabled() );
@@ -100,7 +100,7 @@ public class ComponentFactoryTest extend
         TestCase.assertTrue( instanceMap.containsValue( instanceManager ) );
 
         // check registered components
-        final Component[] allFactoryComponents = findComponentsByName( componentname );
+        final Component[] allFactoryComponents = findComponentConfigurationsByName( componentname, -1 );
         TestCase.assertNotNull( allFactoryComponents );
         TestCase.assertEquals( 2, allFactoryComponents.length );
         for ( int i = 0; i < allFactoryComponents.length; i++ )
@@ -137,7 +137,7 @@ public class ComponentFactoryTest extend
         final String componentname = "factory.component";
         final String componentfactory = "factory.component.factory";
 
-        final Component component = findComponentByName( componentname );
+        final Component component = findComponentDescriptorByName( componentname );
 
         TestCase.assertNotNull( component );
         TestCase.assertFalse( component.isDefaultEnabled() );
@@ -199,7 +199,7 @@ public class ComponentFactoryTest extend
         final String componentname = "factory.component";
         final String componentfactory = "factory.component.factory";
 
-        final Component component = findComponentByName( componentname );
+        final Component component = findComponentDescriptorByName( componentname );
 
         TestCase.assertNotNull( component );
         TestCase.assertFalse( component.isDefaultEnabled() );
@@ -251,7 +251,7 @@ public class ComponentFactoryTest extend
         deleteConfig( componentname );
         delay();
 
-        final Component component = findComponentByName( componentname );
+        final Component component = findComponentDescriptorByName( componentname );
 
         TestCase.assertNotNull( component );
         TestCase.assertFalse( component.isDefaultEnabled() );
@@ -334,7 +334,7 @@ public class ComponentFactoryTest extend
 
         SimpleServiceImpl.create( bundleContext, "ignored" ).setFilterProperty( "ignored" );
 
-        final Component component = findComponentByName( componentname );
+        final Component component = findComponentDescriptorByName( componentname );
 
         TestCase.assertNotNull( component );
         TestCase.assertFalse( component.isDefaultEnabled() );
@@ -383,7 +383,7 @@ public class ComponentFactoryTest extend
         TestCase.assertTrue( instanceMap.containsValue( instanceManager ) );
 
         // check registered components
-        final Component[] allFactoryComponents = findComponentsByName( componentname );
+        final Component[] allFactoryComponents = findComponentConfigurationsByName( componentname, -1 );
         TestCase.assertNotNull( allFactoryComponents );
         TestCase.assertEquals( 2, allFactoryComponents.length );
         for ( int i = 0; i < allFactoryComponents.length; i++ )
@@ -440,7 +440,7 @@ public class ComponentFactoryTest extend
         TestCase.assertTrue( SimpleComponent.INSTANCE.m_multiRef.contains( noMatch ) );
 
         // check registered components
-        final Component[] allFactoryComponents2 = findComponentsByName( componentname );
+        final Component[] allFactoryComponents2 = findComponentConfigurationsByName( componentname, -1 );
         TestCase.assertNotNull( allFactoryComponents2 );
         TestCase.assertEquals( 2, allFactoryComponents2.length );
         for ( int i = 0; i < allFactoryComponents2.length; i++ )
@@ -464,7 +464,7 @@ public class ComponentFactoryTest extend
         delay();
 
         // check registered components (ComponentFactory aint no longer)
-        final Component[] allFactoryComponents3 = findComponentsByName( componentname );
+        final Component[] allFactoryComponents3 = findComponentConfigurationsByName( componentname, -1 );
         TestCase.assertNotNull( allFactoryComponents3 );
         TestCase.assertEquals( 2, allFactoryComponents3.length );
         for ( int i = 0; i < allFactoryComponents3.length; i++ )
@@ -489,7 +489,7 @@ public class ComponentFactoryTest extend
         delay();
 
         // check registered components (ComponentFactory aint no longer)
-        final Component[] allFactoryComponents4 = findComponentsByName( componentname );
+        final Component[] allFactoryComponents4 = findComponentConfigurationsByName( componentname, -1 );
         TestCase.assertNotNull( allFactoryComponents4 );
         TestCase.assertEquals( 1, allFactoryComponents4.length );
         for ( int i = 0; i < allFactoryComponents4.length; i++ )
@@ -520,7 +520,7 @@ public class ComponentFactoryTest extend
     {
         //set up the component that refers to the service the factory will create.
         final String referringComponentName = "ComponentReferringToFactoryObject";
-        final Component referringComponent = findComponentByName( referringComponentName );
+        final Component referringComponent = findComponentDescriptorByName( referringComponentName );
         TestCase.assertNotNull( referringComponent );
         referringComponent.enable();
         delay();
@@ -532,7 +532,7 @@ public class ComponentFactoryTest extend
         final String componentname = "factory.component.referred";
         final String componentfactory = "factory.component.factory.referred";
 
-        final Component component = findComponentByName( componentname );
+        final Component component = findComponentDescriptorByName( componentname );
 
         TestCase.assertNotNull( component );
         TestCase.assertFalse( component.isDefaultEnabled() );
@@ -575,7 +575,7 @@ public class ComponentFactoryTest extend
     public void test_component_factory_with_target_filters() throws InvalidSyntaxException
     {
         final String componentfactory = "factory.component.reference.targetfilter";
-        final Component component = findComponentByName( componentfactory );
+        final Component component = findComponentDescriptorByName( componentfactory );
 
         TestCase.assertNotNull( component );
         TestCase.assertFalse( component.isDefaultEnabled() );
@@ -629,7 +629,7 @@ public class ComponentFactoryTest extend
     public void test_component_factory_set_bundle_location_null() throws Exception
     {
         final String componentfactory = "factory.component.reference.targetfilter";
-        final Component component = findComponentByName( componentfactory );
+        final Component component = findComponentDescriptorByName( componentfactory );
 
         TestCase.assertNotNull( component );
         TestCase.assertFalse( component.isDefaultEnabled() );

Modified: felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/ComponentTestBase.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/ComponentTestBase.java?rev=1602633&r1=1602632&r2=1602633&view=diff
==============================================================================
--- felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/ComponentTestBase.java (original)
+++ felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/ComponentTestBase.java Sun Jun 15 01:09:31 2014
@@ -43,17 +43,21 @@ import java.lang.reflect.Method;
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Collection;
 import java.util.Collections;
 import java.util.Date;
 import java.util.Dictionary;
+import java.util.HashMap;
 import java.util.Hashtable;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Map;
 import java.util.TreeSet;
 import java.util.concurrent.LinkedBlockingQueue;
 
 import javax.inject.Inject;
 
+import junit.framework.Assert;
 import junit.framework.TestCase;
 
 import org.apache.felix.scr.Component;
@@ -76,6 +80,9 @@ import org.osgi.framework.FrameworkListe
 import org.osgi.framework.InvalidSyntaxException;
 import org.osgi.framework.ServiceReference;
 import org.osgi.service.cm.ConfigurationAdmin;
+import org.osgi.service.component.runtime.ServiceComponentRuntime;
+import org.osgi.service.component.runtime.dto.ComponentConfigurationDTO;
+import org.osgi.service.component.runtime.dto.ComponentDescriptionDTO;
 import org.osgi.service.log.LogService;
 import org.osgi.util.tracker.ServiceTracker;
 
@@ -88,9 +95,9 @@ public abstract class ComponentTestBase
 
     protected Bundle bundle;
 
-    protected ServiceTracker scrTracker;
+    protected ServiceTracker<ServiceComponentRuntime, ServiceComponentRuntime> scrTracker;
 
-    protected ServiceTracker configAdminTracker;
+    protected ServiceTracker<ConfigurationAdmin, ConfigurationAdmin> configAdminTracker;
 
     // the name of the system property providing the bundle file to be installed and tested
     protected static final String BUNDLE_JAR_SYS_PROP = "project.bundle.file";
@@ -184,9 +191,9 @@ public abstract class ComponentTestBase
         bundleContext.addFrameworkListener( log );
         bundleContext.registerService( LogService.class.getName(), log, null );
         
-        scrTracker = new ServiceTracker( bundleContext, "org.apache.felix.scr.ScrService", null );
+        scrTracker = new ServiceTracker<ServiceComponentRuntime, ServiceComponentRuntime>( bundleContext, ServiceComponentRuntime.class, null );
         scrTracker.open();
-        configAdminTracker = new ServiceTracker( bundleContext, "org.osgi.service.cm.ConfigurationAdmin", null );
+        configAdminTracker = new ServiceTracker<ConfigurationAdmin, ConfigurationAdmin>( bundleContext, ConfigurationAdmin.class, null );
         configAdminTracker.open();
 
         bundle = installBundle( descriptorFile, COMPONENT_PACKAGE );
@@ -217,41 +224,204 @@ public abstract class ComponentTestBase
     }
 
 
-    protected Component[] getComponents()
+    protected Collection<ComponentDescriptionDTO> getComponentDescriptions()
     {
-        ScrService scr = ( ScrService ) scrTracker.getService();
-        if ( scr != null )
+        ServiceComponentRuntime scr = scrTracker.getService();
+        if ( scr == null )
         {
-            return scr.getComponents();
+        	TestCase.fail("no ServiceComponentRuntime");
         }
+            return scr.getComponentDescriptionDTOs();
+    }
 
-        return null;
+
+    protected ComponentDescriptionDTO findComponentDescriptorByName( String name )
+    {
+        ServiceComponentRuntime scr = scrTracker.getService();
+        if ( scr == null )
+        {
+        	TestCase.fail("no ServiceComponentRuntime");
+        }
+            return scr.getComponentDescriptionDTO(bundle, name);
     }
 
 
-    protected Component findComponentByName( String name )
+    protected Collection<ComponentConfigurationDTO> findComponentConfigurationsByName( Bundle b, String name, int expected )
     {
-        Component[] components = findComponentsByName( name );
-        if ( components != null && components.length > 0 )
+        ServiceComponentRuntime scr = scrTracker.getService();
+        if ( scr == null )
         {
-            return components[0];
+        	TestCase.fail("no ServiceComponentRuntime");
         }
+        	ComponentDescriptionDTO cd = scr.getComponentDescriptionDTO(bundle, name);
+        	Collection<ComponentConfigurationDTO> ccs = scr.getComponentConfigurationDTOs(cd);
+        	if (expected != -1)
+        	{
+        		for (ComponentConfigurationDTO cc: ccs)
+        		{
+        	    	Assert.assertEquals( "for ComponentConfiguration name: " + cc.description.name + " properties" + cc.properties + "Expected state " + STATES.get(expected) + " but was " + STATES.get(cc.state), expected, cc.state);        			
+        		}
+        	}
+        	return ccs;
+    }
+    
+    protected Collection<ComponentConfigurationDTO> findComponentConfigurationsByName( String name, int expected )
+    {
+    	return findComponentConfigurationsByName(bundle, name, expected);
+    }
 
-        return null;
+    protected ComponentConfigurationDTO findComponentConfigurationByName( Bundle b, String name, int expected )
+    {
+    	Collection<ComponentConfigurationDTO> ccs = findComponentConfigurationsByName( b, name, expected);
+    	Assert.assertEquals(1, ccs.size());
+    	return ccs.iterator().next();
     }
 
+    protected ComponentConfigurationDTO findComponentConfigurationByName( String name, int expected )
+    {
+    	return findComponentConfigurationByName( bundle, name, expected );
+    }
+//    protected ComponentConfigurationDTO checkState( String name, int expected)
+//    {
+//    	ComponentConfigurationDTO cc = findComponentConfigurationByName( name, expected);
+//    	return cc;
+//    }
+    
+    static final Map<Integer, String> STATES = new HashMap<Integer, String>();
+    
+    static {
+    	STATES.put(ComponentConfigurationDTO.UNSATISFIED, "Unsatisfied (" + ComponentConfigurationDTO.UNSATISFIED + ")" );
+    	STATES.put(ComponentConfigurationDTO.SATISFIED, "Satisified (" + ComponentConfigurationDTO.SATISFIED + ")" );
+    	STATES.put(ComponentConfigurationDTO.ACTIVE, "Active (" + ComponentConfigurationDTO.ACTIVE + ")" );
+    }
+    
+    protected ComponentConfigurationDTO getDisabledConfigurationAndEnable( Bundle b, String name, int initialState )
+    {
+    	int count = 1;
+        Collection<ComponentConfigurationDTO> ccs = getConfigurationsDisabledThenEnable(
+				b, name, count, initialState);
+		ComponentConfigurationDTO cc = ccs.iterator().next();
+    	return cc;
+    }
+    
+    protected ComponentConfigurationDTO getDisabledConfigurationAndEnable( String name, int initialState )
+    {
+    	return getDisabledConfigurationAndEnable( bundle, name, initialState );
+    }
 
-    protected Component[] findComponentsByName( String name )
+    protected Collection<ComponentConfigurationDTO> getConfigurationsDisabledThenEnable( Bundle b, String name, int count, int initialState) 
+    {
+		ServiceComponentRuntime scr = scrTracker.getService();
+        if ( scr == null )
+        {
+        	TestCase.fail("no ServiceComponentRuntime");
+        }
+    	ComponentDescriptionDTO cd = scr.getComponentDescriptionDTO(b, name);
+    	Assert.assertFalse("Expected component disabled", scr.isComponentEnabled(cd));
+    	scr.enableComponent(cd);
+    	delay();//??
+    	Assert.assertTrue("Expected component enabled", scr.isComponentEnabled(cd));
+    	
+    	Collection<ComponentConfigurationDTO> ccs = scr.getComponentConfigurationDTOs(cd);
+    	Assert.assertEquals(count, ccs.size());
+    	for (ComponentConfigurationDTO cc: ccs) {
+			Assert.assertEquals("Expected state " + STATES.get(initialState)
+					+ " but was " + STATES.get(cc.state), initialState,
+					cc.state);
+		}
+		return ccs;
+	}
+    
+    protected Collection<ComponentConfigurationDTO> getConfigurationsDisabledThenEnable( String name, int count, int initialState) 
+    {
+    	return getConfigurationsDisabledThenEnable(bundle, name, count, initialState);
+    }
+    
+    protected ComponentDescriptionDTO checkConfigurationCount( Bundle b, String name, int count, int expectedState )
+    {		
+    	ServiceComponentRuntime scr = scrTracker.getService();
+    	if ( scr == null )
+    	{
+    		TestCase.fail("no ServiceComponentRuntime");
+    	}
+    	ComponentDescriptionDTO cd = scr.getComponentDescriptionDTO(b, name);
+    	Assert.assertTrue("Expected component enabled", scr.isComponentEnabled(cd));
+
+    	Collection<ComponentConfigurationDTO> ccs = scr.getComponentConfigurationDTOs(cd);
+    	Assert.assertEquals(count, ccs.size());
+    	if (expectedState != -1)
+    	{
+    		for (ComponentConfigurationDTO cc: ccs)
+    		{
+    			Assert.assertEquals("Expected state " + STATES.get(expectedState)
+    					+ " but was " + STATES.get(cc.state), expectedState,
+    					cc.state);
+    		}
+    	}
+    	return cd;
+    }
+    
+    protected ComponentDescriptionDTO checkConfigurationCount( String name, int count, int expectedState )
+    {	
+    	return checkConfigurationCount(bundle, name, count, expectedState);
+    }
+    
+    protected <S> S getServiceFromConfiguration( ComponentConfigurationDTO dto, Class<S> clazz )
+    {
+    	long id = dto.id;
+    	String filter = "(component.id=" + id + ")";
+    	Collection<ServiceReference<S>> srs;
+		try {
+			srs = bundleContext.getServiceReferences(clazz, filter);
+	    	Assert.assertEquals(1, srs.size());
+	    	ServiceReference<S> sr = srs.iterator().next();
+	    	S s = bundleContext.getService(sr);
+	    	Assert.assertNotNull(s);
+	    	return s;
+		} catch (InvalidSyntaxException e) {
+			TestCase.fail(e.getMessage());
+			return null;//unreachable in fact
+		}
+    }
+    
+    protected void enableAndCheck( ComponentDescriptionDTO cd )
     {
-        ScrService scr = ( ScrService ) scrTracker.getService();
+        ServiceComponentRuntime scr = scrTracker.getService();
         if ( scr != null )
         {
-            return scr.getComponents( name );
+        	scr.enableComponent(cd);
+        	Assert.assertTrue("Expected component enabled", scr.isComponentEnabled(cd));
         }
+        else 
+        {
+        	throw new NullPointerException("no ServiceComponentRuntime");
+        }
+    	
+    }
 
-        return null;
+    protected void disableAndCheck( ComponentConfigurationDTO cc )
+    {
+    	ComponentDescriptionDTO cd = cc.description;
+        disableAndCheck(cd);
     }
 
+	protected void disableAndCheck(ComponentDescriptionDTO cd) {
+		ServiceComponentRuntime scr = scrTracker.getService();
+        if ( scr != null )
+        {
+        	scr.disableComponent(cd);
+        	Assert.assertFalse("Expected component disabled", scr.isComponentEnabled(cd));
+        }
+        else 
+        {
+        	throw new NullPointerException("no ServiceComponentRuntime");
+        }
+	}
+
+	protected void disableAndCheck(String name) {
+		ComponentDescriptionDTO cd = findComponentDescriptorByName(name);
+		disableAndCheck(cd);		
+	}
 
     protected static void delay()
     {
@@ -469,126 +639,126 @@ public abstract class ComponentTestBase
 
     void info( PrintStream out )
     {
-        Component[] components = getComponents();
-        if ( components == null )
-        {
-            return;
-        }
-
-        for ( int j = 0; j < components.length; j++ )
-        {
-            Component component = components[j];
-            out.print( "ID: " );
-            out.println( component.getId() );
-            out.print( "Name: " );
-            out.println( component.getName() );
-            out.print( "Bundle: " );
-            out.println( component.getBundle().getSymbolicName() + " (" + component.getBundle().getBundleId() + ")" );
-            out.print( "State: " );
-            out.println( toStateString( component.getState() ) );
-            out.print( "Default State: " );
-            out.println( component.isDefaultEnabled() ? "enabled" : "disabled" );
-            out.print( "Activation: " );
-            out.println( component.isImmediate() ? "immediate" : "delayed" );
-
-            // DS 1.1 new features
-            out.print( "Configuration Policy: " );
-            out.println( component.getConfigurationPolicy() );
-            out.print( "Activate Method: " );
-            out.print( component.getActivate() );
-            if ( component.isActivateDeclared() )
-            {
-                out.print( " (declared in the descriptor)" );
-            }
-            out.println();
-            out.print( "Deactivate Method: " );
-            out.print( component.getDeactivate() );
-            if ( component.isDeactivateDeclared() )
-            {
-                out.print( " (declared in the descriptor)" );
-            }
-            out.println();
-            out.print( "Modified Method: " );
-            if ( component.getModified() != null )
-            {
-                out.print( component.getModified() );
-            }
-            else
-            {
-                out.print( "-" );
-            }
-            out.println();
-
-            if ( component.getFactory() != null )
-            {
-                out.print( "Factory: " );
-                out.println( component.getFactory() );
-            }
-
-            String[] services = component.getServices();
-            if ( services != null )
-            {
-                out.print( "Services: " );
-                out.println( services[0] );
-                for ( int i = 1; i < services.length; i++ )
-                {
-                    out.print( "          " );
-                    out.println( services[i] );
-                }
-                out.print( "Service Scope: " );
-                out.println( component.getServiceScope() );
-            }
-
-            Reference[] refs = component.getReferences();
-            if ( refs != null )
-            {
-                for ( int i = 0; i < refs.length; i++ )
-                {
-                    out.print( "Reference: " );
-                    out.println( refs[i].getName() );
-                    out.print( "    Satisfied: " );
-                    out.println( refs[i].isSatisfied() ? "satisfied" : "unsatisfied" );
-                    out.print( "    Service Name: " );
-                    out.println( refs[i].getServiceName() );
-                    if ( refs[i].getTarget() != null )
-                    {
-                        out.print( "    Target Filter: " );
-                        out.println( refs[i].getTarget() );
-                    }
-                    out.print( "    Multiple: " );
-                    out.println( refs[i].isMultiple() ? "multiple" : "single" );
-                    out.print( "    Optional: " );
-                    out.println( refs[i].isOptional() ? "optional" : "mandatory" );
-                    out.print( "    Policy: " );
-                    out.println( refs[i].isStatic() ? "static" : "dynamic" );
-                    out.print( "    Policy option: " );
-                    out.println( refs[i].isReluctant() ? "reluctant" : "greedy" );
-                }
-            }
-
-            Dictionary props = component.getProperties();
-            if ( props != null )
-            {
-                out.println( "Properties:" );
-                TreeSet keys = new TreeSet( Collections.list( props.keys() ) );
-                for ( Iterator ki = keys.iterator(); ki.hasNext(); )
-                {
-                    Object key = ki.next();
-                    out.print( "    " );
-                    out.print( key );
-                    out.print( " = " );
-
-                    Object prop = props.get( key );
-                    if ( prop.getClass().isArray() )
-                    {
-                        prop = Arrays.asList( ( Object[] ) prop );
-                    }
-                    out.print( prop );
-
-                    out.println();
-                }
-            }
-        }
+//        Component[] components = getComponentDescriptions();
+//        if ( components == null )
+//        {
+//            return;
+//        }
+//
+//        for ( int j = 0; j < components.length; j++ )
+//        {
+//            Component component = components[j];
+//            out.print( "ID: " );
+//            out.println( component.getId() );
+//            out.print( "Name: " );
+//            out.println( component.getName() );
+//            out.print( "Bundle: " );
+//            out.println( component.getBundle().getSymbolicName() + " (" + component.getBundle().getBundleId() + ")" );
+//            out.print( "State: " );
+//            out.println( toStateString( component.getState() ) );
+//            out.print( "Default State: " );
+//            out.println( component.isDefaultEnabled() ? "enabled" : "disabled" );
+//            out.print( "Activation: " );
+//            out.println( component.isImmediate() ? "immediate" : "delayed" );
+//
+//            // DS 1.1 new features
+//            out.print( "Configuration Policy: " );
+//            out.println( component.getConfigurationPolicy() );
+//            out.print( "Activate Method: " );
+//            out.print( component.getActivate() );
+//            if ( component.isActivateDeclared() )
+//            {
+//                out.print( " (declared in the descriptor)" );
+//            }
+//            out.println();
+//            out.print( "Deactivate Method: " );
+//            out.print( component.getDeactivate() );
+//            if ( component.isDeactivateDeclared() )
+//            {
+//                out.print( " (declared in the descriptor)" );
+//            }
+//            out.println();
+//            out.print( "Modified Method: " );
+//            if ( component.getModified() != null )
+//            {
+//                out.print( component.getModified() );
+//            }
+//            else
+//            {
+//                out.print( "-" );
+//            }
+//            out.println();
+//
+//            if ( component.getFactory() != null )
+//            {
+//                out.print( "Factory: " );
+//                out.println( component.getFactory() );
+//            }
+//
+//            String[] services = component.getServices();
+//            if ( services != null )
+//            {
+//                out.print( "Services: " );
+//                out.println( services[0] );
+//                for ( int i = 1; i < services.length; i++ )
+//                {
+//                    out.print( "          " );
+//                    out.println( services[i] );
+//                }
+//                out.print( "Service Scope: " );
+//                out.println( component.getServiceScope() );
+//            }
+//
+//            Reference[] refs = component.getReferences();
+//            if ( refs != null )
+//            {
+//                for ( int i = 0; i < refs.length; i++ )
+//                {
+//                    out.print( "Reference: " );
+//                    out.println( refs[i].getName() );
+//                    out.print( "    Satisfied: " );
+//                    out.println( refs[i].isSatisfied() ? "satisfied" : "unsatisfied" );
+//                    out.print( "    Service Name: " );
+//                    out.println( refs[i].getServiceName() );
+//                    if ( refs[i].getTarget() != null )
+//                    {
+//                        out.print( "    Target Filter: " );
+//                        out.println( refs[i].getTarget() );
+//                    }
+//                    out.print( "    Multiple: " );
+//                    out.println( refs[i].isMultiple() ? "multiple" : "single" );
+//                    out.print( "    Optional: " );
+//                    out.println( refs[i].isOptional() ? "optional" : "mandatory" );
+//                    out.print( "    Policy: " );
+//                    out.println( refs[i].isStatic() ? "static" : "dynamic" );
+//                    out.print( "    Policy option: " );
+//                    out.println( refs[i].isReluctant() ? "reluctant" : "greedy" );
+//                }
+//            }
+//
+//            Dictionary props = component.getProperties();
+//            if ( props != null )
+//            {
+//                out.println( "Properties:" );
+//                TreeSet keys = new TreeSet( Collections.list( props.keys() ) );
+//                for ( Iterator ki = keys.iterator(); ki.hasNext(); )
+//                {
+//                    Object key = ki.next();
+//                    out.print( "    " );
+//                    out.print( key );
+//                    out.print( " = " );
+//
+//                    Object prop = props.get( key );
+//                    if ( prop.getClass().isArray() )
+//                    {
+//                        prop = Arrays.asList( ( Object[] ) prop );
+//                    }
+//                    out.print( prop );
+//
+//                    out.println();
+//                }
+//            }
+//        }
     }
     
     protected boolean isAtLeastR5() 

Modified: felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/ConfigurationChangeTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/ConfigurationChangeTest.java?rev=1602633&r1=1602632&r2=1602633&view=diff
==============================================================================
--- felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/ConfigurationChangeTest.java (original)
+++ felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/ConfigurationChangeTest.java Sun Jun 15 01:09:31 2014
@@ -22,7 +22,6 @@ import java.util.Hashtable;
 
 import junit.framework.TestCase;
 
-import org.apache.felix.scr.Component;
 import org.apache.felix.scr.integration.components.SimpleComponent;
 import org.apache.felix.scr.integration.components.SimpleServiceImpl;
 import org.junit.Test;
@@ -33,6 +32,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)
 public class ConfigurationChangeTest extends ComponentTestBase
@@ -105,20 +105,13 @@ public class ConfigurationChangeTest ext
 
     private void singleTest(String pid, boolean dynamic)
     {
-        final Component component = findComponentByName( pid );
-        TestCase.assertNotNull( component );
-        TestCase.assertEquals( Component.STATE_DISABLED, component.getState() );
-
         final SimpleServiceImpl srv1 = SimpleServiceImpl.create( bundleContext, "srv1" );
         final SimpleServiceImpl srv2 = SimpleServiceImpl.create( bundleContext, "srv2" );
 
         theConfig.put("ref.target", "(value=srv1)");
         configure( pid );
-        // async enabling
-        component.enable();
-        delay();
 
-        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
+		getDisabledConfigurationAndEnable(pid, ComponentConfigurationDTO.ACTIVE);
         final SimpleComponent comp10 = SimpleComponent.INSTANCE;
         TestCase.assertNotNull( comp10 );
         TestCase.assertEquals( srv1, comp10.m_singleRef );
@@ -150,7 +143,7 @@ public class ConfigurationChangeTest ext
             TestCase.assertEquals( 0, comp20.m_singleRefUnbind);
             TestCase.assertEquals( 1, comp10.m_singleRefUnbind);
         }
-        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
+        findComponentConfigurationByName(pid, ComponentConfigurationDTO.ACTIVE);
         TestCase.assertEquals( srv2, comp20.m_singleRef );
         TestCase.assertTrue( comp20.m_multiRef.isEmpty() );
     }
@@ -214,20 +207,14 @@ public class ConfigurationChangeTest ext
 
     private void multipleTest(String pid, boolean dynamic)
     {
-        final Component component = findComponentByName( pid );
-        TestCase.assertNotNull( component );
-        TestCase.assertEquals( Component.STATE_DISABLED, component.getState() );
-
         final SimpleServiceImpl srv1 = SimpleServiceImpl.create( bundleContext, "srv1" );
         final SimpleServiceImpl srv2 = SimpleServiceImpl.create( bundleContext, "srv2" );
 
         theConfig.put("ref.target", "(value=srv1)");
         configure( pid );
-        // async enabling
-        component.enable();
-        delay();
 
-        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
+        getDisabledConfigurationAndEnable(pid, ComponentConfigurationDTO.ACTIVE);
+
         final SimpleComponent comp10 = SimpleComponent.INSTANCE;
         TestCase.assertNotNull( comp10 );
         TestCase.assertEquals( 1, comp10.m_multiRef.size() );
@@ -259,7 +246,7 @@ public class ConfigurationChangeTest ext
             TestCase.assertEquals( 0, comp20.m_multiRefUnbind);
             TestCase.assertEquals( 1, comp10.m_multiRefUnbind);
         }
-        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
+        findComponentConfigurationByName(pid, ComponentConfigurationDTO.ACTIVE);
         TestCase.assertEquals( 1, comp20.m_multiRef.size() );
         TestCase.assertEquals( srv2, comp20.m_multiRef.iterator().next() );
     }
@@ -271,20 +258,15 @@ public class ConfigurationChangeTest ext
         String pid = "test_required_single_dynamic_factory";
         final String factoryPid = "factory_" + pid;
         boolean dynamic = true;
-        final Component component = findComponentByName( pid );
-        TestCase.assertNotNull( component );
-        TestCase.assertEquals( Component.STATE_DISABLED, component.getState() );
 
         final SimpleServiceImpl srv1 = SimpleServiceImpl.create( bundleContext, "srv1" );
         final SimpleServiceImpl srv2 = SimpleServiceImpl.create( bundleContext, "srv2" );
 
         theConfig.put("ref.target", "(value=srv1)");
         configure( pid );
-        // async enabling
-        component.enable();
-        delay();
 
-        TestCase.assertEquals( Component.STATE_FACTORY, component.getState() );
+        getDisabledConfigurationAndEnable(pid, ComponentConfigurationDTO.ACTIVE); //?????? Not clear what should happen.
+//        TestCase.assertEquals( Component.STATE_FACTORY, component.getState() );
         
         // create a component instance
         final ServiceReference[] refs = bundleContext.getServiceReferences( ComponentFactory.class.getName(), "("
@@ -333,7 +315,7 @@ public class ConfigurationChangeTest ext
             TestCase.assertEquals( 0, comp20.m_singleRefUnbind);
             TestCase.assertEquals( 1, comp10.m_singleRefUnbind);
         }
-        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
+        findComponentConfigurationByName(pid, ComponentConfigurationDTO.ACTIVE);
         TestCase.assertEquals( srv2, comp20.m_singleRef );
         TestCase.assertTrue( comp20.m_multiRef.isEmpty() );
     }

Modified: felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/ConfigurationComponentFactoryTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/ConfigurationComponentFactoryTest.java?rev=1602633&r1=1602632&r2=1602633&view=diff
==============================================================================
--- felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/ConfigurationComponentFactoryTest.java (original)
+++ felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/ConfigurationComponentFactoryTest.java Sun Jun 15 01:09:31 2014
@@ -68,7 +68,7 @@ public class ConfigurationComponentFacto
         final String componentname = "factory.component";
         final String componentfactory = "factory.component.factory";
 
-        final Component component = findComponentByName( componentname );
+        final Component component = findComponentDescriptorByName( componentname );
 
         TestCase.assertNotNull( component );
         TestCase.assertFalse( component.isDefaultEnabled() );
@@ -104,7 +104,7 @@ public class ConfigurationComponentFacto
 
 
         // check registered components
-        Component[] allFactoryComponents = findComponentsByName( componentname );
+        Component[] allFactoryComponents = findComponentConfigurationsByName( componentname, -1 );
         TestCase.assertNotNull( allFactoryComponents );
         TestCase.assertEquals( 2, allFactoryComponents.length );
         for ( int i = 0; i < allFactoryComponents.length; i++ )
@@ -136,7 +136,7 @@ public class ConfigurationComponentFacto
         TestCase.assertEquals( PROP_NAME_FACTORY, SimpleComponent.INSTANCE.getProperty( PROP_NAME ) );
 
         // check registered components
-        allFactoryComponents = findComponentsByName( componentname );
+        allFactoryComponents = findComponentConfigurationsByName( componentname, -1 );
         TestCase.assertNotNull( allFactoryComponents );
         TestCase.assertEquals( 2, allFactoryComponents.length );
         for ( int i = 0; i < allFactoryComponents.length; i++ )
@@ -175,7 +175,7 @@ public class ConfigurationComponentFacto
         TestCase.assertEquals( 1, instanceMap.size() );
 
         // check registered components
-        allFactoryComponents = findComponentsByName( componentname );
+        allFactoryComponents = findComponentConfigurationsByName( componentname, -1 );
         TestCase.assertNotNull( allFactoryComponents );
         TestCase.assertEquals( 2, allFactoryComponents.length );
         for ( int i = 0; i < allFactoryComponents.length; i++ )
@@ -205,7 +205,7 @@ public class ConfigurationComponentFacto
         TestCase.assertEquals( 0, instanceMap.size() );
 
         // check registered components
-        allFactoryComponents = findComponentsByName( componentname );
+        allFactoryComponents = findComponentConfigurationsByName( componentname, -1 );
         TestCase.assertNotNull( allFactoryComponents );
         TestCase.assertEquals( 1, allFactoryComponents.length );
         for ( int i = 0; i < allFactoryComponents.length; i++ )

Modified: felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/Felix3680Test.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/Felix3680Test.java?rev=1602633&r1=1602632&r2=1602633&view=diff
==============================================================================
--- felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/Felix3680Test.java (original)
+++ felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/Felix3680Test.java Sun Jun 15 01:09:31 2014
@@ -24,11 +24,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.ComponentDescriptionDTO;
 
 /**
  * This test validates the FELIX-3680 issue.
@@ -64,13 +64,11 @@ public class Felix3680Test extends Compo
     @Test
     public void test_concurrent_reference_bindings()
     {
-        final Component main =
-                findComponentByName("org.apache.felix.scr.integration.components.felix3680.Main");
-        TestCase.assertNotNull(main);
-        main.enable();
+        final ComponentDescriptionDTO main = findComponentDescriptorByName( "org.apache.felix.scr.integration.components.felix3680.Main" );
+        enableAndCheck(main);
 
         delay(30);
-        main.disable();
+        disableAndCheck( main );
         delay( ); //async deactivate
         for (Iterator it = log.foundWarnings().iterator(); it.hasNext();)
         {

Modified: felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/Felix3680_2Test.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/Felix3680_2Test.java?rev=1602633&r1=1602632&r2=1602633&view=diff
==============================================================================
--- felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/Felix3680_2Test.java (original)
+++ felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/Felix3680_2Test.java Sun Jun 15 01:09:31 2014
@@ -25,11 +25,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.ComponentDescriptionDTO;
 
 
 @RunWith(JUnit4TestRunner.class)
@@ -68,11 +68,10 @@ public class Felix3680_2Test extends Com
     {
         for ( int i = 0; i < 6; i++ )
         {
-            final Component main = findComponentByName( "org.apache.felix.scr.integration.components.felix3680_2.Main" );
-            TestCase.assertNotNull( main );
-            main.enable();
+            final ComponentDescriptionDTO main = findComponentDescriptorByName( "org.apache.felix.scr.integration.components.felix3680_2.Main" );
+            enableAndCheck(main);
             delay( 5 ); //run test for 30 seconds
-            main.disable();
+            disableAndCheck(main);
             delay(); //async deactivate
             if ( log.getFirstFrameworkThrowable() != null )
             {

Modified: felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/Felix4188Test.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/Felix4188Test.java?rev=1602633&r1=1602632&r2=1602633&view=diff
==============================================================================
--- felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/Felix4188Test.java (original)
+++ felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/Felix4188Test.java Sun Jun 15 01:09:31 2014
@@ -26,7 +26,6 @@ import java.util.concurrent.CountDownLat
 import javax.inject.Inject;
 
 import junit.framework.TestCase;
-import org.apache.felix.scr.Component;
 import org.apache.felix.scr.integration.components.felix4188.Felix4188Component;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -35,6 +34,7 @@ import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.BundleException;
 import org.osgi.framework.Constants;
+import org.osgi.service.component.runtime.dto.ComponentConfigurationDTO;
 
 import static org.ops4j.pax.tinybundles.core.TinyBundles.bundle;
 import static org.ops4j.pax.tinybundles.core.TinyBundles.withBnd;
@@ -68,15 +68,13 @@ public class Felix4188Test extends Compo
         final Bundle bundle2 = installBundle("/integration_test_FELIX_4188_2.xml", "", "simplecomponent2");
         bundle2.start();
 
-        final Component aComp1 =
-                findComponentByName("org.apache.felix.scr.integration.components.Felix4188Component-1");
-        aComp1.enable();
-        final Object aInst1 = aComp1.getComponentInstance().getInstance();
-
-        final Component aComp2 =
-                findComponentByName("org.apache.felix.scr.integration.components.Felix4188Component-2");
-        aComp2.enable();
-        final Object aInst2 = aComp2.getComponentInstance().getInstance();
+        final ComponentConfigurationDTO aComp1 =
+                findComponentConfigurationByName( bundle1, "org.apache.felix.scr.integration.components.Felix4188Component-1", ComponentConfigurationDTO.ACTIVE);
+        final Felix4188Component aInst1 = getServiceFromConfiguration(aComp1, Felix4188Component.class);
+
+        final ComponentConfigurationDTO aComp2 =
+                findComponentConfigurationByName( bundle1, "org.apache.felix.scr.integration.components.Felix4188Component-2", ComponentConfigurationDTO.ACTIVE);
+        final Felix4188Component aInst2 = getServiceFromConfiguration(aComp2, Felix4188Component.class);
 
         final CountDownLatch latch = new CountDownLatch(1);
 

Modified: felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/Felix4350Test.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/Felix4350Test.java?rev=1602633&r1=1602632&r2=1602633&view=diff
==============================================================================
--- felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/Felix4350Test.java (original)
+++ felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/Felix4350Test.java Sun Jun 15 01:09:31 2014
@@ -18,13 +18,10 @@
  */
 package org.apache.felix.scr.integration;
 
-import javax.inject.Inject;
-
 import junit.framework.TestCase;
-import org.apache.felix.scr.Component;
+import org.apache.felix.scr.integration.components.Felix4350Component;
 import org.apache.felix.scr.integration.components.SimpleComponent;
 import org.apache.felix.scr.integration.components.SimpleComponent2;
-import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.ops4j.pax.exam.junit.JUnit4TestRunner;
@@ -32,7 +29,7 @@ import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.ServiceFactory;
 import org.osgi.framework.ServiceRegistration;
-import org.osgi.service.component.ComponentInstance;
+import org.osgi.service.component.runtime.dto.ComponentDescriptionDTO;
 
 /**
  * This test validates the FELIX-4350 issue.
@@ -81,40 +78,56 @@ public class Felix4350Test extends Compo
 
     protected void doTest(String componentName)
     {
-        final Component main = findComponentByName(componentName);
-        TestCase.assertNotNull(main);
-
         ServiceRegistration dep1Reg = register(new SimpleComponent(), 0);
         ServiceRegistration dep2Reg = register(new SimpleComponent2(), 1000);
-        main.enable();
-        delay(300);
+        
+        final ComponentDescriptionDTO main = findComponentDescriptorByName(componentName);
+        TestCase.assertNotNull(main);
+
+        asyncEnable(main); //needs to be async
+        delay(300); //dep2 getService has not yet returned
         dep1Reg.unregister();
-        delay(2000);
+        delay(2000); //dep2 getService has returned
 
-        ComponentInstance mainCompInst = main.getComponentInstance();
-        TestCase.assertNull(mainCompInst);
+//        ComponentInstance mainCompInst = main.getComponentInstance();
+//        TestCase.assertNull(mainCompInst);
+        Felix4350Component.check(0, 0, false);
 
         dep1Reg = register(new SimpleComponent(), 0);
         delay(300);
 
-        mainCompInst = main.getComponentInstance();
-        TestCase.assertNotNull(mainCompInst);
+//        mainCompInst = main.getComponentInstance();
+//        TestCase.assertNotNull(mainCompInst);
+        Felix4350Component.check(1, 0, true);
 
-        main.disable();
+        disableAndCheck(main);  //does not need to be asyncv??
         dep1Reg.unregister();
         dep2Reg.unregister();
 
+        Felix4350Component.check(1, 1, false);
         dep1Reg = register(new SimpleComponent(), 0);
         dep2Reg = register(new SimpleComponent2(), 1000);
-        main.enable();
+        Felix4350Component.check(1, 1, false);
+        
+        asyncEnable(main); //needs to be async
         delay(300);
         dep1Reg.unregister();
         delay(100);
         dep1Reg = register(new SimpleComponent(), 0);
         delay(2000);
 
-        mainCompInst = main.getComponentInstance();
-        TestCase.assertNotNull(mainCompInst);
+//        mainCompInst = main.getComponentInstance();
+//        TestCase.assertNotNull(mainCompInst);
+        Felix4350Component.check(2, 1, true); //n.b. counts are cumulative
+    }
+    
+    protected void asyncEnable( final ComponentDescriptionDTO cd )
+    {
+    	new Thread( new Runnable() {
+
+			public void run() {
+				enableAndCheck( cd );
+			}}).start();
     }
 
     protected ServiceRegistration register(final Object service, final int delay) {

Modified: felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/LocateTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/LocateTest.java?rev=1602633&r1=1602632&r2=1602633&view=diff
==============================================================================
--- felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/LocateTest.java (original)
+++ felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/LocateTest.java Sun Jun 15 01:09:31 2014
@@ -22,16 +22,12 @@ import static org.junit.Assert.*;
 
 import java.util.Hashtable;
 
-import junit.framework.TestCase;
-
-import org.apache.felix.scr.Component;
-import org.apache.felix.scr.integration.components.SimpleServiceImpl;
-import org.apache.felix.scr.integration.components.deadlock.Consumer;
 import org.apache.felix.scr.integration.components.deadlock.TestComponent;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.ops4j.pax.exam.junit.JUnit4TestRunner;
 import org.osgi.service.cm.Configuration;
+import org.osgi.service.component.runtime.dto.ComponentConfigurationDTO;
 
 @RunWith(JUnit4TestRunner.class)
 public class LocateTest extends ComponentTestBase
@@ -50,9 +46,7 @@ public class LocateTest extends Componen
     {
         bundleContext.registerService( Object.class, new Object(), null );
         
-        final Component consumerComponent = findComponentByName( "AsyncLocate" );
-        TestCase.assertNotNull( consumerComponent );
-        TestCase.assertEquals( Component.STATE_ACTIVE, consumerComponent.getState() );
+        findComponentConfigurationByName( "AsyncLocate", ComponentConfigurationDTO.ACTIVE );
         
         final String pid = "SimpleComponent";
         Configuration config = getConfigurationAdmin().getConfiguration( pid, null );
@@ -61,16 +55,14 @@ public class LocateTest extends Componen
         config.update(props);
         delay();
         
-        final Component component = findComponentByName( pid );
-        TestCase.assertNotNull( component );
         //when deadlock is present the state is actually unsatisfied.
-        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
+        ComponentConfigurationDTO cc = findComponentConfigurationByName( pid, ComponentConfigurationDTO.ACTIVE );
         delay();
         props.put( "target", "foo" );
         config.update(props);
         delay();
        
-        TestComponent tc = (TestComponent) component.getComponentInstance().getInstance();
+        TestComponent tc = getServiceFromConfiguration(cc, TestComponent.class);
         assertTrue(tc.isSuccess1());
         assertTrue(tc.isSuccess2());
     }

Modified: felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/LocationTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/LocationTest.java?rev=1602633&r1=1602632&r2=1602633&view=diff
==============================================================================
--- felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/LocationTest.java (original)
+++ felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/LocationTest.java Sun Jun 15 01:09:31 2014
@@ -20,7 +20,6 @@ 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;
@@ -31,6 +30,7 @@ import org.osgi.service.cm.Configuration
 import org.osgi.service.cm.ConfigurationEvent;
 import org.osgi.service.cm.ConfigurationListener;
 import org.osgi.service.cm.ConfigurationPermission;
+import org.osgi.service.component.runtime.dto.ComponentConfigurationDTO;
 
 @RunWith(JUnit4TestRunner.class)
 public class LocationTest extends ComponentTestBase
@@ -52,45 +52,35 @@ public class LocationTest extends Compon
     public void testLocationBinding() throws Exception
     {
         final String pid = COMPONENT_NAME;
-        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() );
+        checkConfigurationCount(pid, 0, -1);
         TestCase.assertNull( SimpleComponent.INSTANCE );
 
         Configuration config = 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 ) );
         
         
         Bundle b2 = installBundle( descriptorFile, COMPONENT_PACKAGE, "simplecomponent2", "0.0.11", null );
         b2.start();
-        Component[] components = findComponentsByName( pid );
-        TestCase.assertEquals( 2, components.length );
-        Component c2 = components[0] == component? components[1]: components[0];
-        
-        c2.enable();
-        delay();
-        TestCase.assertEquals( Component.STATE_UNSATISFIED, c2.getState() );
+        checkConfigurationCount(b2, pid, 0, -1);
+//        Component[] components = findComponentConfigurationsByName( pid, -1 );
+//        TestCase.assertEquals( 2, components.length );
+//        Component c2 = components[0] == component? components[1]: components[0];
+//        
+//        c2.enable();
+//        delay();
+//        TestCase.assertEquals( Component.STATE_UNSATISFIED, c2.getState() );
         
         bundle.stop();
         delay();
         
-        TestCase.assertEquals( Component.STATE_UNSATISFIED, c2.getState() );
+        checkConfigurationCount(b2, pid, 0, -1);
+//        TestCase.assertEquals( Component.STATE_UNSATISFIED, c2.getState() );
 
         ConfigurationListener listener = new ConfigurationListener() {
 
@@ -109,7 +99,7 @@ public class LocationTest extends Compon
         
         if ( eventReceived )
         {
-            TestCase.assertEquals( Component.STATE_ACTIVE, c2.getState() );
+            checkConfigurationCount(b2, pid, 1, ComponentConfigurationDTO.ACTIVE);
         }
         
         sr.unregister();
@@ -121,45 +111,34 @@ public class LocationTest extends Compon
     public void testLocationChangeToRegionBinding() throws Exception
     {
         final String pid = COMPONENT_NAME;
-        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() );
+        checkConfigurationCount(pid, 0, -1);
         TestCase.assertNull( SimpleComponent.INSTANCE );
 
         Configuration config = configure( pid );
         delay();
 
-        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
+        findComponentConfigurationByName(pid, ComponentConfigurationDTO.ACTIVE);
+//        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
         TestCase.assertNotNull( SimpleComponent.INSTANCE );
         TestCase.assertEquals( PROP_NAME, SimpleComponent.INSTANCE.getProperty( PROP_NAME ) );
         
         
         Bundle b2 = installBundle( descriptorFile, COMPONENT_PACKAGE, "simplecomponent2", "0.0.11", null );
         b2.start();
-        Component[] components = findComponentsByName( pid );
-        TestCase.assertEquals( 2, components.length );
-        Component c2 = components[0] == component? components[1]: components[0];
-        
-        c2.enable();
-        delay();
-        TestCase.assertEquals( Component.STATE_UNSATISFIED, c2.getState() );
+        checkConfigurationCount(b2, pid, 0, -1);
+//        Component[] components = findComponentConfigurationsByName( pid, -1 );
+//        TestCase.assertEquals( 2, components.length );
+//        Component c2 = components[0] == component? components[1]: components[0];
+//        
+//        c2.enable();
+//        delay();
+//        TestCase.assertEquals( Component.STATE_UNSATISFIED, c2.getState() );
         
         bundle.stop();
         delay();
         
-        TestCase.assertEquals( Component.STATE_UNSATISFIED, c2.getState() );
+        checkConfigurationCount(b2, pid, 0, -1);
+//        TestCase.assertEquals( Component.STATE_UNSATISFIED, c2.getState() );
 
         ConfigurationListener listener = new ConfigurationListener() {
 
@@ -178,7 +157,8 @@ public class LocationTest extends Compon
         
         if ( eventReceived )
         {
-            TestCase.assertEquals( Component.STATE_ACTIVE, c2.getState() );
+            checkConfigurationCount(b2, pid, 1, ComponentConfigurationDTO.ACTIVE);
+//            TestCase.assertEquals( Component.STATE_ACTIVE, c2.getState() );
         }
         
         sr.unregister();
@@ -199,40 +179,30 @@ public class LocationTest extends Compon
         }
         
         final String pid = COMPONENT_NAME;
-        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() );
+        checkConfigurationCount(pid, 0, -1);
         TestCase.assertNull( SimpleComponent.INSTANCE );
 
         Configuration config = configure( pid, REGION );
         delay();
 
-        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
+        findComponentConfigurationByName(pid,  ComponentConfigurationDTO.ACTIVE);
+//        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
         TestCase.assertNotNull( SimpleComponent.INSTANCE );
         TestCase.assertEquals( PROP_NAME, SimpleComponent.INSTANCE.getProperty( PROP_NAME ) );
         
         
         Bundle b2 = installBundle( descriptorFile, COMPONENT_PACKAGE, "simplecomponent2", "0.0.11", null );
         b2.start();
-        Component[] components = findComponentsByName( pid );
-        TestCase.assertEquals( 2, components.length );
-        Component c2 = components[0] == component? components[1]: components[0];
-        
-        c2.enable();
-        delay();
-        TestCase.assertEquals( Component.STATE_ACTIVE, c2.getState() );
+//        Component[] components = findComponentConfigurationsByName( pid, -1 );
+//        TestCase.assertEquals( 2, components.length );
+//        Component c2 = components[0] == component? components[1]: components[0];
+//        
+//        c2.enable();
+//        delay();
+        checkConfigurationCount(b2, pid, 1, ComponentConfigurationDTO.ACTIVE);
+//        getDisabledConfigurationAndEnable(b2, pid, ComponentConfigurationDTO.ACTIVE);
+//        TestCase.assertEquals( Component.STATE_ACTIVE, c2.getState() );
     }
 
 }

Modified: felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/MutablePropertiesTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/MutablePropertiesTest.java?rev=1602633&r1=1602632&r2=1602633&view=diff
==============================================================================
--- felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/MutablePropertiesTest.java (original)
+++ felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/MutablePropertiesTest.java Sun Jun 15 01:09:31 2014
@@ -33,6 +33,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;
 
 
 @RunWith(JUnit4TestRunner.class)
@@ -52,9 +53,7 @@ public class MutablePropertiesTest exten
     public void test_mutable_properties() throws InvalidSyntaxException
     {
         String componentName = "components.mutable.properties";
-        final Component component = findComponentByName( componentName );
-        TestCase.assertNotNull( component );
-        TestCase.assertEquals( Component.STATE_REGISTERED, component.getState() );
+        findComponentConfigurationByName(componentName, ComponentConfigurationDTO.SATISFIED);
 
         ServiceReference[] serviceReferences = bundleContext.getServiceReferences( MutatingService.class.getName(), "(service.pid=" + componentName + ")" );
         TestCase.assertEquals( 1, serviceReferences.length );
@@ -64,7 +63,7 @@ public class MutablePropertiesTest exten
         //update theValue
         MutatingService s = ( MutatingService ) bundleContext.getService(serviceReference );
         Assert.assertNotNull(s);
-        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
+        findComponentConfigurationByName(componentName, ComponentConfigurationDTO.ACTIVE);
         Dictionary d = new Hashtable(Collections.singletonMap( PROP_NAME, "anotherValue" ));
         s.updateProperties(d);
         checkProperties(serviceReference, 5, "anotherValue", "p1", "p2");
@@ -86,9 +85,7 @@ public class MutablePropertiesTest exten
     public void test_mutable_properties_returned() throws InvalidSyntaxException
     {
         String componentName = "components.mutable.properties.return";
-        final Component component = findComponentByName( componentName );
-        TestCase.assertNotNull( component );
-        TestCase.assertEquals( Component.STATE_REGISTERED, component.getState() );
+        findComponentConfigurationByName(componentName, ComponentConfigurationDTO.SATISFIED);
 
         ServiceReference[] serviceReferences = bundleContext.getServiceReferences( MutatingService.class.getName(), "(service.pid=" + componentName + ")" );
         TestCase.assertEquals( 1, serviceReferences.length );
@@ -99,7 +96,7 @@ public class MutablePropertiesTest exten
         MutatingService s = ( MutatingService ) bundleContext.getService( serviceReference );
         Assert.assertNotNull(s);
         checkProperties( serviceReference, 8, "anotherValue1", "p1", "p2" );
-        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
+        findComponentConfigurationByName(componentName, ComponentConfigurationDTO.ACTIVE);
         Dictionary d = new Hashtable(Collections.singletonMap( PROP_NAME, "anotherValue" ));
         s.updateProperties(d);
         checkProperties(serviceReference, 5, "anotherValue", "p1", "p2");
@@ -122,9 +119,7 @@ public class MutablePropertiesTest exten
     public void test_mutable_properties_returned_public() throws InvalidSyntaxException
     {
         String componentName = "components.mutable.properties.return.public";
-        final Component component = findComponentByName( componentName );
-        TestCase.assertNotNull( component );
-        TestCase.assertEquals( Component.STATE_REGISTERED, component.getState() );
+        findComponentConfigurationByName(componentName, ComponentConfigurationDTO.SATISFIED);
 
         ServiceReference[] serviceReferences = bundleContext.getServiceReferences( MutatingService.class.getName(), "(service.pid=" + componentName + ")" );
         TestCase.assertEquals( 1, serviceReferences.length );
@@ -135,7 +130,7 @@ public class MutablePropertiesTest exten
         MutatingService s = ( MutatingService ) bundleContext.getService( serviceReference );
         Assert.assertNotNull(s);
         checkProperties( serviceReference, 8, "anotherValue1", "p1", "p2" );
-        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
+        findComponentConfigurationByName(componentName, ComponentConfigurationDTO.ACTIVE);
         Dictionary d = new Hashtable(Collections.singletonMap( PROP_NAME, "anotherValue" ));
         s.updateProperties(d);
         checkProperties(serviceReference, 5, "anotherValue", "p1", "p2");
@@ -158,9 +153,7 @@ public class MutablePropertiesTest exten
     public void test_mutable_properties_bind_returned() throws InvalidSyntaxException
     {
         String componentName = "components.mutable.properties.bind";
-        final Component component = findComponentByName( componentName );
-        TestCase.assertNotNull( component );
-        TestCase.assertEquals( Component.STATE_REGISTERED, component.getState() );
+        findComponentConfigurationByName(componentName, ComponentConfigurationDTO.SATISFIED);
 
         ServiceReference[] serviceReferences = bundleContext.getServiceReferences( MutatingService.class.getName(), "(service.pid=" + componentName + ")" );
         TestCase.assertEquals( 1, serviceReferences.length );

Modified: felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/PersistentComponentFactoryTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/PersistentComponentFactoryTest.java?rev=1602633&r1=1602632&r2=1602633&view=diff
==============================================================================
--- felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/PersistentComponentFactoryTest.java (original)
+++ felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/PersistentComponentFactoryTest.java Sun Jun 15 01:09:31 2014
@@ -62,7 +62,7 @@ public class PersistentComponentFactoryT
         final String componentname = "factory.component";
         final String componentfactory = "factory.component.factory";
 
-        final Component component = findComponentByName( componentname );
+        final Component component = findComponentDescriptorByName( componentname );
 
         TestCase.assertNotNull( component );
         TestCase.assertFalse( component.isDefaultEnabled() );
@@ -100,7 +100,7 @@ public class PersistentComponentFactoryT
         TestCase.assertTrue( instanceMap.containsValue( instanceManager ) );
 
         // check registered components
-        final Component[] allFactoryComponents = findComponentsByName( componentname );
+        final Component[] allFactoryComponents = findComponentConfigurationsByName( componentname, -1 );
         TestCase.assertNotNull( allFactoryComponents );
         TestCase.assertEquals( 2, allFactoryComponents.length );
         for ( int i = 0; i < allFactoryComponents.length; i++ )
@@ -137,7 +137,7 @@ public class PersistentComponentFactoryT
         final String componentname = "factory.component";
         final String componentfactory = "factory.component.factory";
 
-        final Component component = findComponentByName( componentname );
+        final Component component = findComponentDescriptorByName( componentname );
 
         TestCase.assertNotNull( component );
         TestCase.assertFalse( component.isDefaultEnabled() );
@@ -199,7 +199,7 @@ public class PersistentComponentFactoryT
         final String componentname = "factory.component";
         final String componentfactory = "factory.component.factory";
 
-        final Component component = findComponentByName( componentname );
+        final Component component = findComponentDescriptorByName( componentname );
 
         TestCase.assertNotNull( component );
         TestCase.assertFalse( component.isDefaultEnabled() );
@@ -243,7 +243,7 @@ public class PersistentComponentFactoryT
         deleteConfig( componentname );
         delay();
 
-        final Component component = findComponentByName( componentname );
+        final Component component = findComponentDescriptorByName( componentname );
 
         TestCase.assertNotNull( component );
         TestCase.assertFalse( component.isDefaultEnabled() );
@@ -326,7 +326,7 @@ public class PersistentComponentFactoryT
 
         SimpleServiceImpl.create( bundleContext, "ignored" ).setFilterProperty( "ignored" );
 
-        final Component component = findComponentByName( componentname );
+        final Component component = findComponentDescriptorByName( componentname );
 
         TestCase.assertNotNull( component );
         TestCase.assertFalse( component.isDefaultEnabled() );
@@ -375,7 +375,7 @@ public class PersistentComponentFactoryT
         TestCase.assertTrue( instanceMap.containsValue( instanceManager ) );
 
         // check registered components
-        final Component[] allFactoryComponents = findComponentsByName( componentname );
+        final Component[] allFactoryComponents = findComponentConfigurationsByName( componentname, -1 );
         TestCase.assertNotNull( allFactoryComponents );
         TestCase.assertEquals( 2, allFactoryComponents.length );
         for ( int i = 0; i < allFactoryComponents.length; i++ )
@@ -422,7 +422,7 @@ public class PersistentComponentFactoryT
         TestCase.assertTrue( SimpleComponent.INSTANCE.m_multiRef.contains( noMatch ) );
 
         // check registered components
-        final Component[] allFactoryComponents2 = findComponentsByName( componentname );
+        final Component[] allFactoryComponents2 = findComponentConfigurationsByName( componentname, -1 );
         TestCase.assertNotNull( allFactoryComponents2 );
         TestCase.assertEquals( 2, allFactoryComponents2.length );
         for ( int i = 0; i < allFactoryComponents2.length; i++ )
@@ -446,7 +446,7 @@ public class PersistentComponentFactoryT
         delay();
 
         // check registered components (ComponentFactory aint no longer)
-        final Component[] allFactoryComponents3 = findComponentsByName( componentname );
+        final Component[] allFactoryComponents3 = findComponentConfigurationsByName( componentname, -1 );
         TestCase.assertNotNull( allFactoryComponents3 );
         TestCase.assertEquals( 2, allFactoryComponents3.length );
         long lastId = SimpleComponent.INSTANCE.m_id;
@@ -472,7 +472,7 @@ public class PersistentComponentFactoryT
         delay();
 
         // check registered components (ComponentFactory is still present)
-        final Component[] allFactoryComponents4 = findComponentsByName( componentname );
+        final Component[] allFactoryComponents4 = findComponentConfigurationsByName( componentname, -1 );
         TestCase.assertNotNull( allFactoryComponents4 );
         TestCase.assertEquals( 2, allFactoryComponents4.length );
         for ( int i = 0; i < allFactoryComponents4.length; i++ )
@@ -507,7 +507,7 @@ public class PersistentComponentFactoryT
     {
         //set up the component that refers to the service the factory will create.
         final String referringComponentName = "ComponentReferringToFactoryObject";
-        final Component referringComponent = findComponentByName( referringComponentName );
+        final Component referringComponent = findComponentDescriptorByName( referringComponentName );
         TestCase.assertNotNull( referringComponent );
         referringComponent.enable();
         delay();
@@ -519,7 +519,7 @@ public class PersistentComponentFactoryT
         final String componentname = "factory.component.referred";
         final String componentfactory = "factory.component.factory.referred";
 
-        final Component component = findComponentByName( componentname );
+        final Component component = findComponentDescriptorByName( componentname );
 
         TestCase.assertNotNull( component );
         TestCase.assertFalse( component.isDefaultEnabled() );
@@ -562,7 +562,7 @@ public class PersistentComponentFactoryT
     public void test_component_factory_with_target_filters() throws InvalidSyntaxException
     {
         final String componentfactory = "factory.component.reference.targetfilter";
-        final Component component = findComponentByName( componentfactory );
+        final Component component = findComponentDescriptorByName( componentfactory );
 
         TestCase.assertNotNull( component );
         TestCase.assertFalse( component.isDefaultEnabled() );
@@ -616,7 +616,7 @@ public class PersistentComponentFactoryT
     public void test_component_factory_set_bundle_location_null() throws Exception
     {
         final String componentfactory = "factory.component.reference.targetfilter";
-        final Component component = findComponentByName( componentfactory );
+        final Component component = findComponentDescriptorByName( componentfactory );
 
         TestCase.assertNotNull( component );
         TestCase.assertFalse( component.isDefaultEnabled() );



Mime
View raw message