You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by cz...@apache.org on 2017/01/13 17:49:16 UTC
svn commit: r1778640 [2/2] -
/felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/
Modified: felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/Felix5356Test.java
URL: http://svn.apache.org/viewvc/felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/Felix5356Test.java?rev=1778640&r1=1778639&r2=1778640&view=diff
==============================================================================
--- felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/Felix5356Test.java (original)
+++ felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/Felix5356Test.java Fri Jan 13 17:49:16 2017
@@ -24,7 +24,7 @@ import java.util.Hashtable;
import org.apache.felix.scr.integration.components.SimpleService;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.ops4j.pax.exam.junit.JUnit4TestRunner;
+import org.ops4j.pax.exam.junit.PaxExam;
import org.osgi.framework.InvalidSyntaxException;
import org.osgi.framework.ServiceReference;
import org.osgi.service.component.ComponentFactory;
@@ -37,12 +37,9 @@ import junit.framework.TestCase;
* Tests of nonstandard ComponentFactory behavior
*/
-@RunWith(JUnit4TestRunner.class)
+@RunWith(PaxExam.class)
public class Felix5356Test extends ComponentTestBase
{
-
- private static final String PROP_NAME_FACTORY = ComponentTestBase.PROP_NAME + ".factory";
-
static
{
descriptorFile = "/integration_test_simple_factory_components.xml";
Modified: felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/LocateTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/LocateTest.java?rev=1778640&r1=1778639&r2=1778640&view=diff
==============================================================================
--- felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/LocateTest.java (original)
+++ felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/LocateTest.java Fri Jan 13 17:49:16 2017
@@ -18,36 +18,36 @@
*/
package org.apache.felix.scr.integration;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertTrue;
import java.util.Hashtable;
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.ops4j.pax.exam.junit.PaxExam;
import org.osgi.service.cm.Configuration;
import org.osgi.service.component.runtime.dto.ComponentConfigurationDTO;
-@RunWith(JUnit4TestRunner.class)
+@RunWith(PaxExam.class)
public class LocateTest extends ComponentTestBase
{
-
+
static
{
descriptorFile = "/integration_test_locate.xml";
// uncomment to enable debugging of this test class
-// paxRunnerVmOption = DEBUG_VM_OPTION;
+ // paxRunnerVmOption = DEBUG_VM_OPTION;
COMPONENT_PACKAGE = COMPONENT_PACKAGE + ".deadlock";
}
-
+
@Test
public void testAsyncLocate() throws Exception
{
bundleContext.registerService( Object.class, new Object(), null );
-
+
findComponentConfigurationByName( "Consumer", ComponentConfigurationDTO.ACTIVE );
-
+
final String pid = "TestComponent";
Configuration config = getConfigurationAdmin().getConfiguration( pid, null );
final Hashtable props = new Hashtable();
@@ -55,15 +55,15 @@ public class LocateTest extends Componen
props.put( "target", "bar" );
config.update(props);
delay();
-
+
//when deadlock is present the state is actually unsatisfied.
ComponentConfigurationDTO cc = findComponentConfigurationByName( pid, ComponentConfigurationDTO.SATISFIED );
-// delay();
+ // delay();
//correct target property: will bind as new properties are propagated.
props.put( "target", "foo" );
config.update(props);
delay();
-
+
TestComponent tc = getServiceFromConfiguration(cc, TestComponent.class);
assertTrue(tc.isSuccess1());
assertTrue(tc.isSuccess2());
Modified: felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/LocationTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/LocationTest.java?rev=1778640&r1=1778639&r2=1778640&view=diff
==============================================================================
--- felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/LocationTest.java (original)
+++ felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/LocationTest.java Fri Jan 13 17:49:16 2017
@@ -21,7 +21,7 @@ package org.apache.felix.scr.integration
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.ops4j.pax.exam.junit.PaxExam;
import org.osgi.framework.Bundle;
import org.osgi.framework.ServiceRegistration;
import org.osgi.service.cm.Configuration;
@@ -32,7 +32,7 @@ import org.osgi.service.component.runtim
import junit.framework.TestCase;
-@RunWith(JUnit4TestRunner.class)
+@RunWith(PaxExam.class)
public class LocationTest extends ComponentTestBase
{
@@ -79,6 +79,7 @@ public class LocationTest extends Compon
ConfigurationListener listener = new ConfigurationListener()
{
+ @Override
public void configurationEvent(ConfigurationEvent event)
{
if ( event.getType() == ConfigurationEvent.CM_LOCATION_CHANGED )
@@ -89,7 +90,7 @@ public class LocationTest extends Compon
};
ServiceRegistration<ConfigurationListener> sr = bundleContext.registerService( ConfigurationListener.class,
- listener, null );
+ listener, null );
config.setBundleLocation( null );
delay();
@@ -128,6 +129,7 @@ public class LocationTest extends Compon
ConfigurationListener listener = new ConfigurationListener()
{
+ @Override
public void configurationEvent(ConfigurationEvent event)
{
if ( event.getType() == ConfigurationEvent.CM_LOCATION_CHANGED )
@@ -138,7 +140,7 @@ public class LocationTest extends Compon
};
ServiceRegistration<ConfigurationListener> sr = bundleContext.registerService( ConfigurationListener.class,
- listener, null );
+ listener, null );
config.setBundleLocation( REGION );
delay();
Modified: felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/MinimumCardinalityTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/MinimumCardinalityTest.java?rev=1778640&r1=1778639&r2=1778640&view=diff
==============================================================================
--- felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/MinimumCardinalityTest.java (original)
+++ felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/MinimumCardinalityTest.java Fri Jan 13 17:49:16 2017
@@ -18,37 +18,36 @@
*/
package org.apache.felix.scr.integration;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Hashtable;
import java.util.List;
-import junit.framework.TestCase;
-
import org.apache.felix.scr.integration.components.SimpleComponent;
import org.apache.felix.scr.integration.components.SimpleServiceImpl;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.ops4j.pax.exam.junit.JUnit4TestRunner;
+import org.ops4j.pax.exam.junit.PaxExam;
import org.osgi.service.cm.Configuration;
import org.osgi.util.tracker.ServiceTracker;
-@RunWith(JUnit4TestRunner.class)
+@RunWith(PaxExam.class)
public class MinimumCardinalityTest extends ComponentTestBase
{
-
+
private static final String pid = "MinimumCardinality";
-
+
static
{
descriptorFile = "/integration_test_min_cardinality.xml";
// uncomment to enable debugging of this test class
-// paxRunnerVmOption = DEBUG_VM_OPTION;
- COMPONENT_PACKAGE = COMPONENT_PACKAGE;
+ // paxRunnerVmOption = DEBUG_VM_OPTION;
}
-
+
@Test
public void testMinCardinality() throws Exception
{
@@ -64,11 +63,11 @@ public class MinimumCardinalityTest exte
onePresent( tracker, "2" );
onePresent( tracker, new int[] {4, 0} );
onePresent( tracker, null );
-
+
configureOne(1);
required(tracker, 1);
onePresent( tracker, null );
-
+
getConfigurationAdmin().getConfiguration( pid, null ).delete();
delay();
assertNull(tracker.getService());
@@ -77,14 +76,14 @@ public class MinimumCardinalityTest exte
manyPresent( tracker, "-1" );
manyPresent( tracker, new int[] {-4, 0} );
manyPresent( tracker, null );
-
+
configureMany(1);
required(tracker, 1);
configureMany(5);
required(tracker, 5);
manyPresent( tracker, null );
}
-
+
private void required(ServiceTracker<SimpleComponent, SimpleComponent> tracker, int count)
{
delay();
@@ -109,7 +108,7 @@ public class MinimumCardinalityTest exte
assertNotNull(tracker.getService());
assertEquals(1, tracker.getServices().length);
}
-
+
private void configureOne(Object value ) throws IOException
{
configureTarget( "one.cardinality.minimum", value );
@@ -122,7 +121,7 @@ public class MinimumCardinalityTest exte
assertNotNull(tracker.getService());
assertEquals(1, tracker.getServices().length);
}
-
+
private void configureMany(Object value ) throws IOException
{
configureTarget( "many.cardinality.minimum", value );
Modified: felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/MutablePropertiesTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/MutablePropertiesTest.java?rev=1778640&r1=1778639&r2=1778640&view=diff
==============================================================================
--- felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/MutablePropertiesTest.java (original)
+++ felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/MutablePropertiesTest.java Fri Jan 13 17:49:16 2017
@@ -24,22 +24,22 @@ import java.util.Collections;
import java.util.Dictionary;
import java.util.Hashtable;
-import junit.framework.Assert;
-import junit.framework.TestCase;
-
import org.apache.felix.scr.integration.components.MutatingService;
import org.apache.felix.scr.integration.components.MutatingServiceConsumer;
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.ops4j.pax.exam.junit.PaxExam;
import org.osgi.framework.InvalidSyntaxException;
import org.osgi.framework.ServiceReference;
import org.osgi.service.component.runtime.dto.ComponentConfigurationDTO;
import org.osgi.service.component.runtime.dto.ComponentDescriptionDTO;
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
-@RunWith(JUnit4TestRunner.class)
+@RunWith(PaxExam.class)
public class MutablePropertiesTest extends ComponentTestBase
{
Modified: felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/PersistentComponentFactoryTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/PersistentComponentFactoryTest.java?rev=1778640&r1=1778639&r2=1778640&view=diff
==============================================================================
--- felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/PersistentComponentFactoryTest.java (original)
+++ felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/PersistentComponentFactoryTest.java Fri Jan 13 17:49:16 2017
@@ -28,7 +28,7 @@ import org.apache.felix.scr.integration.
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.ops4j.pax.exam.junit.PaxExam;
import org.osgi.framework.InvalidSyntaxException;
import org.osgi.service.component.ComponentFactory;
import org.osgi.service.component.ComponentInstance;
@@ -37,7 +37,7 @@ import org.osgi.service.log.LogService;
import junit.framework.TestCase;
-@RunWith(JUnit4TestRunner.class)
+@RunWith(PaxExam.class)
public class PersistentComponentFactoryTest extends ComponentTestBase
{
@@ -160,8 +160,8 @@ public class PersistentComponentFactoryT
}
private ComponentInstance testConfiguredFactory(final String componentname, final String componentfactory,
- boolean optional, boolean expectComponent)
- throws InvocationTargetException, InterruptedException, InvalidSyntaxException
+ boolean optional, boolean expectComponent)
+ throws InvocationTargetException, InterruptedException, InvalidSyntaxException
{
// ensure there is no configuration for the component
deleteConfig( componentname );
@@ -193,7 +193,7 @@ public class PersistentComponentFactoryT
checkConfigurationCount( componentname, 1, ComponentConfigurationDTO.ACTIVE );
- // delete config, ensure factory is not active anymore and component instance gone
+ // delete config, ensure factory is not active anymore and component instance gone
//(configuration required >> dispose of instance. Also for pre-1.3 components, removing config unconditionally
//deactivates component.
deleteConfig( componentname );
@@ -258,7 +258,7 @@ public class PersistentComponentFactoryT
checkConfigurationCount( componentname, 1, ComponentConfigurationDTO.UNSATISFIED_REFERENCE );
final SimpleServiceImpl noMatch = SimpleServiceImpl.create( bundleContext, "nomatch" ).setFilterProperty(
- "nomatch" );
+ "nomatch" );
delay();
TestCase.assertNotNull( instanceNonMatch.getInstance() );
@@ -300,7 +300,7 @@ public class PersistentComponentFactoryT
//set up the component that refers to the service the factory will create.
final String referringComponentName = "ComponentReferringToFactoryObject";
getConfigurationsDisabledThenEnable( referringComponentName, 1,
- ComponentConfigurationDTO.UNSATISFIED_REFERENCE );
+ ComponentConfigurationDTO.UNSATISFIED_REFERENCE );
final String componentname = "factory.component.referred";
final String componentfactory = "factory.component.factory.referred";
Modified: felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/ServiceBindGreedyTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/ServiceBindGreedyTest.java?rev=1778640&r1=1778639&r2=1778640&view=diff
==============================================================================
--- felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/ServiceBindGreedyTest.java (original)
+++ felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/ServiceBindGreedyTest.java Fri Jan 13 17:49:16 2017
@@ -20,7 +20,6 @@ package org.apache.felix.scr.integration
import java.util.Hashtable;
-import junit.framework.TestCase;
import org.apache.felix.scr.integration.components.SimpleComponent;
import org.apache.felix.scr.integration.components.SimpleComponent2;
@@ -28,16 +27,17 @@ import org.apache.felix.scr.integration.
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.InvalidSyntaxException;
+import org.ops4j.pax.exam.junit.PaxExam;
import org.osgi.framework.ServiceReference;
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;
+import junit.framework.TestCase;
+
-@RunWith(JUnit4TestRunner.class)
+@RunWith(PaxExam.class)
public class ServiceBindGreedyTest extends ComponentTestBase
{
@@ -549,25 +549,25 @@ public class ServiceBindGreedyTest exten
String name ="test_required_multiple_dynamic_factory"; //also pid
final String factoryPid = "factory_" + name;
getConfigurationsDisabledThenEnable(name, 0, ComponentConfigurationDTO.UNSATISFIED_REFERENCE);
-// final String pid = "test_required_multiple_dynamic_factory";
-//
-// final Component component = findComponentDescriptorByName( pid );
-// TestCase.assertNotNull( component );
-// TestCase.assertEquals( Component.STATE_DISABLED, component.getState() );
-//
-// // async enabling (unsatisfied)
-// enableAndCheck(cc.description);
-// delay();
-// findComponentConfigurationByName(name, ComponentConfigurationDTO.UNSATISFIED_REFERENCE);
+ // final String pid = "test_required_multiple_dynamic_factory";
+ //
+ // final Component component = findComponentDescriptorByName( pid );
+ // TestCase.assertNotNull( component );
+ // TestCase.assertEquals( Component.STATE_DISABLED, component.getState() );
+ //
+ // // async enabling (unsatisfied)
+ // enableAndCheck(cc.description);
+ // delay();
+ // findComponentConfigurationByName(name, ComponentConfigurationDTO.UNSATISFIED_REFERENCE);
// register service, satisfying
final SimpleServiceImpl srv1 = SimpleServiceImpl.create( bundleContext, "srv1" );
delay();
-// TestCase.assertEquals( Component.STATE_FACTORY, component.getState() );
+ // TestCase.assertEquals( Component.STATE_FACTORY, component.getState() );
// create a component instance
final ServiceReference[] refs = bundleContext.getServiceReferences( ComponentFactory.class.getName(), "("
- + ComponentConstants.COMPONENT_FACTORY + "=" + factoryPid + ")" );
+ + ComponentConstants.COMPONENT_FACTORY + "=" + factoryPid + ")" );
TestCase.assertNotNull( refs );
TestCase.assertEquals( 1, refs.length );
final ComponentFactory factory = ( ComponentFactory ) bundleContext.getService( refs[0] );
@@ -586,29 +586,29 @@ public class ServiceBindGreedyTest exten
TestCase.assertTrue( sc.m_multiRef.contains( srv1 ) );
// ensure factory is not bound
-// TestCase.assertNull( component.getReferences()[0].getServiceReferences() );
+ // TestCase.assertNull( component.getReferences()[0].getServiceReferences() );
// assert two components managed
checkConfigurationCount(name, 1, ComponentConfigurationDTO.ACTIVE);
-// final Component[] allFactoryComponents = findComponentConfigurationsByName( pid, -1 );
-// TestCase.assertNotNull( allFactoryComponents );
-// TestCase.assertEquals( 2, allFactoryComponents.length );
-// for ( int i = 0; i < allFactoryComponents.length; i++ )
-// {
-// final Component c = allFactoryComponents[i];
-// if ( c.getId() == component.getId() )
-// {
-// TestCase.assertEquals( Component.STATE_FACTORY, c.getState() );
-// }
-// else if ( c.getId() == SimpleComponent.INSTANCE.m_id )
-// {
-// TestCase.assertEquals( Component.STATE_ACTIVE, c.getState() );
-// }
-// else
-// {
-// TestCase.fail( "Unexpected Component " + c );
-// }
-// }
+ // final Component[] allFactoryComponents = findComponentConfigurationsByName( pid, -1 );
+ // TestCase.assertNotNull( allFactoryComponents );
+ // TestCase.assertEquals( 2, allFactoryComponents.length );
+ // for ( int i = 0; i < allFactoryComponents.length; i++ )
+ // {
+ // final Component c = allFactoryComponents[i];
+ // if ( c.getId() == component.getId() )
+ // {
+ // TestCase.assertEquals( Component.STATE_FACTORY, c.getState() );
+ // }
+ // else if ( c.getId() == SimpleComponent.INSTANCE.m_id )
+ // {
+ // TestCase.assertEquals( Component.STATE_ACTIVE, c.getState() );
+ // }
+ // else
+ // {
+ // TestCase.fail( "Unexpected Component " + c );
+ // }
+ // }
// register second service
final SimpleServiceImpl srv11 = SimpleServiceImpl.create( bundleContext, "srv11" );
@@ -620,7 +620,7 @@ public class ServiceBindGreedyTest exten
TestCase.assertTrue( sc.m_multiRef.contains( srv11 ) );
// ensure factory is not bound
-// TestCase.assertNull( component.getReferences()[0].getServiceReferences() );
+ // TestCase.assertNull( component.getReferences()[0].getServiceReferences() );
// drop second service and ensure unbound (and active)
srv11.drop();
@@ -629,7 +629,7 @@ public class ServiceBindGreedyTest exten
TestCase.assertEquals( SimpleComponent.INSTANCE, instance.getInstance() );
TestCase.assertEquals( 1, sc.m_multiRef.size() );
TestCase.assertTrue( sc.m_multiRef.contains( srv1 ) );
-// TestCase.assertNull( component.getReferences()[0].getServiceReferences() );
+ // TestCase.assertNull( component.getReferences()[0].getServiceReferences() );
// remove the service, expect factory to deactivate and instance to dispose
@@ -641,46 +641,46 @@ public class ServiceBindGreedyTest exten
// assert component factory only managed
//TODO this check should be whether the service is registered.
-// final Component[] allFactoryComponents2 = findComponentConfigurationsByName( pid, -1 );
-// TestCase.assertNotNull( allFactoryComponents2 );
-// TestCase.assertEquals( 1, allFactoryComponents2.length );
-// for ( int i = 0; i < allFactoryComponents2.length; i++ )
-// {
-// final Component c = allFactoryComponents2[i];
-// if ( c.getId() == component.getId() )
-// {
-// TestCase.assertEquals( Component.STATE_UNSATISFIED, c.getState() );
-// }
-// else
-// {
-// TestCase.fail( "Unexpected Component " + c );
-// }
-// }
+ // final Component[] allFactoryComponents2 = findComponentConfigurationsByName( pid, -1 );
+ // TestCase.assertNotNull( allFactoryComponents2 );
+ // TestCase.assertEquals( 1, allFactoryComponents2.length );
+ // for ( int i = 0; i < allFactoryComponents2.length; i++ )
+ // {
+ // final Component c = allFactoryComponents2[i];
+ // if ( c.getId() == component.getId() )
+ // {
+ // TestCase.assertEquals( Component.STATE_UNSATISFIED, c.getState() );
+ // }
+ // else
+ // {
+ // TestCase.fail( "Unexpected Component " + c );
+ // }
+ // }
// registeranother service, factory must come back, instance not
final SimpleServiceImpl srv2 = SimpleServiceImpl.create( bundleContext, "srv2" );
delay();
-// TestCase.assertEquals( Component.STATE_FACTORY, component.getState() );
+ // TestCase.assertEquals( Component.STATE_FACTORY, component.getState() );
TestCase.assertNull( instance.getInstance() );
// assert component factory only managed
checkConfigurationCount(name, 0, -1);
-// final Component[] allFactoryComponents3 = findComponentConfigurationsByName( pid, -1 );
-// TestCase.assertNotNull( allFactoryComponents3 );
-// TestCase.assertEquals( 1, allFactoryComponents3.length );
-// for ( int i = 0; i < allFactoryComponents3.length; i++ )
-// {
-// final Component c = allFactoryComponents3[i];
-// if ( c.getId() == component.getId() )
-// {
-// TestCase.assertEquals( Component.STATE_FACTORY, c.getState() );
-// }
-// else
-// {
-// TestCase.fail( "Unexpected Component " + c );
-// }
-// }
+ // final Component[] allFactoryComponents3 = findComponentConfigurationsByName( pid, -1 );
+ // TestCase.assertNotNull( allFactoryComponents3 );
+ // TestCase.assertEquals( 1, allFactoryComponents3.length );
+ // for ( int i = 0; i < allFactoryComponents3.length; i++ )
+ // {
+ // final Component c = allFactoryComponents3[i];
+ // if ( c.getId() == component.getId() )
+ // {
+ // TestCase.assertEquals( Component.STATE_FACTORY, c.getState() );
+ // }
+ // else
+ // {
+ // TestCase.fail( "Unexpected Component " + c );
+ // }
+ // }
}
Modified: felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/ServiceBindTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/ServiceBindTest.java?rev=1778640&r1=1778639&r2=1778640&view=diff
==============================================================================
--- felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/ServiceBindTest.java (original)
+++ felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/ServiceBindTest.java Fri Jan 13 17:49:16 2017
@@ -20,7 +20,6 @@ package org.apache.felix.scr.integration
import java.util.Hashtable;
-import junit.framework.TestCase;
import org.apache.felix.scr.integration.components.SimpleComponent;
import org.apache.felix.scr.integration.components.SimpleComponent2;
@@ -28,16 +27,17 @@ import org.apache.felix.scr.integration.
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.InvalidSyntaxException;
+import org.ops4j.pax.exam.junit.PaxExam;
import org.osgi.framework.ServiceReference;
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;
+import junit.framework.TestCase;
+
-@RunWith(JUnit4TestRunner.class)
+@RunWith(PaxExam.class)
public class ServiceBindTest extends ComponentTestBase
{
@@ -549,25 +549,25 @@ public class ServiceBindTest extends Com
String name ="test_required_multiple_dynamic_factory"; //also pid
final String factoryPid = "factory_" + name;
getConfigurationsDisabledThenEnable(name, 0, ComponentConfigurationDTO.UNSATISFIED_REFERENCE);
-// final String pid = "test_required_multiple_dynamic_factory";
-//
-// final Component component = findComponentDescriptorByName( pid );
-// TestCase.assertNotNull( component );
-// TestCase.assertEquals( Component.STATE_DISABLED, component.getState() );
-//
-// // async enabling (unsatisfied)
-// enableAndCheck(cc.description);
-// delay();
-// findComponentConfigurationByName(name, ComponentConfigurationDTO.UNSATISFIED_REFERENCE);
+ // final String pid = "test_required_multiple_dynamic_factory";
+ //
+ // final Component component = findComponentDescriptorByName( pid );
+ // TestCase.assertNotNull( component );
+ // TestCase.assertEquals( Component.STATE_DISABLED, component.getState() );
+ //
+ // // async enabling (unsatisfied)
+ // enableAndCheck(cc.description);
+ // delay();
+ // findComponentConfigurationByName(name, ComponentConfigurationDTO.UNSATISFIED_REFERENCE);
// register service, satisfying
final SimpleServiceImpl srv1 = SimpleServiceImpl.create( bundleContext, "srv1" );
delay();
-// TestCase.assertEquals( Component.STATE_FACTORY, component.getState() );
+ // TestCase.assertEquals( Component.STATE_FACTORY, component.getState() );
// create a component instance
final ServiceReference[] refs = bundleContext.getServiceReferences( ComponentFactory.class.getName(), "("
- + ComponentConstants.COMPONENT_FACTORY + "=" + factoryPid + ")" );
+ + ComponentConstants.COMPONENT_FACTORY + "=" + factoryPid + ")" );
TestCase.assertNotNull( refs );
TestCase.assertEquals( 1, refs.length );
final ComponentFactory factory = ( ComponentFactory ) bundleContext.getService( refs[0] );
@@ -586,29 +586,29 @@ public class ServiceBindTest extends Com
TestCase.assertTrue( sc.m_multiRef.contains( srv1 ) );
// ensure factory is not bound
-// TestCase.assertNull( component.getReferences()[0].getServiceReferences() );
+ // TestCase.assertNull( component.getReferences()[0].getServiceReferences() );
// assert two components managed
checkConfigurationCount(name, 1, ComponentConfigurationDTO.ACTIVE);
-// final Component[] allFactoryComponents = findComponentConfigurationsByName( pid, -1 );
-// TestCase.assertNotNull( allFactoryComponents );
-// TestCase.assertEquals( 2, allFactoryComponents.length );
-// for ( int i = 0; i < allFactoryComponents.length; i++ )
-// {
-// final Component c = allFactoryComponents[i];
-// if ( c.getId() == component.getId() )
-// {
-// TestCase.assertEquals( Component.STATE_FACTORY, c.getState() );
-// }
-// else if ( c.getId() == SimpleComponent.INSTANCE.m_id )
-// {
-// TestCase.assertEquals( Component.STATE_ACTIVE, c.getState() );
-// }
-// else
-// {
-// TestCase.fail( "Unexpected Component " + c );
-// }
-// }
+ // final Component[] allFactoryComponents = findComponentConfigurationsByName( pid, -1 );
+ // TestCase.assertNotNull( allFactoryComponents );
+ // TestCase.assertEquals( 2, allFactoryComponents.length );
+ // for ( int i = 0; i < allFactoryComponents.length; i++ )
+ // {
+ // final Component c = allFactoryComponents[i];
+ // if ( c.getId() == component.getId() )
+ // {
+ // TestCase.assertEquals( Component.STATE_FACTORY, c.getState() );
+ // }
+ // else if ( c.getId() == SimpleComponent.INSTANCE.m_id )
+ // {
+ // TestCase.assertEquals( Component.STATE_ACTIVE, c.getState() );
+ // }
+ // else
+ // {
+ // TestCase.fail( "Unexpected Component " + c );
+ // }
+ // }
// register second service
final SimpleServiceImpl srv11 = SimpleServiceImpl.create( bundleContext, "srv11" );
@@ -620,7 +620,7 @@ public class ServiceBindTest extends Com
TestCase.assertTrue( sc.m_multiRef.contains( srv11 ) );
// ensure factory is not bound
-// TestCase.assertNull( component.getReferences()[0].getServiceReferences() );
+ // TestCase.assertNull( component.getReferences()[0].getServiceReferences() );
// drop second service and ensure unbound (and active)
srv11.drop();
@@ -629,7 +629,7 @@ public class ServiceBindTest extends Com
TestCase.assertEquals( SimpleComponent.INSTANCE, instance.getInstance() );
TestCase.assertEquals( 1, sc.m_multiRef.size() );
TestCase.assertTrue( sc.m_multiRef.contains( srv1 ) );
-// TestCase.assertNull( component.getReferences()[0].getServiceReferences() );
+ // TestCase.assertNull( component.getReferences()[0].getServiceReferences() );
// remove the service, expect factory to deactivate and instance to dispose
@@ -641,46 +641,46 @@ public class ServiceBindTest extends Com
// assert component factory only managed
//TODO this check should be whether the service is registered.
-// final Component[] allFactoryComponents2 = findComponentConfigurationsByName( pid, -1 );
-// TestCase.assertNotNull( allFactoryComponents2 );
-// TestCase.assertEquals( 1, allFactoryComponents2.length );
-// for ( int i = 0; i < allFactoryComponents2.length; i++ )
-// {
-// final Component c = allFactoryComponents2[i];
-// if ( c.getId() == component.getId() )
-// {
-// TestCase.assertEquals( Component.STATE_UNSATISFIED, c.getState() );
-// }
-// else
-// {
-// TestCase.fail( "Unexpected Component " + c );
-// }
-// }
+ // final Component[] allFactoryComponents2 = findComponentConfigurationsByName( pid, -1 );
+ // TestCase.assertNotNull( allFactoryComponents2 );
+ // TestCase.assertEquals( 1, allFactoryComponents2.length );
+ // for ( int i = 0; i < allFactoryComponents2.length; i++ )
+ // {
+ // final Component c = allFactoryComponents2[i];
+ // if ( c.getId() == component.getId() )
+ // {
+ // TestCase.assertEquals( Component.STATE_UNSATISFIED, c.getState() );
+ // }
+ // else
+ // {
+ // TestCase.fail( "Unexpected Component " + c );
+ // }
+ // }
// registeranother service, factory must come back, instance not
final SimpleServiceImpl srv2 = SimpleServiceImpl.create( bundleContext, "srv2" );
delay();
-// TestCase.assertEquals( Component.STATE_FACTORY, component.getState() );
+ // TestCase.assertEquals( Component.STATE_FACTORY, component.getState() );
TestCase.assertNull( instance.getInstance() );
// assert component factory only managed
checkConfigurationCount(name, 0, -1);
-// final Component[] allFactoryComponents3 = findComponentConfigurationsByName( pid, -1 );
-// TestCase.assertNotNull( allFactoryComponents3 );
-// TestCase.assertEquals( 1, allFactoryComponents3.length );
-// for ( int i = 0; i < allFactoryComponents3.length; i++ )
-// {
-// final Component c = allFactoryComponents3[i];
-// if ( c.getId() == component.getId() )
-// {
-// TestCase.assertEquals( Component.STATE_FACTORY, c.getState() );
-// }
-// else
-// {
-// TestCase.fail( "Unexpected Component " + c );
-// }
-// }
+ // final Component[] allFactoryComponents3 = findComponentConfigurationsByName( pid, -1 );
+ // TestCase.assertNotNull( allFactoryComponents3 );
+ // TestCase.assertEquals( 1, allFactoryComponents3.length );
+ // for ( int i = 0; i < allFactoryComponents3.length; i++ )
+ // {
+ // final Component c = allFactoryComponents3[i];
+ // if ( c.getId() == component.getId() )
+ // {
+ // TestCase.assertEquals( Component.STATE_FACTORY, c.getState() );
+ // }
+ // else
+ // {
+ // TestCase.fail( "Unexpected Component " + c );
+ // }
+ // }
}
Modified: felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/ServiceChangedTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/ServiceChangedTest.java?rev=1778640&r1=1778639&r2=1778640&view=diff
==============================================================================
--- felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/ServiceChangedTest.java (original)
+++ felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/ServiceChangedTest.java Fri Jan 13 17:49:16 2017
@@ -19,17 +19,17 @@
package org.apache.felix.scr.integration;
-import junit.framework.TestCase;
-
import org.apache.felix.scr.integration.components.SimpleComponent;
import org.apache.felix.scr.integration.components.SimpleServiceImpl;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.ops4j.pax.exam.junit.JUnit4TestRunner;
+import org.ops4j.pax.exam.junit.PaxExam;
import org.osgi.service.component.runtime.dto.ComponentConfigurationDTO;
+import junit.framework.TestCase;
+
-@RunWith(JUnit4TestRunner.class)
+@RunWith(PaxExam.class)
public class ServiceChangedTest extends ComponentTestBase
{
static
@@ -46,7 +46,7 @@ public class ServiceChangedTest extends
{
final SimpleServiceImpl srv1 = SimpleServiceImpl.create( bundleContext, "srv1" );
String name = "test_optional_single_dynamic_target";
- getDisabledConfigurationAndEnable(name, ComponentConfigurationDTO.ACTIVE);
+ getDisabledConfigurationAndEnable(name, ComponentConfigurationDTO.ACTIVE);
final SimpleComponent comp10 = SimpleComponent.INSTANCE;
TestCase.assertNotNull( comp10 );
@@ -107,8 +107,8 @@ public class ServiceChangedTest extends
{
final SimpleServiceImpl srv1 = SimpleServiceImpl.create( bundleContext, "srv1" );
String name = "test_required_single_dynamic_target";
- getDisabledConfigurationAndEnable(name, ComponentConfigurationDTO.ACTIVE);
-
+ getDisabledConfigurationAndEnable(name, ComponentConfigurationDTO.ACTIVE);
+
final SimpleComponent comp10 = SimpleComponent.INSTANCE;
TestCase.assertNotNull( comp10 );
TestCase.assertEquals( srv1, comp10.m_singleRef );
@@ -166,7 +166,7 @@ public class ServiceChangedTest extends
{
final SimpleServiceImpl srv1 = SimpleServiceImpl.create( bundleContext, "srv1" );
String name = "test_optional_multiple_dynamic_target";
- getDisabledConfigurationAndEnable(name, ComponentConfigurationDTO.ACTIVE);
+ getDisabledConfigurationAndEnable(name, ComponentConfigurationDTO.ACTIVE);
final SimpleComponent comp10 = SimpleComponent.INSTANCE;
TestCase.assertNotNull( comp10 );
TestCase.assertNull( comp10.m_singleRef );
@@ -229,7 +229,7 @@ public class ServiceChangedTest extends
{
final SimpleServiceImpl srv1 = SimpleServiceImpl.create( bundleContext, "srv1" );
String name = "test_required_multiple_dynamic_target";
- getDisabledConfigurationAndEnable(name, ComponentConfigurationDTO.ACTIVE);
+ getDisabledConfigurationAndEnable(name, ComponentConfigurationDTO.ACTIVE);
final SimpleComponent comp10 = SimpleComponent.INSTANCE;
TestCase.assertNotNull( comp10 );
TestCase.assertNull( comp10.m_singleRef );
@@ -292,7 +292,7 @@ public class ServiceChangedTest extends
{
final SimpleServiceImpl srv1 = SimpleServiceImpl.create( bundleContext, "srv1" );
String name = "test_optional_single_static_target";
- getDisabledConfigurationAndEnable(name, ComponentConfigurationDTO.ACTIVE);
+ getDisabledConfigurationAndEnable(name, ComponentConfigurationDTO.ACTIVE);
final SimpleComponent comp10 = SimpleComponent.INSTANCE;
TestCase.assertNotNull( comp10 );
TestCase.assertEquals( srv1, comp10.m_singleRef );
@@ -363,7 +363,7 @@ public class ServiceChangedTest extends
{
final SimpleServiceImpl srv1 = SimpleServiceImpl.create( bundleContext, "srv1" );
String name = "test_required_single_static_target";
- getDisabledConfigurationAndEnable(name, ComponentConfigurationDTO.ACTIVE);
+ getDisabledConfigurationAndEnable(name, ComponentConfigurationDTO.ACTIVE);
final SimpleComponent comp10 = SimpleComponent.INSTANCE;
TestCase.assertNotNull( comp10 );
TestCase.assertEquals( srv1, comp10.m_singleRef );
@@ -429,7 +429,7 @@ public class ServiceChangedTest extends
{
final SimpleServiceImpl srv1 = SimpleServiceImpl.create( bundleContext, "srv1" );
String name = "test_optional_multiple_static_target";
- getDisabledConfigurationAndEnable(name, ComponentConfigurationDTO.ACTIVE);
+ getDisabledConfigurationAndEnable(name, ComponentConfigurationDTO.ACTIVE);
final SimpleComponent comp10 = SimpleComponent.INSTANCE;
TestCase.assertNotNull( comp10 );
TestCase.assertNull( comp10.m_singleRef );
@@ -505,7 +505,7 @@ public class ServiceChangedTest extends
{
final SimpleServiceImpl srv1 = SimpleServiceImpl.create( bundleContext, "srv1" );
String name = "test_required_multiple_static_target";
- getDisabledConfigurationAndEnable(name, ComponentConfigurationDTO.ACTIVE);
+ getDisabledConfigurationAndEnable(name, ComponentConfigurationDTO.ACTIVE);
final SimpleComponent comp10 = SimpleComponent.INSTANCE;
TestCase.assertNotNull( comp10 );
TestCase.assertNull( comp10.m_singleRef );
@@ -567,5 +567,5 @@ public class ServiceChangedTest extends
TestCase.assertFalse( comp13.m_multiRef.contains( srv2 ) );
TestCase.assertEquals( 1, comp13.m_multiRefBind );
TestCase.assertEquals( 0, comp13.m_multiRefUnbind);
- }
+ }
}
\ No newline at end of file
Modified: felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/ServiceComponentTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/ServiceComponentTest.java?rev=1778640&r1=1778639&r2=1778640&view=diff
==============================================================================
--- felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/ServiceComponentTest.java (original)
+++ felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/ServiceComponentTest.java Fri Jan 13 17:49:16 2017
@@ -19,26 +19,24 @@
package org.apache.felix.scr.integration;
-import java.io.IOException;
-
-import junit.framework.TestCase;
-
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.ops4j.pax.exam.junit.PaxExam;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
import org.osgi.service.component.runtime.dto.ComponentConfigurationDTO;
+import junit.framework.TestCase;
+
-@RunWith(JUnit4TestRunner.class)
+@RunWith(PaxExam.class)
public class ServiceComponentTest extends ComponentTestBase
{
static
{
// uncomment to enable debugging of this test class
-// paxRunnerVmOption = DEBUG_VM_OPTION;
+ // paxRunnerVmOption = DEBUG_VM_OPTION;
}
@@ -48,7 +46,7 @@ public class ServiceComponentTest extend
final String pid = "ServiceComponent";
// one single component exists without configuration
- getDisabledConfigurationAndEnable(pid, ComponentConfigurationDTO.ACTIVE);
+ getDisabledConfigurationAndEnable(pid, ComponentConfigurationDTO.ACTIVE);
final SimpleComponent instance = SimpleComponent.INSTANCE;
TestCase.assertNotNull( instance );
@@ -76,8 +74,8 @@ public class ServiceComponentTest extend
for ( String propKey : reference.getPropertyKeys() )
{
TestCase.assertTrue( "Property key [" + propKey
- + "] must have at least one character and not start with a dot", propKey.length() > 0
- && !propKey.startsWith( "." ) );
+ + "] must have at least one character and not start with a dot", propKey.length() > 0
+ && !propKey.startsWith( "." ) );
}
}
@@ -88,7 +86,7 @@ public class ServiceComponentTest extend
final String pid = "DelayedServiceComponent";
// one single component exists without configuration
- getDisabledConfigurationAndEnable(pid, ComponentConfigurationDTO.SATISFIED);
+ getDisabledConfigurationAndEnable(pid, ComponentConfigurationDTO.SATISFIED);
TestCase.assertNull( SimpleComponent.INSTANCE );
// get the service
@@ -122,7 +120,7 @@ public class ServiceComponentTest extend
// one single component exists without configuration
// the delayed service is expected to only be registered before use
- getDisabledConfigurationAndEnable(pid, ComponentConfigurationDTO.SATISFIED);
+ getDisabledConfigurationAndEnable(pid, ComponentConfigurationDTO.SATISFIED);
TestCase.assertNull( SimpleComponent.INSTANCE );
// get the service once
@@ -160,7 +158,7 @@ public class ServiceComponentTest extend
// one single component exists without configuration
// the delayed service is expected to only be registered before use
- getDisabledConfigurationAndEnable(pid, ComponentConfigurationDTO.SATISFIED);
+ getDisabledConfigurationAndEnable(pid, ComponentConfigurationDTO.SATISFIED);
TestCase.assertNull( SimpleComponent.INSTANCE );
// get the service
Modified: felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/TargetPropertyTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/TargetPropertyTest.java?rev=1778640&r1=1778639&r2=1778640&view=diff
==============================================================================
--- felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/TargetPropertyTest.java (original)
+++ felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/TargetPropertyTest.java Fri Jan 13 17:49:16 2017
@@ -18,30 +18,23 @@
*/
package org.apache.felix.scr.integration;
-import java.util.Hashtable;
-
-import junit.framework.TestCase;
-
import org.apache.felix.scr.integration.components.SimpleComponent;
import org.apache.felix.scr.integration.components.SimpleServiceImpl;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.ops4j.pax.exam.junit.JUnit4TestRunner;
-import org.osgi.framework.InvalidSyntaxException;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.component.ComponentConstants;
-import org.osgi.service.component.ComponentFactory;
-import org.osgi.service.component.ComponentInstance;
+import org.ops4j.pax.exam.junit.PaxExam;
import org.osgi.service.component.runtime.dto.ComponentConfigurationDTO;
-@RunWith(JUnit4TestRunner.class)
+import junit.framework.TestCase;
+
+@RunWith(PaxExam.class)
public class TargetPropertyTest extends ComponentTestBase
{
static
{
// uncomment to enable debugging of this test class
-// paxRunnerVmOption = DEBUG_VM_OPTION;
+ // paxRunnerVmOption = DEBUG_VM_OPTION;
descriptorFile = "/integration_test_target_properties.xml";
}
@@ -87,26 +80,26 @@ public class TargetPropertyTest extends
final SimpleServiceImpl srv1 = SimpleServiceImpl.create( bundleContext, expected );
final SimpleServiceImpl srv2 = SimpleServiceImpl.create( bundleContext, "baz" );
- getDisabledConfigurationAndEnable(pid, ComponentConfigurationDTO.ACTIVE);
+ getDisabledConfigurationAndEnable(pid, ComponentConfigurationDTO.ACTIVE);
checkTarget(expected, srv1);
-
+
//configuration not setting target property does not change it
configure( pid );
delay();//all cm event to complete
checkTarget(expected, srv1);
-
+
// update configuration to target srv2
theConfig.put("one.target", "(value=baz)");
configure( pid );
delay();
checkTarget("baz", srv2);
-
+
//update configuration removing target property
theConfig.remove("one.target");
configure( pid );
delay();//all cm event to complete
checkTarget(expected, srv1);
-
+
}
void checkTarget(String expected, final SimpleServiceImpl srv1)
Modified: felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/TargetedPIDTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/TargetedPIDTest.java?rev=1778640&r1=1778639&r2=1778640&view=diff
==============================================================================
--- felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/TargetedPIDTest.java (original)
+++ felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/TargetedPIDTest.java Fri Jan 13 17:49:16 2017
@@ -18,19 +18,13 @@
*/
package org.apache.felix.scr.integration;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
import java.util.HashSet;
-import java.util.List;
import java.util.Set;
-import junit.framework.TestCase;
-
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.ops4j.pax.exam.junit.PaxExam;
import org.osgi.framework.Bundle;
//import org.osgi.framework.ServiceRegistration;
import org.osgi.service.cm.Configuration;
@@ -39,10 +33,12 @@ import org.osgi.service.cm.Configuration
import org.osgi.service.cm.ConfigurationPermission;
import org.osgi.service.component.runtime.dto.ComponentConfigurationDTO;
-@RunWith(JUnit4TestRunner.class)
+import junit.framework.TestCase;
+
+@RunWith(PaxExam.class)
public class TargetedPIDTest extends ComponentTestBase
{
-
+
private static final String TARGETED_PID = "targetedPID";
private static final String COMPONENT_NAME = "SimpleComponent.configuration.require";
private static final String REGION = "?foo";
@@ -52,7 +48,7 @@ public class TargetedPIDTest extends Com
bsnVersionUniqueness = "multiple";
descriptorFile = "/integration_test_simple_components_location.xml";
// uncomment to enable debugging of this test class
-// paxRunnerVmOption = DEBUG_VM_OPTION;
+ // paxRunnerVmOption = DEBUG_VM_OPTION;
}
@@ -71,70 +67,70 @@ public class TargetedPIDTest extends Com
theConfig.put(TARGETED_PID, pid);
Configuration config = configure( pid );
config.setBundleLocation( REGION );
-
+
String pidSN = pid + "|simplecomponent2";
theConfig.put(TARGETED_PID, pidSN);
Configuration configSN = configure( pidSN );
configSN.setBundleLocation( REGION );
-
+
String pidSNV = pidSN + "|0.0.12";
theConfig.put(TARGETED_PID, pidSNV);
Configuration configSNV = configure( pidSNV );
configSNV.setBundleLocation( REGION );
-
+
String pidSNVL = pidSNV + "|bundleLocation";
theConfig.put(TARGETED_PID, pidSNVL);
Configuration configSNVL = configure( pidSNVL );
configSNVL.setBundleLocation( REGION );
-
+
delay();
-
+
//Add more and more specific components to check that they pick up the appropriate configuration
Set<ComponentConfigurationDTO> known = new HashSet<ComponentConfigurationDTO>();
-
+
final ComponentConfigurationDTO component = findComponentConfigurationByName( COMPONENT_NAME, ComponentConfigurationDTO.ACTIVE );
known.add( component );
TestCase.assertNotNull( SimpleComponent.INSTANCE );
SimpleComponent sc = SimpleComponent.INSTANCE;
TestCase.assertEquals( pid, sc.getProperty( TARGETED_PID ) );
-
-
+
+
Bundle bSN = installBundle( descriptorFile, COMPONENT_PACKAGE, "simplecomponent2", "0.0.11", null );
bSN.start();
findComponentConfigurationByName( bSN, pid, ComponentConfigurationDTO.ACTIVE );
-
+
SimpleComponent scSN = SimpleComponent.INSTANCE;
TestCase.assertEquals( pidSN, scSN.getProperty( TARGETED_PID ) );
-
+
Bundle bSNV = installBundle( descriptorFile, COMPONENT_PACKAGE, "simplecomponent2", "0.0.12", null );
bSNV.start();
findComponentConfigurationByName( bSNV, pid, ComponentConfigurationDTO.ACTIVE );
SimpleComponent scSNV = SimpleComponent.INSTANCE;
TestCase.assertEquals( pidSNV, scSNV.getProperty( TARGETED_PID ) );
-
+
Bundle bSNVL = installBundle( descriptorFile, COMPONENT_PACKAGE, "simplecomponent2", "0.0.12", "bundleLocation" );
bSNVL.start();
findComponentConfigurationsByName( bSNVL, pid, ComponentConfigurationDTO.ACTIVE );
SimpleComponent scSNVL = SimpleComponent.INSTANCE;
TestCase.assertEquals( pidSNVL, scSNVL.getProperty( TARGETED_PID ) );
-
+
//remove configurations to check that the components now use the less specific configurations.
-
+
configSNVL.delete();
delay();
findComponentConfigurationsByName( bSNVL, pid, ComponentConfigurationDTO.ACTIVE );
TestCase.assertEquals( pidSNV, scSNVL.getProperty( TARGETED_PID ) );
-
+
configSNV.delete();
delay();
findComponentConfigurationsByName( bSNVL, pid, ComponentConfigurationDTO.ACTIVE );
TestCase.assertEquals( pidSN, scSNVL.getProperty( TARGETED_PID ) );
findComponentConfigurationByName( bSNV, pid, ComponentConfigurationDTO.ACTIVE );
TestCase.assertEquals( pidSN, scSNV.getProperty( TARGETED_PID ) );
-
+
configSN.delete();
delay();
findComponentConfigurationsByName( bSNVL, pid, ComponentConfigurationDTO.ACTIVE );
@@ -143,8 +139,8 @@ public class TargetedPIDTest extends Com
TestCase.assertEquals( pid, scSNV.getProperty( TARGETED_PID ) );
findComponentConfigurationByName( bSN, pid, ComponentConfigurationDTO.ACTIVE );
TestCase.assertEquals( pid, scSN.getProperty( TARGETED_PID ) );
-
-
+
+
}
}