Test refactoring.
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1479879 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/ipojo/runtime/api-it/pom.xml b/ipojo/runtime/api-it/pom.xml
index b69bbc0..aaa8ace 100644
--- a/ipojo/runtime/api-it/pom.xml
+++ b/ipojo/runtime/api-it/pom.xml
@@ -206,7 +206,7 @@
<dependency>
<groupId>org.ow2.chameleon.testing</groupId>
<artifactId>osgi-helpers</artifactId>
- <version>0.6.0</version>
+ <version>0.6.1-SNAPSHOT</version>
<scope>test</scope>
</dependency>
diff --git a/ipojo/runtime/api-it/src/it/ipojo-api-test/src/test/java/org/apache/felix/ipojo/runtime/core/api/Common.java b/ipojo/runtime/api-it/src/it/ipojo-api-test/src/test/java/org/apache/felix/ipojo/runtime/core/api/Common.java
index 36dbd65..df7c115 100644
--- a/ipojo/runtime/api-it/src/it/ipojo-api-test/src/test/java/org/apache/felix/ipojo/runtime/core/api/Common.java
+++ b/ipojo/runtime/api-it/src/it/ipojo-api-test/src/test/java/org/apache/felix/ipojo/runtime/core/api/Common.java
@@ -19,97 +19,24 @@
package org.apache.felix.ipojo.runtime.core.api;
-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.ComponentInstance;
import org.apache.felix.ipojo.ServiceContext;
import org.apache.felix.ipojo.composite.CompositeManager;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.runner.RunWith;
-import org.ops4j.pax.exam.Configuration;
-import org.ops4j.pax.exam.CoreOptions;
import org.ops4j.pax.exam.Option;
-import org.ops4j.pax.exam.junit.PaxExam;
-import org.ops4j.pax.exam.options.CompositeOption;
-import org.ops4j.pax.exam.options.DefaultCompositeOption;
import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
import org.ops4j.pax.exam.spi.reactors.PerMethod;
-import org.ops4j.pax.tinybundles.core.TinyBundle;
-import org.ops4j.pax.tinybundles.core.TinyBundles;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.Constants;
-import org.osgi.framework.ServiceReference;
-import org.ow2.chameleon.testing.helpers.IPOJOHelper;
-import org.ow2.chameleon.testing.helpers.OSGiHelper;
-import org.ow2.chameleon.testing.tinybundles.ipojo.IPOJOStrategy;
-import org.slf4j.LoggerFactory;
+import org.ow2.chameleon.testing.helpers.BaseTest;
-import javax.inject.Inject;
-import java.io.File;
-import java.io.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.*;
+import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
/**
* Bootstrap the test from this project
*/
-@RunWith(PaxExam.class)
@ExamReactorStrategy(PerMethod.class)
-public class Common {
-
- @Inject
- protected
- BundleContext bc;
- protected OSGiHelper osgiHelper;
- protected IPOJOHelper ipojoHelper;
- protected boolean deployTestedBundle = true;
-
- public static Option junitAndMockitoBundles() {
- return new DefaultCompositeOption(
- // Repository required to load harmcrest (OSGi-fied version).
- repository("http://repository.springsource.com/maven/bundles/external").id(
- "com.springsource.repository.bundles.external"),
-
- // Mockito without Hamcrest and Objenesis
- mavenBundle("org.mockito", "mockito-core", "1.9.5"),
-
- // Hamcrest with a version matching the range expected by Mockito
- mavenBundle("org.hamcrest", "com.springsource.org.hamcrest.core", "1.1.0"),
-
- // Objenesis with a version matching the range expected by Mockito
- wrappedBundle(mavenBundle("org.objenesis", "objenesis", "1.2"))
- .exports("*;version=1.2"),
-
- // The default JUnit bundle also exports Hamcrest, but with an (incorrect) version of
- // 4.9 which does not match the Mockito import.
- CoreOptions.junitBundles(),
-
- /*
- * Felix has implicit boot delegation enabled by default. It conflicts with Mockito:
- * java.lang.LinkageError: loader constraint violation in interface itable initialization:
- * when resolving method "org.osgi.service.useradmin.User$$EnhancerByMockitoWithCGLIB$$dd2f81dc
- * .newInstance(Lorg/mockito/cglib/proxy/Callback;)Ljava/lang/Object;" the class loader
- * (instance of org/mockito/internal/creation/jmock/SearchingClassLoader) of the current class,
- * org/osgi/service/useradmin/User$$EnhancerByMockitoWithCGLIB$$dd2f81dc, and the class loader
- * (instance of org/apache/felix/framework/BundleWiringImpl$BundleClassLoaderJava5) for interface
- * org/mockito/cglib/proxy/Factory have different Class objects for the type org/mockito/cglib/
- * proxy/Callback used in the signature
- *
- * So we disable the bootdelegation.
- */
- frameworkProperty("felix.bootdelegation.implicit").value("false")
- );
- }
+public class Common extends BaseTest {
public static ServiceContext getServiceContext(ComponentInstance ci) {
if (ci instanceof CompositeManager) {
@@ -119,203 +46,28 @@
}
}
- @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")
- );
- }
+ @Override
+ public boolean deployiPOJOComposite() {
+ return true;
}
- @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 deployConfigAdmin() {
+ return true;
}
- @After
- public void commonTearDown() {
- ipojoHelper.dispose();
- osgiHelper.dispose();
+ @Override
+ protected Option[] getCustomOptions() {
+ return new Option[]{
+ mavenBundle("org.apache.felix", "org.apache.felix.ipojo.handler.whiteboard").versionAsInProject(),
+ mavenBundle("org.apache.felix", "org.apache.felix.ipojo.api").versionAsInProject()
+ };
}
- public BundleContext getContext() {
- return bc;
- }
-
- public CompositeOption ipojoBundles() {
- return new DefaultCompositeOption(
- mavenBundle("org.apache.felix", "org.apache.felix.ipojo").versionAsInProject(),
- mavenBundle("org.apache.felix", "org.apache.felix.ipojo.composite").versionAsInProject(),
- mavenBundle("org.apache.felix", "org.apache.felix.ipojo.api").versionAsInProject(),
- mavenBundle("org.ow2.chameleon.testing", "osgi-helpers").versionAsInProject(),
- // configuration admin
- mavenBundle("org.apache.felix", "org.apache.felix.configadmin").versionAsInProject(),
- // whiteboard pattern handler
- mavenBundle("org.apache.felix", "org.apache.felix.ipojo.handler.whiteboard").versionAsInProject()
+ @Override
+ protected List<String> getExtraExports() {
+ return Arrays.asList(
+ "org.apache.felix.ipojo.runtime.core.api.components"
);
}
-
- public Option testedBundle() throws MalformedURLException {
- File out = new File("target/tested/bundle.jar");
- if (out.exists()) {
- return bundle(out.toURI().toURL().toExternalForm());
- }
-
- TinyBundle tested = TinyBundles.bundle();
-
- // We look inside target/classes to find the class and resources
- File classes = new File("target/classes");
- Collection<File> files = FileUtils.listFilesAndDirs(classes, TrueFileFilter.INSTANCE, TrueFileFilter.INSTANCE);
- List<File> services = new ArrayList<File>();
- for (File file : files) {
- if (file.isDirectory()) {
- // By convention we export of .services and .service package
- if (file.getName().endsWith("services") || file.getName().endsWith("service")) {
- services.add(file);
- }
- } else {
- // We need to compute the path
- String path = file.getAbsolutePath().substring(classes.getAbsolutePath().length() + 1);
- tested.add(path, file.toURI().toURL());
- System.out.println(file.getName() + " added to " + path);
- }
- }
-
- // Export the components and services
- String export = "org.apache.felix.ipojo.runtime.core.api.components";
- 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;
- }
-
-
}
diff --git a/ipojo/runtime/composite-it/pom.xml b/ipojo/runtime/composite-it/pom.xml
index 7cf9920..42e8c48 100644
--- a/ipojo/runtime/composite-it/pom.xml
+++ b/ipojo/runtime/composite-it/pom.xml
@@ -75,10 +75,11 @@
</includes>
<excludes>
<exclude>src/main/appended-resources/**</exclude>
- <exclude>**/*.iml</exclude> <!-- Exclude iml files -->
+ <exclude>**/*.iml</exclude>
+ <!-- Exclude iml files -->
<!-- Exclude target folders that may have been created during
the integration-tests -->
- <exclude>src/it/**/target/**/*</exclude>
+ <exclude>src/it/**/target/**/*</exclude>
</excludes>
</configuration>
</plugin>
@@ -123,13 +124,6 @@
</dependency>
<dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.framework</artifactId>
- <version>4.2.0</version>
- <scope>test</scope>
- </dependency>
-
- <dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
<version>0.9.6</version>
@@ -167,12 +161,24 @@
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.ipojo</artifactId>
<version>1.9.0-SNAPSHOT</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
-
+
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.ipojo.composite</artifactId>
<version>1.9.0-SNAPSHOT</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
@@ -197,7 +203,7 @@
<dependency>
<groupId>org.ow2.chameleon.testing</groupId>
<artifactId>osgi-helpers</artifactId>
- <version>0.6.0</version>
+ <version>0.6.1-SNAPSHOT</version>
<scope>test</scope>
</dependency>
@@ -215,6 +221,12 @@
test.
-->
<version>1.8.0</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
@@ -256,6 +268,12 @@
<version>5.2.0</version>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ <version>4.3.1</version>
+ <scope>provided</scope>
+ </dependency>
</dependencies>
</profile>
@@ -278,13 +296,19 @@
<version>3.8.1.v20120830-144521</version>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ <version>4.3.1</version>
+ <scope>provided</scope>
+ </dependency>
</dependencies>
</profile>
<profile>
<id>felix</id>
<activation>
- <activeByDefault>false</activeByDefault>
+ <activeByDefault>true</activeByDefault>
<property>
<name>pax.exam.framework</name>
<value>felix</value>
@@ -300,10 +324,54 @@
<version>4.2.0</version>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ <version>4.3.1</version>
+ <scope>provided</scope>
+ </dependency>
</dependencies>
</profile>
<profile>
+ <!--
+ avoid using the invoker and use a regular reactor instead.
+ it must be coupled with another profile to select the right OSGi framework implementation
+
+ * mvn clean install -Preactor,felix
+ * mvn clean install -Preactor,equinox
+ * mvn clean install -Preactor,knopflerfish
+ -->
+ <id>reactor</id>
+
+ <modules>
+ <module>src/it/ipojo-composite-runtime-test</module>
+ <module>src/it/ipojo-composite-import-export-test</module>
+ <module>src/it/ipojo-composite-instance-test</module>
+ <module>src/it/ipojo-composite-service-providing-test</module>
+ </modules>
+
+ <build>
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>2.14.1</version>
+ <configuration>
+ <systemPropertyVariables>
+ <!-- TIME_FACTOR can be set from the command line with -DTIME_FACTOR=9-->
+ <TIME_FACTOR>${TIME_FACTOR}</TIME_FACTOR>
+ </systemPropertyVariables>
+ </configuration>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ </build>
+
+ </profile>
+
+ <profile>
<id>test</id>
<activation>
<activeByDefault>true</activeByDefault>
diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-import-export-test/src/test/java/org/apache/felix/ipojo/runtime/core/Common.java b/ipojo/runtime/composite-it/src/it/ipojo-composite-import-export-test/src/test/java/org/apache/felix/ipojo/runtime/core/Common.java
index 3ea95ca..13a950f 100644
--- a/ipojo/runtime/composite-it/src/it/ipojo-composite-import-export-test/src/test/java/org/apache/felix/ipojo/runtime/core/Common.java
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-import-export-test/src/test/java/org/apache/felix/ipojo/runtime/core/Common.java
@@ -19,150 +19,28 @@
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.ComponentInstance;
import org.apache.felix.ipojo.ServiceContext;
import org.apache.felix.ipojo.composite.CompositeManager;
-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 org.ow2.chameleon.testing.helpers.BaseTest;
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")
- );
- }
+ @Override
+ public boolean deployiPOJOComposite() {
+ return true;
}
- public static Option junitAndMockitoBundles() {
- return new DefaultCompositeOption(
- // Repository required to load harmcrest (OSGi-fied version).
- repository("http://repository.springsource.com/maven/bundles/external").id(
- "com.springsource.repository.bundles.external"),
-
- // Mockito without Hamcrest and Objenesis
- mavenBundle("org.mockito", "mockito-core", "1.9.5"),
-
- // Hamcrest with a version matching the range expected by Mockito
- mavenBundle("org.hamcrest", "com.springsource.org.hamcrest.core", "1.1.0"),
-
- // Objenesis with a version matching the range expected by Mockito
- wrappedBundle(mavenBundle("org.objenesis", "objenesis", "1.2"))
- .exports("*;version=1.2"),
-
- // The default JUnit bundle also exports Hamcrest, but with an (incorrect) version of
- // 4.9 which does not match the Mockito import.
- CoreOptions.junitBundles(),
-
- /*
- * Felix has implicit boot delegation enabled by default. It conflicts with Mockito:
- * java.lang.LinkageError: loader constraint violation in interface itable initialization:
- * when resolving method "org.osgi.service.useradmin.User$$EnhancerByMockitoWithCGLIB$$dd2f81dc
- * .newInstance(Lorg/mockito/cglib/proxy/Callback;)Ljava/lang/Object;" the class loader
- * (instance of org/mockito/internal/creation/jmock/SearchingClassLoader) of the current class,
- * org/osgi/service/useradmin/User$$EnhancerByMockitoWithCGLIB$$dd2f81dc, and the class loader
- * (instance of org/apache/felix/framework/BundleWiringImpl$BundleClassLoaderJava5) for interface
- * org/mockito/cglib/proxy/Factory have different Class objects for the type org/mockito/cglib/
- * proxy/Callback used in the signature
- *
- * So we disable the bootdelegation.
- */
- frameworkProperty("felix.bootdelegation.implicit").value("false")
- );
- }
-
-
- @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 BundleContext getContext() {
- return bc;
- }
public static ServiceContext getServiceContext(ComponentInstance ci) {
if (ci instanceof CompositeManager) {
@@ -172,69 +50,6 @@
}
}
- public CompositeOption ipojoBundles() {
- return new DefaultCompositeOption(
- mavenBundle("org.apache.felix", "org.apache.felix.ipojo").versionAsInProject(),
- mavenBundle("org.apache.felix", "org.apache.felix.ipojo.composite").versionAsInProject(),
- mavenBundle("org.ow2.chameleon.testing", "osgi-helpers").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);
- }
- }
-
- // Export the inherited package, components and strategies
- 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)) {
@@ -243,76 +58,4 @@
}
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;
- }
-
-
}
diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-instance-test/src/test/java/org/apache/felix/ipojo/runtime/core/Common.java b/ipojo/runtime/composite-it/src/it/ipojo-composite-instance-test/src/test/java/org/apache/felix/ipojo/runtime/core/Common.java
index 3ea95ca..b0bf76b 100644
--- a/ipojo/runtime/composite-it/src/it/ipojo-composite-instance-test/src/test/java/org/apache/felix/ipojo/runtime/core/Common.java
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-instance-test/src/test/java/org/apache/felix/ipojo/runtime/core/Common.java
@@ -19,150 +19,18 @@
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.ComponentInstance;
import org.apache.felix.ipojo.ServiceContext;
import org.apache.felix.ipojo.composite.CompositeManager;
-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
- 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();
- }
-
- public BundleContext getContext() {
- return bc;
- }
+public class Common extends BaseTest {
public static ServiceContext getServiceContext(ComponentInstance ci) {
if (ci instanceof CompositeManager) {
@@ -172,147 +40,8 @@
}
}
- public CompositeOption ipojoBundles() {
- return new DefaultCompositeOption(
- mavenBundle("org.apache.felix", "org.apache.felix.ipojo").versionAsInProject(),
- mavenBundle("org.apache.felix", "org.apache.felix.ipojo.composite").versionAsInProject(),
- mavenBundle("org.ow2.chameleon.testing", "osgi-helpers").versionAsInProject(),
- // configuration admin
- mavenBundle("org.apache.felix", "org.apache.felix.configadmin").versionAsInProject()
- );
+ @Override
+ public boolean deployiPOJOComposite() {
+ return true;
}
-
- 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 = "";
- 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;
- }
-
-
}
diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/test/java/org/apache/felix/ipojo/runtime/core/Common.java b/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/test/java/org/apache/felix/ipojo/runtime/core/Common.java
index 3ea95ca..0b3f1b9 100644
--- a/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/test/java/org/apache/felix/ipojo/runtime/core/Common.java
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/test/java/org/apache/felix/ipojo/runtime/core/Common.java
@@ -19,150 +19,18 @@
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.ComponentInstance;
import org.apache.felix.ipojo.ServiceContext;
import org.apache.felix.ipojo.composite.CompositeManager;
-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
- 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();
- }
-
- public BundleContext getContext() {
- return bc;
- }
+public class Common extends BaseTest {
public static ServiceContext getServiceContext(ComponentInstance ci) {
if (ci instanceof CompositeManager) {
@@ -172,147 +40,9 @@
}
}
- public CompositeOption ipojoBundles() {
- return new DefaultCompositeOption(
- mavenBundle("org.apache.felix", "org.apache.felix.ipojo").versionAsInProject(),
- mavenBundle("org.apache.felix", "org.apache.felix.ipojo.composite").versionAsInProject(),
- mavenBundle("org.ow2.chameleon.testing", "osgi-helpers").versionAsInProject(),
- // configuration admin
- mavenBundle("org.apache.felix", "org.apache.felix.configadmin").versionAsInProject()
- );
+ @Override
+ public boolean deployiPOJOComposite() {
+ return true;
}
- 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 = "";
- 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;
- }
-
-
}
diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-service-providing-test/src/test/java/org/apache/felix/ipojo/runtime/core/Common.java b/ipojo/runtime/composite-it/src/it/ipojo-composite-service-providing-test/src/test/java/org/apache/felix/ipojo/runtime/core/Common.java
index 125f419..b0bf76b 100644
--- a/ipojo/runtime/composite-it/src/it/ipojo-composite-service-providing-test/src/test/java/org/apache/felix/ipojo/runtime/core/Common.java
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-service-providing-test/src/test/java/org/apache/felix/ipojo/runtime/core/Common.java
@@ -19,150 +19,18 @@
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.ComponentInstance;
import org.apache.felix.ipojo.ServiceContext;
import org.apache.felix.ipojo.composite.CompositeManager;
-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
- 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();
- }
-
- public BundleContext getContext() {
- return bc;
- }
+public class Common extends BaseTest {
public static ServiceContext getServiceContext(ComponentInstance ci) {
if (ci instanceof CompositeManager) {
@@ -172,148 +40,8 @@
}
}
- public CompositeOption ipojoBundles() {
- return new DefaultCompositeOption(
- mavenBundle("org.apache.felix", "org.apache.felix.ipojo").versionAsInProject(),
- mavenBundle("org.apache.felix", "org.apache.felix.ipojo.composite").versionAsInProject(),
- mavenBundle("org.ow2.chameleon.testing", "osgi-helpers").versionAsInProject(),
- // configuration admin
- mavenBundle("org.apache.felix", "org.apache.felix.configadmin").versionAsInProject()
- );
+ @Override
+ public boolean deployiPOJOComposite() {
+ return true;
}
-
- 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";
- 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;
- }
-
-
-
}
diff --git a/ipojo/runtime/core-it/pom.xml b/ipojo/runtime/core-it/pom.xml
index 1712f89..dffe93c 100644
--- a/ipojo/runtime/core-it/pom.xml
+++ b/ipojo/runtime/core-it/pom.xml
@@ -311,6 +311,66 @@
</profile>
<profile>
+ <id>release</id>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>make-assembly</id>
+ <phase>package</phase>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ <configuration>
+ <descriptorRefs>
+ <descriptorRef>project</descriptorRef>
+ </descriptorRefs>
+ <!-- we don't want to attach all the assemblies, such as bz2 -->
+ <attach>false</attach>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <!-- only attach the project and bin assemblies, in tar.gz and zip flavors -->
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>attach-assemblies</id>
+ <phase>package</phase>
+ <goals>
+ <goal>attach-artifact</goal>
+ </goals>
+ <configuration>
+ <artifacts>
+ <artifact>
+ <file>
+ ${project.build.directory}/${project.artifactId}-${project.version}-project.tar.gz
+ </file>
+ <classifier>project</classifier>
+ <type>tar.gz</type>
+ </artifact>
+ <artifact>
+ <file>
+ ${project.build.directory}/${project.artifactId}-${project.version}-project.zip
+ </file>
+ <classifier>project</classifier>
+ <type>zip</type>
+ </artifact>
+ </artifacts>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+
+ <profile>
<id>knopflerfish</id>
<activation>
<activeByDefault>false</activeByDefault>
diff --git a/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestComplexConfigurations.java b/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestComplexConfigurations.java
index 9615874..e718d41 100644
--- a/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestComplexConfigurations.java
+++ b/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestComplexConfigurations.java
@@ -34,6 +34,7 @@
import org.osgi.framework.BundleException;
import org.osgi.framework.Constants;
import org.osgi.framework.ServiceReference;
+import org.ow2.chameleon.testing.helpers.TimeUtils;
import org.ow2.chameleon.testing.tinybundles.ipojo.IPOJOStrategy;
import java.io.IOException;
@@ -120,6 +121,7 @@
if (isKnopflerfish()) {
return; // Test disabled on KF
}
+ TimeUtils.grace(500);
osgiHelper.waitForService(FooService.class, null, 10000);
ServiceReference ref1 = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), "complex1");
diff --git a/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestConfigurationOfMyComponent.java b/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestConfigurationOfMyComponent.java
index bbd943b..e02df8a 100644
--- a/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestConfigurationOfMyComponent.java
+++ b/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestConfigurationOfMyComponent.java
@@ -29,6 +29,7 @@
import org.ops4j.pax.exam.OptionUtils;
import org.ops4j.pax.tinybundles.core.TinyBundles;
import org.osgi.framework.Constants;
+import org.ow2.chameleon.testing.helpers.TimeUtils;
import org.ow2.chameleon.testing.tinybundles.ipojo.IPOJOStrategy;
import java.io.IOException;
@@ -71,6 +72,7 @@
return; // Test disabled on KF
}
+ TimeUtils.grace(500);
osgiHelper.waitForService(FooService.class, null, 10000);
// Check configuration
diff --git a/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestConfigurationOfThreeInstancesUsingMethods.java b/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestConfigurationOfThreeInstancesUsingMethods.java
index 6eb7030..03c726f 100644
--- a/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestConfigurationOfThreeInstancesUsingMethods.java
+++ b/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestConfigurationOfThreeInstancesUsingMethods.java
@@ -32,6 +32,7 @@
import org.ops4j.pax.tinybundles.core.TinyBundles;
import org.osgi.framework.Constants;
import org.osgi.framework.ServiceReference;
+import org.ow2.chameleon.testing.helpers.TimeUtils;
import org.ow2.chameleon.testing.tinybundles.ipojo.IPOJOStrategy;
import java.io.IOException;
@@ -75,9 +76,10 @@
return; // Test disabled on KF
}
+ TimeUtils.grace(500);
osgiHelper.waitForService(FooService.class, null, 10000);
- // Check we have two instances
+ // Check we have three instances
ServiceReference[] refs = osgiHelper.getServiceReferences(FooService.class, null);
Assert.assertEquals(refs.length, 3);
diff --git a/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestConfigurationOfTwoInstances.java b/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestConfigurationOfTwoInstances.java
index c9cd979..7f162e2 100644
--- a/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestConfigurationOfTwoInstances.java
+++ b/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestConfigurationOfTwoInstances.java
@@ -31,6 +31,7 @@
import org.ops4j.pax.tinybundles.core.TinyBundles;
import org.osgi.framework.Constants;
import org.osgi.framework.ServiceReference;
+import org.ow2.chameleon.testing.helpers.TimeUtils;
import org.ow2.chameleon.testing.tinybundles.ipojo.IPOJOStrategy;
import java.io.IOException;
@@ -74,6 +75,7 @@
return; // Test disabled on KF
}
+ TimeUtils.grace(500);
osgiHelper.waitForService(FooService.class, null, 10000);
// Check we have two instances
diff --git a/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestConfigurationWithInheritedInstance.java b/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestConfigurationWithInheritedInstance.java
index 7f26415..d0b0c68 100644
--- a/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestConfigurationWithInheritedInstance.java
+++ b/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestConfigurationWithInheritedInstance.java
@@ -32,6 +32,7 @@
import org.ops4j.pax.tinybundles.core.TinyBundles;
import org.osgi.framework.Constants;
import org.osgi.framework.ServiceReference;
+import org.ow2.chameleon.testing.helpers.TimeUtils;
import org.ow2.chameleon.testing.tinybundles.ipojo.IPOJOStrategy;
import java.io.IOException;
@@ -76,6 +77,7 @@
return; // Test disabled on KF
}
+ TimeUtils.grace(500);
osgiHelper.waitForService(FooService.class, null, 10000);
// Check we have two instances
diff --git a/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestConfigurationWithOverriddenInstance.java b/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestConfigurationWithOverriddenInstance.java
index 6b27139..a537953 100644
--- a/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestConfigurationWithOverriddenInstance.java
+++ b/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestConfigurationWithOverriddenInstance.java
@@ -32,6 +32,7 @@
import org.ops4j.pax.tinybundles.core.TinyBundles;
import org.osgi.framework.Constants;
import org.osgi.framework.ServiceReference;
+import org.ow2.chameleon.testing.helpers.TimeUtils;
import org.ow2.chameleon.testing.tinybundles.ipojo.IPOJOStrategy;
import java.io.IOException;
@@ -76,6 +77,7 @@
return; // Test disabled on KF
}
+ TimeUtils.grace(500);
osgiHelper.waitForService(FooService.class, null, 10000);
// Check we have two instances
diff --git a/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestSeveralConfigurations.java b/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestSeveralConfigurations.java
index 3b466b4..571669a 100644
--- a/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestSeveralConfigurations.java
+++ b/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestSeveralConfigurations.java
@@ -32,6 +32,7 @@
import org.ops4j.pax.tinybundles.core.TinyBundles;
import org.osgi.framework.Constants;
import org.osgi.framework.ServiceReference;
+import org.ow2.chameleon.testing.helpers.TimeUtils;
import org.ow2.chameleon.testing.tinybundles.ipojo.IPOJOStrategy;
import java.io.IOException;
@@ -76,6 +77,7 @@
return; // Test disabled on KF
}
+ TimeUtils.grace(500);
osgiHelper.waitForService(FooService.class, null, 10000);
// Check we have two instances
diff --git a/ipojo/runtime/core-it/src/it/ipojo-core-factory-version-test/src/test/java/org/apache/felix/ipojo/tests/core/VersionConflictTest.java b/ipojo/runtime/core-it/src/it/ipojo-core-factory-version-test/src/test/java/org/apache/felix/ipojo/tests/core/VersionConflictTest.java
index 7471e67..8b37121 100644
--- a/ipojo/runtime/core-it/src/it/ipojo-core-factory-version-test/src/test/java/org/apache/felix/ipojo/tests/core/VersionConflictTest.java
+++ b/ipojo/runtime/core-it/src/it/ipojo-core-factory-version-test/src/test/java/org/apache/felix/ipojo/tests/core/VersionConflictTest.java
@@ -186,7 +186,7 @@
//Assert.assertEquals(bundles[i].getSymbolicName() + " is not active", Bundle.ACTIVE, bundles[i].getState());
}
- Bundle consBundle = osgiHelper.getBundle("MyCons");
+// Bundle consBundle = osgiHelper.getBundle("MyCons");
// BundleWiring wiring = consBundle.adapt(BundleWiring.class);
// System.out.println("Bundle Wiring req: ");
// for (BundleWire wire : wiring.getRequiredWires(null)) {