You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by cl...@apache.org on 2013/05/05 15:55:10 UTC

svn commit: r1479322 [2/5] - in /felix/trunk/ipojo/runtime: core-it/ core-it/src/it/ipojo-core-annotations-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/annotations/ core-it/src/it/ipojo-core-configuration-admin-test/src/test/java/org/apa...

Modified: felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-admin-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestManagedServiceFactoryTestForServices.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-admin-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestManagedServiceFactoryTestForServices.java?rev=1479322&r1=1479321&r2=1479322&view=diff
==============================================================================
--- felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-admin-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestManagedServiceFactoryTestForServices.java (original)
+++ felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-admin-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestManagedServiceFactoryTestForServices.java Sun May  5 13:55:09 2013
@@ -23,13 +23,10 @@ import org.apache.felix.ipojo.ComponentF
 import org.apache.felix.ipojo.PrimitiveInstanceDescription;
 import org.apache.felix.ipojo.architecture.Architecture;
 import org.apache.felix.ipojo.runtime.core.services.FooService;
-import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
-import org.osgi.framework.InvalidSyntaxException;
 import org.osgi.framework.ServiceReference;
 import org.osgi.service.cm.Configuration;
-import org.osgi.service.cm.ConfigurationAdmin;
 
 import java.io.IOException;
 import java.util.Dictionary;
@@ -41,40 +38,10 @@ import static org.junit.Assert.*;
 public class TestManagedServiceFactoryTestForServices extends Common {
 
     private ComponentFactory factory;
-    private ConfigurationAdmin admin;
 
     @Before
     public void setUp() {
         factory = (ComponentFactory) ipojoHelper.getFactory("CA-ConfigurableProvider");
-        admin = (ConfigurationAdmin) osgiHelper.getServiceObject(ConfigurationAdmin.class.getName(), null);
-        assertNotNull("Check configuration admin availability", admin);
-        try {
-            Configuration[] configurations = admin.listConfigurations("(service.factoryPid=CA-ConfigurableProvider)");
-            for (int i = 0; configurations != null && i < configurations.length; i++) {
-                configurations[i].delete();
-            }
-        } catch (IOException e) {
-            e.printStackTrace();
-        } catch (InvalidSyntaxException e) {
-            e.printStackTrace();
-        }
-    }
-
-    @After
-    public void tearDown() {
-        try {
-            Configuration[] configurations = admin.listConfigurations("(service.factoryPid=CA-ConfigurableProvider)");
-            for (int i = 0; configurations != null && i < configurations.length; i++) {
-                configurations[i].delete();
-            }
-        } catch (IOException e) {
-            e.printStackTrace();
-        } catch (InvalidSyntaxException e) {
-            e.printStackTrace();
-        }
-        admin = null;
-
-
     }
 
     @Test
@@ -124,12 +91,7 @@ public class TestManagedServiceFactoryTe
 
 
         // Wait for the processing of the first configuration.
-        try {
-            Thread.sleep(UPDATE_WAIT_TIME);
-        } catch (InterruptedException e1) {
-            fail(e1.getMessage());
-        }
-
+        grace();
 
         Dictionary p2 = configuration.getProperties();
         p2.put("message", "message2");
@@ -138,7 +100,7 @@ public class TestManagedServiceFactoryTe
 
             configuration.update(p2);
             // Update the configuration ...
-            Thread.sleep(UPDATE_WAIT_TIME);
+            grace();
         } catch (Exception e) {
             fail(e.getMessage());
         }
@@ -157,7 +119,7 @@ public class TestManagedServiceFactoryTe
 
         try {
             configuration.delete();
-            Thread.sleep(UPDATE_WAIT_TIME);
+            grace();
         } catch (Exception e) {
             fail(e.getMessage());
         }
@@ -196,17 +158,13 @@ public class TestManagedServiceFactoryTe
         assertEquals("Check no object", 0, ((PrimitiveInstanceDescription) architecture.getInstanceDescription()).getCreatedObjects().length);
 
         // Wait for the processing of the first configuration.
-        try {
-            Thread.sleep(UPDATE_WAIT_TIME);
-        } catch (InterruptedException e1) {
-            fail(e1.getMessage());
-        }
+        grace();
 
         props.put("message", "message2");
         try {
             configuration.update(props);
             // Update the configuration ...
-            Thread.sleep(UPDATE_WAIT_TIME);
+            grace();
         } catch (Exception e) {
             fail(e.getMessage());
         }
@@ -228,7 +186,7 @@ public class TestManagedServiceFactoryTe
 
         try {
             configuration.delete();
-            Thread.sleep(UPDATE_WAIT_TIME);
+            grace();
         } catch (Exception e) {
             fail(e.getMessage());
         }
@@ -284,11 +242,7 @@ public class TestManagedServiceFactoryTe
         assertEquals("Check 1 object", 1, ((PrimitiveInstanceDescription) architecture.getInstanceDescription()).getCreatedObjects().length);
 
         // Wait for the processing of the first configuration.
-        try {
-            Thread.sleep(UPDATE_WAIT_TIME);
-        } catch (InterruptedException e1) {
-            fail(e1.getMessage());
-        }
+        grace();
 
         System.out.println("===");
 
@@ -296,7 +250,7 @@ public class TestManagedServiceFactoryTe
         try {
             configuration.update(props);
             // Update the configuration ...
-            Thread.sleep(UPDATE_WAIT_TIME);
+            grace();
         } catch (Exception e) {
             fail(e.getMessage());
         }
@@ -315,7 +269,7 @@ public class TestManagedServiceFactoryTe
 
         try {
             configuration.delete();
-            Thread.sleep(UPDATE_WAIT_TIME);
+            grace();
         } catch (Exception e) {
             fail(e.getMessage());
         }
@@ -361,17 +315,13 @@ public class TestManagedServiceFactoryTe
         assertEquals("Check no object", 0, ((PrimitiveInstanceDescription) architecture.getInstanceDescription()).getCreatedObjects().length);
 
         // Wait for the processing of the first configuration.
-        try {
-            Thread.sleep(UPDATE_WAIT_TIME);
-        } catch (InterruptedException e1) {
-            fail(e1.getMessage());
-        }
+        grace();
 
         props.put("message", "message2");
         try {
             configuration.update(props);
             // Update the configuration ...
-            Thread.sleep(UPDATE_WAIT_TIME);
+            grace();
         } catch (Exception e) {
             fail(e.getMessage());
         }
@@ -393,7 +343,7 @@ public class TestManagedServiceFactoryTe
 
         try {
             configuration.delete();
-            Thread.sleep(UPDATE_WAIT_TIME);
+            grace();
         } catch (Exception e) {
             fail(e.getMessage());
         }

Modified: felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-admin-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestManagedServiceTestForImmediate.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-admin-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestManagedServiceTestForImmediate.java?rev=1479322&r1=1479321&r2=1479322&view=diff
==============================================================================
--- felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-admin-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestManagedServiceTestForImmediate.java (original)
+++ felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-admin-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestManagedServiceTestForImmediate.java Sun May  5 13:55:09 2013
@@ -24,10 +24,8 @@ import org.apache.felix.ipojo.ComponentI
 import org.apache.felix.ipojo.PrimitiveInstanceDescription;
 import org.apache.felix.ipojo.architecture.Architecture;
 import org.apache.felix.ipojo.runtime.core.services.FooService;
-import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
-import org.osgi.framework.InvalidSyntaxException;
 import org.osgi.framework.ServiceReference;
 import org.osgi.service.cm.Configuration;
 import org.osgi.service.cm.ConfigurationAdmin;
@@ -47,37 +45,9 @@ public class TestManagedServiceTestForIm
 
     private ComponentFactory factImm;
 
-    private ConfigurationAdmin admin;
-
-    ConfigurationMonitor listener;
-
     @Before
     public void setUp() throws InterruptedException {
         factImm = (ComponentFactory) ipojoHelper.getFactory(factNameImm);
-        admin = (ConfigurationAdmin) osgiHelper.getServiceObject(ConfigurationAdmin.class.getName(), null);
-        assertNotNull("Check configuration admin availability", admin);
-        cleanConfigurationAdmin();
-        listener = new ConfigurationMonitor(bc);
-    }
-
-    @After
-    public void tearDown() {
-        listener.stop();
-        cleanConfigurationAdmin();
-        admin = null;
-    }
-
-    private void cleanConfigurationAdmin() {
-        try {
-            Configuration[] configurations = admin.listConfigurations("(service.pid=" + msp + ")");
-            for (int i = 0; configurations != null && i < configurations.length; i++) {
-                configurations[i].delete();
-            }
-        } catch (IOException e) {
-            e.printStackTrace();
-        } catch (InvalidSyntaxException e) {
-            e.printStackTrace();
-        }
     }
 
     @Test
@@ -116,7 +86,7 @@ public class TestManagedServiceTestForIm
             prc.put("message", "message2");
             configuration.update(prc);
             System.err.println("updated ? ");
-            Thread.sleep(UPDATE_WAIT_TIME);
+            grace();
         } catch (Exception e) {
             fail(e.getMessage());
         }
@@ -134,7 +104,6 @@ public class TestManagedServiceTestForIm
         assertEquals("Check count", 2, count);
 
         instance.dispose();
-        cleanConfigurationAdmin();
     }
 
     /**
@@ -146,7 +115,6 @@ public class TestManagedServiceTestForIm
     public void testCreationUsingFactoryConfigurationSettingTheManagedServicePid() {
         Configuration conf = null;
         try {
-            //TODO test multi-location:?
             conf = admin.createFactoryConfiguration(factNameImm, getTestBundle().getLocation());
             Dictionary props = conf.getProperties();
             if (props == null) {
@@ -155,7 +123,7 @@ public class TestManagedServiceTestForIm
             props.put("managed.service.pid", msp);
             props.put("message", "message");
             conf.update(props);
-            Thread.sleep(UPDATE_WAIT_TIME); // Wait for the creation.
+            grace();
         } catch (Exception e) {
             fail(e.getMessage());
         }
@@ -186,7 +154,7 @@ public class TestManagedServiceTestForIm
             }
             prc.put("message", "message2");
             configuration.update(prc);
-            Thread.sleep(UPDATE_WAIT_TIME);
+            grace();
         } catch (Exception e) {
             fail(e.getMessage());
         }
@@ -212,6 +180,7 @@ public class TestManagedServiceTestForIm
 
         try {
             conf.delete();
+            grace();
         } catch (IOException e) {
             fail(e.getMessage());
         }
@@ -232,7 +201,7 @@ public class TestManagedServiceTestForIm
             }
             prc.put("message", "message2");
             configuration.update(prc);
-            Thread.sleep(UPDATE_WAIT_TIME);
+            grace();
         } catch (Exception e) {
             fail(e.getMessage());
         }
@@ -243,7 +212,7 @@ public class TestManagedServiceTestForIm
         ComponentInstance instance = null;
         try {
             instance = factImm.createComponentInstance(props);
-            Thread.sleep(UPDATE_WAIT_TIME);
+            grace();
         } catch (Exception e) {
             fail(e.getMessage());
         }
@@ -272,7 +241,7 @@ public class TestManagedServiceTestForIm
             }
             prc.put("message", "message3");
             configuration.update(prc);
-            Thread.sleep(UPDATE_WAIT_TIME);
+            grace();
         } catch (Exception e) {
             fail(e.getMessage());
         }
@@ -284,7 +253,7 @@ public class TestManagedServiceTestForIm
         instance = null;
         try {
             instance = factImm.createComponentInstance(props);
-            Thread.sleep(UPDATE_WAIT_TIME * 2);
+            grace();
         } catch (Exception e) {
             fail(e.getMessage());
         }
@@ -319,8 +288,9 @@ public class TestManagedServiceTestForIm
             }
             prc.put("message", "message2");
             configuration.update(prc);
-            Thread.sleep(UPDATE_WAIT_TIME);
+            grace();
         } catch (Exception e) {
+            e.printStackTrace();
             fail(e.getMessage());
         }
 
@@ -330,7 +300,7 @@ public class TestManagedServiceTestForIm
         ComponentInstance instance = null;
         try {
             instance = factImm.createComponentInstance(props);
-            Thread.sleep(UPDATE_WAIT_TIME);
+            grace();
         } catch (Exception e) {
             fail(e.getMessage());
         }
@@ -356,8 +326,7 @@ public class TestManagedServiceTestForIm
             }
             prc.put("message", "message3");
             configuration.update(prc);
-            //Thread.sleep(UPDATE_WAIT_TIME);
-            Thread.sleep(UPDATE_WAIT_TIME);
+            grace();
         } catch (Exception e) {
             fail(e.getMessage());
         }

Modified: felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-admin-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestManagedServiceTestForService.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-admin-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestManagedServiceTestForService.java?rev=1479322&r1=1479321&r2=1479322&view=diff
==============================================================================
--- felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-admin-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestManagedServiceTestForService.java (original)
+++ felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-admin-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestManagedServiceTestForService.java Sun May  5 13:55:09 2013
@@ -24,10 +24,8 @@ import org.apache.felix.ipojo.ComponentI
 import org.apache.felix.ipojo.PrimitiveInstanceDescription;
 import org.apache.felix.ipojo.architecture.Architecture;
 import org.apache.felix.ipojo.runtime.core.services.FooService;
-import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
-import org.osgi.framework.InvalidSyntaxException;
 import org.osgi.framework.ServiceReference;
 import org.osgi.service.cm.Configuration;
 import org.osgi.service.cm.ConfigurationAdmin;
@@ -44,40 +42,11 @@ public class TestManagedServiceTestForSe
 
     private String factNameSvc = "CA-ConfigurableProvider";
     private String msp = "foo";
-
     private ComponentFactory factSvc;
 
-    private ConfigurationAdmin admin;
-
-    ConfigurationMonitor listener;
-
     @Before
     public void setUp() {
         factSvc = (ComponentFactory) ipojoHelper.getFactory(factNameSvc);
-        admin = (ConfigurationAdmin) osgiHelper.getServiceObject(ConfigurationAdmin.class.getName(), null);
-        assertNotNull("Check configuration admin availability", admin);
-        cleanConfigurationAdmin();
-        listener = new ConfigurationMonitor(bc);
-    }
-
-    @After
-    public void tearDown() {
-        listener.stop();
-        cleanConfigurationAdmin();
-        admin = null;
-    }
-
-    private void cleanConfigurationAdmin() {
-        try {
-            Configuration[] configurations = admin.listConfigurations("(service.pid=" + msp + ")");
-            for (int i = 0; configurations != null && i < configurations.length; i++) {
-                configurations[i].delete();
-            }
-        } catch (IOException e) {
-            e.printStackTrace();
-        } catch (InvalidSyntaxException e) {
-            e.printStackTrace();
-        }
     }
 
     @Test
@@ -114,7 +83,7 @@ public class TestManagedServiceTestForSe
             }
             prc.put("message", "message2");
             configuration.update(prc);
-            Thread.sleep(UPDATE_WAIT_TIME);
+            grace();
         } catch (Exception e) {
             fail(e.getMessage());
         }
@@ -152,7 +121,7 @@ public class TestManagedServiceTestForSe
             props.put("managed.service.pid", msp);
             props.put("message", "message");
             conf.update(props);
-            Thread.sleep(UPDATE_WAIT_TIME); // Wait for the creation.
+            grace();
         } catch (Exception e) {
             fail(e.getMessage());
         }
@@ -182,7 +151,7 @@ public class TestManagedServiceTestForSe
             }
             prc.put("message", "message2");
             configuration.update(prc);
-            Thread.sleep(UPDATE_WAIT_TIME);
+            grace();
         } catch (Exception e) {
             fail(e.getMessage());
         }
@@ -229,7 +198,7 @@ public class TestManagedServiceTestForSe
             prc.put("message", "message2");
             configuration.update(prc);
             //listener.waitForEvent(msp, "1");
-            Thread.sleep(UPDATE_WAIT_TIME);
+            grace();
         } catch (Exception e) {
             fail(e.getMessage());
         }
@@ -240,7 +209,7 @@ public class TestManagedServiceTestForSe
         ComponentInstance instance = null;
         try {
             instance = factSvc.createComponentInstance(props);
-            Thread.sleep(UPDATE_WAIT_TIME);
+            grace();
         } catch (Exception e) {
             fail(e.getMessage());
         }
@@ -268,7 +237,7 @@ public class TestManagedServiceTestForSe
             }
             prc.put("message", "message3");
             configuration.update(prc);
-            listener.waitForEvent(msp, "2");
+            grace();
         } catch (Exception e) {
             fail(e.getMessage());
         }
@@ -280,7 +249,7 @@ public class TestManagedServiceTestForSe
         instance = null;
         try {
             instance = factSvc.createComponentInstance(props);
-            Thread.sleep(UPDATE_WAIT_TIME);
+            grace();
         } catch (Exception e) {
             fail(e.getMessage());
         }
@@ -316,7 +285,7 @@ public class TestManagedServiceTestForSe
             }
             prc.put("message", "message2");
             configuration.update(prc);
-            Thread.sleep(UPDATE_WAIT_TIME);
+            grace();
         } catch (Exception e) {
             fail(e.getMessage());
         }
@@ -327,7 +296,7 @@ public class TestManagedServiceTestForSe
         ComponentInstance instance = null;
         try {
             instance = factSvc.createComponentInstance(props);
-            Thread.sleep(UPDATE_WAIT_TIME);
+            grace();
         } catch (Exception e) {
             fail(e.getMessage());
         }
@@ -353,7 +322,7 @@ public class TestManagedServiceTestForSe
             }
             prc.put("message", "message3");
             configuration.update(prc);
-            Thread.sleep(UPDATE_WAIT_TIME);
+            grace();
         } catch (Exception e) {
             fail(e.getMessage());
         }
@@ -367,7 +336,7 @@ public class TestManagedServiceTestForSe
         instance = null;
         try {
             instance = factSvc.createComponentInstance(props);
-            Thread.sleep(UPDATE_WAIT_TIME);
+            grace();
         } catch (Exception e) {
             fail(e.getMessage());
         }

Modified: felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/Common.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/Common.java?rev=1479322&r1=1479321&r2=1479322&view=diff
==============================================================================
--- felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/Common.java (original)
+++ felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/Common.java Sun May  5 13:55:09 2013
@@ -19,331 +19,27 @@
 
 package org.apache.felix.ipojo.runtime.core;
 
-import ch.qos.logback.classic.Level;
-import ch.qos.logback.classic.Logger;
-import org.apache.commons.io.FileUtils;
-import org.apache.commons.io.filefilter.TrueFileFilter;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.runner.RunWith;
-import org.ops4j.pax.exam.Configuration;
-import org.ops4j.pax.exam.CoreOptions;
-import org.ops4j.pax.exam.Option;
-import org.ops4j.pax.exam.junit.PaxExam;
-import org.ops4j.pax.exam.options.CompositeOption;
-import org.ops4j.pax.exam.options.DefaultCompositeOption;
-import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
-import org.ops4j.pax.exam.spi.reactors.PerMethod;
-import org.ops4j.pax.tinybundles.core.TinyBundle;
-import org.ops4j.pax.tinybundles.core.TinyBundles;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.Constants;
-import org.osgi.framework.ServiceReference;
-import org.ow2.chameleon.testing.helpers.IPOJOHelper;
-import org.ow2.chameleon.testing.helpers.OSGiHelper;
-import org.ow2.chameleon.testing.tinybundles.ipojo.IPOJOStrategy;
-import org.slf4j.LoggerFactory;
+import org.ow2.chameleon.testing.helpers.BaseTest;
 
-import javax.inject.Inject;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Collection;
+import java.util.Arrays;
 import java.util.List;
 
-import static junit.framework.Assert.fail;
-import static org.ops4j.pax.exam.CoreOptions.*;
+public class Common extends BaseTest {
 
-/**
- * Bootstrap the test from this project
- */
-@RunWith(PaxExam.class)
-@ExamReactorStrategy(PerMethod.class)
-public class Common {
-
-    @Inject
-    protected
-    BundleContext bc;
-    protected OSGiHelper osgiHelper;
-    protected IPOJOHelper ipojoHelper;
-    protected boolean deployTestedBundle = true;
-
-    public static Option junitAndMockitoBundles() {
-        return new DefaultCompositeOption(
-                // Repository required to load harmcrest (OSGi-fied version).
-                repository("http://repository.springsource.com/maven/bundles/external").id(
-                        "com.springsource.repository.bundles.external"),
-
-                // Mockito without Hamcrest and Objenesis
-                mavenBundle("org.mockito", "mockito-core", "1.9.5"),
-
-                // Hamcrest with a version matching the range expected by Mockito
-                mavenBundle("org.hamcrest", "com.springsource.org.hamcrest.core", "1.1.0"),
-
-                // Objenesis with a version matching the range expected by Mockito
-                wrappedBundle(mavenBundle("org.objenesis", "objenesis", "1.2"))
-                        .exports("*;version=1.2"),
-
-                // The default JUnit bundle also exports Hamcrest, but with an (incorrect) version of
-                // 4.9 which does not match the Mockito import.
-                CoreOptions.junitBundles(),
-
-                /*
-                 * Felix has implicit boot delegation enabled by default. It conflicts with Mockito:
-                 * java.lang.LinkageError: loader constraint violation in interface itable initialization:
-                 * when resolving method "org.osgi.service.useradmin.User$$EnhancerByMockitoWithCGLIB$$dd2f81dc
-                 * .newInstance(Lorg/mockito/cglib/proxy/Callback;)Ljava/lang/Object;" the class loader
-                 * (instance of org/mockito/internal/creation/jmock/SearchingClassLoader) of the current class,
-                 * org/osgi/service/useradmin/User$$EnhancerByMockitoWithCGLIB$$dd2f81dc, and the class loader
-                 * (instance of org/apache/felix/framework/BundleWiringImpl$BundleClassLoaderJava5) for interface
-                 * org/mockito/cglib/proxy/Factory have different Class objects for the type org/mockito/cglib/
-                 * proxy/Callback used in the signature
-                 *
-                 * So we disable the bootdelegation.
-                 */
-                frameworkProperty("felix.bootdelegation.implicit").value("false")
-        );
+    @Override
+    public boolean deployConfigAdmin() {
+        return true;
     }
 
-    public static void dump(BundleContext bc, File output) throws IOException {
-        if (!output.exists()) {
-            output.mkdirs();
-        }
-
-        for (Bundle bundle : bc.getBundles()) {
-            if (bundle.getBundleId() == 0) {
-                continue;
-            }
-            System.out.println("Location : " + bundle.getLocation());
-            if ("local".equals(bundle.getLocation())) {
-                continue; // Pax Exam, when you hug me, I feel so...
-            }
-            URL location = new URL(bundle.getLocation());
-            FileOutputStream outputStream = null;
-            if (bundle.getVersion() != null) {
-                outputStream = new FileOutputStream(new File(output,
-                        bundle.getSymbolicName() + "-" + bundle.getVersion().toString() + ".jar"));
-            } else {
-                outputStream = new FileOutputStream(new File(output, bundle.getSymbolicName() + ".jar"));
-            }
-
-            int read = 0;
-            byte[] bytes = new byte[1024];
-
-            InputStream inputStream = location.openStream();
-            while ((read = inputStream.read(bytes)) != -1) {
-                outputStream.write(bytes, 0, read);
-            }
-            inputStream.close();
-            outputStream.close();
-        }
-    }
-
-    @Configuration
-    public Option[] config() throws IOException {
-        Logger root = (Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
-        root.setLevel(Level.INFO);
-
-        if (deployTestedBundle) {
-            return options(
-                    cleanCaches(),
-                    ipojoBundles(),
-                    junitBundles(),
-                    testedBundle(),
-                    systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value("WARN")
-            );
-        } else {
-            return options(
-                    cleanCaches(),
-                    ipojoBundles(),
-                    junitBundles(),
-                    systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value("WARN")
-            );
-        }
-    }
-
-    @Before
-    public void commonSetUp() {
-        osgiHelper = new OSGiHelper(bc);
-        ipojoHelper = new IPOJOHelper(bc);
-
-        // Dump OSGi Framework information
-        String vendor = (String) osgiHelper.getBundle(0).getHeaders().get(Constants.BUNDLE_VENDOR);
-        if (vendor == null) {
-            vendor = (String) osgiHelper.getBundle(0).getHeaders().get(Constants.BUNDLE_SYMBOLICNAME);
-        }
-        String version = (String) osgiHelper.getBundle(0).getHeaders().get(Constants.BUNDLE_VERSION);
-        System.out.println("OSGi Framework : " + vendor + " - " + version);
-
-        waitForStability(bc);
-    }
-
-    @After
-    public void commonTearDown() {
-        ipojoHelper.dispose();
-        osgiHelper.dispose();
-    }
-
-    public CompositeOption ipojoBundles() {
-        return new DefaultCompositeOption(
-                mavenBundle("org.apache.felix", "org.apache.felix.ipojo").versionAsInProject(),
-                mavenBundle("org.ow2.chameleon.testing", "osgi-helpers").versionAsInProject(),
-                // harmcrest-all
-                //mavenBundle("de.twentyeleven.skysail", "org.hamcrest.hamcrest-all-osgi").versionAsInProject(),
-                // configuration admin
-                mavenBundle("org.apache.felix", "org.apache.felix.configadmin").versionAsInProject()
+    @Override
+    protected List<String> getExtraExports() {
+        return Arrays.asList(
+                "org.apache.felix.ipojo.runtime.core.components"
         );
     }
 
-    public Option testedBundle() throws MalformedURLException {
-        File out = new File("target/tested/bundle.jar");
-        if (out.exists()) {
-            return bundle(out.toURI().toURL().toExternalForm());
-        }
-
-        TinyBundle tested = TinyBundles.bundle();
-
-        // We look inside target/classes to find the class and resources
-        File classes = new File("target/classes");
-        Collection<File> files = FileUtils.listFilesAndDirs(classes, TrueFileFilter.INSTANCE, TrueFileFilter.INSTANCE);
-        List<File> services = new ArrayList<File>();
-        for (File file : files) {
-            if (file.isDirectory()) {
-                // By convention we export of .services and .service package
-                if (file.getName().endsWith("services") || file.getName().endsWith("service")) {
-                    services.add(file);
-                }
-            } else {
-                // We need to compute the path
-                String path = file.getAbsolutePath().substring(classes.getAbsolutePath().length() + 1);
-                tested.add(path, file.toURI().toURL());
-                System.out.println(file.getName() + " added to " + path);
-            }
-        }
-
-        // Export the inherited package, components and strategies
-        String export = "org.apache.felix.ipojo.runtime.core.components.inherited";
-        export += ", org.apache.felix.ipojo.runtime.core.components";
-        export += ", org.apache.felix.ipojo.runtime.core.components.strategies";
-        // Inheritance.
-        export += ", org.apache.felix.ipojo.runtime.core.components.inheritance.a";
-        export += ", org.apache.felix.ipojo.runtime.core.components.inheritance.b";
-        for (File file : services) {
-            if (export.length() > 0) {
-                export += ", ";
-            }
-            String path = file.getAbsolutePath().substring(classes.getAbsolutePath().length() + 1);
-            String packageName = path.replace('/', '.');
-            export += packageName;
-        }
-
-        System.out.println("Exported packages : " + export);
-
-        InputStream inputStream = tested
-                .set(Constants.BUNDLE_SYMBOLICNAME, "test.bundle")
-                .set(Constants.IMPORT_PACKAGE, "*")
-                .set(Constants.EXPORT_PACKAGE, export)
-                .build(IPOJOStrategy.withiPOJO(new File("src/main/resources")));
-
-        try {
-            org.apache.commons.io.FileUtils.copyInputStreamToFile(inputStream, out);
-            return bundle(out.toURI().toURL().toExternalForm());
-        } catch (MalformedURLException e) {
-            throw new RuntimeException("Cannot compute the url of the manipulated bundle");
-        } catch (IOException e) {
-            throw new RuntimeException("Cannot write of the manipulated bundle");
-        }
-    }
-
-    public void assertContains(String s, String[] arrays, String object) {
-        for (String suspect : arrays) {
-            if (object.equals(suspect)) {
-                return;
-            }
-        }
-        fail("Assertion failed : " + s);
-    }
-
-    /**
-     * Waits for stability:
-     * <ul>
-     * <li>all bundles are activated
-     * <li>service count is stable
-     * </ul>
-     * If the stability can't be reached after a specified time,
-     * the method throws a {@link IllegalStateException}.
-     *
-     * @param context the bundle context
-     * @throws IllegalStateException when the stability can't be reach after a several attempts.
-     */
-    private void waitForStability(BundleContext context) throws IllegalStateException {
-        // Wait for bundle initialization.
-        boolean bundleStability = getBundleStability(context);
-        int count = 0;
-        while (!bundleStability && count < 500) {
-            try {
-                Thread.sleep(5);
-            } catch (InterruptedException e) {
-                // Interrupted
-            }
-            count++;
-            bundleStability = getBundleStability(context);
-        }
-
-        if (count == 500) {
-            System.err.println("Bundle stability isn't reached after 500 tries");
-            throw new IllegalStateException("Cannot reach the bundle stability");
-        }
-
-        boolean serviceStability = false;
-        count = 0;
-        int count1 = 0;
-        int count2 = 0;
-        while (!serviceStability && count < 500) {
-            try {
-                ServiceReference[] refs = context.getServiceReferences((String) null, null);
-                count1 = refs.length;
-                Thread.sleep(500);
-                refs = context.getServiceReferences((String) null, null);
-                count2 = refs.length;
-                serviceStability = count1 == count2;
-            } catch (Exception e) {
-                System.err.println(e);
-                serviceStability = false;
-                // Nothing to do, while recheck the condition
-            }
-            count++;
-        }
-
-        if (count == 500) {
-            System.err.println("Service stability isn't reached after 500 tries (" + count1 + " != " + count2);
-            throw new IllegalStateException("Cannot reach the service stability");
-        }
-    }
-
-    /**
-     * Are bundle stables.
-     *
-     * @param bc the bundle context
-     * @return <code>true</code> if every bundles are activated.
-     */
-    private boolean getBundleStability(BundleContext bc) {
-        boolean stability = true;
-        Bundle[] bundles = bc.getBundles();
-        for (Bundle bundle : bundles) {
-            stability = stability && (bundle.getState() == Bundle.ACTIVE);
-        }
-        return stability;
-    }
-
-    public boolean isKF() {
-        return bc.getClass().toString().contains("knopflerfish");
+    @Override
+    public boolean deployTestBundle() {
+        return false;
     }
-
-
 }

Modified: felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestComplexConfigurations.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestComplexConfigurations.java?rev=1479322&r1=1479321&r2=1479322&view=diff
==============================================================================
--- felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestComplexConfigurations.java (original)
+++ felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestComplexConfigurations.java Sun May  5 13:55:09 2013
@@ -50,7 +50,6 @@ public class TestComplexConfigurations e
 
     @Configuration
     public Option[] config() throws IOException {
-        deployTestedBundle = false;
         Option[] options = super.config();
 
         // Build a service bundle
@@ -90,7 +89,7 @@ public class TestComplexConfigurations e
      */
     @Test
     public void testDynamism() throws BundleException {
-        if (isKF()) {
+        if (isKnopflerfish()) {
             return; // Test disabled on KF
         }
         //1)
@@ -118,7 +117,7 @@ public class TestComplexConfigurations e
 
     @Test
     public void testConfiguration() {
-        if (isKF()) {
+        if (isKnopflerfish()) {
             return; // Test disabled on KF
         }
         osgiHelper.waitForService(FooService.class, null, 10000);

Modified: felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestConfigurationInAnotherBundle.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestConfigurationInAnotherBundle.java?rev=1479322&r1=1479321&r2=1479322&view=diff
==============================================================================
--- felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestConfigurationInAnotherBundle.java (original)
+++ felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestConfigurationInAnotherBundle.java Sun May  5 13:55:09 2013
@@ -44,7 +44,7 @@ public class TestConfigurationInAnotherB
 
     @Configuration
     public Option[] config() throws IOException {
-        deployTestedBundle = false;
+
         Option[] options = super.config();
 
         // Build a service bundle
@@ -82,7 +82,7 @@ public class TestConfigurationInAnotherB
      */
     @Test
     public void testDynamism() throws BundleException {
-        if (isKF()) {
+        if (isKnopflerfish()) {
             return; // Test disabled on KF
         }
         //1)

Modified: felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestConfigurationOfMyComponent.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestConfigurationOfMyComponent.java?rev=1479322&r1=1479321&r2=1479322&view=diff
==============================================================================
--- felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestConfigurationOfMyComponent.java (original)
+++ felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestConfigurationOfMyComponent.java Sun May  5 13:55:09 2013
@@ -43,7 +43,7 @@ public class TestConfigurationOfMyCompon
 
     @Configuration
     public Option[] config() throws IOException {
-        deployTestedBundle = false;
+
         Option[] options = super.config();
 
         // Build a service bundle
@@ -67,7 +67,7 @@ public class TestConfigurationOfMyCompon
 
     @Test
     public void testConfiguration() throws IOException {
-        if (isKF()) {
+        if (isKnopflerfish()) {
             return; // Test disabled on KF
         }
 

Modified: felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestConfigurationOfThreeInstancesUsingMethods.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestConfigurationOfThreeInstancesUsingMethods.java?rev=1479322&r1=1479321&r2=1479322&view=diff
==============================================================================
--- felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestConfigurationOfThreeInstancesUsingMethods.java (original)
+++ felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestConfigurationOfThreeInstancesUsingMethods.java Sun May  5 13:55:09 2013
@@ -47,7 +47,7 @@ public class TestConfigurationOfThreeIns
 
     @Configuration
     public Option[] config() throws IOException {
-        deployTestedBundle = false;
+
         Option[] options = super.config();
 
         // Build a service bundle
@@ -71,7 +71,7 @@ public class TestConfigurationOfThreeIns
 
     @Test
     public void testConfiguration() {
-        if (isKF()) {
+        if (isKnopflerfish()) {
             return; // Test disabled on KF
         }
 

Modified: felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestConfigurationOfTwoInstances.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestConfigurationOfTwoInstances.java?rev=1479322&r1=1479321&r2=1479322&view=diff
==============================================================================
--- felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestConfigurationOfTwoInstances.java (original)
+++ felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestConfigurationOfTwoInstances.java Sun May  5 13:55:09 2013
@@ -46,7 +46,7 @@ public class TestConfigurationOfTwoInsta
 
     @Configuration
     public Option[] config() throws IOException {
-        deployTestedBundle = false;
+
         Option[] options = super.config();
 
         // Build a service bundle
@@ -70,7 +70,7 @@ public class TestConfigurationOfTwoInsta
 
     @Test
     public void testConfiguration() {
-        if (isKF()) {
+        if (isKnopflerfish()) {
             return; // Test disabled on KF
         }
 

Modified: felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestConfigurationWithInheritedInstance.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestConfigurationWithInheritedInstance.java?rev=1479322&r1=1479321&r2=1479322&view=diff
==============================================================================
--- felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestConfigurationWithInheritedInstance.java (original)
+++ felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestConfigurationWithInheritedInstance.java Sun May  5 13:55:09 2013
@@ -47,7 +47,7 @@ public class TestConfigurationWithInheri
 
     @Configuration
     public Option[] config() throws IOException {
-        deployTestedBundle = false;
+
         Option[] options = super.config();
 
         // Build a service bundle
@@ -72,7 +72,7 @@ public class TestConfigurationWithInheri
 
     @Test
     public void testConfiguration() {
-        if (isKF()) {
+        if (isKnopflerfish()) {
             return; // Test disabled on KF
         }
 

Modified: felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestConfigurationWithOverriddenInstance.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestConfigurationWithOverriddenInstance.java?rev=1479322&r1=1479321&r2=1479322&view=diff
==============================================================================
--- felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestConfigurationWithOverriddenInstance.java (original)
+++ felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestConfigurationWithOverriddenInstance.java Sun May  5 13:55:09 2013
@@ -47,7 +47,7 @@ public class TestConfigurationWithOverri
 
     @Configuration
     public Option[] config() throws IOException {
-        deployTestedBundle = false;
+
         Option[] options = super.config();
 
         // Build a service bundle
@@ -72,7 +72,7 @@ public class TestConfigurationWithOverri
 
     @Test
     public void testConfiguration() {
-        if (isKF()) {
+        if (isKnopflerfish()) {
             return; // Test disabled on KF
         }
 

Modified: felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestEmptyConfiguration.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestEmptyConfiguration.java?rev=1479322&r1=1479321&r2=1479322&view=diff
==============================================================================
--- felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestEmptyConfiguration.java (original)
+++ felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestEmptyConfiguration.java Sun May  5 13:55:09 2013
@@ -29,6 +29,7 @@ import org.ops4j.pax.exam.Option;
 import org.ops4j.pax.exam.OptionUtils;
 import org.ops4j.pax.tinybundles.core.TinyBundles;
 import org.osgi.framework.Constants;
+import org.ow2.chameleon.testing.helpers.TimeUtils;
 import org.ow2.chameleon.testing.tinybundles.ipojo.IPOJOStrategy;
 
 import java.io.IOException;
@@ -43,7 +44,7 @@ public class TestEmptyConfiguration exte
 
     @Configuration
     public Option[] config() throws IOException {
-        deployTestedBundle = false;
+
         Option[] options = super.config();
 
         // Build a service bundle
@@ -67,7 +68,7 @@ public class TestEmptyConfiguration exte
 
     @Test
     public void testConfiguration() throws InterruptedException {
-        Thread.sleep(200);
+        TimeUtils.grace(1000);
         // Check configuration
         Assert.assertNull(osgiHelper.getServiceReference(FooService.class));
     }

Modified: felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestSeveralConfigurations.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestSeveralConfigurations.java?rev=1479322&r1=1479321&r2=1479322&view=diff
==============================================================================
--- felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestSeveralConfigurations.java (original)
+++ felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestSeveralConfigurations.java Sun May  5 13:55:09 2013
@@ -47,7 +47,7 @@ public class TestSeveralConfigurations e
 
     @Configuration
     public Option[] config() throws IOException {
-        deployTestedBundle = false;
+
         Option[] options = super.config();
 
         // Build a service bundle
@@ -72,7 +72,7 @@ public class TestSeveralConfigurations e
 
     @Test
     public void testConfiguration() {
-        if (isKF()) {
+        if (isKnopflerfish()) {
             return; // Test disabled on KF
         }
 

Modified: felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-test/src/test/java/org/apache/felix/ipojo/runtime/core/Common.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-test/src/test/java/org/apache/felix/ipojo/runtime/core/Common.java?rev=1479322&r1=1479321&r2=1479322&view=diff
==============================================================================
--- felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-test/src/test/java/org/apache/felix/ipojo/runtime/core/Common.java (original)
+++ felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-test/src/test/java/org/apache/felix/ipojo/runtime/core/Common.java Sun May  5 13:55:09 2013
@@ -19,225 +19,43 @@
 
 package org.apache.felix.ipojo.runtime.core;
 
-import ch.qos.logback.classic.Level;
-import ch.qos.logback.classic.Logger;
-import org.apache.commons.io.FileUtils;
-import org.apache.commons.io.filefilter.TrueFileFilter;
-import org.apache.felix.ipojo.runtime.core.components.*;
-import org.apache.felix.ipojo.runtime.core.services.CheckService;
-import org.apache.felix.ipojo.runtime.core.services.FooService;
 import org.junit.After;
 import org.junit.Before;
-import org.junit.runner.RunWith;
-import org.ops4j.pax.exam.Configuration;
-import org.ops4j.pax.exam.Option;
-import org.ops4j.pax.exam.junit.PaxExam;
-import org.ops4j.pax.exam.options.CompositeOption;
-import org.ops4j.pax.exam.options.DefaultCompositeOption;
-import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
-import org.ops4j.pax.exam.spi.reactors.PerClass;
-import org.ops4j.pax.tinybundles.core.TinyBundle;
-import org.ops4j.pax.tinybundles.core.TinyBundles;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.Constants;
-import org.osgi.framework.ServiceReference;
-import org.ow2.chameleon.testing.helpers.IPOJOHelper;
-import org.ow2.chameleon.testing.helpers.OSGiHelper;
-import org.ow2.chameleon.testing.tinybundles.ipojo.IPOJOStrategy;
-import org.slf4j.LoggerFactory;
-
-import javax.inject.Inject;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.MalformedURLException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-import static org.ops4j.pax.exam.CoreOptions.*;
+import org.osgi.service.cm.ConfigurationAdmin;
+import org.ow2.chameleon.testing.helpers.BaseTest;
+import org.ow2.chameleon.testing.helpers.ConfigAdminHelper;
+import org.ow2.chameleon.testing.helpers.TimeUtils;
 
 /**
  * Bootstrap the test from this project
  */
-@RunWith(PaxExam.class)
-@ExamReactorStrategy(PerClass.class)
-public class Common {
-
-    @Inject
-    BundleContext bc;
-
-    OSGiHelper osgiHelper;
-    IPOJOHelper ipojoHelper;
-
-    @Configuration
-    public Option[] config() throws MalformedURLException {
-        Logger root = (Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
-        root.setLevel(Level.INFO);
-
-        return options(
-                ipojoBundles(),
-                junitBundles(),
-                testedBundle(),
-                systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value("WARN")
-        );
-    }
+public class Common extends BaseTest {
 
-    @Before
-    public void commonSetUp() {
-        osgiHelper = new OSGiHelper(bc);
-        ipojoHelper = new IPOJOHelper(bc);
-
-        // Dump OSGi Framework information
-        String vendor = (String) osgiHelper.getBundle(0).getHeaders().get(Constants.BUNDLE_VENDOR);
-        if (vendor == null) {
-            vendor = (String) osgiHelper.getBundle(0).getHeaders().get(Constants.BUNDLE_SYMBOLICNAME);
-        }
-        String version = (String) osgiHelper.getBundle(0).getHeaders().get(Constants.BUNDLE_VERSION);
-        System.out.println("OSGi Framework : " + vendor + " - " + version);
+    public static int UPDATE_WAIT_TIME = 2000;
 
-        waitForStability(bc);
-    }
-
-    @After
-    public void commonTearDown() {
-        ipojoHelper.dispose();
-        osgiHelper.dispose();
-    }
+    public ConfigAdminHelper caHelper = null;
 
-    public CompositeOption ipojoBundles() {
-        return new DefaultCompositeOption(
-                mavenBundle("org.apache.felix", "org.apache.felix.ipojo").versionAsInProject(),
-                mavenBundle("org.ow2.chameleon.testing", "osgi-helpers").versionAsInProject(),
-                mavenBundle("org.apache.felix", "org.apache.felix.configadmin").versionAsInProject());
-    }
+    public ConfigurationAdmin admin;
 
-    public Bundle getTestBundle() {
-        return osgiHelper.getBundle("test.bundle");
+    public void grace() {
+        TimeUtils.grace(UPDATE_WAIT_TIME);
     }
 
-    public Option testedBundle() throws MalformedURLException {
-        File out = new File("target/tested/bundle.jar");
-
-        TinyBundle tested = TinyBundles.bundle();
-
-        // We look inside target/classes to find the class and resources
-        File classes = new File("target/classes");
-        Collection<File> files = FileUtils.listFilesAndDirs(classes, TrueFileFilter.INSTANCE, TrueFileFilter.INSTANCE);
-        List<File> services = new ArrayList<File>();
-        for (File file : files) {
-            if (file.isDirectory()) {
-                // By convention we export of .services and .service package
-                if (file.getName().endsWith("services")  || file.getName().endsWith("service")) {
-                    services.add(file);
-                }
-            } else {
-                // We need to compute the path
-                String path = file.getAbsolutePath().substring(classes.getAbsolutePath().length() +1);
-                tested.add(path, file.toURI().toURL());
-                System.out.println(file.getName() + " added to " + path);
-            }
-        }
-
-        String export = "";
-        for (File file : services) {
-            if (export.length() > 0) { export += ", "; }
-            String path = file.getAbsolutePath().substring(classes.getAbsolutePath().length() +1);
-            String packageName = path.replace('/', '.');
-            export += packageName;
-        }
-
-        System.out.println("Exported packages : " + export);
-
-        InputStream inputStream = tested
-                .set(Constants.BUNDLE_SYMBOLICNAME, "test.bundle")
-                .set(Constants.IMPORT_PACKAGE, "*")
-                .set(Constants.EXPORT_PACKAGE, export)
-                .build(IPOJOStrategy.withiPOJO(new File("src/main/resources")));
-
-        try {
-            org.apache.commons.io.FileUtils.copyInputStreamToFile(inputStream, out);
-            return bundle(out.toURI().toURL().toExternalForm());
-        } catch (MalformedURLException e) {
-            throw new RuntimeException("Cannot compute the url of the manipulated bundle");
-        } catch (IOException e) {
-            throw new RuntimeException("Cannot write of the manipulated bundle");
-        }
+    @Override
+    public boolean deployConfigAdmin() {
+        return true;
     }
 
-    /**
-     * Waits for stability:
-     * <ul>
-     * <li>all bundles are activated
-     * <li>service count is stable
-     * </ul>
-     * If the stability can't be reached after a specified time,
-     * the method throws a {@link IllegalStateException}.
-     * @param context the bundle context
-     * @throws IllegalStateException when the stability can't be reach after a several attempts.
-     */
-    private void waitForStability(BundleContext context) throws IllegalStateException {
-        // Wait for bundle initialization.
-        boolean bundleStability = getBundleStability(context);
-        int count = 0;
-        while (!bundleStability && count < 1000) {
-            try {
-                Thread.sleep(100);
-            } catch (InterruptedException e) {
-                // Interrupted
-            }
-            count++;
-            bundleStability = getBundleStability(context);
-        }
-
-        if (count == 1000) {
-            for (Bundle bundle : bc.getBundles()) {
-                System.out.println("Bundle " + bundle.getSymbolicName() + " - " + bundle.getState());
-            }
-            System.err.println("Bundle stability isn't reached after 1000 tries");
-            throw new IllegalStateException("Cannot reach the bundle stability");
-        }
-
-        boolean serviceStability = false;
-        count = 0;
-        int count1 = 0;
-        int count2 = 0;
-        while (! serviceStability && count < 1000) {
-            try {
-                ServiceReference[] refs = context.getServiceReferences((String) null, null);
-                count1 = refs.length;
-                Thread.sleep(1000);
-                refs = context.getServiceReferences((String) null, null);
-                count2 = refs.length;
-                serviceStability = count1 == count2;
-            } catch (Exception e) {
-                System.err.println(e);
-                serviceStability = false;
-                // Nothing to do, while recheck the condition
-            }
-            count++;
-        }
-
-        if (count == 1000) {
-            System.err.println("Service stability isn't reached after 1000 tries (" + count1 + " != " + count2);
-            throw new IllegalStateException("Cannot reach the service stability");
-        }
+    @Before
+    public void initializeConfigAdmin() {
+        caHelper = new ConfigAdminHelper(bc);
+        admin = caHelper.getConfigurationAdmin();
+        caHelper.deleteAllConfigurations();
     }
 
-    /**
-     * Are bundle stables.
-     * @param bc the bundle context
-     * @return <code>true</code> if every bundles are activated.
-     */
-    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);
-        }
-        return stability;
+    @After
+    public void stoppingConfigAdmin() {
+        caHelper.deleteAllConfigurations();
+        caHelper.dispose();
     }
-
-
 }

Modified: felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestDynamicallyConfigurablePropertiesUsingConfigAdmin.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestDynamicallyConfigurablePropertiesUsingConfigAdmin.java?rev=1479322&r1=1479321&r2=1479322&view=diff
==============================================================================
--- felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestDynamicallyConfigurablePropertiesUsingConfigAdmin.java (original)
+++ felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestDynamicallyConfigurablePropertiesUsingConfigAdmin.java Sun May  5 13:55:09 2013
@@ -49,8 +49,6 @@ public class TestDynamicallyConfigurable
 
     @Before
     public void setUp() {
-        cleanupConfigurationAdmin();
-
         String type = "CONFIG-FooProviderType-3";
 
         Hashtable<String, String> p1 = new Hashtable<String, String>();
@@ -66,31 +64,6 @@ public class TestDynamicallyConfigurable
         instance2 = ipojoHelper.createComponentInstance(type, p2);
     }
 
-    private void cleanupConfigurationAdmin() {
-        ConfigurationAdmin admin = (ConfigurationAdmin) osgiHelper.getServiceObject(ConfigurationAdmin.class.getName
-                (), null);
-        assertNotNull("Check configuration admin availability", admin);
-        try {
-            int found = 0;
-            Configuration[] configurations = admin.listConfigurations(null);
-            for (int i = 0; configurations != null && i < configurations.length; i++) {
-                System.out.println("Deleting configuration " + configurations[i].getPid());
-                configurations[i].delete();
-                found++;
-            }
-
-            // Wait the dispatching.
-            Thread.sleep(found * 500);
-
-        } catch (IOException e) {
-            e.printStackTrace();
-        } catch (InvalidSyntaxException e) {
-            e.printStackTrace();
-        } catch (InterruptedException e) {
-            e.printStackTrace();
-        }
-    }
-
     @After
     public void tearDown() {
         instance.dispose();
@@ -126,7 +99,7 @@ public class TestDynamicallyConfigurable
         configuration.update(conf);
 
         // Asynchronous dispatching of the configuration
-        Thread.sleep(1000);
+        grace();
 
         // Recheck props
         fooRef = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), instance.getInstanceName());
@@ -164,7 +137,7 @@ public class TestDynamicallyConfigurable
 
         // Asynchronous dispatching of the configuration
         configuration.update(conf);
-        Thread.sleep(200);
+        grace();
 
         // Recheck props
         fooRef = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), instance2.getInstanceName());
@@ -203,7 +176,7 @@ public class TestDynamicallyConfigurable
 
         // Asynchronous dispatching of the configuration
         configuration.update(conf);
-        Thread.sleep(200);
+        grace();
 
         // Recheck props
         fooRef = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), instance.getInstanceName());
@@ -253,7 +226,7 @@ public class TestDynamicallyConfigurable
 
         // Asynchronous dispatching of the configuration
         configuration.update(conf);
-        Thread.sleep(1000);
+        grace();
 
         // Recheck props
         fooRef = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), instance2.getInstanceName());
@@ -305,7 +278,7 @@ public class TestDynamicallyConfigurable
 
         // Asynchronous dispatching of the configuration
         configuration.update(conf);
-        Thread.sleep(200);
+        grace();
 
         // Recheck props
         fooRef = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), instance.getInstanceName());
@@ -359,7 +332,7 @@ public class TestDynamicallyConfigurable
 
         // Asynchronous dispatching of the configuration
         configuration.update(conf);
-        Thread.sleep(1000);
+        grace();
 
         System.out.println(instance.getInstanceDescription().getDescription());
 
@@ -409,7 +382,7 @@ public class TestDynamicallyConfigurable
 
         // Asynchronous dispatching of the configuration
         configuration.update(conf);
-        Thread.sleep(1000);
+        grace();
 
         // Recheck props
         fooRef = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), instance2.getInstanceName());

Modified: felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestUpdatedMethodAndConfigAdmin.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestUpdatedMethodAndConfigAdmin.java?rev=1479322&r1=1479321&r2=1479322&view=diff
==============================================================================
--- felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestUpdatedMethodAndConfigAdmin.java (original)
+++ felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestUpdatedMethodAndConfigAdmin.java Sun May  5 13:55:09 2013
@@ -122,7 +122,7 @@ public class TestUpdatedMethodAndConfigA
 
         // Asynchronous dispatching of the configuration
         configuration.update(conf);
-        Thread.sleep(200);
+        grace();
 
         // Recheck props
         fooRef = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), instance.getInstanceName());
@@ -168,7 +168,7 @@ public class TestUpdatedMethodAndConfigA
 
         // Asynchronous dispatching of the configuration
         configuration.update(conf);
-        Thread.sleep(200);
+        grace();
 
         // Recheck props
         fooRef = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), instance2.getInstanceName());
@@ -215,7 +215,7 @@ public class TestUpdatedMethodAndConfigA
 
         // Asynchronous dispatching of the configuration
         configuration.update(conf);
-        Thread.sleep(200);
+        grace();
 
         // Recheck props
         fooRef = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), instance.getInstanceName());
@@ -269,7 +269,7 @@ public class TestUpdatedMethodAndConfigA
 
         // Asynchronous dispatching of the configuration
         configuration.update(conf);
-        Thread.sleep(200);
+        grace();
 
         // Recheck props
         fooRef = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), instance2.getInstanceName());
@@ -326,7 +326,7 @@ public class TestUpdatedMethodAndConfigA
 
         // Asynchronous dispatching of the configuration
         configuration.update(conf);
-        Thread.sleep(200);
+        grace();
 
         // Recheck props
         fooRef = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), instance.getInstanceName());

Modified: felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestUpdatedMethodAndManagedService.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestUpdatedMethodAndManagedService.java?rev=1479322&r1=1479321&r2=1479322&view=diff
==============================================================================
--- felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestUpdatedMethodAndManagedService.java (original)
+++ felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestUpdatedMethodAndManagedService.java Sun May  5 13:55:09 2013
@@ -73,43 +73,14 @@ public class TestUpdatedMethodAndManaged
      */
     ComponentInstance instance3;
 
-    private void cleanupConfigurationAdmin() {
-        ConfigurationAdmin admin = (ConfigurationAdmin) osgiHelper.getServiceObject(ConfigurationAdmin.class.getName
-                (), null);
-        assertNotNull("Check configuration admin availability", admin);
-        try {
-            int found = 0;
-            Configuration[] configurations = admin.listConfigurations(null);
-            for (int i = 0; configurations != null && i < configurations.length; i++) {
-                System.out.println("Deleting configuration " + configurations[i].getPid());
-                configurations[i].delete();
-                found++;
-            }
-
-            // Wait the dispatching.
-            Thread.sleep(found * 500);
-
-        } catch (IOException e) {
-            e.printStackTrace();
-        } catch (InvalidSyntaxException e) {
-            e.printStackTrace();
-        } catch (InterruptedException e) {
-            e.printStackTrace();
-        }
-    }
-
     @Before
     public void setUp() throws IOException {
-        osgiHelper = new OSGiHelper(bc);
-        ipojoHelper = new IPOJOHelper(bc);
 
         for (HandlerFactory handler : osgiHelper.getServiceObjects(HandlerFactory.class)) {
             System.out.println("handler : " + handler.getHandlerName() + " - " + handler.getState() + " - " + handler
                     .getMissingHandlers());
         }
 
-        cleanupConfigurationAdmin();
-
         String type = "CONFIG-FooProviderType-4Updated";
         Hashtable<String, String> p = new Hashtable<String, String>();
         p.put("instance.name", "instance");

Modified: felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestUpdatedNoArgMethodAndConfigAdmin.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestUpdatedNoArgMethodAndConfigAdmin.java?rev=1479322&r1=1479321&r2=1479322&view=diff
==============================================================================
--- felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestUpdatedNoArgMethodAndConfigAdmin.java (original)
+++ felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestUpdatedNoArgMethodAndConfigAdmin.java Sun May  5 13:55:09 2013
@@ -121,7 +121,7 @@ public class TestUpdatedNoArgMethodAndCo
 
         // Asynchronous dispatching of the configuration
         configuration.update(conf);
-        Thread.sleep(200);
+        grace();
 
         // Recheck props
         fooRef = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), instance.getInstanceName());
@@ -165,7 +165,7 @@ public class TestUpdatedNoArgMethodAndCo
 
         // Asynchronous dispatching of the configuration
         configuration.update(conf);
-        Thread.sleep(200);
+        grace();
 
         // Recheck props
         fooRef = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), instance2.getInstanceName());
@@ -210,7 +210,7 @@ public class TestUpdatedNoArgMethodAndCo
 
         // Asynchronous dispatching of the configuration
         configuration.update(conf);
-        Thread.sleep(200);
+        grace();
 
         // Recheck props
         fooRef = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), instance.getInstanceName());
@@ -262,7 +262,7 @@ public class TestUpdatedNoArgMethodAndCo
 
         // Asynchronous dispatching of the configuration
         configuration.update(conf);
-        Thread.sleep(200);
+        grace();
 
         // Recheck props
         fooRef = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), instance2.getInstanceName());
@@ -316,7 +316,7 @@ public class TestUpdatedNoArgMethodAndCo
 
         // Asynchronous dispatching of the configuration
         configuration.update(conf);
-        Thread.sleep(200);
+        grace();
 
         // Recheck props
         fooRef = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), instance.getInstanceName());

Modified: felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-external-handlers-test/src/test/java/org/apache/felix/ipojo/runtime/externalhandlers/test/Common.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-external-handlers-test/src/test/java/org/apache/felix/ipojo/runtime/externalhandlers/test/Common.java?rev=1479322&r1=1479321&r2=1479322&view=diff
==============================================================================
--- felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-external-handlers-test/src/test/java/org/apache/felix/ipojo/runtime/externalhandlers/test/Common.java (original)
+++ felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-external-handlers-test/src/test/java/org/apache/felix/ipojo/runtime/externalhandlers/test/Common.java Sun May  5 13:55:09 2013
@@ -19,220 +19,11 @@
 
 package org.apache.felix.ipojo.runtime.externalhandlers.test;
 
-import ch.qos.logback.classic.Level;
-import ch.qos.logback.classic.Logger;
-import org.apache.commons.io.FileUtils;
-import org.apache.commons.io.filefilter.TrueFileFilter;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.runner.RunWith;
-import org.ops4j.pax.exam.Configuration;
-import org.ops4j.pax.exam.Option;
-import org.ops4j.pax.exam.junit.PaxExam;
-import org.ops4j.pax.exam.options.CompositeOption;
-import org.ops4j.pax.exam.options.DefaultCompositeOption;
-import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
-import org.ops4j.pax.exam.spi.reactors.PerClass;
-import org.ops4j.pax.tinybundles.core.TinyBundle;
-import org.ops4j.pax.tinybundles.core.TinyBundles;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.Constants;
-import org.osgi.framework.ServiceReference;
-import org.ow2.chameleon.testing.helpers.IPOJOHelper;
-import org.ow2.chameleon.testing.helpers.OSGiHelper;
-import org.ow2.chameleon.testing.tinybundles.ipojo.IPOJOStrategy;
-import org.slf4j.LoggerFactory;
-
-import javax.inject.Inject;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.MalformedURLException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-import static org.ops4j.pax.exam.CoreOptions.*;
+import org.ow2.chameleon.testing.helpers.BaseTest;
 
 /**
  * Bootstrap the test from this project
  */
-@RunWith(PaxExam.class)
-@ExamReactorStrategy(PerClass.class)
-public class Common {
-
-    @Inject
-    BundleContext bc;
-
-    OSGiHelper osgiHelper;
-    IPOJOHelper ipojoHelper;
-
-    Bundle testedBundle;
-
-    @Configuration
-    public Option[] config() throws MalformedURLException {
-        Logger root = (Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
-        root.setLevel(Level.INFO);
-
-        return options(
-                ipojoBundles(),
-                junitBundles(),
-                testedBundle(),
-                systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value("WARN")
-        );
-    }
-
-    @Before
-    public void commonSetUp() {
-        osgiHelper = new OSGiHelper(bc);
-        ipojoHelper = new IPOJOHelper(bc);
-
-        testedBundle = osgiHelper.getBundle("test.bundle");
-
-        // Dump OSGi Framework information
-        String vendor = (String) osgiHelper.getBundle(0).getHeaders().get(Constants.BUNDLE_VENDOR);
-        if (vendor == null) {
-            vendor = (String) osgiHelper.getBundle(0).getHeaders().get(Constants.BUNDLE_SYMBOLICNAME);
-        }
-        String version = (String) osgiHelper.getBundle(0).getHeaders().get(Constants.BUNDLE_VERSION);
-        System.out.println("OSGi Framework : " + vendor + " - " + version);
-
-        waitForStability(bc);
-    }
-
-    @After
-    public void commonTearDown() {
-        ipojoHelper.dispose();
-        osgiHelper.dispose();
-    }
-
-    public CompositeOption ipojoBundles() {
-        return new DefaultCompositeOption(
-                mavenBundle("org.apache.felix", "org.apache.felix.ipojo").versionAsInProject(),
-                mavenBundle("org.ow2.chameleon.testing", "osgi-helpers").versionAsInProject());
-    }
-
-    public Option testedBundle() throws MalformedURLException {
-        File out = new File("target/tested/bundle.jar");
-
-        TinyBundle tested = TinyBundles.bundle();
-
-        // We look inside target/classes to find the class and resources
-        File classes = new File("target/classes");
-        Collection<File> files = FileUtils.listFilesAndDirs(classes, TrueFileFilter.INSTANCE, TrueFileFilter.INSTANCE);
-        List<File> services = new ArrayList<File>();
-        for (File file : files) {
-            if (file.isDirectory()) {
-                // By convention we export of .services and .service package
-                if (file.getName().endsWith("services") || file.getName().endsWith("service")) {
-                    services.add(file);
-                }
-            } else {
-                // We need to compute the path
-                String path = file.getAbsolutePath().substring(classes.getAbsolutePath().length() + 1);
-                tested.add(path, file.toURI().toURL());
-                System.out.println(file.getName() + " added to " + path);
-            }
-        }
-
-        String export = "";
-        for (File file : services) {
-            if (export.length() > 0) {
-                export += ", ";
-            }
-            String path = file.getAbsolutePath().substring(classes.getAbsolutePath().length() + 1);
-            String packageName = path.replace('/', '.');
-            export += packageName;
-        }
-
-        System.out.println("Exported packages : " + export);
-
-        InputStream inputStream = tested
-                .set(Constants.BUNDLE_SYMBOLICNAME, "test.bundle")
-                .set(Constants.IMPORT_PACKAGE, "*")
-                .set(Constants.EXPORT_PACKAGE, export)
-                .build(IPOJOStrategy.withiPOJO(new File("src/main/resources")));
-
-        try {
-            FileUtils.copyInputStreamToFile(inputStream, out);
-            return bundle(out.toURI().toURL().toExternalForm());
-        } catch (MalformedURLException e) {
-            throw new RuntimeException("Cannot compute the url of the manipulated bundle");
-        } catch (IOException e) {
-            throw new RuntimeException("Cannot write of the manipulated bundle");
-        }
-    }
-
-    /**
-     * Waits for stability:
-     * <ul>
-     * <li>all bundles are activated
-     * <li>service count is stable
-     * </ul>
-     * If the stability can't be reached after a specified time,
-     * the method throws a {@link IllegalStateException}.
-     * @param context the bundle context
-     * @throws IllegalStateException when the stability can't be reach after a several attempts.
-     */
-    private void waitForStability(BundleContext context) throws IllegalStateException {
-        // Wait for bundle initialization.
-        boolean bundleStability = getBundleStability(context);
-        int count = 0;
-        while (!bundleStability && count < 500) {
-            try {
-                Thread.sleep(5);
-            } catch (InterruptedException e) {
-                // Interrupted
-            }
-            count++;
-            bundleStability = getBundleStability(context);
-        }
-
-        if (count == 500) {
-            System.err.println("Bundle stability isn't reached after 500 tries");
-            throw new IllegalStateException("Cannot reach the bundle stability");
-        }
-
-        boolean serviceStability = false;
-        count = 0;
-        int count1 = 0;
-        int count2 = 0;
-        while (! serviceStability && count < 500) {
-            try {
-                ServiceReference[] refs = context.getServiceReferences((String) null, null);
-                count1 = refs.length;
-                Thread.sleep(500);
-                refs = context.getServiceReferences((String) null, null);
-                count2 = refs.length;
-                serviceStability = count1 == count2;
-            } catch (Exception e) {
-                System.err.println(e);
-                serviceStability = false;
-                // Nothing to do, while recheck the condition
-            }
-            count++;
-        }
-
-        if (count == 500) {
-            System.err.println("Service stability isn't reached after 500 tries (" + count1 + " != " + count2);
-            throw new IllegalStateException("Cannot reach the service stability");
-        }
-    }
-
-    /**
-     * Are bundle stables.
-     * @param bc the bundle context
-     * @return <code>true</code> if every bundles are activated.
-     */
-    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);
-        }
-        return stability;
-    }
-
+public class Common extends BaseTest{
 
 }

Modified: felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-external-handlers-test/src/test/java/org/apache/felix/ipojo/runtime/externalhandlers/test/HandlerTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-external-handlers-test/src/test/java/org/apache/felix/ipojo/runtime/externalhandlers/test/HandlerTest.java?rev=1479322&r1=1479321&r2=1479322&view=diff
==============================================================================
--- felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-external-handlers-test/src/test/java/org/apache/felix/ipojo/runtime/externalhandlers/test/HandlerTest.java (original)
+++ felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-external-handlers-test/src/test/java/org/apache/felix/ipojo/runtime/externalhandlers/test/HandlerTest.java Sun May  5 13:55:09 2013
@@ -64,7 +64,7 @@ public class HandlerTest extends Common 
 		ServiceReference sr = null;
 		ServiceReference[] refs = null;
         String filter = "("+"instance.name"+"="+name+")";
-        refs =osgiHelper.getServiceReferences(CheckService.class.getName(), filter);
+        refs = osgiHelper.getServiceReferences(CheckService.class.getName(), filter);
         if(refs != null) { sr = refs[0]; }
         
 		assertNotNull("Check the check service availability", sr);