felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clem...@apache.org
Subject svn commit: r1479322 [4/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-service-dependency-optional-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/Common.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-optional-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/Common.java?rev=1479322&r1=1479321&r2=1479322&view=diff
==============================================================================
--- felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-optional-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/Common.java (original)
+++ felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-optional-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/Common.java Sun May  5 13:55:09 2013
@@ -19,189 +19,33 @@
 
 package org.apache.felix.ipojo.runtime.core.test.dependencies;
 
-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 org.ow2.chameleon.testing.helpers.BaseTest;
+
+import java.util.Arrays;
 import java.util.List;
 
-import static org.ops4j.pax.exam.CoreOptions.*;
+import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
 
 /**
  * Bootstrap the test from this project
  */
-@RunWith(PaxExam.class)
-@ExamReactorStrategy(PerClass.class)
-public class Common {
-
-    @Inject
-    BundleContext bc;
-
-    protected OSGiHelper osgiHelper;
-    protected 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(
-                cleanCaches(),
-                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);
-
-        // Wait for stability.
-        waitForStability(bc);
-    }
-
-    /**
-     * 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.out.println("Bundle stability isn't reached after 500 tries");
-            dumpBundles(context);
-            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);
-            dumpBundles(context);
-            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 {
 
-    /**
-     * Prints the bundle list.
-     *
-     * @param bc the bundle context.
-     */
-    public void dumpBundles(BundleContext bc) {
-        System.out.println("Bundles:");
-        Bundle[] bundles = bc.getBundles();
-        for (int i = 0; i < bundles.length; i++) {
-            System.out.println(bundles[i].getSymbolicName() + " - " + bundles[i].getState());
-        }
+    @Override
+    protected Option[] getCustomOptions() {
+        return new Option[]{
+                eventadmin()
+        };
     }
 
-
-    @After
-    public void commonTearDown() {
-        osgiHelper.dispose();
-        ipojoHelper.dispose();
-    }
-
-    public CompositeOption ipojoBundles() {
-        return new DefaultCompositeOption(
-                mavenBundle("org.apache.felix", "org.apache.felix.ipojo").versionAsInProject(),
-                mavenBundle("org.ow2.chameleon.testing", "osgi-helpers").versionAsInProject());
+    @Override
+    protected List<String> getExtraExports() {
+        return Arrays.asList(
+                "org.apache.felix.ipojo.runtime.core.test.components.inner"
+        );
     }
 
     public CompositeOption eventadmin() {
@@ -211,63 +55,4 @@ public class Common {
                         "1.8.0").versionAsInProject());
     }
 
-    public Option testedBundle() throws MalformedURLException {
-        File out = new File("target/bundles/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);
-            }
-        }
-
-        // We export 'inner'
-        String export = "org.apache.felix.ipojo.runtime.core.test.components.inner";
-        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 BundleContext getContext() {
-        return bc;
-    }
-
 }

Modified: felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-policies/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/Common.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-policies/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/Common.java?rev=1479322&r1=1479321&r2=1479322&view=diff
==============================================================================
--- felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-policies/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/Common.java (original)
+++ felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-policies/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/Common.java Sun May  5 13:55:09 2013
@@ -19,189 +19,33 @@
 
 package org.apache.felix.ipojo.runtime.core.test.dependencies;
 
-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 org.ow2.chameleon.testing.helpers.BaseTest;
+
+import java.util.Arrays;
 import java.util.List;
 
-import static org.ops4j.pax.exam.CoreOptions.*;
+import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
 
 /**
  * Bootstrap the test from this project
  */
-@RunWith(PaxExam.class)
-@ExamReactorStrategy(PerClass.class)
-public class Common {
-
-    @Inject
-    BundleContext bc;
-
-    protected OSGiHelper osgiHelper;
-    protected 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(
-                cleanCaches(),
-                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);
-
-        // Wait for stability.
-        waitForStability(bc);
-    }
-
-    /**
-     * 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.out.println("Bundle stability isn't reached after 500 tries");
-            dumpBundles(context);
-            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);
-            dumpBundles(context);
-            throw new IllegalStateException("Cannot reach the service stability");
-        }
+public class Common extends BaseTest {
 
+    @Override
+    protected Option[] getCustomOptions() {
+        return new Option[]{
+                eventadmin()
+        };
     }
 
-    /**
-     * 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;
-    }
-
-    /**
-     * Prints the bundle list.
-     *
-     * @param bc the bundle context.
-     */
-    public void dumpBundles(BundleContext bc) {
-        System.out.println("Bundles:");
-        Bundle[] bundles = bc.getBundles();
-        for (int i = 0; i < bundles.length; i++) {
-            System.out.println(bundles[i].getSymbolicName() + " - " + bundles[i].getState());
-        }
-    }
-
-
-    @After
-    public void commonTearDown() {
-        osgiHelper.dispose();
-        ipojoHelper.dispose();
-    }
-
-    public CompositeOption ipojoBundles() {
-        return new DefaultCompositeOption(
-                mavenBundle("org.apache.felix", "org.apache.felix.ipojo").versionAsInProject(),
-                mavenBundle("org.ow2.chameleon.testing", "osgi-helpers").versionAsInProject());
+    @Override
+    protected List<String> getExtraExports() {
+        return Arrays.asList(
+                "org.apache.felix.ipojo.runtime.core.test.components.inner"
+        );
     }
 
     public CompositeOption eventadmin() {
@@ -211,63 +55,5 @@ public class Common {
                         "1.8.0").versionAsInProject());
     }
 
-    public Option testedBundle() throws MalformedURLException {
-        File out = new File("target/bundles/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);
-            }
-        }
-
-        // We export 'inner'
-        String export = "org.apache.felix.ipojo.runtime.core.test.components.inner";
-        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 BundleContext getContext() {
-        return bc;
-    }
 
 }

Modified: felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-proxies/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/Common.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-proxies/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/Common.java?rev=1479322&r1=1479321&r2=1479322&view=diff
==============================================================================
--- felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-proxies/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/Common.java (original)
+++ felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-proxies/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/Common.java Sun May  5 13:55:09 2013
@@ -19,190 +19,33 @@
 
 package org.apache.felix.ipojo.runtime.core.test.dependencies;
 
-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 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.Arrays;
 import java.util.List;
 
-import static org.ops4j.pax.exam.CoreOptions.*;
+import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
 
 /**
  * Bootstrap the test from this project
  */
-@RunWith(PaxExam.class)
-@ExamReactorStrategy(PerClass.class)
-public class Common {
+public class Common extends BaseTest {
 
-    @Inject
-    protected
-    BundleContext bc;
-
-    protected OSGiHelper osgiHelper;
-    protected 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(
-                cleanCaches(),
-                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);
-
-        // Wait for stability.
-        waitForStability(bc);
-    }
-
-    /**
-     * 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.out.println("Bundle stability isn't reached after 500 tries");
-            dumpBundles(context);
-            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);
-            dumpBundles(context);
-            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;
+    @Override
+    protected Option[] getCustomOptions() {
+        return new Option[]{
+                eventadmin()
+        };
     }
 
-    /**
-     * Prints the bundle list.
-     *
-     * @param bc the bundle context.
-     */
-    public void dumpBundles(BundleContext bc) {
-        System.out.println("Bundles:");
-        Bundle[] bundles = bc.getBundles();
-        for (int i = 0; i < bundles.length; i++) {
-            System.out.println(bundles[i].getSymbolicName() + " - " + bundles[i].getState());
-        }
-    }
-
-
-    @After
-    public void commonTearDown() {
-        osgiHelper.dispose();
-        ipojoHelper.dispose();
-    }
-
-    public CompositeOption ipojoBundles() {
-        return new DefaultCompositeOption(
-                mavenBundle("org.apache.felix", "org.apache.felix.ipojo").versionAsInProject(),
-                mavenBundle("org.ow2.chameleon.testing", "osgi-helpers").versionAsInProject());
+    @Override
+    protected List<String> getExtraExports() {
+        return Arrays.asList(
+                "org.apache.felix.ipojo.runtime.core.test.components.inner"
+        );
     }
 
     public CompositeOption eventadmin() {
@@ -212,63 +55,4 @@ public class Common {
                         "1.8.0").versionAsInProject());
     }
 
-    public Option testedBundle() throws MalformedURLException {
-        File out = new File("target/bundles/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);
-            }
-        }
-
-        // We export 'inner'
-        String export = "org.apache.felix.ipojo.runtime.core.test.components.inner";
-        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 BundleContext getContext() {
-        return bc;
-    }
-
 }

Modified: felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/main/resources/metadata.xml
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/main/resources/metadata.xml?rev=1479322&r1=1479321&r2=1479322&view=diff
==============================================================================
--- felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/main/resources/metadata.xml (original)
+++ felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/main/resources/metadata.xml Sun May  5 13:55:09 2013
@@ -222,371 +222,13 @@ xmlns:xsi="http://www.w3.org/2001/XMLSch
   </component>
 
   <!-- Simple & Optional Dependencies -->
+  <!-- used for architecture test -->
   <component
     classname="org.apache.felix.ipojo.runtime.core.test.components.CheckServiceProvider"
     name="SimpleOptionalCheckServiceProvider" architecture="true">
     <requires field="fs" optional="true" id="FooService" proxy="false"/>
     <provides />
   </component>
-  <component
-    classname="org.apache.felix.ipojo.runtime.core.test.components.CheckServiceProvider"
-    name="SimpleOptionalNoNullableCheckServiceProvider" architecture="true">
-    <requires field="fs" optional="true" nullable="false" />
-    <provides />
-  </component>
-  <component
-    classname="org.apache.felix.ipojo.runtime.core.test.components.CheckServiceProvider"
-    name="VoidOptionalCheckServiceProvider" architecture="true">
-    <requires field="fs" optional="true" proxy="false">
-      <callback type="bind" method="voidBind" />
-      <callback type="unbind" method="voidUnbind" />
-    </requires>
-    <provides />
-  </component>
-  <component
-    classname="org.apache.felix.ipojo.runtime.core.test.components.CheckServiceProvider"
-    name="VoidOptionalNoNullableCheckServiceProvider" architecture="true">
-    <requires field="fs" optional="true" nullable="false">
-      <callback type="bind" method="voidBind" />
-      <callback type="unbind" method="voidUnbind" />
-    </requires>
-    <provides />
-  </component>
-  <component
-    classname="org.apache.felix.ipojo.runtime.core.test.components.CheckServiceProvider"
-    name="ObjectOptionalCheckServiceProvider" architecture="true">
-    <requires field="fs" optional="true" proxy="false">
-      <callback type="bind" method="objectBind" />
-      <callback type="unbind" method="objectUnbind" />
-    </requires>
-    <provides />
-  </component>
-  <component
-    classname="org.apache.felix.ipojo.runtime.core.test.components.CheckServiceProvider"
-    name="ObjectOptionalNoNullableCheckServiceProvider" architecture="true">
-    <requires field="fs" optional="true" nullable="false">
-      <callback type="bind" method="objectBind" />
-      <callback type="unbind" method="objectUnbind" />
-    </requires>
-    <provides />
-  </component>
-  <component
-    classname="org.apache.felix.ipojo.runtime.core.test.components.CheckServiceProvider"
-    name="RefOptionalCheckServiceProvider" architecture="true">
-    <requires field="fs" optional="true" proxy="false">
-      <callback type="bind" method="refBind" />
-      <callback type="unbind" method="refUnbind" />
-    </requires>
-    <provides />
-  </component>
-  <component
-    classname="org.apache.felix.ipojo.runtime.core.test.components.CheckServiceProvider"
-    name="RefOptionalNoNullableCheckServiceProvider" architecture="true">
-    <requires field="fs" optional="true" nullable="false">
-      <callback type="bind" method="refBind" />
-      <callback type="unbind" method="refUnbind" />
-    </requires>
-    <provides />
-  </component>
-  <component
-    classname="org.apache.felix.ipojo.runtime.core.test.components.CheckServiceProvider"
-    name="BothOptionalCheckServiceProvider" architecture="true">
-    <requires field="fs" optional="true" proxy="false">
-      <callback type="bind" method="bothBind" />
-      <callback type="unbind" method="bothUnbind" />
-    </requires>
-    <provides />
-  </component>
-  <component
-    classname="org.apache.felix.ipojo.runtime.core.test.components.CheckServiceProvider"
-    name="MapOptionalCheckServiceProvider" architecture="true">
-    <requires field="fs" optional="true" proxy="false">
-      <callback type="bind" method="propertiesMapBind" />
-      <callback type="unbind" method="propertiesMapUnbind" />
-    </requires>
-    <provides />
-  </component>
-  <component
-    classname="org.apache.felix.ipojo.runtime.core.test.components.CheckServiceProvider"
-    name="DictOptionalCheckServiceProvider" architecture="true">
-    <requires field="fs" optional="true" proxy="false">
-      <callback type="bind" method="propertiesDictionaryBind" />
-      <callback type="unbind" method="propertiesDictionaryUnbind" />
-    </requires>
-    <provides />
-  </component>
-
-  <component
-    classname="org.apache.felix.ipojo.runtime.core.test.components.CheckServiceProvider"
-    name="ProxiedSimpleOptionalCheckServiceProvider" architecture="true">
-    <requires field="fs" optional="true" id="FooService"/>
-    <provides />
-  </component>
-  <component
-    classname="org.apache.felix.ipojo.runtime.core.test.components.CheckServiceProvider"
-    name="ProxiedVoidOptionalCheckServiceProvider" architecture="true">
-    <requires field="fs" optional="true">
-      <callback type="bind" method="voidBind" />
-      <callback type="unbind" method="voidUnbind" />
-    </requires>
-    <provides />
-  </component>
-  <component
-    classname="org.apache.felix.ipojo.runtime.core.test.components.CheckServiceProvider"
-    name="ProxiedObjectOptionalCheckServiceProvider" architecture="true">
-    <requires field="fs" optional="true">
-      <callback type="bind" method="objectBind" />
-      <callback type="unbind" method="objectUnbind" />
-    </requires>
-    <provides />
-  </component>
-  <component
-    classname="org.apache.felix.ipojo.runtime.core.test.components.CheckServiceProvider"
-    name="ProxiedRefOptionalCheckServiceProvider" architecture="true">
-    <requires field="fs" optional="true">
-      <callback type="bind" method="refBind" />
-      <callback type="unbind" method="refUnbind" />
-    </requires>
-    <provides />
-  </component>
-  <component
-    classname="org.apache.felix.ipojo.runtime.core.test.components.CheckServiceProvider"
-    name="ProxiedBothOptionalCheckServiceProvider" architecture="true">
-    <requires field="fs" optional="true">
-      <callback type="bind" method="bothBind" />
-      <callback type="unbind" method="bothUnbind" />
-    </requires>
-    <provides />
-  </component>
-  <component
-    classname="org.apache.felix.ipojo.runtime.core.test.components.CheckServiceProvider"
-    name="ProxiedMapOptionalCheckServiceProvider" architecture="true">
-    <requires field="fs" optional="true">
-      <callback type="bind" method="propertiesMapBind" />
-      <callback type="unbind" method="propertiesMapUnbind" />
-    </requires>
-    <provides />
-  </component>
-  <component
-    classname="org.apache.felix.ipojo.runtime.core.test.components.CheckServiceProvider"
-    name="ProxiedDictOptionalCheckServiceProvider" architecture="true">
-    <requires field="fs" optional="true">
-      <callback type="bind" method="propertiesDictionaryBind" />
-      <callback type="unbind" method="propertiesDictionaryUnbind" />
-    </requires>
-    <provides />
-  </component>
-
-  <component
-    classname="org.apache.felix.ipojo.runtime.core.test.components.CheckServiceProvider"
-    name="BothOptionalNoNullableCheckServiceProvider" architecture="true">
-    <requires field="fs" optional="true" nullable="false">
-      <callback type="bind" method="bothBind" />
-      <callback type="unbind" method="bothUnbind" />
-    </requires>
-    <provides />
-  </component>
-  <component
-    classname="org.apache.felix.ipojo.runtime.core.test.components.CheckServiceProvider"
-    name="MapOptionalNoNullableCheckServiceProvider" architecture="true">
-    <requires field="fs" optional="true" nullable="false">
-      <callback type="bind" method="propertiesMapBind" />
-      <callback type="unbind" method="propertiesMapUnbind" />
-    </requires>
-    <provides />
-  </component>
-  <component
-    classname="org.apache.felix.ipojo.runtime.core.test.components.CheckServiceProvider"
-    name="DictOptionalNoNullableCheckServiceProvider" architecture="true">
-    <requires field="fs" optional="true" nullable="false">
-      <callback type="bind" method="propertiesDictionaryBind" />
-      <callback type="unbind" method="propertiesDictionaryUnbind" />
-    </requires>
-    <provides />
-  </component>
-
-  <component
-    classname="org.apache.felix.ipojo.runtime.core.test.components.MethodCheckServiceProvider"
-    name="MObjectOptionalCheckServiceProvider" architecture="true">
-    <requires optional="true">
-      <callback type="bind" method="objectBind" />
-      <callback type="unbind" method="objectUnbind" />
-    </requires>
-    <provides />
-  </component>
-  <component
-    classname="org.apache.felix.ipojo.runtime.core.test.components.MethodCheckServiceProvider"
-    name="MRefOptionalCheckServiceProvider" architecture="true">
-    <requires
-      specification="org.apache.felix.ipojo.runtime.core.test.services.FooService"
-      optional="true">
-      <callback type="bind" method="refBind" />
-      <callback type="unbind" method="refUnbind" />
-    </requires>
-    <provides />
-  </component>
-  <component
-    classname="org.apache.felix.ipojo.runtime.core.test.components.MethodCheckServiceProvider"
-    name="MBothOptionalCheckServiceProvider" architecture="true">
-    <requires
-      specification="org.apache.felix.ipojo.runtime.core.test.services.FooService"
-      optional="true">
-      <callback type="bind" method="bothBind" />
-      <callback type="unbind" method="bothUnbind" />
-    </requires>
-    <provides />
-  </component>
-  <component
-    classname="org.apache.felix.ipojo.runtime.core.test.components.MethodCheckServiceProvider"
-    name="MMapOptionalCheckServiceProvider" architecture="true">
-    <requires
-      specification="org.apache.felix.ipojo.runtime.core.test.services.FooService"
-      optional="true">
-      <callback type="bind" method="propertiesMapBind" />
-      <callback type="unbind" method="propertiesMapUnbind" />
-    </requires>
-    <provides />
-  </component>
-  <component
-    classname="org.apache.felix.ipojo.runtime.core.test.components.MethodCheckServiceProvider"
-    name="MDictOptionalCheckServiceProvider" architecture="true">
-    <requires
-      specification="org.apache.felix.ipojo.runtime.core.test.services.FooService"
-      optional="true">
-      <callback type="bind" method="propertiesDictionaryBind" />
-      <callback type="unbind" method="propertiesDictionaryUnbind" />
-    </requires>
-    <provides />
-  </component>
-
-
-  <!-- Simple & Optional Dependencies with default-implementation -->
-  <component
-    classname="org.apache.felix.ipojo.runtime.core.test.components.CheckServiceProvider"
-    name="DISimpleOptionalCheckServiceProvider" architecture="true">
-    <requires field="fs" optional="true"
-      default-implementation="org.apache.felix.ipojo.runtime.core.test.components.FooServiceDefaultImpl" />
-    <provides />
-  </component>
-  <component
-    classname="org.apache.felix.ipojo.runtime.core.test.components.CheckServiceProvider"
-    name="DIVoidOptionalCheckServiceProvider" architecture="true">
-    <requires field="fs" optional="true"
-      default-implementation="org.apache.felix.ipojo.runtime.core.test.components.FooServiceDefaultImpl">
-      <callback type="bind" method="voidBind" />
-      <callback type="unbind" method="voidUnbind" />
-    </requires>
-    <provides />
-  </component>
-  <component
-    classname="org.apache.felix.ipojo.runtime.core.test.components.CheckServiceProvider"
-    name="DIObjectOptionalCheckServiceProvider" architecture="true">
-    <requires field="fs" optional="true"
-      default-implementation="org.apache.felix.ipojo.runtime.core.test.components.FooServiceDefaultImpl">
-      <callback type="bind" method="objectBind" />
-      <callback type="unbind" method="objectUnbind" />
-    </requires>
-    <provides />
-  </component>
-  <component
-    classname="org.apache.felix.ipojo.runtime.core.test.components.CheckServiceProvider"
-    name="DIRefOptionalCheckServiceProvider" architecture="true">
-    <requires field="fs" optional="true"
-      default-implementation="org.apache.felix.ipojo.runtime.core.test.components.FooServiceDefaultImpl">
-      <callback type="bind" method="refBind" />
-      <callback type="unbind" method="refUnbind" />
-    </requires>
-    <provides />
-  </component>
-  <component
-    classname="org.apache.felix.ipojo.runtime.core.test.components.CheckServiceProvider"
-    name="DIBothOptionalCheckServiceProvider" architecture="true">
-    <requires field="fs" optional="true"
-      default-implementation="org.apache.felix.ipojo.runtime.core.test.components.FooServiceDefaultImpl">
-      <callback type="bind" method="bothBind" />
-      <callback type="unbind" method="bothUnbind" />
-    </requires>
-    <provides />
-  </component>
-  <component
-    classname="org.apache.felix.ipojo.runtime.core.test.components.CheckServiceProvider"
-    name="DIMapOptionalCheckServiceProvider" architecture="true">
-    <requires field="fs" optional="true"
-      default-implementation="org.apache.felix.ipojo.runtime.core.test.components.FooServiceDefaultImpl">
-      <callback type="bind" method="propertiesMapBind" />
-      <callback type="unbind" method="propertiesMapUnbind" />
-    </requires>
-    <provides />
-  </component>
-  <component
-    classname="org.apache.felix.ipojo.runtime.core.test.components.CheckServiceProvider"
-    name="DIDictOptionalCheckServiceProvider" architecture="true">
-    <requires field="fs" optional="true"
-      default-implementation="org.apache.felix.ipojo.runtime.core.test.components.FooServiceDefaultImpl">
-      <callback type="bind" method="propertiesDictionaryBind" />
-      <callback type="unbind" method="propertiesDictionaryUnbind" />
-    </requires>
-    <provides />
-  </component>
-
-  <component
-    classname="org.apache.felix.ipojo.runtime.core.test.components.MethodCheckServiceProvider"
-    name="DIMObjectOptionalCheckServiceProvider" architecture="true">
-    <requires optional="true"
-      default-implementation="org.apache.felix.ipojo.runtime.core.test.components.FooServiceDefaultImpl">
-      <callback type="bind" method="objectBind" />
-      <callback type="unbind" method="objectUnbind" />
-    </requires>
-    <provides />
-  </component>
-  <component
-    classname="org.apache.felix.ipojo.runtime.core.test.components.MethodCheckServiceProvider"
-    name="DIMRefOptionalCheckServiceProvider" architecture="true">
-    <requires
-      specification="org.apache.felix.ipojo.runtime.core.test.services.FooService"
-      optional="true"
-      default-implementation="org.apache.felix.ipojo.runtime.core.test.components.FooServiceDefaultImpl">
-      <callback type="bind" method="refBind" />
-      <callback type="unbind" method="refUnbind" />
-    </requires>
-    <provides />
-  </component>
-  <component
-    classname="org.apache.felix.ipojo.runtime.core.test.components.MethodCheckServiceProvider"
-    name="DIMBothOptionalCheckServiceProvider" architecture="true">
-    <requires
-      specification="org.apache.felix.ipojo.runtime.core.test.services.FooService"
-      optional="true"
-      default-implementation="org.apache.felix.ipojo.runtime.core.test.components.FooServiceDefaultImpl">
-      <callback type="bind" method="bothBind" />
-      <callback type="unbind" method="bothUnbind" />
-    </requires>
-    <provides />
-  </component>
-  <component
-    classname="org.apache.felix.ipojo.runtime.core.test.components.MethodCheckServiceProvider"
-    name="DIMMapOptionalCheckServiceProvider" architecture="true">
-    <requires
-      specification="org.apache.felix.ipojo.runtime.core.test.services.FooService"
-      optional="true"
-      default-implementation="org.apache.felix.ipojo.runtime.core.test.components.FooServiceDefaultImpl">
-      <callback type="bind" method="propertiesMapBind" />
-      <callback type="unbind" method="propertiesMapUnbind" />
-    </requires>
-    <provides />
-  </component>
-  <component
-    classname="org.apache.felix.ipojo.runtime.core.test.components.MethodCheckServiceProvider"
-    name="DIMDictOptionalCheckServiceProvider" architecture="true">
-    <requires
-      specification="org.apache.felix.ipojo.runtime.core.test.services.FooService"
-      optional="true"
-      default-implementation="org.apache.felix.ipojo.runtime.core.test.components.FooServiceDefaultImpl">
-      <callback type="bind" method="propertiesDictionaryBind" />
-      <callback type="unbind" method="propertiesDictionaryUnbind" />
-    </requires>
-    <provides />
-  </component>
 
   <!--  Multiple Dependencies -->
   <component
@@ -597,13 +239,6 @@ xmlns:xsi="http://www.w3.org/2001/XMLSch
   </component>
   <component
     classname="org.apache.felix.ipojo.runtime.core.test.components.MultipleCheckService"
-    name="ProxiedSimpleMultipleCheckServiceProvider" architecture="true">
-    <requires field="fs" />
-    <provides />
-  </component>
-
-  <component
-    classname="org.apache.felix.ipojo.runtime.core.test.components.MultipleCheckService"
     name="VoidMultipleCheckServiceProvider" architecture="true">
     <requires field="fs" proxy="false">
       <callback type="bind" method="voidBind" />
@@ -613,15 +248,6 @@ xmlns:xsi="http://www.w3.org/2001/XMLSch
   </component>
   <component
     classname="org.apache.felix.ipojo.runtime.core.test.components.MultipleCheckService"
-    name="ProxiedVoidMultipleCheckServiceProvider" architecture="true">
-    <requires field="fs">
-      <callback type="bind" method="voidBind" />
-      <callback type="unbind" method="voidUnbind" />
-    </requires>
-    <provides />
-  </component>
-  <component
-    classname="org.apache.felix.ipojo.runtime.core.test.components.MultipleCheckService"
     name="ObjectMultipleCheckServiceProvider" architecture="true">
     <requires field="fs" proxy="false">
       <callback type="bind" method="objectBind" />
@@ -631,15 +257,6 @@ xmlns:xsi="http://www.w3.org/2001/XMLSch
   </component>
   <component
     classname="org.apache.felix.ipojo.runtime.core.test.components.MultipleCheckService"
-    name="ProxiedObjectMultipleCheckServiceProvider" architecture="true">
-    <requires field="fs">
-      <callback type="bind" method="objectBind" />
-      <callback type="unbind" method="objectUnbind" />
-    </requires>
-    <provides />
-  </component>
-  <component
-    classname="org.apache.felix.ipojo.runtime.core.test.components.MultipleCheckService"
     name="RefMultipleCheckServiceProvider" architecture="true">
     <requires field="fs" proxy="false">
       <callback type="bind" method="refBind" />
@@ -647,15 +264,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSch
     </requires>
     <provides />
   </component>
-  <component
-    classname="org.apache.felix.ipojo.runtime.core.test.components.MultipleCheckService"
-    name="ProxiedRefMultipleCheckServiceProvider" architecture="true">
-    <requires field="fs">
-      <callback type="bind" method="refBind" />
-      <callback type="unbind" method="refUnbind" />
-    </requires>
-    <provides />
-  </component>
+
 
   <component
     classname="org.apache.felix.ipojo.runtime.core.test.components.MultipleCheckService"
@@ -668,15 +277,6 @@ xmlns:xsi="http://www.w3.org/2001/XMLSch
   </component>
   <component
     classname="org.apache.felix.ipojo.runtime.core.test.components.MultipleCheckService"
-    name="ProxiedBothMultipleCheckServiceProvider" architecture="true">
-    <requires field="fs">
-      <callback type="bind" method="bothBind" />
-      <callback type="unbind" method="bothUnbind" />
-    </requires>
-    <provides />
-  </component>
-  <component
-    classname="org.apache.felix.ipojo.runtime.core.test.components.MultipleCheckService"
     name="MapMultipleCheckServiceProvider" architecture="true">
     <requires field="fs" proxy="false">
       <callback type="bind" method="propertiesMapBind" />
@@ -684,15 +284,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSch
     </requires>
     <provides />
   </component>
-  <component
-    classname="org.apache.felix.ipojo.runtime.core.test.components.MultipleCheckService"
-    name="ProxiedMapMultipleCheckServiceProvider" architecture="true">
-    <requires field="fs">
-      <callback type="bind" method="propertiesMapBind" />
-      <callback type="unbind" method="propertiesMapUnbind" />
-    </requires>
-    <provides />
-  </component>
+
 
   <component
     classname="org.apache.felix.ipojo.runtime.core.test.components.MultipleCheckService"
@@ -703,15 +295,6 @@ xmlns:xsi="http://www.w3.org/2001/XMLSch
     </requires>
     <provides />
   </component>
-  <component
-    classname="org.apache.felix.ipojo.runtime.core.test.components.MultipleCheckService"
-    name="ProxiedDictMultipleCheckServiceProvider" architecture="true">
-    <requires field="fs">
-      <callback type="bind" method="propertiesDictionaryBind" />
-      <callback type="unbind" method="propertiesDictionaryUnbind" />
-    </requires>
-    <provides />
-  </component>
 
   <component
     classname="org.apache.felix.ipojo.runtime.core.test.components.MethodMultipleCheckService"
@@ -762,6 +345,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSch
   </component>
 
   <!-- Multiple & Optional Dependencies -->
+  <!-- Used in architecture tests -->
   <component
     classname="org.apache.felix.ipojo.runtime.core.test.components.MultipleCheckService"
     name="SimpleOptionalMultipleCheckServiceProvider"
@@ -769,97 +353,6 @@ xmlns:xsi="http://www.w3.org/2001/XMLSch
     <requires field="fs" optional="true" proxy="false"/>
     <provides />
   </component>
-  <component
-    classname="org.apache.felix.ipojo.runtime.core.test.components.MultipleCheckService"
-    name="VoidOptionalMultipleCheckServiceProvider"
-    architecture="true">
-    <requires field="fs" optional="true" proxy="false">
-      <callback type="bind" method="voidBind" />
-      <callback type="unbind" method="voidUnbind" />
-    </requires>
-    <provides />
-  </component>
-  <component
-    classname="org.apache.felix.ipojo.runtime.core.test.components.MultipleCheckService"
-    name="ObjectOptionalMultipleCheckServiceProvider"
-    architecture="true">
-    <requires field="fs" optional="true" proxy="false">
-      <callback type="bind" method="objectBind" />
-      <callback type="unbind" method="objectUnbind" />
-    </requires>
-    <provides />
-  </component>
-  <component
-    classname="org.apache.felix.ipojo.runtime.core.test.components.MultipleCheckService"
-    name="RefOptionalMultipleCheckServiceProvider"
-    architecture="true">
-    <requires field="fs" optional="true" proxy="false">
-      <callback type="bind" method="refBind" />
-      <callback type="unbind" method="refUnbind" />
-    </requires>
-    <provides />
-  </component>
-
-  <component
-    classname="org.apache.felix.ipojo.runtime.core.test.components.MultipleCheckService"
-    name="ProxiedSimpleOptionalMultipleCheckServiceProvider"
-    architecture="true">
-    <requires field="fs" optional="true" />
-    <provides />
-  </component>
-  <component
-    classname="org.apache.felix.ipojo.runtime.core.test.components.MultipleCheckService"
-    name="ProxiedVoidOptionalMultipleCheckServiceProvider"
-    architecture="true">
-    <requires field="fs" optional="true">
-      <callback type="bind" method="voidBind" />
-      <callback type="unbind" method="voidUnbind" />
-    </requires>
-    <provides />
-  </component>
-  <component
-    classname="org.apache.felix.ipojo.runtime.core.test.components.MultipleCheckService"
-    name="ProxiedObjectOptionalMultipleCheckServiceProvider"
-    architecture="true">
-    <requires field="fs" optional="true">
-      <callback type="bind" method="objectBind" />
-      <callback type="unbind" method="objectUnbind" />
-    </requires>
-    <provides />
-  </component>
-  <component
-    classname="org.apache.felix.ipojo.runtime.core.test.components.MultipleCheckService"
-    name="ProxiedRefOptionalMultipleCheckServiceProvider"
-    architecture="true">
-    <requires field="fs" optional="true">
-      <callback type="bind" method="refBind" />
-      <callback type="unbind" method="refUnbind" />
-    </requires>
-    <provides />
-  </component>
-
-  <component
-    classname="org.apache.felix.ipojo.runtime.core.test.components.MethodMultipleCheckService"
-    name="MObjectOptionalMultipleCheckServiceProvider"
-    architecture="true">
-    <requires aggregate="true" optional="true">
-      <callback type="bind" method="objectBind" />
-      <callback type="unbind" method="objectUnbind" />
-    </requires>
-    <provides />
-  </component>
-  <component
-    classname="org.apache.felix.ipojo.runtime.core.test.components.MethodMultipleCheckService"
-    name="MRefOptionalMultipleCheckServiceProvider"
-    architecture="true">
-    <requires
-      specification="org.apache.felix.ipojo.runtime.core.test.services.FooService"
-      aggregate="true" optional="true">
-      <callback type="bind" method="refBind" />
-      <callback type="unbind" method="refUnbind" />
-    </requires>
-    <provides />
-  </component>
 
   <!-- Aggregate dependency as List -->
   <component
@@ -877,19 +370,6 @@ xmlns:xsi="http://www.w3.org/2001/XMLSch
       specification="org.apache.felix.ipojo.runtime.core.test.services.FooService" field="fs" optional="true" />
     <provides />
   </component>
-   <component
-    classname="org.apache.felix.ipojo.runtime.core.test.components.ListCheckService"
-    name="ProxiedSimpleListCheckServiceProvider" architecture="true">
-    <requires field="fs" specification="org.apache.felix.ipojo.runtime.core.test.services.FooService"/>
-    <provides />
-  </component>
-  <component
-    classname="org.apache.felix.ipojo.runtime.core.test.components.ListCheckService"
-    name="ProxiedOptionalListCheckServiceProvider"
-    architecture="true">
-    <requires specification="org.apache.felix.ipojo.runtime.core.test.services.FooService" field="fs" optional="true" />
-    <provides />
-  </component>
 
   <!-- Aggregate dependency as Vector -->
   <component
@@ -923,19 +403,6 @@ xmlns:xsi="http://www.w3.org/2001/XMLSch
     <requires proxy="false" specification="org.apache.felix.ipojo.runtime.core.test.services.FooService" field="fs" optional="true" />
     <provides />
   </component>
-  <component
-    classname="org.apache.felix.ipojo.runtime.core.test.components.SetCheckService"
-    name="ProxiedSimpleSetCheckServiceProvider" architecture="true">
-    <requires field="fs" specification="org.apache.felix.ipojo.runtime.core.test.services.FooService"/>
-    <provides />
-  </component>
-  <component
-    classname="org.apache.felix.ipojo.runtime.core.test.components.SetCheckService"
-    name="ProxiedOptionalSetCheckServiceProvider"
-    architecture="true">
-    <requires specification="org.apache.felix.ipojo.runtime.core.test.services.FooService" field="fs" optional="true" />
-    <provides />
-  </component>
 
   <!-- Aggregate dependency as Collection -->
   <component
@@ -946,12 +413,6 @@ xmlns:xsi="http://www.w3.org/2001/XMLSch
   </component>
   <component
     classname="org.apache.felix.ipojo.runtime.core.test.components.CollectionCheckService"
-    name="ProxiedSimpleCollectionCheckServiceProvider" architecture="true">
-    <requires field="fs" specification="org.apache.felix.ipojo.runtime.core.test.services.FooService"/>
-    <provides />
-  </component>
-  <component
-    classname="org.apache.felix.ipojo.runtime.core.test.components.CollectionCheckService"
     name="OptionalCollectionCheckServiceProvider"
     architecture="true">
     <requires specification="org.apache.felix.ipojo.runtime.core.test.services.FooService" field="fs" optional="true"
@@ -959,15 +420,6 @@ xmlns:xsi="http://www.w3.org/2001/XMLSch
     />
     <provides />
   </component>
-  <component
-    classname="org.apache.felix.ipojo.runtime.core.test.components.CollectionCheckService"
-    name="ProxiedOptionalCollectionCheckServiceProvider"
-    architecture="true">
-    <requires specification="org.apache.felix.ipojo.runtime.core.test.services.FooService" field="fs" optional="true"
-      proxy="false"
-    />
-    <provides />
-  </component>
 
 
   <!-- Modify method test -->
@@ -1040,22 +492,6 @@ xmlns:xsi="http://www.w3.org/2001/XMLSch
     <provides />
   </component>
 
-  <!--  Proxy Tests -->
-  <component classname="org.apache.felix.ipojo.runtime.core.test.components.proxy.CheckServiceDelegator">
-    <provides/>
-    <requires field="fs" optional="true"/>
-  </component>
-  <component classname="org.apache.felix.ipojo.runtime.core.test.components.proxy.CheckServiceGetAndDelegate">
-    <provides/>
-    <requires field="fs" optional="true"/>
-  </component>
-  <component classname="org.apache.felix.ipojo.runtime.core.test.components.proxy.CheckServiceNoDelegate">
-      <provides/>
-      <requires field="fs" optional="true"/>
-      <callback transition="validate" method="start"/>
-    <callback transition="invalidate" method="stop"/>
-  </component>
-
   <component
   	classname="org.apache.felix.ipojo.runtime.core.test.components.proxy.CheckServiceUsingStringService"
   	immediate="true">

Modified: felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/Common.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/Common.java?rev=1479322&r1=1479321&r2=1479322&view=diff
==============================================================================
--- felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/Common.java (original)
+++ felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/Common.java Sun May  5 13:55:09 2013
@@ -19,255 +19,21 @@
 
 package org.apache.felix.ipojo.runtime.core.test.dependencies;
 
-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 org.ow2.chameleon.testing.helpers.BaseTest;
 
-import static org.ops4j.pax.exam.CoreOptions.*;
+import java.util.Arrays;
+import java.util.List;
 
 /**
  * Bootstrap the test from this project
  */
-@RunWith(PaxExam.class)
-@ExamReactorStrategy(PerClass.class)
-public class Common {
-
-    @Inject
-    BundleContext bc;
-
-    protected OSGiHelper osgiHelper;
-    protected 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(
-                cleanCaches(),
-                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);
-
-        // Wait for stability.
-        waitForStability(bc);
-    }
-
-    /**
-     * 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.out.println("Bundle stability isn't reached after 500 tries");
-            dumpBundles(context);
-            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);
-            dumpBundles(context);
-            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 {
 
-    /**
-     * Prints the bundle list.
-     *
-     * @param bc the bundle context.
-     */
-    public void dumpBundles(BundleContext bc) {
-        System.out.println("Bundles:");
-        Bundle[] bundles = bc.getBundles();
-        for (int i = 0; i < bundles.length; i++) {
-            System.out.println(bundles[i].getSymbolicName() + " - " + bundles[i].getState());
-        }
-    }
-
-
-    @After
-    public void commonTearDown() {
-        osgiHelper.dispose();
-        ipojoHelper.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 CompositeOption eventadmin() {
-        return new DefaultCompositeOption(
-                mavenBundle("org.apache.felix", "org.apache.felix.eventadmin", "1.3.0"),
-                mavenBundle("org.apache.felix", "org.apache.felix.ipojo.handler.eventadmin",
-                        "1.8.0").versionAsInProject());
-    }
-
-    public Option testedBundle() throws MalformedURLException {
-        File out = new File("target/bundles/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);
-            }
-        }
-
-        // We export 'inner'
-        String export = "org.apache.felix.ipojo.runtime.core.test.components.inner";
-        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 BundleContext getContext() {
-        return bc;
+    @Override
+    protected List<String> getExtraExports() {
+        return Arrays.asList(
+                "org.apache.felix.ipojo.runtime.core.test.components.inner"
+        );
     }
 
 }

Modified: felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/TestSimpleDependencies.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/TestSimpleDependencies.java?rev=1479322&r1=1479321&r2=1479322&view=diff
==============================================================================
--- felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/TestSimpleDependencies.java (original)
+++ felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/TestSimpleDependencies.java Sun May  5 13:55:09 2013
@@ -26,6 +26,7 @@ import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 import org.osgi.framework.ServiceReference;
+import org.ow2.chameleon.testing.helpers.Stability;
 
 import java.util.Properties;
 
@@ -38,6 +39,8 @@ public class TestSimpleDependencies exte
 
     @Before
     public void setUp() {
+        Stability.waitForStability(getContext());
+        System.gc();
         try {
             Properties prov = new Properties();
             prov.put("instance.name", "FooProvider");

Modified: felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-service-providing-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-service-providing-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-service-providing-test/src/test/java/org/apache/felix/ipojo/runtime/core/Common.java (original)
+++ felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-service-providing-test/src/test/java/org/apache/felix/ipojo/runtime/core/Common.java Sun May  5 13:55:09 2013
@@ -19,213 +19,34 @@
 
 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 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.Arrays;
 import java.util.List;
 
 import static junit.framework.Assert.fail;
-import static org.ops4j.pax.exam.CoreOptions.*;
 
 /**
  * Bootstrap the test from this project
  */
-@RunWith(PaxExam.class)
-@ExamReactorStrategy(PerMethod.class)
-public class Common {
+public class Common extends BaseTest {
 
-    @Inject
-    protected
-    BundleContext bc;
-
-    protected OSGiHelper osgiHelper;
-    protected IPOJOHelper ipojoHelper;
-
-    protected boolean deployTestedBundle = true;
-
-    @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")
-            );
-        }
-    }
-
-    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();
+    @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()
+    @Override
+    protected List<String> getExtraExports() {
+        return Arrays.asList(
+                "org.apache.felix.ipojo.runtime.core.components",
+                "org.apache.felix.ipojo.runtime.core.components.inherited",
+                "org.apache.felix.ipojo.runtime.core.components.strategies",
+                "org.apache.felix.ipojo.runtime.core.components.inheritance.a",
+                "org.apache.felix.ipojo.runtime.core.components.inheritance.b"
         );
     }
 
-    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)) {
@@ -235,75 +56,5 @@ 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 (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-service-providing-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestProvidedServiceArchitecture.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-service-providing-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestProvidedServiceArchitecture.java?rev=1479322&r1=1479321&r2=1479322&view=diff
==============================================================================
--- felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-service-providing-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestProvidedServiceArchitecture.java (original)
+++ felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-service-providing-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestProvidedServiceArchitecture.java Sun May  5 13:55:09 2013
@@ -174,7 +174,6 @@ public class TestProvidedServiceArchitec
         assertEquals("Check ProvidedService number", ps.length, 1);
         assertEquals("Check Provided Service Specs - 1", ps[0].getServiceSpecifications().length, 2);
         assertContains("Check provided service specs - 2", ps[0].getServiceSpecifications(), FooService.class.getName());
-        ;
         assertContains("Check provided service specs - 2", ps[0].getServiceSpecifications(), BarService.class.getName());
         assertEquals("Check Provided Service availability", ps[0].getState(), ProvidedServiceDescription.REGISTERED);
 



Mime
View raw message