You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by fm...@apache.org on 2009/08/17 12:00:53 UTC
svn commit: r804915 - in /felix/trunk/configadmin/src:
main/java/org/apache/felix/cm/impl/ConfigurationImpl.java
test/java/org/apache/felix/cm/integration/ConfigurationTest.java
Author: fmeschbe
Date: Mon Aug 17 10:00:53 2009
New Revision: 804915
URL: http://svn.apache.org/viewvc?rev=804915&view=rev
Log:
FELIX-1488 Setting a static configuration binding must
also set the "staticallyBound" flag according to the
new binding: true if bound, false if unbound
Modified:
felix/trunk/configadmin/src/main/java/org/apache/felix/cm/impl/ConfigurationImpl.java
felix/trunk/configadmin/src/test/java/org/apache/felix/cm/integration/ConfigurationTest.java
Modified: felix/trunk/configadmin/src/main/java/org/apache/felix/cm/impl/ConfigurationImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/configadmin/src/main/java/org/apache/felix/cm/impl/ConfigurationImpl.java?rev=804915&r1=804914&r2=804915&view=diff
==============================================================================
--- felix/trunk/configadmin/src/main/java/org/apache/felix/cm/impl/ConfigurationImpl.java (original)
+++ felix/trunk/configadmin/src/main/java/org/apache/felix/cm/impl/ConfigurationImpl.java Mon Aug 17 10:00:53 2009
@@ -307,7 +307,7 @@
{
// set binding and mark static and store everything
this.bundleLocation = bundleLocation;
- this.staticallyBound = staticBinding;
+ this.staticallyBound = bundleLocation != null;
// 104.15.2.8 The bundle location will be set persistently
try
Modified: felix/trunk/configadmin/src/test/java/org/apache/felix/cm/integration/ConfigurationTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/configadmin/src/test/java/org/apache/felix/cm/integration/ConfigurationTest.java?rev=804915&r1=804914&r2=804915&view=diff
==============================================================================
--- felix/trunk/configadmin/src/test/java/org/apache/felix/cm/integration/ConfigurationTest.java (original)
+++ felix/trunk/configadmin/src/test/java/org/apache/felix/cm/integration/ConfigurationTest.java Mon Aug 17 10:00:53 2009
@@ -492,6 +492,65 @@
@Test
+ public void test_create_with_location_unbind_before_service_supply() throws BundleException, IOException
+ {
+
+ /*
+ * 1. create Configuration with pid and non-null location.
+ * 2. update the configuration with non-null props.
+ * 3. set location of the configuration to null.
+ * 4. bundleA registers a ManagedService service with the pid.
+ */
+
+ final String pid = "test_create_with_location_unbind_before_service_supply";
+ final String dummyLocation = "http://some/dummy/location";
+
+ // 1. create and statically bind the configuration
+ final ConfigurationAdmin ca = getConfigurationAdmin();
+ final Configuration config = ca.getConfiguration( pid, dummyLocation );
+ TestCase.assertEquals( pid, config.getPid() );
+ TestCase.assertEquals( dummyLocation, config.getBundleLocation() );
+
+ // 2. update configuration
+ Hashtable<String, String> props = new Hashtable<String, String>();
+ props.put( PROP_NAME, PROP_NAME );
+ config.update(props);
+ TestCase.assertEquals( PROP_NAME, config.getProperties().get( PROP_NAME ) );
+ TestCase.assertEquals( pid, config.getPid() );
+ TestCase.assertEquals( dummyLocation, config.getBundleLocation() );
+
+ // 3. (statically) set location to null
+ config.setBundleLocation( null );
+ TestCase.assertNull( config.getBundleLocation() );
+
+ // 4. install bundle with service
+ bundle = installBundle( pid);
+ bundle.start();
+ delay();
+
+ final TestActivator tester = TestActivator.INSTANCE;
+ TestCase.assertNotNull( "Activator not started !!", tester );
+
+ // assert activater has configuration (two calls, one per pid)
+ TestCase.assertNotNull( "Expect Properties after Service Registration", tester.props );
+ TestCase.assertEquals( "Expect a single update call", 1, tester.numUpdatedCalls );
+
+ TestCase.assertEquals( bundle.getLocation(), config.getBundleLocation() );
+
+ bundle.uninstall();
+ bundle = null;
+
+ delay();
+
+ // statically bound configurations must remain bound after bundle uninstall
+ TestCase.assertNull( config.getBundleLocation() );
+
+ // remove the configuration for good
+ deleteConfig( pid );
+ }
+
+
+ @Test
public void test_statically_bound() throws BundleException
{
final String pid = "test_statically_bound";