configSNVL.setBundleLocation( REGION );
//Add more and more specific components to check that they pick up the appropriate configuration
Set<Component> known = new HashSet<Component>();
final Component component = findComponentByName( COMPONENT_NAME );
known.add( component );
component.enable();
delay();
TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
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();
Component[] components = findComponentsByName( pid );
TestCase.assertEquals( 2, components.length );
Component cSN = getNewComponent( known, components );
cSN.enable();
delay();
TestCase.assertEquals( Component.STATE_ACTIVE, cSN.getState() );
SimpleComponent scSN = SimpleComponent.INSTANCE;
TestCase.assertEquals( pidSN, scSN.getProperty( TARGETED_PID ) );
Bundle bSNV = installBundle( descriptorFile, COMPONENT_PACKAGE, "simplecomponent2", "0.0.12", null );
bSNV.start();
components = findComponentsByName( pid );
TestCase.assertEquals( 3, components.length );
Component cSNV = getNewComponent( known, components );
cSNV.enable();
delay();
TestCase.assertEquals( Component.STATE_ACTIVE, cSNV.getState() );
SimpleComponent scSNV = SimpleComponent.INSTANCE;
TestCase.assertEquals( pidSNV, scSNV.getProperty( TARGETED_PID ) );
Bundle bSNVL = installBundle( descriptorFile, COMPONENT_PACKAGE, "simplecomponent2", "0.0.12", "bundleLocation" );
bSNVL.start();
components = findComponentsByName( pid );
TestCase.assertEquals( 4, components.length );
Component cSNVL = getNewComponent( known, components );
cSNVL.enable();
delay();
TestCase.assertEquals( Component.STATE_ACTIVE, cSNVL.getState() );
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();
TestCase.assertEquals( Component.STATE_ACTIVE, cSNVL.getState() );
TestCase.assertEquals( pidSNV, scSNVL.getProperty( TARGETED_PID ) );
configSNV.delete();
delay();
TestCase.assertEquals( Component.STATE_ACTIVE, cSNVL.getState() );
TestCase.assertEquals( pidSN, scSNVL.getProperty( TARGETED_PID ) );
TestCase.assertEquals( Component.STATE_ACTIVE, cSNV.getState() );
TestCase.assertEquals( pidSN, scSNV.getProperty( TARGETED_PID ) );
configSN.delete();
delay();
TestCase.assertEquals( Component.STATE_ACTIVE, cSNVL.getState() );
TestCase.assertEquals( pid, scSNVL.getProperty( TARGETED_PID ) );
TestCase.assertEquals( Component.STATE_ACTIVE, cSNV.getState() );
TestCase.assertEquals( pid, scSNV.getProperty( TARGETED_PID ) );
TestCase.assertEquals( Component.STATE_ACTIVE, cSN.getState() );
TestCase.assertEquals( pid, scSN.getProperty( TARGETED_PID ) );