felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clem...@apache.org
Subject svn commit: r1479322 [3/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...
Date Sun, 05 May 2013 13:55:10 GMT
Modified: felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-factory-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-factory-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-factory-test/src/test/java/org/apache/felix/ipojo/runtime/core/Common.java (original)
+++ felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-factory-test/src/test/java/org/apache/felix/ipojo/runtime/core/Common.java Sun May  5 13:55:09 2013
@@ -19,152 +19,44 @@
 
 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 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;
 
 import static junit.framework.Assert.fail;
-import static org.ops4j.pax.exam.CoreOptions.*;
 
 /**
  * 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;
+    public ConfigAdminHelper caHelper = null;
+    public ConfigurationAdmin admin;
 
-        waitForStability(bc);
+    public void grace() {
+        TimeUtils.grace(UPDATE_WAIT_TIME);
     }
 
-    @After
-    public void commonTearDown() {
-        ipojoHelper.dispose();
-        osgiHelper.dispose();
+    @Override
+    public boolean deployConfigAdmin() {
+        return true;
     }
 
-    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()
-        );
+    @Before
+    public void initializeConfigAdmin() {
+        caHelper = new ConfigAdminHelper(bc);
+        admin = caHelper.getConfigurationAdmin();
+        caHelper.deleteAllConfigurations();
     }
 
-    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");
-        }
+    @After
+    public void stoppingConfigAdmin() {
+        caHelper.deleteAllConfigurations();
+        caHelper.dispose();
     }
 
     public void assertContains(String s, String[] arrays, String object) {
@@ -175,76 +67,4 @@ public class Common {
         }
         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;
-    }
-
-
 }

Modified: felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-factory-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestConfigAdmin.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-factory-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestConfigAdmin.java?rev=1479322&r1=1479321&r2=1479322&view=diff
==============================================================================
--- felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-factory-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestConfigAdmin.java (original)
+++ felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-factory-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestConfigAdmin.java Sun May  5 13:55:09 2013
@@ -50,7 +50,7 @@ public class TestConfigAdmin extends Com
         p.put("intAProp", new int[]{1, 2});
 
         conf.update(p);
-        Thread.sleep(200);
+        grace();
 
         String pid = conf.getPid();
         ServiceReference ref = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), pid);
@@ -58,7 +58,7 @@ public class TestConfigAdmin extends Com
 
         // Deletion of the configuration
         conf.delete();
-        Thread.sleep(200);
+        grace();
 
         ref = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), pid);
         assertNull("Check instance deletion", ref);
@@ -80,7 +80,7 @@ public class TestConfigAdmin extends Com
         p.put("intAProp", "{1,2}");
 
         conf.update(p);
-        Thread.sleep(200);
+        grace();
 
         String pid = conf.getPid();
         ServiceReference ref = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), pid);
@@ -88,7 +88,7 @@ public class TestConfigAdmin extends Com
         assertNotNull("Check instance creation", ref);
 
         conf.delete();
-        Thread.sleep(200);
+        grace();
 
         ref = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), pid);
         assertNull("Check instance deletion", ref);
@@ -110,7 +110,7 @@ public class TestConfigAdmin extends Com
         p.put("intAProp", new int[]{1, 2});
 
         conf.update(p);
-        Thread.sleep(200);
+        grace();
 
         String pid = conf.getPid();
         ServiceReference ref = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), pid);
@@ -119,14 +119,14 @@ public class TestConfigAdmin extends Com
 
         p.put("int", 4);
         conf.update(p);
-        Thread.sleep(200);
+        grace();
 
         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);
+        grace();
 
         ref = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), pid);
         assertNull("Check instance deletion", ref);
@@ -149,7 +149,7 @@ public class TestConfigAdmin extends Com
         p.put("intAProp", "{1,2}");
 
         conf.update(p);
-        Thread.sleep(200);
+        grace();
 
         String pid = conf.getPid();
 
@@ -157,12 +157,14 @@ public class TestConfigAdmin extends Com
         assertNotNull("Check instance creation", ref);
         p.put("int", new Integer("4"));
         conf.update(p);
-        Thread.sleep(200);
+        grace();
+
         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);
+        grace();
+
         ref = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), pid);
         assertNull("Check instance deletion", ref);
     }

Modified: felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-factory-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestReconfiguration.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-factory-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestReconfiguration.java?rev=1479322&r1=1479321&r2=1479322&view=diff
==============================================================================
--- felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-factory-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestReconfiguration.java (original)
+++ felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-factory-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestReconfiguration.java Sun May  5 13:55:09 2013
@@ -39,41 +39,6 @@ import static org.junit.Assert.fail;
 
 public class TestReconfiguration extends Common {
 
-    private ConfigurationAdmin admin;
-
-    @Before
-    public void setUp() {
-        admin = osgiHelper.getServiceObject(ConfigurationAdmin.class);
-        assertNotNull("Check configuration admin availability", admin);
-        try {
-            Configuration[] configurations = admin.listConfigurations(
-                    "(service.factoryPid=org.apache.felix.ipojo.runtime.core.components.ReconfigurableSimpleType)");
-            for (int i = 0; configurations != null && i < configurations.length; i++) {
-                configurations[i].delete();
-            }
-        } catch (IOException e) {
-            fail(e.getMessage());
-        } catch (InvalidSyntaxException e) {
-            fail(e.getMessage());
-        }
-    }
-
-    @After
-    public void tearDown() {
-        try {
-            Configuration[] configurations = admin.listConfigurations(
-                    "(service.factoryPid=org.apache.felix.ipojo.runtime.core.components.ReconfigurableSimpleType)");
-            for (int i = 0; configurations != null && i < configurations.length; i++) {
-                configurations[i].delete();
-            }
-        } catch (IOException e) {
-            fail(e.getMessage());
-        } catch (InvalidSyntaxException e) {
-            fail(e.getMessage());
-        }
-        admin = null;
-    }
-
     @Test
     public void testRevalidationOnReconfiguration() {
         ComponentFactory factory = (ComponentFactory) ipojoHelper.getFactory(
@@ -106,8 +71,6 @@ public class TestReconfiguration extends
         assertEquals("instance valid", ComponentInstance.VALID, ci.getState());
     }
 
-    public static long UPDATE_WAIT_TIME = 2000;
-
     @Test public void testRevalidationOnReconfigurationUsingConfigAdmin() throws InvalidSyntaxException {
         Configuration configuration = null;
         try {
@@ -132,11 +95,7 @@ public class TestReconfiguration extends
         String pid = configuration.getPid();
 
         // Wait for the processing of the first configuration.
-        try {
-            Thread.sleep(UPDATE_WAIT_TIME);
-        } catch (InterruptedException e1) {
-            fail(e1.getMessage());
-        }
+        grace();
 
         Assert.assertNull("No architecture", osgiHelper.getServiceReference(Architecture.class.getName(),
                 "(architecture.instance=" + pid + ")"));
@@ -155,11 +114,7 @@ public class TestReconfiguration extends
         pid = configuration.getPid();
 
         // Wait for the processing of the first configuration.
-        try {
-            Thread.sleep(UPDATE_WAIT_TIME);
-        } catch (InterruptedException e1) {
-            fail(e1.getMessage());
-        }
+        grace();
 
         Assert.assertNotNull("architecture", osgiHelper.getServiceReference(Architecture.class.getName(), "(architecture.instance=" + pid + ")"));
         Architecture arch = (Architecture) osgiHelper.getServiceObject( Architecture.class.getName(), "(architecture.instance=" + pid + ")");
@@ -222,11 +177,7 @@ public class TestReconfiguration extends
         String pid = configuration.getPid();
 
         // Wait for the processing of the first configuration.
-        try {
-            Thread.sleep(UPDATE_WAIT_TIME);
-        } catch (InterruptedException e1) {
-            fail(e1.getMessage());
-        }
+        grace();
 
         // Invalid ... controller effect
         Assert.assertNotNull("architecture", osgiHelper.getServiceReference(Architecture.class.getName(), "(architecture.instance=" + pid + ")"));
@@ -240,18 +191,13 @@ public class TestReconfiguration extends
 
         try {
             configuration.update(props);
+            grace();
         } catch (IOException e) {
             fail(e.getMessage());
         }
 
         pid = configuration.getPid();
 
-        // Wait for the processing of the first configuration.
-        try {
-            Thread.sleep(UPDATE_WAIT_TIME);
-        } catch (InterruptedException e1) {
-            fail(e1.getMessage());
-        }
 
         Assert.assertNotNull("architecture", osgiHelper.getServiceReference(Architecture.class.getName(), "(architecture.instance=" + pid + ")"));
         arch = (Architecture) osgiHelper.getServiceObject( Architecture.class.getName(), "(architecture.instance=" + pid + ")");
@@ -307,19 +253,13 @@ public class TestReconfiguration extends
 
         try {
             configuration.update(props);
+            grace();
         } catch (IOException e) {
             fail(e.getMessage());
         }
 
         String pid = configuration.getPid();
 
-        // Wait for the processing of the first configuration.
-        try {
-            Thread.sleep(UPDATE_WAIT_TIME);
-        } catch (InterruptedException e1) {
-            fail(e1.getMessage());
-        }
-
         // Invalid ... controller effect
         Assert.assertNotNull("architecture", osgiHelper.getServiceReference(Architecture.class.getName(), "(architecture.instance=" + pid + ")"));
         Architecture arch = (Architecture) osgiHelper.getServiceObject( Architecture.class.getName(), "(architecture.instance=" + pid + ")");
@@ -332,19 +272,13 @@ public class TestReconfiguration extends
 
         try {
             configuration.update(props);
+            grace();
         } catch (IOException e) {
             fail(e.getMessage());
         }
 
         pid = configuration.getPid();
 
-        // Wait for the processing of the first configuration.
-        try {
-            Thread.sleep(UPDATE_WAIT_TIME);
-        } catch (InterruptedException e1) {
-            fail(e1.getMessage());
-        }
-
         Assert.assertNotNull("architecture", osgiHelper.getServiceReference(Architecture.class.getName(), "(architecture.instance=" + pid + ")"));
         arch = (Architecture) osgiHelper.getServiceObject( Architecture.class.getName(), "(architecture.instance=" + pid + ")");
 

Modified: felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-factory-version-test/src/test/java/org/apache/felix/ipojo/tests/core/Common.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-factory-version-test/src/test/java/org/apache/felix/ipojo/tests/core/Common.java?rev=1479322&r1=1479321&r2=1479322&view=diff
==============================================================================
--- felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-factory-version-test/src/test/java/org/apache/felix/ipojo/tests/core/Common.java (original)
+++ felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-factory-version-test/src/test/java/org/apache/felix/ipojo/tests/core/Common.java Sun May  5 13:55:09 2013
@@ -19,71 +19,29 @@
 
 package org.apache.felix.ipojo.tests.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.core.tests.services.MyService;
-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 org.ow2.chameleon.testing.helpers.BaseTest;
 
-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 static org.ops4j.pax.exam.CoreOptions.bundle;
 import static org.ops4j.pax.tinybundles.core.TinyBundles.withBnd;
 
 /**
  * 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 IOException {
-        Logger root = (Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
-        root.setLevel(Level.INFO);
-
-        return options(
-                cleanCaches(),
-                ipojoBundles(),
-                junitBundles(),
-                //testedBundle(),
-                systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value("WARN")
-        );
+public class Common extends BaseTest {
+
+    @Override
+    public boolean deployTestBundle() {
+        return false;
     }
 
     public Option createServiceBundleV1() throws MalformedURLException {
@@ -130,163 +88,4 @@ public class Common {
         }
     }
 
-
-
-
-
-
-
-    @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());
-    }
-
-    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.
-     */
-    public 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) {
-            for (Bundle bundle : bc.getBundles()) {
-                System.out.println("Bundle " + bundle.getSymbolicName() + " - " + bundle.getState());
-            }
-            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;
-    }
-
-
 }

Modified: felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-factory-version-test/src/test/java/org/apache/felix/ipojo/tests/core/VersionConflictTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-factory-version-test/src/test/java/org/apache/felix/ipojo/tests/core/VersionConflictTest.java?rev=1479322&r1=1479321&r2=1479322&view=diff
==============================================================================
--- felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-factory-version-test/src/test/java/org/apache/felix/ipojo/tests/core/VersionConflictTest.java (original)
+++ felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-factory-version-test/src/test/java/org/apache/felix/ipojo/tests/core/VersionConflictTest.java Sun May  5 13:55:09 2013
@@ -39,6 +39,7 @@ import org.ops4j.pax.tinybundles.core.Ti
 import org.osgi.framework.*;
 import org.osgi.framework.wiring.BundleWire;
 import org.osgi.framework.wiring.BundleWiring;
+import org.ow2.chameleon.testing.helpers.Stability;
 import org.ow2.chameleon.testing.tinybundles.ipojo.IPOJOStrategy;
 
 import javax.inject.Inject;
@@ -179,7 +180,7 @@ public class VersionConflictTest extends
         Bundle b5 = context.installBundle(context.getProperty("cons"));
         b5.start();
 
-        waitForStability(bc);
+        Stability.waitForStability(bc);
 
         Bundle[] bundles = context.getBundles();
         for (Bundle bundle : bundles) {

Modified: felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-handler-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-handler-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-handler-test/src/test/java/org/apache/felix/ipojo/runtime/core/Common.java (original)
+++ felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-handler-test/src/test/java/org/apache/felix/ipojo/runtime/core/Common.java Sun May  5 13:55:09 2013
@@ -19,309 +19,21 @@
 
 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.options.libraries.JUnitBundlesOption;
-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 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 junit.framework.Assert.fail;
-import static org.ops4j.pax.exam.CoreOptions.*;
+import org.ow2.chameleon.testing.helpers.BaseTest;
 
 /**
  * Bootstrap the test from this project
  */
-@RunWith(PaxExam.class)
-@ExamReactorStrategy(PerMethod.class)
-public class Common {
-
-    @Inject
-    BundleContext bc;
-
-    OSGiHelper osgiHelper;
-    IPOJOHelper ipojoHelper;
-
-    @Configuration
-    public Option[] config() throws IOException {
-        Logger root = (Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
-        root.setLevel(Level.DEBUG);
-
-        return options(
-                cleanCaches(),
-                ipojoBundles(),
-                junitAndMockitoBundles(),
-                // No tested bundle in this project
-                systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value("DEBUG")
-        );
-    }
-
-    public static Option junitAndMockitoBundles() {
-        return new DefaultCompositeOption(
-                // Repository required to load harmcrest (OSGi-fied version).
-                repository("http://repo1.maven.org/maven2").id(
-                        "central"),
-                repository("http://repository.springsource.com/maven/bundles/external").id(
-                        "com.springsource.repository.bundles.external"),
-
-                // Hamcrest with a version matching the range expected by Mockito
-                mavenBundle("org.hamcrest", "com.springsource.org.hamcrest.core", "1.1.0"),
-
-                // Mockito core does not includes Hamcrest
-                mavenBundle("org.mockito", "mockito-core", "1.9.5"),
-
-                // 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. When deployed after the hamcrest bundles, it gets
-                // resolved correctly.
-                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. this property has no effect on the other OSGi implementation.
-                 */
-                frameworkProperty("felix.bootdelegation.implicit").value("false")
-        );
-    }
-
-
-
-    /**
-     * Creates a {@link org.ops4j.pax.exam.options.libraries.JUnitBundlesOption}.
-     *
-     * @return junit bundles option
-     */
-    public static CompositeOption junitBundles() {
-        return new DefaultCompositeOption(
-                // We need the spring source repository to get hamcrest
-                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.
-                new JUnitBundlesOption(),
-
-                // see config1()
-                frameworkProperty("felix.bootdelegation.implicit").value("false")
-        );
-
-//        return new DefaultCompositeOption(new JUnitBundlesOption(),
-//                systemProperty("pax.exam.invoker").value("junit"),
-//                bundle("mvn:org.ops4j.pax.tipi/org.ops4j.pax.tipi.hamcrest.core/1.3.0.1"),
-//                bundle("link:classpath:META-INF/links/org.ops4j.pax.exam.invoker.junit.link"));
-    }
-
-    @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 class Common extends BaseTest {
 
-        waitForStability(bc);
+    @Override
+    public boolean deployTestBundle() {
+        return false;
     }
 
-    @After
-    public void commonTearDown() {
-        ipojoHelper.dispose();
-        osgiHelper.dispose();
+    @Override
+    public boolean deployMockito() {
+        return true;
     }
 
-    public static 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 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");
-        }
-    }
-
-    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.
-     */
-    public 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) {
-            for (Bundle bundle : bc.getBundles()) {
-                System.out.println("Bundle " + bundle.getSymbolicName() + " - " + bundle.getState());
-            }
-            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;
-    }
-
-
 }

Modified: felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-lifecycle-callback-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-lifecycle-callback-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-lifecycle-callback-test/src/test/java/org/apache/felix/ipojo/runtime/core/Common.java (original)
+++ felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-lifecycle-callback-test/src/test/java/org/apache/felix/ipojo/runtime/core/Common.java Sun May  5 13:55:09 2013
@@ -19,271 +19,12 @@
 
 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.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 junit.framework.Assert.fail;
-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;
-
-    @Configuration
-    public Option[] config() throws IOException {
-        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 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")
-        );
-    }
-
-
-    @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()
-        );
-    }
-
-    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);
-            }
-        }
-
-        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");
-        }
-    }
-
-    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 (int i = 0; i < bundles.length; i++) {
-            stability = stability && (bundles[i].getState() == Bundle.ACTIVE);
-        }
-        return stability;
-    }
-
+public class Common extends BaseTest {
 
+    // No custom configuration required.
 }

Modified: felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-lifecycle-controller-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-lifecycle-controller-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-lifecycle-controller-test/src/test/java/org/apache/felix/ipojo/runtime/core/Common.java (original)
+++ felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-lifecycle-controller-test/src/test/java/org/apache/felix/ipojo/runtime/core/Common.java Sun May  5 13:55:09 2013
@@ -19,273 +19,13 @@
 
 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.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 junit.framework.Assert.fail;
-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;
-
-    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")
-        );
-    }
-
-    @Configuration
-    public Option[] config() throws IOException {
-        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);
-
-        // 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()
-        );
-    }
-
-    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);
-            }
-        }
-
-        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");
-        }
-    }
-
-    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 class Common extends BaseTest {
 
+    // No custom configuration required.
 
 }

Modified: felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-logger-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-logger-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-logger-test/src/test/java/org/apache/felix/ipojo/runtime/core/Common.java (original)
+++ felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-logger-test/src/test/java/org/apache/felix/ipojo/runtime/core/Common.java Sun May  5 13:55:09 2013
@@ -19,275 +19,16 @@
 
 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.PerClass;
-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 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 junit.framework.Assert.fail;
-import static org.ops4j.pax.exam.CoreOptions.*;
+import org.ow2.chameleon.testing.helpers.BaseTest;
 
 /**
  * Bootstrap the test from this project
  */
-@RunWith(PaxExam.class)
-@ExamReactorStrategy(PerMethod.class)
-public class Common {
-
-    @Inject
-    BundleContext bc;
-
-    OSGiHelper osgiHelper;
-    IPOJOHelper ipojoHelper;
-
-    @Configuration
-    public Option[] config() throws IOException {
-        Logger root = (Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
-        root.setLevel(Level.INFO);
-
-        return options(
-                ipojoBundles(),
-                junitBundles(),
-                //testedBundle(), // No tested bundle to deploy
-                systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value("WARN")
-        );
-    }
-
-    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"),
+public class Common extends BaseTest {
 
-                // 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")
-        );
-    }
-
-
-    @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);
+    @Override
+    public boolean deployTestBundle() {
+        return false;
     }
 
-    @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()
-        );
-    }
-
-    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);
-            }
-        }
-
-        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");
-        }
-    }
-
-    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) {
-            for (Bundle bundle : bc.getBundles()) {
-                System.out.println("Bundle " + bundle.getSymbolicName() + " - " + bundle.getState());
-            }
-            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;
-    }
-
-
 }



Mime
View raw message