final String pid = "test_listener";
Configuration config = configure( pid, null, false );
// Synchronous listener expecting synchronous events being
// registered as a SynchronousConfigurationListener
final TestListener testListener = new SynchronousTestListener();
final ServiceRegistration listener = this.bundleContext.registerService(
SynchronousConfigurationListener.class.getName(), testListener, null );
// Synchronous listener expecting asynchronous events being
// registered as a regular ConfigurationListener
final TestListener testListenerAsync = new SynchronousTestListener();
final ServiceRegistration listenerAsync = this.bundleContext.registerService(
ConfigurationListener.class.getName(), testListenerAsync, null );
int eventCount = 0;
int eventCountAsync = 0;
try
{
delay();
testListener.assertNoEvent();
testListenerAsync.assertNoEvent();
config.update( new Hashtable<String, Object>()
{
{
put( "x", "x" );
}
} );
delay();
testListener.assertEvent( ConfigurationEvent.CM_UPDATED, pid, null, false, ++eventCount );
testListenerAsync.assertEvent( ConfigurationEvent.CM_UPDATED, pid, null, true, ++eventCountAsync );
config.update( new Hashtable<String, Object>()
{
{
put( "x", "x" );
}
} );
delay();
testListener.assertEvent( ConfigurationEvent.CM_UPDATED, pid, null, false, ++eventCount );
testListenerAsync.assertEvent( ConfigurationEvent.CM_UPDATED, pid, null, true, ++eventCountAsync );
config.setBundleLocation( "new_Location" );
delay();
testListener.assertEvent( ConfigurationEvent.CM_LOCATION_CHANGED, pid, null, false, ++eventCount );
testListenerAsync.assertEvent( ConfigurationEvent.CM_LOCATION_CHANGED, pid, null, true, ++eventCountAsync );
config.update();
testListener.assertNoEvent();
testListenerAsync.assertNoEvent();
config.delete();
config = null;
delay();
testListener.assertEvent( ConfigurationEvent.CM_DELETED, pid, null, false, ++eventCount );
testListenerAsync.assertEvent( ConfigurationEvent.CM_DELETED, pid, null, true, ++eventCountAsync );
}
finally
{
if ( config != null )
{