>From cc2297cff2758c73a12cd497e5c5bb56dc1e9e6f Mon Sep 17 00:00:00 2001 From: Charles Moulliard Date: Thu, 20 Dec 2012 16:13:23 +0100 Subject: [PATCH] WELD-1287: Add integration test to validate weld osgi on Apache Karaf --- environments/osgi/tests/tester/pom.xml | 245 ++++++++++++++++++++- .../osgi/tests/karaf/ContainerTest.java | 8 +- .../osgi/tests/karaf/WeldOSGIContainerSupport.java | 11 +- .../environment/osgi/tests/util/Environment.java | 11 + pom.xml | 46 +++- 5 files changed, 301 insertions(+), 20 deletions(-) diff --git a/environments/osgi/tests/tester/pom.xml b/environments/osgi/tests/tester/pom.xml index f2cd212..09c47aa 100644 --- a/environments/osgi/tests/tester/pom.xml +++ b/environments/osgi/tests/tester/pom.xml @@ -54,9 +54,10 @@ - org.openengsb.labs.paxexam.karaf - paxexam-karaf-options - 1.0.0 + org.apache.karaf + apache-karaf + 2.3.0 + tar.gz test @@ -67,18 +68,134 @@ - org.ops4j.pax.exam - pax-exam-junit4 + org.apache.karaf + apache-karaf + 2.3.0 + tar.gz + test + + + + org.ops4j.pax.url + pax-url-aether test org.ops4j.pax.exam - pax-exam-container-native + pax-exam-link-mvn test + org.openengsb.labs.paxexam.karaf + paxexam-karaf-container + 1.0.0 + + + org.apache.karaf + org.apache.karaf.client + + + org.ops4j.pax.exam + pax-exam + + + org.ops4j.pax.exam + pax-exam-spi + + + org.ops4j.pax.exam + pax-exam-container-rbc + + + org.ops4j.pax.exam + pax-exam-container-rbc-client + + + org.ops4j.pax.exam + pax-exam-container-remote + + + org.ops4j.pax.exam + pax-exam-invoker-junit + + + org.ops4j.pax.exam + pax-exam + + + org.ops4j.pax.exam + pax-exam + + + + + + org.ops4j.pax.exam + pax-exam + ${pax.exam.version} + test + + + org.ops4j.pax.swissbox + pax-swissbox-tinybundles + ${pax.swissbox.version} + test + + + org.ops4j.pax.exam + pax-exam-spi + ${pax.exam.version} + test + + + org.ops4j.pax.exam + pax-exam-container-rbc + ${pax.exam.version} + test + + + org.ops4j.pax.exam + pax-exam-container-rbc-client + ${pax.exam.version} + test + + + org.ops4j.pax.exam + pax-exam-container-remote + ${pax.exam.version} + test + + + org.ops4j.pax.exam + pax-exam-extender-service + ${pax.exam.version} + test + + + org.ops4j.pax.exam + pax-exam-inject + ${pax.exam.version} + + + org.ops4j.pax.exam + pax-exam-invoker-junit + ${pax.exam.version} + test + + + org.ops4j.pax.exam + pax-exam-junit4 + ${pax.exam.version} + test + + + + + org.osgi org.osgi.core @@ -119,6 +338,7 @@ org.jboss.weld.osgi weld-osgi-core-spi + test @@ -243,4 +463,15 @@ + + + + Apache Maven Repo + http://repo1.maven.org/maven2 + + + + + + diff --git a/environments/osgi/tests/tester/src/test/java/org/jboss/weld/environment/osgi/tests/karaf/ContainerTest.java b/environments/osgi/tests/tester/src/test/java/org/jboss/weld/environment/osgi/tests/karaf/ContainerTest.java index ea04e08..d2161a9 100644 --- a/environments/osgi/tests/tester/src/test/java/org/jboss/weld/environment/osgi/tests/karaf/ContainerTest.java +++ b/environments/osgi/tests/tester/src/test/java/org/jboss/weld/environment/osgi/tests/karaf/ContainerTest.java @@ -6,10 +6,11 @@ import org.jboss.weld.environment.osgi.tests.util.Environment; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; -import org.openengsb.labs.paxexam.karaf.options.KarafDistributionOption; import org.ops4j.pax.exam.Option; import org.ops4j.pax.exam.junit.Configuration; +import org.ops4j.pax.exam.junit.ExamReactorStrategy; import org.ops4j.pax.exam.junit.JUnit4TestRunner; +import org.ops4j.pax.exam.spi.reactors.AllConfinedStagedReactorFactory; import org.osgi.framework.*; import javax.enterprise.event.Event; @@ -21,10 +22,10 @@ import java.util.Collection; import static org.jboss.weld.environment.osgi.tests.karaf.WeldOSGIContainerSupport.getDefaultKarafOptions; import static org.jboss.weld.environment.osgi.tests.util.Environment.toMavenBundle; -import static org.ops4j.pax.exam.CoreOptions.options; import static org.ops4j.pax.exam.OptionUtils.combine; @RunWith(JUnit4TestRunner.class) +@ExamReactorStrategy(AllConfinedStagedReactorFactory.class) public class ContainerTest { @Configuration @@ -33,7 +34,7 @@ public class ContainerTest { getDefaultKarafOptions(), - Environment.toCDIOSGiEnvironment( + Environment.toCDIKarafEnvironment( toMavenBundle("org.jboss.weld.osgi.tests", "weld-osgi-bundle1"), toMavenBundle("org.jboss.weld.osgi.tests", "weld-osgi-bundle2"), toMavenBundle("org.jboss.weld.osgi.tests", "weld-osgi-bundle3") @@ -49,6 +50,7 @@ public class ContainerTest { @Test public void launchTest() throws InterruptedException, BundleException, InvalidSyntaxException { + Environment.waitForEnvironment(context); Bundle bundle1 = null, bundle2 = null, bundle3 = null; diff --git a/environments/osgi/tests/tester/src/test/java/org/jboss/weld/environment/osgi/tests/karaf/WeldOSGIContainerSupport.java b/environments/osgi/tests/tester/src/test/java/org/jboss/weld/environment/osgi/tests/karaf/WeldOSGIContainerSupport.java index 3f40a59..0bf5c00 100644 --- a/environments/osgi/tests/tester/src/test/java/org/jboss/weld/environment/osgi/tests/karaf/WeldOSGIContainerSupport.java +++ b/environments/osgi/tests/tester/src/test/java/org/jboss/weld/environment/osgi/tests/karaf/WeldOSGIContainerSupport.java @@ -2,11 +2,13 @@ package org.jboss.weld.environment.osgi.tests.karaf; import org.openengsb.labs.paxexam.karaf.options.KarafDistributionOption; +import org.openengsb.labs.paxexam.karaf.options.LogLevelOption; import org.ops4j.pax.exam.Option; import java.io.File; import static org.openengsb.labs.paxexam.karaf.options.KarafDistributionOption.karafDistributionConfiguration; +import static org.openengsb.labs.paxexam.karaf.options.KarafDistributionOption.logLevel; import static org.openengsb.labs.paxexam.karaf.options.KarafDistributionOption.replaceConfigurationFile; import static org.ops4j.pax.exam.CoreOptions.maven; @@ -17,16 +19,17 @@ public class WeldOSGIContainerSupport { // Set the karaf environment with some customer configuration new Option[]{ karafDistributionConfiguration() - .frameworkUrl(maven().groupId("org.apache.karaf").artifactId("apache-karaf").type("tar.gz").versionAsInProject()) - // This version is not actual karaf version that we use. + .frameworkUrl(maven().groupId("org.apache.karaf").artifactId("apache-karaf").type("tar.gz").version("2.3.0")) .karafVersion("2.3.0") .name("Apache Karaf") .useDeployFolder(false).unpackDirectory(new File("target/paxexam/unpack/")), KarafDistributionOption.keepRuntimeFolder(), + logLevel(LogLevelOption.LogLevel.INFO), + // override the config.properties (to fix pax-exam bug) - replaceConfigurationFile("etc/config.properties", new File("src/test/resources/org/jboss/weld/environment/osgi/tests/karaf/config.properties")), - replaceConfigurationFile("etc/custom.properties", new File("src/test/resources/org/jboss/weld/environment/osgi/tests/karaf/custom.properties")) + replaceConfigurationFile("etc/config.properties", new File("src/test/resources/org/jboss/weld/environment/osgi/tests/karaf/config.properties")) + //replaceConfigurationFile("etc/custom.properties", new File("src/test/resources/org/jboss/weld/environment/osgi/tests/karaf/custom.properties")) }; return options; diff --git a/environments/osgi/tests/tester/src/test/java/org/jboss/weld/environment/osgi/tests/util/Environment.java b/environments/osgi/tests/tester/src/test/java/org/jboss/weld/environment/osgi/tests/util/Environment.java index cce0fc9..64148f7 100644 --- a/environments/osgi/tests/tester/src/test/java/org/jboss/weld/environment/osgi/tests/util/Environment.java +++ b/environments/osgi/tests/tester/src/test/java/org/jboss/weld/environment/osgi/tests/util/Environment.java @@ -54,6 +54,17 @@ public class Environment { return result.toArray(new Option[result.size()]); } + public static Option[] toCDIKarafEnvironment(Option... options) { + List