Move tests to avoid using the managed service factory directly (not exposed anymore)

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1477242 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/ipojo/runtime/core-it/src/it/ipojo-core-configuration-admin-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestManagedServiceTestForImmediate.java b/ipojo/runtime/core-it/src/it/ipojo-core-configuration-admin-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestManagedServiceTestForImmediate.java
index c116ab1..b130c14 100644
--- a/ipojo/runtime/core-it/src/it/ipojo-core-configuration-admin-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestManagedServiceTestForImmediate.java
+++ b/ipojo/runtime/core-it/src/it/ipojo-core-configuration-admin-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestManagedServiceTestForImmediate.java
@@ -116,8 +116,7 @@
             prc.put("message", "message2");
             configuration.update(prc);
             System.err.println("updated ? ");
-            //Thread.sleep(UPDATE_WAIT_TIME);
-            listener.waitForEvent(configuration.getPid(), "1");
+            Thread.sleep(UPDATE_WAIT_TIME);
         } catch (Exception e) {
             fail(e.getMessage());
         }
@@ -187,8 +186,7 @@
             }
             prc.put("message", "message2");
             configuration.update(prc);
-            //Thread.sleep(UPDATE_WAIT_TIME);
-            listener.waitForEvent(configuration.getPid(), "1");
+            Thread.sleep(UPDATE_WAIT_TIME);
         } catch (Exception e) {
             fail(e.getMessage());
         }
@@ -274,7 +272,7 @@
             }
             prc.put("message", "message3");
             configuration.update(prc);
-            listener.waitForEvent(msp, "1");
+            Thread.sleep(UPDATE_WAIT_TIME);
         } catch (Exception e) {
             fail(e.getMessage());
         }
@@ -321,7 +319,7 @@
             }
             prc.put("message", "message2");
             configuration.update(prc);
-            listener.waitForEvent(msp, "1");
+            Thread.sleep(UPDATE_WAIT_TIME);
         } catch (Exception e) {
             fail(e.getMessage());
         }
@@ -359,7 +357,7 @@
             prc.put("message", "message3");
             configuration.update(prc);
             //Thread.sleep(UPDATE_WAIT_TIME);
-            listener.waitForEvent(msp, "1");
+            Thread.sleep(UPDATE_WAIT_TIME);
         } catch (Exception e) {
             fail(e.getMessage());
         }
diff --git a/ipojo/runtime/core-it/src/it/ipojo-core-configuration-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestDynamicallyConfigurablePropertiesUsingConfigAdmin.java b/ipojo/runtime/core-it/src/it/ipojo-core-configuration-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestDynamicallyConfigurablePropertiesUsingConfigAdmin.java
index 84ebf4a..7b9b8d1 100644
--- a/ipojo/runtime/core-it/src/it/ipojo-core-configuration-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestDynamicallyConfigurablePropertiesUsingConfigAdmin.java
+++ b/ipojo/runtime/core-it/src/it/ipojo-core-configuration-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestDynamicallyConfigurablePropertiesUsingConfigAdmin.java
@@ -24,13 +24,10 @@
 import org.junit.Before;

 import org.junit.Test;

 import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;

-import org.ops4j.pax.exam.spi.reactors.PerClass;

 import org.ops4j.pax.exam.spi.reactors.PerMethod;

 import org.osgi.framework.ServiceReference;

 import org.osgi.service.cm.Configuration;

 import org.osgi.service.cm.ConfigurationAdmin;

-import org.osgi.service.cm.ConfigurationException;

-import org.osgi.service.cm.ManagedServiceFactory;

 

 import java.io.IOException;

 import java.util.Hashtable;

@@ -38,7 +35,7 @@
 

 import static junit.framework.Assert.assertEquals;

 import static org.junit.Assert.assertNotNull;

-import static org.junit.Assert.fail;

+import static org.junit.Assert.assertNull;

 

 /**

  * iPOJO does not expose the ManagedServiceFactory anymore, we must use the configuration admin.

@@ -330,6 +327,7 @@
         conf.put("bar", new Integer(2));

         conf.put("propagated1", "propagated");

         conf.put("propagated2", new Integer(1));

+        conf.put(".notpropagated", "xxx");

 

         // Asynchronous dispatching of the configuration

         configuration.update(conf);

@@ -340,10 +338,11 @@
         fooP = (String) fooRef.getProperty("foo");

         barP = (Integer) fooRef.getProperty("bar");

         bazP = (String) fooRef.getProperty("baz");

-        assertNotNull("Check the propagated1 existency", fooRef.getProperty("propagated1"));

+        assertNotNull("Check the propagated1 existence", fooRef.getProperty("propagated1"));

         String prop1 = (String) fooRef.getProperty("propagated1");

-        assertNotNull("Check the propagated2 existency", fooRef.getProperty("propagated2"));

+        assertNotNull("Check the propagated2 existence", fooRef.getProperty("propagated2"));

         Integer prop2 = (Integer) fooRef.getProperty("propagated2");

+        assertNull("Check the not propagated non-existence", fooRef.getProperty(".notpropagated"));

 

         assertEquals("Check foo equality", fooP, "foo");

         assertEquals("Check bar equality", barP, new Integer(2));

diff --git a/ipojo/runtime/core-it/src/it/ipojo-core-factory-test/src/test/java/org/apache/felix/ipojo/runtime/core/Common.java b/ipojo/runtime/core-it/src/it/ipojo-core-factory-test/src/test/java/org/apache/felix/ipojo/runtime/core/Common.java
index aeb0efe..f03d3bc 100644
--- a/ipojo/runtime/core-it/src/it/ipojo-core-factory-test/src/test/java/org/apache/felix/ipojo/runtime/core/Common.java
+++ b/ipojo/runtime/core-it/src/it/ipojo-core-factory-test/src/test/java/org/apache/felix/ipojo/runtime/core/Common.java
@@ -240,8 +240,8 @@
     private boolean getBundleStability(BundleContext bc) {
         boolean stability = true;
         Bundle[] bundles = bc.getBundles();
-        for (int i = 0; i < bundles.length; i++) {
-            stability = stability && (bundles[i].getState() == Bundle.ACTIVE);
+        for (Bundle bundle : bundles) {
+            stability = stability && (bundle.getState() == Bundle.ACTIVE);
         }
         return stability;
     }
diff --git a/ipojo/runtime/core-it/src/it/ipojo-core-factory-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestConfigAdmin.java b/ipojo/runtime/core-it/src/it/ipojo-core-factory-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestConfigAdmin.java
index abe1d16..bf61d30 100644
--- a/ipojo/runtime/core-it/src/it/ipojo-core-factory-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestConfigAdmin.java
+++ b/ipojo/runtime/core-it/src/it/ipojo-core-factory-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestConfigAdmin.java
@@ -21,9 +21,10 @@
 import org.apache.felix.ipojo.runtime.core.services.FooService;
 import org.junit.Test;
 import org.osgi.framework.ServiceReference;
-import org.osgi.service.cm.ConfigurationException;
-import org.osgi.service.cm.ManagedServiceFactory;
+import org.osgi.service.cm.Configuration;
+import org.osgi.service.cm.ConfigurationAdmin;
 
+import java.io.IOException;
 import java.util.Properties;
 
 import static org.junit.Assert.*;
@@ -33,23 +34,13 @@
  */
 public class TestConfigAdmin extends Common {
 
-    private ManagedServiceFactory getFactoryByName(String pid) {
-        ServiceReference[] refs;
-
-        refs = osgiHelper.getServiceReferences(ManagedServiceFactory.class.getName(), "(service.pid=" + pid + ")");
-        if (refs == null) {
-            return null;
-        }
-
-        return ((ManagedServiceFactory) osgiHelper.getServiceObject((refs[0])));
-    }
-
     /**
      * Check creation.
      */
     @Test
-    public void testCreation() {
-        ManagedServiceFactory f = getFactoryByName("Factories-FooProviderType-2");
+    public void testCreation() throws IOException, InterruptedException {
+        ConfigurationAdmin admin = osgiHelper.getServiceObject(ConfigurationAdmin.class, null);
+        Configuration conf = admin.createFactoryConfiguration("Factories-FooProviderType-2", "?");
 
         Properties p = new Properties();
         p.put("int", 3);
@@ -58,24 +49,28 @@
         p.put("strAProp", new String[]{"a"});
         p.put("intAProp", new int[]{1, 2});
 
-        try {
-            f.updated("ok2", p);
-            ServiceReference ref = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), "ok2");
-            assertNotNull("Check instance creation", ref);
-            f.deleted("ok2");
-            ref = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), "ok2");
-            assertNull("Check instance deletion", ref);
-        } catch (ConfigurationException e) {
-            fail("An acceptable configuration is rejected : " + e.getMessage());
-        }
+        conf.update(p);
+        Thread.sleep(200);
+
+        String pid = conf.getPid();
+        ServiceReference ref = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), pid);
+        assertNotNull("Check instance creation", ref);
+
+        // Deletion of the configuration
+        conf.delete();
+        Thread.sleep(200);
+
+        ref = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), pid);
+        assertNull("Check instance deletion", ref);
     }
 
     /**
      * Check creation (push String).
      */
     @Test
-    public void testCreationString() {
-        ManagedServiceFactory f = getFactoryByName("Factories-FooProviderType-2");
+    public void testCreationString() throws IOException, InterruptedException {
+        ConfigurationAdmin admin = osgiHelper.getServiceObject(ConfigurationAdmin.class, null);
+        Configuration conf = admin.createFactoryConfiguration("Factories-FooProviderType-2", "?");
 
         Properties p = new Properties();
         p.put("int", "3");
@@ -84,24 +79,28 @@
         p.put("strAProp", "{a}");
         p.put("intAProp", "{1,2}");
 
-        try {
-            f.updated("ok2", p);
-            ServiceReference ref = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), "ok2");
-            assertNotNull("Check instance creation", ref);
-            f.deleted("ok2");
-            ref = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), "ok2");
-            assertNull("Check instance deletion", ref);
-        } catch (ConfigurationException e) {
-            fail("An acceptable configuration is rejected : " + e.getMessage());
-        }
+        conf.update(p);
+        Thread.sleep(200);
+
+        String pid = conf.getPid();
+        ServiceReference ref = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), pid);
+
+        assertNotNull("Check instance creation", ref);
+
+        conf.delete();
+        Thread.sleep(200);
+
+        ref = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), pid);
+        assertNull("Check instance deletion", ref);
     }
 
     /**
      * Check update and delete.
      */
     @Test
-    public void testUpdate() {
-        ManagedServiceFactory f = getFactoryByName("Factories-FooProviderType-2");
+    public void testUpdate() throws IOException, InterruptedException {
+        ConfigurationAdmin admin = osgiHelper.getServiceObject(ConfigurationAdmin.class, null);
+        Configuration conf = admin.createFactoryConfiguration("Factories-FooProviderType-2", "?");
 
         Properties p = new Properties();
         p.put("int", 3);
@@ -110,21 +109,27 @@
         p.put("strAProp", new String[]{"a"});
         p.put("intAProp", new int[]{1, 2});
 
-        try {
-            f.updated("okkkk", p);
-            ServiceReference ref = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), "okkkk");
-            assertNotNull("Check instance creation", ref);
-            p.put("int", new Integer("4"));
-            f.updated("okkkk", p);
-            ref = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), "okkkk");
-            Integer test = (Integer) ref.getProperty("int");
-            assertEquals("Check instance modification", 4, test.intValue());
-            f.deleted("okkkk");
-            ref = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), "okkkk");
-            assertNull("Check instance deletion", ref);
-        } catch (ConfigurationException e) {
-            fail("An acceptable configuration is rejected : " + e.getMessage());
-        }
+        conf.update(p);
+        Thread.sleep(200);
+
+        String pid = conf.getPid();
+        ServiceReference ref = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), pid);
+
+        assertNotNull("Check instance creation", ref);
+
+        p.put("int", 4);
+        conf.update(p);
+        Thread.sleep(200);
+
+        ref = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), pid);
+        Integer test = (Integer) ref.getProperty("int");
+        assertEquals("Check instance modification", 4, test.intValue());
+
+        conf.delete();
+        Thread.sleep(200);
+
+        ref = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), pid);
+        assertNull("Check instance deletion", ref);
     }
 
     /**
@@ -132,8 +137,9 @@
      * (Push String).
      */
     @Test
-    public void testUpdateString() {
-        ManagedServiceFactory f = getFactoryByName("Factories-FooProviderType-2");
+    public void testUpdateString() throws IOException, InterruptedException {
+        ConfigurationAdmin admin = osgiHelper.getServiceObject(ConfigurationAdmin.class, null);
+        Configuration conf = admin.createFactoryConfiguration("Factories-FooProviderType-2", "?");
 
         Properties p = new Properties();
         p.put("int", "3");
@@ -142,21 +148,23 @@
         p.put("strAProp", "{a}");
         p.put("intAProp", "{1,2}");
 
-        try {
-            f.updated("okkkk", p);
-            ServiceReference ref = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), "okkkk");
-            assertNotNull("Check instance creation", ref);
-            p.put("int", new Integer("4"));
-            f.updated("okkkk", p);
-            ref = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), "okkkk");
-            Integer test = (Integer) ref.getProperty("int");
-            assertEquals("Check instance modification", 4, test.intValue());
-            f.deleted("okkkk");
-            ref = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), "okkkk");
-            assertNull("Check instance deletion", ref);
-        } catch (ConfigurationException e) {
-            fail("An acceptable configuration is rejected : " + e.getMessage());
-        }
+        conf.update(p);
+        Thread.sleep(200);
+
+        String pid = conf.getPid();
+
+        ServiceReference ref = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), pid);
+        assertNotNull("Check instance creation", ref);
+        p.put("int", new Integer("4"));
+        conf.update(p);
+        Thread.sleep(200);
+        ref = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), pid);
+        Integer test = (Integer) ref.getProperty("int");
+        assertEquals("Check instance modification", 4, test.intValue());
+        conf.delete();
+        Thread.sleep(200);
+        ref = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), pid);
+        assertNull("Check instance deletion", ref);
     }
 
 }
diff --git a/ipojo/runtime/core-it/src/it/ipojo-core-factory-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestReconfiguration.java b/ipojo/runtime/core-it/src/it/ipojo-core-factory-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestReconfiguration.java
index c9d3575..7ab84a4 100644
--- a/ipojo/runtime/core-it/src/it/ipojo-core-factory-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestReconfiguration.java
+++ b/ipojo/runtime/core-it/src/it/ipojo-core-factory-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestReconfiguration.java
@@ -111,7 +111,8 @@
     @Test public void testRevalidationOnReconfigurationUsingConfigAdmin() throws InvalidSyntaxException {
         Configuration configuration = null;
         try {
-            configuration = admin.createFactoryConfiguration("org.apache.felix.ipojo.runtime.core.components.ReconfigurableSimpleType", null);
+            configuration = admin.createFactoryConfiguration("org.apache.felix.ipojo.runtime.core.components" +
+                    ".ReconfigurableSimpleType", "?");
         } catch (IOException e) {
             fail(e.getMessage());
         }
@@ -201,7 +202,7 @@
         Configuration configuration = null;
         try {
             configuration = admin.createFactoryConfiguration("org.apache.felix.ipojo.runtime.core.components.ReconfigurableSimpleType2",
-                    null);
+                    "?");
         } catch (IOException e) {
             fail(e.getMessage());
         }
@@ -293,7 +294,7 @@
         Configuration configuration = null;
         try {
             configuration = admin.createFactoryConfiguration("org.apache.felix.ipojo.runtime.core.components.ReconfigurableSimpleType3",
-                    null);
+                    "?");
         } catch (IOException e) {
             fail(e.getMessage());
         }
diff --git a/ipojo/runtime/core-it/src/it/ipojo-core-service-providing-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestDynamicPropsReconfiguration.java b/ipojo/runtime/core-it/src/it/ipojo-core-service-providing-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestDynamicPropsReconfiguration.java
index ceba456..838c104 100644
--- a/ipojo/runtime/core-it/src/it/ipojo-core-service-providing-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestDynamicPropsReconfiguration.java
+++ b/ipojo/runtime/core-it/src/it/ipojo-core-service-providing-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestDynamicPropsReconfiguration.java
@@ -24,9 +24,10 @@
 import org.junit.Before;

 import org.junit.Test;

 import org.osgi.framework.ServiceReference;

-import org.osgi.service.cm.ConfigurationException;

-import org.osgi.service.cm.ManagedServiceFactory;

+import org.osgi.service.cm.Configuration;

+import org.osgi.service.cm.ConfigurationAdmin;

 

+import java.io.IOException;

 import java.util.Properties;

 

 import static junit.framework.Assert.assertEquals;

@@ -41,9 +42,9 @@
         String type2 = "PS-FooProviderType-Dyn2";

         Properties p3 = new Properties();

         p3.put("instance.name", "FooProvider-3");

-        p3.put("int", new Integer(0));

-        p3.put("boolean", new Boolean(true));

-        p3.put("string", new String(""));

+        p3.put("int", 0);

+        p3.put("boolean", true);

+        p3.put("string", "");

         p3.put("strAProp", new String[0]);

         p3.put("intAProp", new int[0]);

         fooProvider3 = ipojoHelper.createComponentInstance(type2, p3);

@@ -86,9 +87,9 @@
         Factory fact = (Factory) osgiHelper.getServiceObject(fact_ref);

         Properties p3 = new Properties();

         p3.put("instance.name", "FooProvider-3");

-        p3.put("int", new Integer(1));

-        p3.put("boolean", new Boolean(true));

-        p3.put("string", new String("foo"));

+        p3.put("int", 1);

+        p3.put("boolean", true);

+        p3.put("string", "foo");

         p3.put("strAProp", new String[]{"foo", "bar", "baz"});

         p3.put("intAProp", new int[]{1, 2, 3});

         try {

@@ -108,8 +109,8 @@
         intAProp = (int[]) sr.getProperty("intAProp");

 

         assertEquals("Check intProp equality", intProp, new Integer(1));

-        assertEquals("Check longProp equality", boolProp, new Boolean(true));

-        assertEquals("Check strProp equality", strProp, new String("foo"));

+        assertEquals("Check longProp equality", boolProp, Boolean.TRUE);

+        assertEquals("Check strProp equality", strProp, "foo");

         assertNotNull("Check strAProp not nullity", strAProp);

         v = new String[]{"foo", "bar", "baz"};

         for (int i = 0; i < strAProp.length; i++) {

@@ -137,8 +138,8 @@
         intAProp = (int[]) sr.getProperty("intAProp");

 

         assertEquals("Check intProp equality", intProp, new Integer(2));

-        assertEquals("Check longProp equality", boolProp, new Boolean(true));

-        assertEquals("Check strProp equality", strProp, new String("foo"));

+        assertEquals("Check longProp equality", boolProp, Boolean.TRUE);

+        assertEquals("Check strProp equality", strProp, "foo");

         assertNotNull("Check strAProp not nullity", strAProp);

         v = new String[]{"foo", "bar"};

         for (int i = 0; i < strAProp.length; i++) {

@@ -153,9 +154,9 @@
         fact = (Factory) osgiHelper.getServiceObject(fact_ref);

         p3 = new Properties();

         p3.put("instance.name", "FooProvider-3");

-        p3.put("int", new Integer(1));

-        p3.put("boolean", new Boolean(true));

-        p3.put("string", new String("foo"));

+        p3.put("int", 1);

+        p3.put("boolean", true);

+        p3.put("string", "foo");

         p3.put("strAProp", new String[]{"foo", "bar", "baz"});

         p3.put("intAProp", new int[]{1, 2, 3});

         try {

@@ -175,8 +176,8 @@
         intAProp = (int[]) sr.getProperty("intAProp");

 

         assertEquals("Check intProp equality", intProp, new Integer(1));

-        assertEquals("Check longProp equality", boolProp, new Boolean(true));

-        assertEquals("Check strProp equality", strProp, new String("foo"));

+        assertEquals("Check longProp equality", boolProp, Boolean.TRUE);

+        assertEquals("Check strProp equality", strProp, "foo");

         assertNotNull("Check strAProp not nullity", strAProp);

         v = new String[]{"foo", "bar", "baz"};

         for (int i = 0; i < strAProp.length; i++) {

@@ -191,9 +192,6 @@
                 fail("Check the intAProp Equality");

             }

         }

-

-        fact = null;

-        fs = null;

     }

 

     @Test

@@ -209,8 +207,8 @@
         int[] intAProp = (int[]) sr.getProperty("intAProp");

 

         assertEquals("Check intProp equality", intProp, new Integer(0));

-        assertEquals("Check longProp equality", boolProp, new Boolean(true));

-        assertEquals("Check strProp equality", strProp, new String(""));

+        assertEquals("Check longProp equality", boolProp, Boolean.TRUE);

+        assertEquals("Check strProp equality", strProp, "");

         assertNotNull("Check strAProp not nullity", strAProp);

         String[] v = new String[0];

         for (int i = 0; i < strAProp.length; i++) {

@@ -282,8 +280,8 @@
         intAProp = (int[]) sr.getProperty("intAProp");

 

         assertEquals("Check intProp equality", intProp, new Integer(2));

-        assertEquals("Check longProp equality", boolProp, new Boolean(true));

-        assertEquals("Check strProp equality", strProp, new String("foo"));

+        assertEquals("Check longProp equality", boolProp, Boolean.TRUE);

+        assertEquals("Check strProp equality", strProp, "foo");

         assertNotNull("Check strAProp not nullity", strAProp);

         v = new String[]{"foo", "bar"};

         for (int i = 0; i < strAProp.length; i++) {

@@ -291,7 +289,7 @@
                 fail("Check the strAProp Equality");

             }

         }

-        assertNull("Check intAProp hidding (no value)", intAProp);

+        assertNull("Check intAProp hiding (no value)", intAProp);

 

         //	Reconfiguration

         fact_ref = ipojoHelper.getServiceReferenceByName(Factory.class.getName(), "PS-FooProviderType-Dyn2");

@@ -320,8 +318,8 @@
         intAProp = (int[]) sr.getProperty("intAProp");

 

         assertEquals("Check intProp equality", intProp, new Integer(1));

-        assertEquals("Check longProp equality", boolProp, new Boolean(true));

-        assertEquals("Check strProp equality", strProp, new String("foo"));

+        assertEquals("Check longProp equality", boolProp, Boolean.TRUE);

+        assertEquals("Check strProp equality", strProp, "foo");

         assertNotNull("Check strAProp not nullity", strAProp);

         v = new String[]{"foo", "bar", "baz"};

         for (int i = 0; i < strAProp.length; i++) {

@@ -336,13 +334,10 @@
                 fail("Check the intAProp Equality");

             }

         }

-

-        fact = null;

-        fs = null;

     }

 

     @Test

-    public void testMSFReconf() {

+    public void testReconfigurationUsingManagedService() throws IOException, InterruptedException {

         ServiceReference sr = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), "FooProvider-3");

         assertNotNull("Check the availability of the FS service", sr);

 

@@ -354,8 +349,8 @@
         int[] intAProp = (int[]) sr.getProperty("intAProp");

 

         assertEquals("Check intProp equality", intProp, new Integer(0));

-        assertEquals("Check longProp equality", boolProp, new Boolean(true));

-        assertEquals("Check strProp equality", strProp, new String(""));

+        assertEquals("Check longProp equality", boolProp, Boolean.TRUE);

+        assertEquals("Check strProp equality", strProp, "");

         assertNotNull("Check strAProp not nullity", strAProp);

         String[] v = new String[0];

         for (int i = 0; i < strAProp.length; i++) {

@@ -372,19 +367,18 @@
         }

 

         // Reconfiguration

-        ServiceReference fact_ref = ipojoHelper.getServiceReferenceByName(ManagedServiceFactory.class.getName(), "PS-FooProviderType-Dyn2");

-        ManagedServiceFactory fact = (ManagedServiceFactory) osgiHelper.getServiceObject(fact_ref);

+        ConfigurationAdmin admin = osgiHelper.getServiceObject(ConfigurationAdmin.class);

+        Configuration configuration = admin.getConfiguration("FooProvider-3", "?");

+

         Properties p3 = new Properties();

-        p3.put("int", new Integer(1));

-        p3.put("boolean", new Boolean(true));

-        p3.put("string", new String("foo"));

+        p3.put("int", 1);

+        p3.put("boolean", true);

+        p3.put("string", "foo");

         p3.put("strAProp", new String[]{"foo", "bar", "baz"});

         p3.put("intAProp", new int[]{1, 2, 3});

-        try {

-            fact.updated("FooProvider-3", p3);

-        } catch (ConfigurationException e) {

-            fail("Unable to reconfigure the instance with : " + p3);

-        }

+

+        configuration.update(p3);

+        Thread.sleep(200);

 

         sr = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), "FooProvider-3");

         assertNotNull("Check the availability of the FS service", sr);

@@ -397,8 +391,8 @@
         intAProp = (int[]) sr.getProperty("intAProp");

 

         assertEquals("Check intProp equality", intProp, new Integer(1));

-        assertEquals("Check longProp equality", boolProp, new Boolean(true));

-        assertEquals("Check strProp equality", strProp, new String("foo"));

+        assertEquals("Check longProp equality", boolProp, Boolean.TRUE);

+        assertEquals("Check strProp equality", strProp, "foo");

         assertNotNull("Check strAProp not nullity", strAProp);

         v = new String[]{"foo", "bar", "baz"};

         for (int i = 0; i < strAProp.length; i++) {

@@ -426,8 +420,8 @@
         intAProp = (int[]) sr.getProperty("intAProp");

 

         assertEquals("Check intProp equality", intProp, new Integer(2));

-        assertEquals("Check longProp equality", boolProp, new Boolean(true));

-        assertEquals("Check strProp equality", strProp, new String("foo"));

+        assertEquals("Check longProp equality", boolProp, Boolean.TRUE);

+        assertEquals("Check strProp equality", strProp, "foo");

         assertNotNull("Check strAProp not nullity", strAProp);

         v = new String[]{"foo", "bar"};

         for (int i = 0; i < strAProp.length; i++) {

@@ -435,22 +429,19 @@
                 fail("Check the strAProp Equality");

             }

         }

-        assertNull("Check intAProp hidding (no value)", intAProp);

+        assertNull("Check intAProp hiding (no value)", intAProp);

 

         //	Reconfiguration

-        fact_ref = ipojoHelper.getServiceReferenceByName(ManagedServiceFactory.class.getName(), "PS-FooProviderType-Dyn2");

-        fact = (ManagedServiceFactory) osgiHelper.getServiceObject(fact_ref);

+

         p3 = new Properties();

-        p3.put("int", new Integer(1));

-        p3.put("boolean", new Boolean(true));

-        p3.put("string", new String("foo"));

+        p3.put("int", 1);

+        p3.put("boolean", true);

+        p3.put("string", "foo");

         p3.put("strAProp", new String[]{"foo", "bar", "baz"});

         p3.put("intAProp", new int[]{1, 2, 3});

-        try {

-            fact.updated("FooProvider-3", p3);

-        } catch (ConfigurationException e) {

-            fail("Unable to reconfigure the instance with : " + p3);

-        }

+

+        configuration.update(p3);

+        Thread.sleep(200);

 

         sr = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), "FooProvider-3");

         assertNotNull("Check the availability of the FS service", sr);

@@ -463,8 +454,8 @@
         intAProp = (int[]) sr.getProperty("intAProp");

 

         assertEquals("Check intProp equality", intProp, new Integer(1));

-        assertEquals("Check longProp equality", boolProp, new Boolean(true));

-        assertEquals("Check strProp equality", strProp, new String("foo"));

+        assertEquals("Check longProp equality", boolProp, Boolean.TRUE);

+        assertEquals("Check strProp equality", strProp, "foo");

         assertNotNull("Check strAProp not nullity", strAProp);

         v = new String[]{"foo", "bar", "baz"};

         for (int i = 0; i < strAProp.length; i++) {

@@ -479,13 +470,10 @@
                 fail("Check the intAProp Equality");

             }

         }

-

-        fact = null;

-        fs = null;

     }

 

     @Test

-    public void testMSFReconfString() {

+    public void testReconfiguraitonUsingManagedServiceWithStrings() throws IOException, InterruptedException {

         ServiceReference sr = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), "FooProvider-3");

         assertNotNull("Check the availability of the FS service", sr);

 

@@ -497,8 +485,8 @@
         int[] intAProp = (int[]) sr.getProperty("intAProp");

 

         assertEquals("Check intProp equality", intProp, new Integer(0));

-        assertEquals("Check longProp equality", boolProp, new Boolean(true));

-        assertEquals("Check strProp equality", strProp, new String(""));

+        assertEquals("Check longProp equality", boolProp, Boolean.TRUE);

+        assertEquals("Check strProp equality", strProp, "");

         assertNotNull("Check strAProp not nullity", strAProp);

         String[] v = new String[0];

         for (int i = 0; i < strAProp.length; i++) {

@@ -515,19 +503,19 @@
         }

 

         // Reconfiguration

-        ServiceReference fact_ref = ipojoHelper.getServiceReferenceByName(ManagedServiceFactory.class.getName(), "PS-FooProviderType-Dyn2");

-        ManagedServiceFactory fact = (ManagedServiceFactory) osgiHelper.getServiceObject(fact_ref);

+        ConfigurationAdmin admin = osgiHelper.getServiceObject(ConfigurationAdmin.class);

+        Configuration configuration = admin.getConfiguration("FooProvider-3", "?");

+

+

         Properties p3 = new Properties();

         p3.put("int", "1");

         p3.put("boolean", "true");

         p3.put("string", "foo");

         p3.put("strAProp", "{foo, bar, baz}");

         p3.put("intAProp", "{ 1, 2, 3}");

-        try {

-            fact.updated("FooProvider-3", p3);

-        } catch (ConfigurationException e) {

-            fail("Unable to reconfigure the instance with : " + p3);

-        }

+

+        configuration.update(p3);

+        Thread.sleep(200);

 

         sr = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), "FooProvider-3");

         assertNotNull("Check the availability of the FS service", sr);

@@ -540,8 +528,8 @@
         intAProp = (int[]) sr.getProperty("intAProp");

 

         assertEquals("Check intProp equality", intProp, new Integer(1));

-        assertEquals("Check longProp equality", boolProp, new Boolean(true));

-        assertEquals("Check strProp equality", strProp, new String("foo"));

+        assertEquals("Check longProp equality", boolProp, Boolean.TRUE);

+        assertEquals("Check strProp equality", strProp, "foo");

         assertNotNull("Check strAProp not nullity", strAProp);

         v = new String[]{"foo", "bar", "baz"};

         for (int i = 0; i < strAProp.length; i++) {

@@ -569,8 +557,8 @@
         intAProp = (int[]) sr.getProperty("intAProp");

 

         assertEquals("Check intProp equality", intProp, new Integer(2));

-        assertEquals("Check longProp equality", boolProp, new Boolean(true));

-        assertEquals("Check strProp equality", strProp, new String("foo"));

+        assertEquals("Check longProp equality", boolProp, Boolean.TRUE);

+        assertEquals("Check strProp equality", strProp, "foo");

         assertNotNull("Check strAProp not nullity", strAProp);

         v = new String[]{"foo", "bar"};

         for (int i = 0; i < strAProp.length; i++) {

@@ -581,19 +569,16 @@
         assertNull("Check intAProp hidding (no value)", intAProp);

 

         //	Reconfiguration

-        fact_ref = ipojoHelper.getServiceReferenceByName(ManagedServiceFactory.class.getName(), "PS-FooProviderType-Dyn2");

-        fact = (ManagedServiceFactory) osgiHelper.getServiceObject(fact_ref);

+

         p3 = new Properties();

         p3.put("int", "1");

         p3.put("boolean", "true");

         p3.put("string", "foo");

         p3.put("strAProp", "{foo, bar, baz}");

         p3.put("intAProp", "{ 1, 2, 3}");

-        try {

-            fact.updated("FooProvider-3", p3);

-        } catch (ConfigurationException e) {

-            fail("Unable to reconfigure the instance with : " + p3);

-        }

+

+        configuration.update(p3);

+        Thread.sleep(200);

 

         sr = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), "FooProvider-3");

         assertNotNull("Check the availability of the FS service", sr);

@@ -606,8 +591,8 @@
         intAProp = (int[]) sr.getProperty("intAProp");

 

         assertEquals("Check intProp equality", intProp, new Integer(1));

-        assertEquals("Check longProp equality", boolProp, new Boolean(true));

-        assertEquals("Check strProp equality", strProp, new String("foo"));

+        assertEquals("Check longProp equality", boolProp, Boolean.TRUE);

+        assertEquals("Check strProp equality", strProp, "foo");

         assertNotNull("Check strAProp not nullity", strAProp);

         v = new String[]{"foo", "bar", "baz"};

         for (int i = 0; i < strAProp.length; i++) {

@@ -622,9 +607,6 @@
                 fail("Check the intAProp Equality");

             }

         }

-

-        fact = null;

-        fs = null;

     }

 

     @Test

diff --git a/ipojo/runtime/core-it/src/it/ipojo-core-service-providing-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestStaticPropsReconfiguration.java b/ipojo/runtime/core-it/src/it/ipojo-core-service-providing-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestStaticPropsReconfiguration.java
index 99c9ac3..cc23056 100644
--- a/ipojo/runtime/core-it/src/it/ipojo-core-service-providing-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestStaticPropsReconfiguration.java
+++ b/ipojo/runtime/core-it/src/it/ipojo-core-service-providing-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestStaticPropsReconfiguration.java
@@ -23,9 +23,10 @@
 import org.junit.Before;

 import org.junit.Test;

 import org.osgi.framework.ServiceReference;

-import org.osgi.service.cm.ConfigurationException;

-import org.osgi.service.cm.ManagedServiceFactory;

+import org.osgi.service.cm.Configuration;

+import org.osgi.service.cm.ConfigurationAdmin;

 

+import java.io.IOException;

 import java.util.Dictionary;

 import java.util.Properties;

 

@@ -42,9 +43,9 @@
 

         Properties p2 = new Properties();

         p2.put("instance.name", "FooProvider-2");

-        p2.put("int", new Integer(4));

-        p2.put("long", new Long(42));

-        p2.put("string", new String("bar"));

+        p2.put("int", 4);

+        p2.put("long", (long) 42);

+        p2.put("string", "bar");

         p2.put("strAProp", new String[]{"bar", "foo"});

         p2.put("intAProp", new int[]{1, 2, 3});

         ipojoHelper.createComponentInstance(type, p2);

@@ -124,8 +125,6 @@
             }

         }

 

-        fact = null;

-

     }

 

     @Test

@@ -142,7 +141,7 @@
 

         assertEquals("Check intProp equality", intProp, new Integer(4));

         assertEquals("Check longProp equality", longProp, new Long(42));

-        assertEquals("Check strProp equality", strProp, new String("bar"));

+        assertEquals("Check strProp equality", strProp, "bar");

 

         assertNotNull("Check strAProp not nullity", strAProp);

         String[] v = new String[]{"bar", "foo"};

@@ -161,11 +160,11 @@
 

         // Reconfiguration

         ServiceReference fact_ref = ipojoHelper.getServiceReferenceByName(Factory.class.getName(), "PS-FooProviderType-2");

-        Dictionary reconf = new Properties();

+        Properties reconf = new Properties();

         reconf.put("instance.name", "FooProvider-2");

-        reconf.put("int", new Integer(5));

-        reconf.put("long", new Long(43));

-        reconf.put("string", new String("toto"));

+        reconf.put("int", 5);

+        reconf.put("long", (long) 43);

+        reconf.put("string", "toto");

         reconf.put("strAProp", new String[]{"foo", "baz"});

         reconf.put("intAProp", new int[]{3, 2, 1});

         Factory fact = (Factory) osgiHelper.getServiceObject(fact_ref);

@@ -184,7 +183,7 @@
 

         assertEquals("Check intProp equality after reconfiguration", intProp, new Integer(5));

         assertEquals("Check longProp equality after reconfiguration", longProp, new Long(43));

-        assertEquals("Check strProp equality after reconfiguration", strProp, new String("toto"));

+        assertEquals("Check strProp equality after reconfiguration", strProp, "toto");

         assertNotNull("Check strAProp not nullity after reconfiguration", strAProp);

         v = new String[]{"foo", "baz"};

         for (int i = 0; i < strAProp.length; i++) {

@@ -199,11 +198,10 @@
                 fail("Check the intAProp Equality");

             }

         }

-        fact = null;

     }

 

     @Test

-    public void testMSFFactory1() {

+    public void testMSFFactory1() throws IOException, InterruptedException {

         ServiceReference sr = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), "FooProvider-1");

         assertNotNull("Check the availability of the FS service", sr);

 

@@ -216,7 +214,7 @@
 

         assertEquals("Check intProp equality", intProp, new Integer(2));

         assertEquals("Check longProp equality", longProp, new Long(40));

-        assertEquals("Check strProp equality", strProp, new String("foo"));

+        assertEquals("Check strProp equality", strProp, "foo");

         assertNotNull("Check strAProp not nullity", strAProp);

         String[] v = new String[]{"foo", "bar"};

         for (int i = 0; i < strAProp.length; i++) {

@@ -233,19 +231,18 @@
         }

 

         // Reconfiguration

-        ServiceReference fact_ref = ipojoHelper.getServiceReferenceByName(ManagedServiceFactory.class.getName(), "PS-FooProviderType-2");

-        Dictionary reconf = new Properties();

-        reconf.put("int", new Integer(5));

-        reconf.put("long", new Long(43));

-        reconf.put("string", new String("toto"));

+        ConfigurationAdmin admin = osgiHelper.getServiceObject(ConfigurationAdmin.class);

+        Configuration configuration = admin.getConfiguration("FooProvider-1", "?");

+

+        Properties reconf = new Properties();

+        reconf.put("int", 5);

+        reconf.put("long", (long) 43);

+        reconf.put("string", "toto");

         reconf.put("strAProp", new String[]{"foo", "baz"});

         reconf.put("intAProp", new int[]{3, 2, 1});

-        ManagedServiceFactory fact = (ManagedServiceFactory) osgiHelper.getServiceObject(fact_ref);

-        try {

-            fact.updated("FooProvider-1", reconf);

-        } catch (ConfigurationException e) {

-            fail("Configuration non acceptable : " + reconf);

-        }

+

+        configuration.update(reconf);

+        Thread.sleep(200);

 

         sr = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), "FooProvider-1");

         assertNotNull("Check the availability of the FS service", sr);

@@ -259,7 +256,7 @@
 

         assertEquals("Check intProp equality after reconfiguration", intProp, new Integer(5));

         assertEquals("Check longProp equality after reconfiguration", longProp, new Long(43));

-        assertEquals("Check strProp equality after reconfiguration", strProp, new String("toto"));

+        assertEquals("Check strProp equality after reconfiguration", strProp, "toto");

         assertNotNull("Check strAProp not nullity after reconfiguration", strAProp);

         v = new String[]{"foo", "baz"};

         for (int i = 0; i < strAProp.length; i++) {

@@ -274,13 +271,10 @@
                 fail("Check the intAProp Equality");

             }

         }

-

-        fact = null;

-

     }

 

     @Test

-    public void testReconfMSF2() {

+    public void testReconfMSF2() throws IOException, InterruptedException {

         ServiceReference sr = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), "FooProvider-2");

         assertNotNull("Check the availability of the FS service", sr);

 

@@ -293,7 +287,7 @@
 

         assertEquals("Check intProp equality", intProp, new Integer(4));

         assertEquals("Check longProp equality", longProp, new Long(42));

-        assertEquals("Check strProp equality", strProp, new String("bar"));

+        assertEquals("Check strProp equality", strProp, "bar");

 

         assertNotNull("Check strAProp not nullity", strAProp);

         String[] v = new String[]{"bar", "foo"};

@@ -310,20 +304,19 @@
             }

         }

 

+        ConfigurationAdmin admin = osgiHelper.getServiceObject(ConfigurationAdmin.class);

+        Configuration configuration = admin.getConfiguration("FooProvider-2", "?");

+

         // Reconfiguration

-        ServiceReference fact_ref = ipojoHelper.getServiceReferenceByName(ManagedServiceFactory.class.getName(), "PS-FooProviderType-2");

-        Dictionary reconf = new Properties();

-        reconf.put("int", new Integer(5));

-        reconf.put("long", new Long(43));

-        reconf.put("string", new String("toto"));

+        Properties reconf = new Properties();

+        reconf.put("int", 5);

+        reconf.put("long", (long) 43);

+        reconf.put("string", "toto");

         reconf.put("strAProp", new String[]{"foo", "baz"});

         reconf.put("intAProp", new int[]{3, 2, 1});

-        ManagedServiceFactory fact = (ManagedServiceFactory) osgiHelper.getServiceObject(fact_ref);

-        try {

-            fact.updated("FooProvider-2", reconf);

-        } catch (ConfigurationException e) {

-            fail("Configuration non acceptable : " + reconf);

-        }

+

+        configuration.update(reconf);

+        Thread.sleep(200);

 

         // Check service properties after the reconfiguration

         intProp = (Integer) sr.getProperty("int");

@@ -334,7 +327,7 @@
 

         assertEquals("Check intProp equality after reconfiguration", intProp, new Integer(5));

         assertEquals("Check longProp equality after reconfiguration", longProp, new Long(43));

-        assertEquals("Check strProp equality after reconfiguration", strProp, new String("toto"));

+        assertEquals("Check strProp equality after reconfiguration", strProp, "toto");

         assertNotNull("Check strAProp not nullity after reconfiguration", strAProp);

         v = new String[]{"foo", "baz"};

         for (int i = 0; i < strAProp.length; i++) {