FELIX-3176 Implement Configuration Admin 4.1 changes:
- Add some test for expected events
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1186810 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/configadmin/src/test/java/org/apache/felix/cm/integration/ConfigurationBindingTest.java b/configadmin/src/test/java/org/apache/felix/cm/integration/ConfigurationBindingTest.java
index 8008412..20678c1 100644
--- a/configadmin/src/test/java/org/apache/felix/cm/integration/ConfigurationBindingTest.java
+++ b/configadmin/src/test/java/org/apache/felix/cm/integration/ConfigurationBindingTest.java
@@ -953,6 +953,54 @@
TestCase.assertEquals( 2, testerB1.numManagedServiceFactoryUpdatedCalls );
}
+
+ @Test
+ public void test_location_changed_events() throws BundleException, IOException
+ {
+ String pid = "test_location_changed_events";
+ configure( pid );
+ delay();
+ configListener.assertEvents( ConfigurationEvent.CM_UPDATED, 1 );
+
+ // ensure configuration is unbound
+ final Configuration config = getConfiguration( pid );
+ TestCase.assertNull( config.getBundleLocation() );
+
+ bundle = installBundle( pid );
+ bundle.start();
+ delay();
+
+ // ensure no configuration bound before start
+ configListener.assertEvents( ConfigurationEvent.CM_LOCATION_CHANGED, 1 );
+
+ // uninstall the bundle, dynamic location changed
+ bundle.uninstall();
+ bundle = null;
+ delay();
+ configListener.assertEvents( ConfigurationEvent.CM_LOCATION_CHANGED, 1 );
+
+ // change the location
+ config.setBundleLocation( "some_location_1" );
+ delay();
+ configListener.assertEvents( ConfigurationEvent.CM_LOCATION_CHANGED, 1 );
+
+ // change the location
+ config.setBundleLocation( "some_location_2" );
+ delay();
+ configListener.assertEvents( ConfigurationEvent.CM_LOCATION_CHANGED, 1 );
+
+ // remove configuration, delete event
+ config.delete();
+ delay();
+ configListener.assertEvents( ConfigurationEvent.CM_DELETED, 1 );
+
+ // no more events
+ delay();
+ configListener.assertEvents( ConfigurationEvent.CM_DELETED, 0 );
+ configListener.assertEvents( ConfigurationEvent.CM_UPDATED, 0 );
+ configListener.assertEvents( ConfigurationEvent.CM_LOCATION_CHANGED, 0 );
+ }
+
private static class ConfigListener implements ConfigurationListener {
private int[] events = new int[3];