You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by cl...@apache.org on 2013/05/07 14:22:52 UTC
svn commit: r1479879 [1/2] - in /felix/trunk/ipojo/runtime: api-it/
api-it/src/it/ipojo-api-test/src/test/java/org/apache/felix/ipojo/runtime/core/api/
composite-it/
composite-it/src/it/ipojo-composite-import-export-test/src/test/java/org/apache/felix/...
Author: clement
Date: Tue May 7 12:22:52 2013
New Revision: 1479879
URL: http://svn.apache.org/r1479879
Log:
Test refactoring.
Modified:
felix/trunk/ipojo/runtime/api-it/pom.xml
felix/trunk/ipojo/runtime/api-it/src/it/ipojo-api-test/src/test/java/org/apache/felix/ipojo/runtime/core/api/Common.java
felix/trunk/ipojo/runtime/composite-it/pom.xml
felix/trunk/ipojo/runtime/composite-it/src/it/ipojo-composite-import-export-test/src/test/java/org/apache/felix/ipojo/runtime/core/Common.java
felix/trunk/ipojo/runtime/composite-it/src/it/ipojo-composite-instance-test/src/test/java/org/apache/felix/ipojo/runtime/core/Common.java
felix/trunk/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/test/java/org/apache/felix/ipojo/runtime/core/Common.java
felix/trunk/ipojo/runtime/composite-it/src/it/ipojo-composite-service-providing-test/src/test/java/org/apache/felix/ipojo/runtime/core/Common.java
felix/trunk/ipojo/runtime/core-it/pom.xml
felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestComplexConfigurations.java
felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestConfigurationOfMyComponent.java
felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestConfigurationOfThreeInstancesUsingMethods.java
felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestConfigurationOfTwoInstances.java
felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestConfigurationWithInheritedInstance.java
felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestConfigurationWithOverriddenInstance.java
felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestSeveralConfigurations.java
felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-factory-version-test/src/test/java/org/apache/felix/ipojo/tests/core/VersionConflictTest.java
Modified: felix/trunk/ipojo/runtime/api-it/pom.xml
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/api-it/pom.xml?rev=1479879&r1=1479878&r2=1479879&view=diff
==============================================================================
--- felix/trunk/ipojo/runtime/api-it/pom.xml (original)
+++ felix/trunk/ipojo/runtime/api-it/pom.xml Tue May 7 12:22:52 2013
@@ -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>
Modified: felix/trunk/ipojo/runtime/api-it/src/it/ipojo-api-test/src/test/java/org/apache/felix/ipojo/runtime/core/api/Common.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/api-it/src/it/ipojo-api-test/src/test/java/org/apache/felix/ipojo/runtime/core/api/Common.java?rev=1479879&r1=1479878&r2=1479879&view=diff
==============================================================================
--- felix/trunk/ipojo/runtime/api-it/src/it/ipojo-api-test/src/test/java/org/apache/felix/ipojo/runtime/core/api/Common.java (original)
+++ felix/trunk/ipojo/runtime/api-it/src/it/ipojo-api-test/src/test/java/org/apache/felix/ipojo/runtime/core/api/Common.java Tue May 7 12:22:52 2013
@@ -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 @@ public class Common {
}
}
- @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;
- }
-
-
}
Modified: felix/trunk/ipojo/runtime/composite-it/pom.xml
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/composite-it/pom.xml?rev=1479879&r1=1479878&r2=1479879&view=diff
==============================================================================
--- felix/trunk/ipojo/runtime/composite-it/pom.xml (original)
+++ felix/trunk/ipojo/runtime/composite-it/pom.xml Tue May 7 12:22:52 2013
@@ -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>
Modified: felix/trunk/ipojo/runtime/composite-it/src/it/ipojo-composite-import-export-test/src/test/java/org/apache/felix/ipojo/runtime/core/Common.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/composite-it/src/it/ipojo-composite-import-export-test/src/test/java/org/apache/felix/ipojo/runtime/core/Common.java?rev=1479879&r1=1479878&r2=1479879&view=diff
==============================================================================
--- felix/trunk/ipojo/runtime/composite-it/src/it/ipojo-composite-import-export-test/src/test/java/org/apache/felix/ipojo/runtime/core/Common.java (original)
+++ felix/trunk/ipojo/runtime/composite-it/src/it/ipojo-composite-import-export-test/src/test/java/org/apache/felix/ipojo/runtime/core/Common.java Tue May 7 12:22:52 2013
@@ -19,151 +19,29 @@
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 {
-
- @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(),
+public class Common extends BaseTest {
- /*
- * Felix has implicit boot delegation enabled by default. It conflicts with Mockito:
- * java.lang.LinkageError: loader constraint violation in interface itable initialization:
- * when resolving method "org.osgi.service.useradmin.User$$EnhancerByMockitoWithCGLIB$$dd2f81dc
- * .newInstance(Lorg/mockito/cglib/proxy/Callback;)Ljava/lang/Object;" the class loader
- * (instance of org/mockito/internal/creation/jmock/SearchingClassLoader) of the current class,
- * org/osgi/service/useradmin/User$$EnhancerByMockitoWithCGLIB$$dd2f81dc, and the class loader
- * (instance of org/apache/felix/framework/BundleWiringImpl$BundleClassLoaderJava5) for interface
- * org/mockito/cglib/proxy/Factory have different Class objects for the type org/mockito/cglib/
- * proxy/Callback used in the signature
- *
- * So we disable the bootdelegation.
- */
- frameworkProperty("felix.bootdelegation.implicit").value("false")
- );
+ @Override
+ public boolean 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);
- }
-
- @After
- public void commonTearDown() {
- ipojoHelper.dispose();
- osgiHelper.dispose();
- }
-
- public BundleContext getContext() {
- return bc;
- }
-
public static ServiceContext getServiceContext(ComponentInstance ci) {
if (ci instanceof CompositeManager) {
return ((CompositeManager) ci).getServiceContext();
@@ -172,69 +50,6 @@ public class Common {
}
}
- 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 @@ 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/composite-it/src/it/ipojo-composite-instance-test/src/test/java/org/apache/felix/ipojo/runtime/core/Common.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/composite-it/src/it/ipojo-composite-instance-test/src/test/java/org/apache/felix/ipojo/runtime/core/Common.java?rev=1479879&r1=1479878&r2=1479879&view=diff
==============================================================================
--- felix/trunk/ipojo/runtime/composite-it/src/it/ipojo-composite-instance-test/src/test/java/org/apache/felix/ipojo/runtime/core/Common.java (original)
+++ felix/trunk/ipojo/runtime/composite-it/src/it/ipojo-composite-instance-test/src/test/java/org/apache/felix/ipojo/runtime/core/Common.java Tue May 7 12:22:52 2013
@@ -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 class Common {
}
}
- 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)) {
- 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;
+ @Override
+ public boolean deployiPOJOComposite() {
+ return true;
}
-
-
}
Modified: felix/trunk/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/test/java/org/apache/felix/ipojo/runtime/core/Common.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/test/java/org/apache/felix/ipojo/runtime/core/Common.java?rev=1479879&r1=1479878&r2=1479879&view=diff
==============================================================================
--- felix/trunk/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/test/java/org/apache/felix/ipojo/runtime/core/Common.java (original)
+++ felix/trunk/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/test/java/org/apache/felix/ipojo/runtime/core/Common.java Tue May 7 12:22:52 2013
@@ -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 class Common {
}
}
- 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;
- }
-
-
}
Modified: felix/trunk/ipojo/runtime/composite-it/src/it/ipojo-composite-service-providing-test/src/test/java/org/apache/felix/ipojo/runtime/core/Common.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/composite-it/src/it/ipojo-composite-service-providing-test/src/test/java/org/apache/felix/ipojo/runtime/core/Common.java?rev=1479879&r1=1479878&r2=1479879&view=diff
==============================================================================
--- felix/trunk/ipojo/runtime/composite-it/src/it/ipojo-composite-service-providing-test/src/test/java/org/apache/felix/ipojo/runtime/core/Common.java (original)
+++ felix/trunk/ipojo/runtime/composite-it/src/it/ipojo-composite-service-providing-test/src/test/java/org/apache/felix/ipojo/runtime/core/Common.java Tue May 7 12:22:52 2013
@@ -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 class Common {
}
}
- 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;
- }
-
-
-
}
Modified: felix/trunk/ipojo/runtime/core-it/pom.xml
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/core-it/pom.xml?rev=1479879&r1=1479878&r2=1479879&view=diff
==============================================================================
--- felix/trunk/ipojo/runtime/core-it/pom.xml (original)
+++ felix/trunk/ipojo/runtime/core-it/pom.xml Tue May 7 12:22:52 2013
@@ -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>
Modified: felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestComplexConfigurations.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestComplexConfigurations.java?rev=1479879&r1=1479878&r2=1479879&view=diff
==============================================================================
--- felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestComplexConfigurations.java (original)
+++ felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestComplexConfigurations.java Tue May 7 12:22:52 2013
@@ -34,6 +34,7 @@ import org.ops4j.pax.tinybundles.core.Ti
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 @@ public class TestComplexConfigurations e
if (isKnopflerfish()) {
return; // Test disabled on KF
}
+ TimeUtils.grace(500);
osgiHelper.waitForService(FooService.class, null, 10000);
ServiceReference ref1 = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), "complex1");
Modified: felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestConfigurationOfMyComponent.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestConfigurationOfMyComponent.java?rev=1479879&r1=1479878&r2=1479879&view=diff
==============================================================================
--- felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestConfigurationOfMyComponent.java (original)
+++ felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestConfigurationOfMyComponent.java Tue May 7 12:22:52 2013
@@ -29,6 +29,7 @@ import org.ops4j.pax.exam.Option;
import org.ops4j.pax.exam.OptionUtils;
import org.ops4j.pax.tinybundles.core.TinyBundles;
import org.osgi.framework.Constants;
+import org.ow2.chameleon.testing.helpers.TimeUtils;
import org.ow2.chameleon.testing.tinybundles.ipojo.IPOJOStrategy;
import java.io.IOException;
@@ -71,6 +72,7 @@ public class TestConfigurationOfMyCompon
return; // Test disabled on KF
}
+ TimeUtils.grace(500);
osgiHelper.waitForService(FooService.class, null, 10000);
// Check configuration
Modified: felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestConfigurationOfThreeInstancesUsingMethods.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestConfigurationOfThreeInstancesUsingMethods.java?rev=1479879&r1=1479878&r2=1479879&view=diff
==============================================================================
--- felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestConfigurationOfThreeInstancesUsingMethods.java (original)
+++ felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestConfigurationOfThreeInstancesUsingMethods.java Tue May 7 12:22:52 2013
@@ -32,6 +32,7 @@ import org.ops4j.pax.exam.OptionUtils;
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 @@ public class TestConfigurationOfThreeIns
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);
Modified: felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestConfigurationOfTwoInstances.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestConfigurationOfTwoInstances.java?rev=1479879&r1=1479878&r2=1479879&view=diff
==============================================================================
--- felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestConfigurationOfTwoInstances.java (original)
+++ felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestConfigurationOfTwoInstances.java Tue May 7 12:22:52 2013
@@ -31,6 +31,7 @@ import org.ops4j.pax.exam.OptionUtils;
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 @@ public class TestConfigurationOfTwoInsta
return; // Test disabled on KF
}
+ TimeUtils.grace(500);
osgiHelper.waitForService(FooService.class, null, 10000);
// Check we have two instances
Modified: felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestConfigurationWithInheritedInstance.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestConfigurationWithInheritedInstance.java?rev=1479879&r1=1479878&r2=1479879&view=diff
==============================================================================
--- felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestConfigurationWithInheritedInstance.java (original)
+++ felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestConfigurationWithInheritedInstance.java Tue May 7 12:22:52 2013
@@ -32,6 +32,7 @@ import org.ops4j.pax.exam.OptionUtils;
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 @@ public class TestConfigurationWithInheri
return; // Test disabled on KF
}
+ TimeUtils.grace(500);
osgiHelper.waitForService(FooService.class, null, 10000);
// Check we have two instances
Modified: felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestConfigurationWithOverriddenInstance.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestConfigurationWithOverriddenInstance.java?rev=1479879&r1=1479878&r2=1479879&view=diff
==============================================================================
--- felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestConfigurationWithOverriddenInstance.java (original)
+++ felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestConfigurationWithOverriddenInstance.java Tue May 7 12:22:52 2013
@@ -32,6 +32,7 @@ import org.ops4j.pax.exam.OptionUtils;
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 @@ public class TestConfigurationWithOverri
return; // Test disabled on KF
}
+ TimeUtils.grace(500);
osgiHelper.waitForService(FooService.class, null, 10000);
// Check we have two instances
Modified: felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestSeveralConfigurations.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestSeveralConfigurations.java?rev=1479879&r1=1479878&r2=1479879&view=diff
==============================================================================
--- felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestSeveralConfigurations.java (original)
+++ felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-processor-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestSeveralConfigurations.java Tue May 7 12:22:52 2013
@@ -32,6 +32,7 @@ import org.ops4j.pax.exam.OptionUtils;
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 @@ public class TestSeveralConfigurations e
return; // Test disabled on KF
}
+ TimeUtils.grace(500);
osgiHelper.waitForService(FooService.class, null, 10000);
// Check we have two instances