delay(); // for the event to be distributed
configListener.assertEvents( ConfigurationEvent.CM_UPDATED, 1 );
// ensure configuration is unbound
final Configuration beforeInstall = getConfiguration( pid );
TestCase.assertNull( beforeInstall.getBundleLocation() );
bundle = installBundle( pid );
// ensure no configuration bound before start
final Configuration beforeStart = getConfiguration( pid );
TestCase.assertNull( beforeInstall.getBundleLocation() );
TestCase.assertNull( beforeStart.getBundleLocation() );
configListener.assertEvents( ConfigurationEvent.CM_LOCATION_CHANGED, 0 );
bundle.start();
final ManagedServiceTestActivator tester = ManagedServiceTestActivator.INSTANCE;
TestCase.assertNotNull( "Activator not started !!", tester );
// give cm time for distribution
delay();
// assert activater has configuration
TestCase.assertNotNull( "Expect Properties after Service Registration", tester.props );
TestCase.assertEquals( "Expect a single update call", 1, tester.numManagedServiceUpdatedCalls );
configListener.assertEvents( ConfigurationEvent.CM_LOCATION_CHANGED, 1 );
// ensure a freshly retrieved object also has the location
final Configuration beforeStop = getConfiguration( pid );
TestCase.assertEquals( beforeStop.getBundleLocation(), bundle.getLocation() );
// check whether bundle context is set on first configuration
TestCase.assertEquals( beforeInstall.getBundleLocation(), bundle.getLocation() );
TestCase.assertEquals( beforeStart.getBundleLocation(), bundle.getLocation() );
bundle.stop();
delay();
// ensure configuration still bound
TestCase.assertEquals( beforeInstall.getBundleLocation(), bundle.getLocation() );
TestCase.assertEquals( beforeStart.getBundleLocation(), bundle.getLocation() );
TestCase.assertEquals( beforeStop.getBundleLocation(), bundle.getLocation() );
// ensure a freshly retrieved object also has the location
final Configuration beforeUninstall = getConfiguration( pid );
TestCase.assertEquals( beforeUninstall.getBundleLocation(), bundle.getLocation() );
bundle.uninstall();
bundle = null;
delay();
// ensure configuration is not bound any more
TestCase.assertNull( beforeInstall.getBundleLocation() );
TestCase.assertNull( beforeStart.getBundleLocation() );
TestCase.assertNull( beforeStop.getBundleLocation() );
TestCase.assertNull( beforeUninstall.getBundleLocation() );
configListener.assertEvents( ConfigurationEvent.CM_LOCATION_CHANGED, 1 );
// ensure a freshly retrieved object also does not have the location
final Configuration atEnd = getConfiguration( pid );
TestCase.assertNull( atEnd.getBundleLocation() );
// remove the configuration for good
deleteConfig( pid );
delay();
configListener.assertEvents( ConfigurationEvent.CM_DELETED, 1 );