[SM-2947] Migrate itests to java
diff --git a/itests/pom.xml b/itests/pom.xml
index 42d9cfc..68d3671 100644
--- a/itests/pom.xml
+++ b/itests/pom.xml
@@ -33,11 +33,13 @@
<name>Apache ServiceMix :: Integration Tests</name>
<dependencies>
- <dependency>
- <groupId>org.scala-lang</groupId>
- <artifactId>scala-library</artifactId>
- <version>${scala.version}</version>
- </dependency>
+ <dependency>
+ <groupId>org.apache.servicemix.features</groupId>
+ <artifactId>servicemix-examples</artifactId>
+ <type>xml</type>
+ <classifier>features</classifier>
+ <version>${project.version}</version>
+ </dependency>
<dependency>
<groupId>junit</groupId>
@@ -102,8 +104,6 @@
</dependencies>
<build>
- <sourceDirectory>src/main/scala</sourceDirectory>
- <testSourceDirectory>src/test/scala</testSourceDirectory>
<plugins>
<plugin>
<groupId>org.apache.servicemix.tooling</groupId>
@@ -118,29 +118,6 @@
</executions>
</plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- <configuration>
- <redirectTestOutputToFile>true</redirectTestOutputToFile>
- <systemPropertyVariables>
- <org.ops4j.pax.logging.DefaultServiceLog.level>INFO</org.ops4j.pax.logging.DefaultServiceLog.level>
- </systemPropertyVariables>
- </configuration>
- </plugin>
-
- <plugin>
- <groupId>org.scala-tools</groupId>
- <artifactId>maven-scala-plugin</artifactId>
- <executions>
- <execution>
- <id>compile</id>
- <goals>
- <goal>testCompile</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
</plugins>
</build>
diff --git a/itests/src/test/java/org/apache/servicemix/itests/BasicDistroTest.java b/itests/src/test/java/org/apache/servicemix/itests/BasicDistroTest.java
new file mode 100644
index 0000000..c35e6d2
--- /dev/null
+++ b/itests/src/test/java/org/apache/servicemix/itests/BasicDistroTest.java
@@ -0,0 +1,88 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.servicemix.itests;
+
+import java.io.File;
+import java.nio.charset.Charset;
+import java.nio.file.Files;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.servicemix.itests.base.ServiceMixDistroTest;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.junit.PaxExam;
+import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
+import org.ops4j.pax.exam.spi.reactors.PerClass;
+import org.osgi.framework.Bundle;
+
+@RunWith(PaxExam.class)
+@ExamReactorStrategy(PerClass.class)
+public class BasicDistroTest extends ServiceMixDistroTest {
+
+ @Test
+ public void testCorrectStatus() throws Exception {
+ Bundle[] bundles = context.getBundles();
+ for (Bundle bundle : bundles) {
+ if (!isActive(bundle) && !isFragment(bundle)) {
+ // Starting bundle to cause error
+ bundle.start();
+ }
+ if (!isResolved(bundle) && isFragment(bundle)) {
+ throw new IllegalStateException("Bundle " + bundle.getSymbolicName() + " is not resolved");
+ }
+ }
+ }
+
+ @Test
+ public void testNoErrors() throws Exception {
+ File servicemixHomeFolder = new File(System.getProperty("servicemix.home"));
+ File dataFolder = new File(servicemixHomeFolder, "data");
+ File logFolder = new File(dataFolder, "log");
+ File logFile = new File(logFolder, "servicemix.log");
+ List<String> lines = Files.readAllLines(logFile.toPath(), Charset.forName("utf-8"));
+ List<String> errors = filterErrors(lines);
+ if (errors.size() > 0) {
+ Assert.fail("There should be no errors in the log but found :\n" + errors.toString());
+ }
+ }
+
+ private List<String> filterErrors(List<String> lines) {
+ List<String> errors = new ArrayList<>();
+ for (String line : lines) {
+ String lcLine = line.toLowerCase();
+ if (lcLine.contains("ERROR") || lcLine.contains("exception")) {
+ errors.add(lcLine);
+ }
+ }
+ return errors;
+ }
+
+ private boolean isFragment(Bundle bundle) {
+ return bundle.getHeaders().get("Fragment-Host") != null;
+ }
+
+ private boolean isActive(Bundle bundle) {
+ return Bundle.ACTIVE == bundle.getState();
+ }
+
+ private boolean isResolved(Bundle bundle) {
+ return Bundle.RESOLVED == bundle.getState();
+ }
+
+}
diff --git a/itests/src/test/java/org/apache/servicemix/itests/ExamplesCXFTest.java b/itests/src/test/java/org/apache/servicemix/itests/ExamplesCXFTest.java
new file mode 100644
index 0000000..9610999
--- /dev/null
+++ b/itests/src/test/java/org/apache/servicemix/itests/ExamplesCXFTest.java
@@ -0,0 +1,87 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.servicemix.itests;
+
+import org.apache.servicemix.itests.base.Features;
+import org.apache.servicemix.itests.base.ServiceMixDistroTest;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.junit.PaxExam;
+import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
+import org.ops4j.pax.exam.spi.reactors.PerClass;
+
+@RunWith(PaxExam.class)
+@ExamReactorStrategy(PerClass.class)
+public class ExamplesCXFTest extends ServiceMixDistroTest {
+
+ @Test
+ public void testExampleCxfJAXRS() throws Exception {
+ try (Features features = install("examples-cxf-jaxrs", "camel-http")) {
+ log.expectContains("Setting the server's publish address to be /crm");
+ }
+ }
+
+ @Test
+ public void testExampleCxfJAXRSBlueprint() throws Exception {
+ try (Features features = install("examples-cxf-jaxrs-blueprint", "camel-http4")) {
+ log.expectContains("Setting the server's publish address to be /crm");
+ }
+ }
+
+ @Test
+ public void testExampleCxfJAXWSBlueprint() throws Exception {
+ try (Features features = install("examples-cxf-jaxws-blueprint", "camel-http4")) {
+ log.expectContains("Setting the server's publish address to be /HelloWorld");
+ }
+ }
+
+ @Test
+ public void testExampleCxfOSGi() throws Exception {
+ try (Features features = install("examples-cxf-osgi")) {
+ log.expectContains("Setting the server's publish address to be /HelloWorld");
+ }
+ }
+
+ //@Test
+ public void testExampleCxfWsRm() throws Exception {
+ try (Features features = install("examples-cxf-ws-rm")) {
+ log.expectContains("Setting the server's publish address to be /HelloWorld");
+ }
+ }
+
+ @Test
+ public void testExampleCxfWsSecurityBlueprint() throws Exception {
+ try (Features features = installOnly("examples-cxf-ws-security-blueprint")) {
+ log.expectContains("Setting the server's publish address to be /HelloWorldSecurity");
+ }
+ }
+
+ @Test
+ public void testExampleCxfWsSecurityOSGi() throws Exception {
+ try (Features features = install("examples-cxf-ws-security-osgi")) {
+ log.expectContains("Setting the server's publish address to be /HelloWorldSecurity");
+ }
+ }
+
+ @Test
+ public void testExampleCxfWsSecuritySignature() throws Exception {
+ try (Features features = install("examples-cxf-ws-security-signature")) {
+ log.expectContains("Setting the server's publish address to be /HelloWorldSecurity");
+ }
+ }
+
+}
diff --git a/itests/src/test/java/org/apache/servicemix/itests/ExamplesCamelTest.java b/itests/src/test/java/org/apache/servicemix/itests/ExamplesCamelTest.java
new file mode 100644
index 0000000..887b46a
--- /dev/null
+++ b/itests/src/test/java/org/apache/servicemix/itests/ExamplesCamelTest.java
@@ -0,0 +1,67 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.servicemix.itests;
+
+import org.apache.servicemix.itests.base.Features;
+import org.apache.servicemix.itests.base.ServiceMixDistroTest;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.junit.PaxExam;
+import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
+import org.ops4j.pax.exam.spi.reactors.PerClass;
+
+@RunWith(PaxExam.class)
+@ExamReactorStrategy(PerClass.class)
+public class ExamplesCamelTest extends ServiceMixDistroTest {
+
+ @Test
+ public void testExampleCamelCxf() throws Exception {
+ try (Features features = install("examples-camel-cxf-soap", "examples-camel-cxf-rest")) {
+ log.expectContains("Setting the server's publish address to be http://localhost:8989/soap");
+ log.expectContains("Setting the server's publish address to be http://localhost:8989/rest");
+ }
+ }
+
+ @Test
+ public void testExampleCamelOsgi() throws Exception {
+ try (Features features = install("examples-camel-osgi")) {
+ log.expectContains("JavaDSL set body");
+ log.expectContains("MyTransform set body");
+ }
+ }
+
+ @Test
+ public void testExampleCamelBlueprint() throws Exception {
+ try (Features features = install("examples-camel-blueprint")) {
+ log.expectContains("Blueprint-Example set body");
+ }
+ }
+
+ @Test
+ public void testExampleCamelDrools() throws Exception {
+ try (Features features = install("examples-camel-drools")) {
+ log.expectContains("Serve this");
+ }
+ }
+
+ @Test
+ public void testExampleCamelDroolsBlueprint() throws Exception {
+ try (Features features = install("examples-camel-drools-blueprint")) {
+ log.expectContains("Serve this");
+ }
+ }
+}
diff --git a/itests/src/test/java/org/apache/servicemix/itests/ExamplesDrools6Test.java b/itests/src/test/java/org/apache/servicemix/itests/ExamplesDrools6Test.java
new file mode 100644
index 0000000..7428a6f
--- /dev/null
+++ b/itests/src/test/java/org/apache/servicemix/itests/ExamplesDrools6Test.java
@@ -0,0 +1,78 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.servicemix.itests;
+
+import org.apache.servicemix.itests.base.Features;
+import org.apache.servicemix.itests.base.ServiceMixDistroTest;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.junit.PaxExam;
+import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
+import org.ops4j.pax.exam.spi.reactors.PerClass;
+
+@RunWith(PaxExam.class)
+@ExamReactorStrategy(PerClass.class)
+public class ExamplesDrools6Test extends ServiceMixDistroTest {
+
+ @Test
+ public void testKieBlueprint() throws Exception {
+ try (Features features = install("kie-aries-blueprint")) {
+ }
+ }
+
+ @Test
+ public void testKieSpring() throws Exception {
+ try (Features features = install("kie-spring")) {
+ }
+ }
+
+ @Test
+ public void testKieCamel() throws Exception {
+ try (Features features = install("kie-camel")) {
+ }
+ }
+
+ @Test
+ public void testDroolsSimpleExample() throws Exception {
+ try (Features features = install("examples-drools-simple")) {
+ log.expectContains("Customer [salary=1000, type=POOR]");
+ log.expectContains("Customer [salary=5000, type=NORMAL]");
+ log.expectContains("Customer [salary=9001, type=VIP]");
+ }
+ }
+
+ @Test
+ public void testDroolsCamelExample() throws Exception {
+ try (Features features = install("examples-drools-camel-blueprint")) {
+ log.expectContains("Total 2 routes, of which 2 is started");
+ }
+ }
+
+ @Test
+ public void testDroolSpringExample() throws Exception {
+ try (Features features = install("examples-drools-spring")) {
+ log.expectContains("KieModule was added: org.drools.osgi.compiler.OsgiKieModule");
+ }
+ }
+
+ @Test
+ public void testDroolsCamelServerExample() throws Exception {
+ try (Features features = install("examples-drools-camel-cxf-server")) {
+ log.expectContains("<execution-results><result identifier=\"customer\">");
+ }
+ }
+}
diff --git a/itests/src/test/java/org/apache/servicemix/itests/ExamplesTest.java b/itests/src/test/java/org/apache/servicemix/itests/ExamplesTest.java
new file mode 100644
index 0000000..43b2f1b
--- /dev/null
+++ b/itests/src/test/java/org/apache/servicemix/itests/ExamplesTest.java
@@ -0,0 +1,57 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.servicemix.itests;
+
+import java.io.File;
+import java.nio.file.Files;
+
+import org.apache.servicemix.itests.base.Features;
+import org.apache.servicemix.itests.base.ServiceMixDistroTest;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.junit.PaxExam;
+import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
+import org.ops4j.pax.exam.spi.reactors.PerClass;
+
+@RunWith(PaxExam.class)
+@ExamReactorStrategy(PerClass.class)
+public class ExamplesTest extends ServiceMixDistroTest {
+
+ @Test
+ public void testActivity() throws Exception {
+ try (Features features = install("activiti", "examples-activiti-camel")) {
+ File orderDir = new File("var/activiti-camel/order");
+ orderDir.mkdirs();
+ Files.copy(stream("Some nice order message goes here"), new File(orderDir, "001").toPath());
+
+ log.expectContains("Processing order");
+
+ File deliveryDir = new File("var/activiti-camel/delivery");
+ deliveryDir.mkdirs();
+ Files.copy(stream("Some nice delicery message goes here"), new File(deliveryDir, "001").toPath());
+ log.expectContains("Processing delivery for order");
+ }
+ }
+
+ @Test
+ public void testExampleActiveMQ() throws Exception {
+ try (Features features = install("examples-activemq-camel-blueprint")) {
+ log.expectContains("ActiveMQ-Blueprint-Example set body");
+ }
+ }
+
+}
diff --git a/itests/src/test/java/org/apache/servicemix/itests/base/Features.java b/itests/src/test/java/org/apache/servicemix/itests/base/Features.java
new file mode 100644
index 0000000..5971217
--- /dev/null
+++ b/itests/src/test/java/org/apache/servicemix/itests/base/Features.java
@@ -0,0 +1,28 @@
+package org.apache.servicemix.itests.base;
+
+import java.util.Arrays;
+import java.util.EnumSet;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.karaf.features.FeaturesService;
+
+public class Features implements AutoCloseable {
+ private Set<String> featureSet;
+ private FeaturesService featuresService;
+ private boolean uninstall;
+
+ public Features(FeaturesService featuresService, boolean uninstall, String ... names) throws Exception {
+ this.featuresService = featuresService;
+ this.uninstall = uninstall;
+ featureSet = new HashSet<>(Arrays.asList(names));
+ featuresService.installFeatures(featureSet, EnumSet.noneOf(FeaturesService.Option.class));
+ }
+
+ @Override
+ public void close() throws Exception {
+ if (this.uninstall) {
+ featuresService.uninstallFeatures(featureSet, EnumSet.noneOf(FeaturesService.Option.class));
+ }
+ }
+}
diff --git a/itests/src/test/java/org/apache/servicemix/itests/base/LogCollector.java b/itests/src/test/java/org/apache/servicemix/itests/base/LogCollector.java
new file mode 100644
index 0000000..89aeea8
--- /dev/null
+++ b/itests/src/test/java/org/apache/servicemix/itests/base/LogCollector.java
@@ -0,0 +1,69 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.servicemix.itests.base;
+
+import java.util.ArrayList;
+import java.util.Dictionary;
+import java.util.Hashtable;
+import java.util.List;
+import java.util.concurrent.TimeoutException;
+
+import org.ops4j.pax.logging.spi.PaxAppender;
+import org.ops4j.pax.logging.spi.PaxLoggingEvent;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceRegistration;
+
+public class LogCollector implements PaxAppender {
+
+ List<PaxLoggingEvent> log = new ArrayList<>();
+ private ServiceRegistration<PaxAppender> reg;
+
+ public LogCollector(BundleContext context) {
+ Dictionary<String, String> props = new Hashtable<>();
+ props.put("org.ops4j.pax.logging.appender.name", "ITestLogAppender");
+ reg = context.registerService(PaxAppender.class, this, props);
+ }
+
+ @Override
+ public synchronized void doAppend(PaxLoggingEvent event) {
+ log.add(event);
+ this.notify();
+ }
+
+ public synchronized void expectContains(String message) throws InterruptedException, TimeoutException {
+ for (PaxLoggingEvent event : log) {
+ if (event.getMessage().contains(message)) {
+ return;
+ }
+ }
+ long startTime = System.currentTimeMillis();
+ while (System.currentTimeMillis() - startTime < 10 * 1000) {
+ this.wait(100);
+ if (log.size() > 0) {
+ PaxLoggingEvent event = log.get(log.size() - 1);
+ if (event.getMessage().contains(message)) {
+ return;
+ }
+ }
+ }
+ throw new TimeoutException("Timeout waiting for log message containing " + message);
+ }
+
+ public void close() {
+ reg.unregister();
+ }
+}
diff --git a/itests/src/test/java/org/apache/servicemix/itests/base/ServiceMixDistroTest.java b/itests/src/test/java/org/apache/servicemix/itests/base/ServiceMixDistroTest.java
new file mode 100644
index 0000000..8efff92
--- /dev/null
+++ b/itests/src/test/java/org/apache/servicemix/itests/base/ServiceMixDistroTest.java
@@ -0,0 +1,111 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.servicemix.itests.base;
+
+import static org.ops4j.pax.exam.CoreOptions.maven;
+import static org.ops4j.pax.exam.CoreOptions.systemProperty;
+import static org.ops4j.pax.exam.CoreOptions.when;
+import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.configureSecurity;
+import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.editConfigurationFilePut;
+import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.karafDistributionConfiguration;
+import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.keepRuntimeFolder;
+import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.logLevel;
+
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
+
+import javax.inject.Inject;
+
+import org.apache.karaf.features.FeaturesService;
+import org.junit.Before;
+import org.ops4j.pax.exam.Configuration;
+import org.ops4j.pax.exam.CoreOptions;
+import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.karaf.options.KarafDistributionOption;
+import org.ops4j.pax.exam.karaf.options.LogLevelOption.LogLevel;
+import org.ops4j.pax.exam.options.MavenArtifactUrlReference;
+import org.osgi.framework.BundleContext;
+
+public class ServiceMixDistroTest {
+ protected LogCollector log;
+
+ @Inject
+ protected BundleContext context;
+
+ @Inject
+ protected FeaturesService featuresService;
+
+ protected MavenArtifactUrlReference examples;
+
+ private MavenArtifactUrlReference karafUrl;
+
+ @Before
+ public void initLog() {
+ log = new LogCollector(context);
+ }
+
+ public Features installOnly(String ... names) throws Exception {
+ return new Features(featuresService, false, names);
+ }
+
+ public Features install(String ... names) throws Exception {
+ return new Features(featuresService, true, names);
+ }
+
+ public Option baseConfig() {
+ examples = maven().groupId("org.apache.servicemix.features").artifactId("servicemix-examples").type("xml").classifier("features").versionAsInProject();
+ karafUrl = maven().groupId("org.apache.servicemix").artifactId("apache-servicemix").type("zip").versionAsInProject();
+ String LOCAL_REPOSITORY = System.getProperty("org.ops4j.pax.url.mvn.localRepository");
+ return CoreOptions.composite(
+ // KarafDistributionOption.debugConfiguration("8889", true),
+ karafDistributionConfiguration().frameworkUrl(karafUrl)
+ .name("Apache Servicemix")
+ .unpackDirectory(new File("target/exam"))
+ .useDeployFolder(false),
+ systemProperty("pax.exam.osgi.unresolved.fail").value("true"),
+ configureSecurity().disableKarafMBeanServerBuilder(),
+ keepRuntimeFolder(),
+ logLevel(LogLevel.INFO),
+ editConfigurationFilePut("etc/custom.properties", "karaf.delay.console", "false"),
+ editConfigurationFilePut("etc/org.ops4j.pax.logging.cfg", "log4j.logger.org.apache.karaf.features", "WARN"),
+ editConfigurationFilePut("etc/org.ops4j.pax.logging.cfg", "log4j.logger.org.apache.aries.spifly", "WARN"),
+ KarafDistributionOption.features(examples, "transaction"),
+ when(null != LOCAL_REPOSITORY && LOCAL_REPOSITORY.length() > 0)
+ .useOptions(editConfigurationFilePut("etc/org.ops4j.pax.url.mvn.cfg", "org.ops4j.pax.url.mvn.localRepository", LOCAL_REPOSITORY))
+
+ );
+ }
+
+ @Configuration
+ public Option[] config() {
+ return new Option[] {
+ baseConfig()
+ };
+ }
+
+ protected InputStream stream(String content) throws UnsupportedEncodingException {
+ return new ByteArrayInputStream(content.getBytes("UTF-8"));
+ }
+
+ @Before
+ public void closeLog() {
+ log = new LogCollector(context);
+ }
+
+}
diff --git a/itests/src/test/resources/OSGI-INF/blueprint/blueprint.xml b/itests/src/test/resources/OSGI-INF/blueprint/blueprint.xml
deleted file mode 100644
index b052a7e..0000000
--- a/itests/src/test/resources/OSGI-INF/blueprint/blueprint.xml
+++ /dev/null
@@ -1,26 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
-
- <camelContext id="context" xmlns="http://camel.apache.org/schema/blueprint" />
-
- <bean class="org.apache.servicemix.itests.CamelContextHolder" factory-method="apply">
- <argument ref="context"/>
- </bean>
-
-</blueprint>
\ No newline at end of file
diff --git a/itests/src/test/resources/log4j.properties b/itests/src/test/resources/log4j.properties
index 47129bb..996139c 100644
--- a/itests/src/test/resources/log4j.properties
+++ b/itests/src/test/resources/log4j.properties
@@ -18,7 +18,8 @@
#
# The logging properties used during tests..
#
-log4j.rootLogger=DEBUG, stdout, out
+log4j.rootLogger=WARN, stdout, out
+
# CONSOLE appender not used by default
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
diff --git a/itests/src/test/scala/org/apache/servicemix/itests/Await.scala b/itests/src/test/scala/org/apache/servicemix/itests/Await.scala
deleted file mode 100644
index 501de77..0000000
--- a/itests/src/test/scala/org/apache/servicemix/itests/Await.scala
+++ /dev/null
@@ -1,40 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.servicemix.itests
-
-/**
- * Convenience trait to wait for a certain condition to occur by retrying it a few times,
- * using an exponential back-off delay scheme
- */
-trait Await {
-
- val INITIAL_DELAY = 125
- val MAXIMUM_DELAY = 8000
-
- def await[T](condition: => Option[T]) : Option[T] = await(condition, INITIAL_DELAY)
-
- private[this] def await[T](condition: => Option[T], delay: Long) : Option[T] =
- condition match {
- case result@Some(_) => result
- case None => if (delay > MAXIMUM_DELAY) None else {
- // let's sleep for a while and give it another go
- Thread.sleep(delay)
- await(condition, delay * 2)
- }
- }
-
-}
diff --git a/itests/src/test/scala/org/apache/servicemix/itests/BasicAssemblyTests.scala b/itests/src/test/scala/org/apache/servicemix/itests/BasicAssemblyTests.scala
deleted file mode 100644
index 4ebbe18..0000000
--- a/itests/src/test/scala/org/apache/servicemix/itests/BasicAssemblyTests.scala
+++ /dev/null
@@ -1,62 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.servicemix.itests;
-
-import org.junit.Test
-import org.junit.runner.RunWith
-import org.junit.Assert._
-import io.Source
-import org.osgi.framework.Bundle
-import org.ops4j.pax.exam.spi.reactors.{PerClass, ExamReactorStrategy}
-import org.ops4j.pax.exam.junit.PaxExam
-import org.ops4j.pax.exam.Configuration
-
-/**
- * A set of quick sanity checks to be run for all three types of container packaging we offer (default, minimal and full)
- */
-trait BasicAssemblyTests { self: IntegrationTestSupport =>
-
- def isActive(bundle: Bundle) = Bundle.ACTIVE == bundle.getState
- def isResolved(bundle: Bundle) = Bundle.RESOLVED == bundle.getState
- def isFragment(bundle: Bundle) = bundle.getHeaders().get("Fragment-Host") != null
-
-
- @Test
- def testInitialBundlesStarted = {
- val failed = context.getBundles filterNot { bundle => isActive(bundle) || (isResolved(bundle) && isFragment(bundle))}
- assertTrue(s"There should be no failed bundles - found ${failed.mkString}", failed.isEmpty)
- }
-
- @Test
- def noErrorsInTheLog = {
- val errors = Source.fromFile(logFile).getLines filter { line =>
- line.toLowerCase.contains("error") || line.toLowerCase.contains("exception")
- }
- assertTrue(s"There should be no errors in the log file - found ${errors.mkString}", errors.isEmpty)
- }
-
-}
-
-@RunWith(classOf[PaxExam])
-@ExamReactorStrategy(Array(classOf[PerClass]))
-class DefaultAssemblyTest extends IntegrationTestSupport with BasicAssemblyTests {
-
- @Configuration
- def config() = servicemixTestConfiguration ++ scalaTestConfiguration
-
-}
-
diff --git a/itests/src/test/scala/org/apache/servicemix/itests/CamelTestSupport.scala b/itests/src/test/scala/org/apache/servicemix/itests/CamelTestSupport.scala
deleted file mode 100644
index e700a41..0000000
--- a/itests/src/test/scala/org/apache/servicemix/itests/CamelTestSupport.scala
+++ /dev/null
@@ -1,54 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.servicemix.itests
-
-import org.apache.camel.impl.DefaultProducerTemplate
-import org.apache.camel.{ProducerTemplate, CamelContext}
-
-/**
- * Provides access to a Camel context and producer to use for integration testing.
- */
-trait CamelTestSupport extends Await {
-
- def camelContext = await(CamelContextHolder.context)
-
- lazy val camelProducer : ProducerTemplate = {
- val producer = new DefaultProducerTemplate(camelContext.getOrElse(throw new RuntimeException("Gave up waiting for a CamelContext")))
- producer.start()
- producer
- }
-
- /**
- * Convenience method to perform a Camel request and return a String
- */
- def requestString(url: String) : String = camelProducer.requestBody(url, null, classOf[String])
-
-}
-
-/**
- * Singleton object that gets a CamelContext injected through Blueprint
- */
-object CamelContextHolder {
-
- var context: Option[CamelContext] = None
-
- def apply(c: CamelContext) = {
- context = Option(c)
- context
- }
-
-}
diff --git a/itests/src/test/scala/org/apache/servicemix/itests/Drools6IntegrationTests.scala b/itests/src/test/scala/org/apache/servicemix/itests/Drools6IntegrationTests.scala
deleted file mode 100644
index 49c20c8..0000000
--- a/itests/src/test/scala/org/apache/servicemix/itests/Drools6IntegrationTests.scala
+++ /dev/null
@@ -1,132 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.servicemix.itests
-
-import org.junit.runner.RunWith
-import org.junit.{ Ignore, Test }
-import org.ops4j.pax.exam.spi.reactors.{ PerMethod, PerClass, ExamReactorStrategy }
-import org.ops4j.pax.exam.Configuration
-import org.ops4j.pax.exam.junit.PaxExam
-import org.ops4j.pax.exam.CoreOptions._
-import org.ops4j.pax.exam.karaf.options.KarafDistributionOption._
-import org.apache.karaf.features.Feature
-
-/**
- * Base configuration for all Drools 6 integration tests
- */
-@RunWith(classOf[PaxExam])
-@ExamReactorStrategy(Array(classOf[PerClass]))
-abstract class Drools6IntegrationTests extends ExamplesIntegrationTests {
-
-}
-/**
- * Tests for the Drools feature installation
- */
-class Drools6FeatureTest extends Drools6IntegrationTests {
- /**
- * Check feature installation
- */
- def installed(feature: String): Option[String] = {
- var f: Feature = featuresService.getFeature(feature)
- if (featuresService.isInstalled(f)) Some("Ok") else None
- }
-
- /**
- * Test for The Drools 6 feature kie-aries-blueprint
- */
- @Test
- def testKieBlueprintFeature = testWithFeature("kie-aries-blueprint") {
- expect {
- installed("kie-aries-blueprint")
- }
- }
-
- /**
- * Test for The Drools 6 feature kie-spring
- */
- @Test
- def testKieSpringFeature = testWithFeature("kie-spring") {
- expect {
- installed("kie-spring")
- }
- }
-
- /**
- * Test for The Drools 6 feature kie-camel
- */
- @Test
- def testKieCamelFeature = testWithFeature("kie-camel") {
- expect {
- installed("kie-camel")
- }
- }
-}
-
-/**
- * Tests for the Drools examples
- */
-class Drools6ExamplesTest extends Drools6IntegrationTests {
-
- @Test
- def testDroolsSimpleExample = testWithFeature(false, "examples-drools-simple") {
- expect {
- logging.containsMessage(line => line.contains("Customer [salary=1000, type=POOR]"))
- }
- expect {
- logging.containsMessage(line => line.contains("Customer [salary=5000, type=NORMAL]"))
- }
- expect {
- logging.containsMessage(line => line.contains("Customer [salary=9001, type=VIP]"))
- }
- }
-
- @Test
- def testDroolsCamelExample = testWithFeature("examples-drools-camel-blueprint") {
- expect {
- logging.containsMessage(line => line.contains("Total 2 routes, of which 2 is started"))
- }
- }
-}
-
-/**
- * Tests for the Drools with spring
- */
-class Drools6SpringExamplesTest extends Drools6IntegrationTests {
-
- /**
- * Test installation Spring with drools example.
- */
- @Test
- def testDroolsSpringExample = testWithFeature("examples-drools-spring") {
- expect {
- logging.containsMessage(line => line.contains("KieModule was added: org.drools.osgi.compiler.OsgiKieModule"))
- }
- }
-}
-
-/**
- * Tests for the Camel Rest Server examples
- */
-class Drools6CamelServiceExamplesTest extends Drools6IntegrationTests {
-
- @Test
- def testDroolsCamelServerExample = testWithFeature("examples-drools-camel-cxf-server") {
- expect {
- logging.containsMessage(line => line.contains("<execution-results><result identifier=\"customer\">"))
- }
- }
-}
diff --git a/itests/src/test/scala/org/apache/servicemix/itests/ExamplesIntegrationTests.scala b/itests/src/test/scala/org/apache/servicemix/itests/ExamplesIntegrationTests.scala
deleted file mode 100644
index 4e2c088..0000000
--- a/itests/src/test/scala/org/apache/servicemix/itests/ExamplesIntegrationTests.scala
+++ /dev/null
@@ -1,211 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.servicemix.itests
-
-import org.junit.runner.RunWith
-import org.junit.{Ignore, Test}
-import org.apache.camel.{Exchange, Processor}
-import org.ops4j.pax.exam.spi.reactors.{PerMethod, PerClass, ExamReactorStrategy}
-import org.ops4j.pax.exam.Configuration
-import org.ops4j.pax.exam.junit.PaxExam
-import org.ops4j.pax.exam.CoreOptions._
-import org.ops4j.pax.exam.karaf.options.KarafDistributionOption._
-
-/**
- * Base configuration for all examples' integration tests
- */
-@RunWith(classOf[PaxExam])
-@ExamReactorStrategy(Array(classOf[PerClass]))
-abstract class ExamplesIntegrationTests extends IntegrationTestSupport with CamelTestSupport {
-
- @Configuration
- def config() = servicemixTestConfiguration ++ scalaTestConfiguration
-
-}
-
-/**
- * Tests for the ActiveMQ examples
- */
-class ActiveMQExamplesTest extends ExamplesIntegrationTests {
-
- @Test
- def testActiveMQCamelBlueprintExample = testWithFeature("examples-activemq-camel-blueprint") {
- expect {
- logging.containsMessage(line => line.contains("ActiveMQ-Blueprint-Example set body"))
- }
- }
-}
-
-/**
- * Tests for the Activiti examples
- */
-class ActivitiExamplesTest extends ExamplesIntegrationTests {
-
- @Test
- // running the test without uninstalling the feature afterwards, cfr. SM-2244
- // installing the features separately, cfr. SM-2867
- def testActivitiCamelExample = testWithFeature(false, true, "transaction", "activiti", "examples-activiti-camel") {
- val orderId = "001"
-
- camelProducer.send("file:var/activiti-camel/order", new Processor() {
- def process(exchange: Exchange) = {
- exchange.getIn().setBody("Some nice order message goes here")
- exchange.getIn().setHeader(Exchange.FILE_NAME, orderId)
- }
- })
- expect { logging.containsMessage(line => line.contains(s"Processing order ${orderId}")) }
-
- camelProducer.send("file:var/activiti-camel/delivery", new Processor() {
- def process(exchange: Exchange) = {
- exchange.getIn().setBody("Some nice delivery message goes here")
- exchange.getIn().setHeader(Exchange.FILE_NAME, orderId)
- }
- })
- expect { logging.containsMessage(line => line.contains(s"Processing delivery for order ${orderId}")) }
- }
-}
-
-/**
- * Tests for the Camel examples
- */
-class CamelExamplesTest extends ExamplesIntegrationTests {
-
- @Test
- def testCamelOsgiExample : Unit = testWithFeature("examples-camel-osgi") {
- expect {
- logging.containsMessage(line => line.contains("JavaDSL set body"))
- }
- expect {
- logging.containsMessage(line => line.contains("MyTransform set body"))
- }
- }
-
- @Test
- def testCamelBlueprintExample : Unit = testWithFeature("examples-camel-blueprint") {
- expect {
- logging.containsMessage(line => line.contains("Blueprint-Example set body"))
- }
- }
-
- @Test
- def testCamelCxfSoap : Unit = testWithFeature("examples-camel-cxf-soap") {
- expect {
- logging.containsMessage(line => line.contains("Setting the server's publish address to be http://localhost:8989/soap"))
- }
- }
-
- @Test
- def testCamelCxfRest : Unit = testWithFeature("examples-camel-cxf-rest") {
- expect {
- logging.containsMessage(line => line.contains("Setting the server's publish address to be http://localhost:8989/rest"))
- }
- }
-}
-
-/**
- * Tests for the Camel Drools 5 examples
- */
-@ExamReactorStrategy(Array(classOf[PerMethod]))
-class CamelDrools5ExamplesTest extends ExamplesIntegrationTests {
-
- @Test
- def testCamelDroolsExample = testWithFeature("examples-camel-drools") {
- expect {
- logging.containsEvent( _.getLoggerName == "ServeDrink" )
- }
- }
-
- @Test
- def testCamelDroolsBlueprintExample = testWithFeature("examples-camel-drools-blueprint") {
- expect {
- logging.containsEvent( _.getLoggerName == "ServeDrink" )
- }
- }
-}
-
-/**
- * Tests for the CXF examples
- */
-@ExamReactorStrategy(Array(classOf[PerMethod]))
-class CxfExamplesTest extends ExamplesIntegrationTests {
-
- @Test
- def testCxfJaxRsExample = testWithFeature(false,"examples-cxf-jaxrs", "camel-http") {
- expect { logging.containsMessage( _.contains("Setting the server's publish address to be /crm")) }
- // TODO: the service appears to be started, but the URLs are not accessible
- // assertTrue(httpGet("http://localhost:8181/cxf/crm/customerservice/customers/123").contains("<Customer><id>123</id>"))
- }
-
- @Test
- def testCxfJaxRsBlueprintExample = testWithFeature("examples-cxf-jaxrs-blueprint", "camel-http4") {
- expect { logging.containsMessage( _.contains("Setting the server's publish address to be /crm")) }
- // assertTrue(requestString("http4://localhost:8181/cxf/crm/customerservice/customers/123").contains("<Customer><id>123</id>"))
- }
-
- @Test
- def testCxfJaxWsBlueprintExample = testWithFeature("examples-cxf-jaxws-blueprint", "camel-http4") {
- expect { logging.containsMessage( _.contains("Setting the server's publish address to be /HelloWorld")) }
- // TODO: uncomment this once
- // assertNotNull(requestString("http4://localhost:8181/cxf/HelloWorld?wsdl"))
- }
-
- @Test
- def testCxfOsgi = testWithFeature("examples-cxf-osgi") {
- expect { logging.containsMessage( _.contains("Setting the server's publish address to be /HelloWorld")) }
- }
-
- @Test
- def testCxfWsRm = testWithFeature("examples-cxf-ws-rm") {
- expect { logging.containsMessage( _.contains("Setting the server's publish address to be /HelloWorld")) }
- }
-
- @Test
- def testCxfWsSecurityBlueprint = testWithFeature("examples-cxf-ws-security-blueprint") {
- expect { logging.containsMessage( _.contains("Setting the server's publish address to be /HelloWorldSecurity")) }
- }
-
- @Test
- def testCxfWsSecurityOsgi = testWithFeature("examples-cxf-ws-security-osgi") {
- expect { logging.containsMessage( _.contains("Setting the server's publish address to be /HelloWorldSecurity")) }
- }
-
- @Test
- def testCxfWsSecuritySignature = testWithFeature("examples-cxf-ws-security-signature") {
- expect { logging.containsMessage( _.contains("Setting the server's publish address to be /HelloWorldSecurity")) }
- }
-}
-
-/**
- * Tests for the CXF WSN examples
- */
-@ExamReactorStrategy(Array(classOf[PerMethod]))
-class CxfWsnExamplesTest extends ExamplesIntegrationTests {
-
- @Configuration
- override def config() = super.config() ++ cxfWsnExampleTestConfiguration
-
- @Test
- def testCxfWsn = testWithFeature("examples-cxf-wsn-receive","examples-cxf-wsn-notifier") {
- expect { logging.containsMessage( _.contains("### YOU GOT MAIL ####\n")) }
- }
-
- def cxfWsnExampleTestConfiguration =
- Array(
- editConfigurationFilePut("etc/org.apache.cxf.wsn.cfg", "cxf.wsn.activemq.username", "smx"),
- editConfigurationFilePut("etc/org.apache.cxf.wsn.cfg", "cxf.wsn.activemq.password", "smx")
- )
-}
\ No newline at end of file
diff --git a/itests/src/test/scala/org/apache/servicemix/itests/IntegrationTestConfigurations.scala b/itests/src/test/scala/org/apache/servicemix/itests/IntegrationTestConfigurations.scala
deleted file mode 100644
index b494257..0000000
--- a/itests/src/test/scala/org/apache/servicemix/itests/IntegrationTestConfigurations.scala
+++ /dev/null
@@ -1,66 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.servicemix.itests
-
-import scala.Array
-import org.ops4j.pax.exam.CoreOptions._
-import org.ops4j.pax.exam.karaf.options.KarafDistributionOption._
-import scala.Some
-import java.io.File
-
-/**
- * Pax-Exam-Karaf configurations for integration testing
- */
-trait IntegrationTestConfigurations {
-
- lazy val LOCAL_REPOSITORY = System.getProperty("org.ops4j.pax.url.mvn.localRepository")
-
- /**
- * The default integration test configuration, using Scala and the Apache ServiceMix default assembly
- */
- def defaultIntegrationTestConfiguration = servicemixTestConfiguration ++ scalaTestConfiguration
-
- /**
- * Add support for Scala-based integration tests
- */
- def scalaTestConfiguration =
- Array(mavenBundle("org.scala-lang", "scala-library").versionAsInProject())
-
- /**
- * Add an Apache ServiceMix container configuration
- */
- def servicemixTestConfiguration = {
- val name = "default"
- val artifact = "apache-servicemix"
-
- Array(
- karafDistributionConfiguration().
- frameworkUrl(
- maven().groupId("org.apache.servicemix").artifactId(artifact).`type`("zip").versionAsInProject()).
- karafVersion("4.0.3").name("Apache ServiceMix (${name})").
- unpackDirectory(new File(s"target/pax-exam/${artifact}")).
- useDeployFolder(false),
- keepRuntimeFolder(),
- when(null != LOCAL_REPOSITORY && LOCAL_REPOSITORY.length() > 0).useOptions(
- //systemProperty("org.ops4j.pax.url.mvn.localRepository").value(LOCAL_REPOSITORY)
- editConfigurationFilePut("etc/org.ops4j.pax.url.mvn.cfg", "org.ops4j.pax.url.mvn.localRepository", LOCAL_REPOSITORY)
- ),
- // TODO: investigate why we need this to get Pax Logging going again
- editConfigurationFilePut("etc/org.ops4j.pax.logging.cfg", "log4j.rootLogger", "INFO,stdout,osgi:*"))
- }
-
-}
diff --git a/itests/src/test/scala/org/apache/servicemix/itests/IntegrationTestSupport.scala b/itests/src/test/scala/org/apache/servicemix/itests/IntegrationTestSupport.scala
deleted file mode 100644
index fc95e26..0000000
--- a/itests/src/test/scala/org/apache/servicemix/itests/IntegrationTestSupport.scala
+++ /dev/null
@@ -1,131 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.servicemix.itests
-
-import javax.inject.Inject
-import org.osgi.framework.{ServiceRegistration, BundleContext}
-import java.io.File
-import scala.Some
-import org.junit.{Before, BeforeClass, After}
-import org.ops4j.pax.logging.spi.{PaxLoggingEvent, PaxAppender}
-import collection.mutable.ArrayBuffer
-import java.util.Hashtable
-import org.junit.Assert.fail
-import org.apache.karaf.features.{Feature, FeaturesService}
-import scala.collection.JavaConversions.setAsJavaSet
-import java.util
-// allow for postfix notation
-import scala.language.postfixOps
-
-/**
- * Base class for building Apache ServiceMix integration tests
- */
-abstract class IntegrationTestSupport extends Await with IntegrationTestConfigurations {
-
- @Inject
- var context: BundleContext = null;
-
- @Inject
- var featuresService: FeaturesService = null
-
- /*
- * List of services to be unregistered after the test
- */
- val registrations = ArrayBuffer.empty[ServiceRegistration[_]]
-
- @Before
- def clearLogging = logging.clear
-
- /*
- * A set of convenience vals for referring to directories within the test container
- */
- lazy val servicemixHomeFolder = new File(System.getProperty("servicemix.home"))
- lazy val dataFolder = new File(servicemixHomeFolder, "data")
- lazy val logFolder = new File(dataFolder, "log")
- lazy val logFile : File = new File(logFolder, "servicemix.log")
-
- /**
- * Install a feature and run a block of code. Afterwards, uninstall the feature again
- */
- def testWithFeature(names: String*)(block: => Unit) : Unit = testWithFeature(true, names:_*)(block)
-
- /**
- * Install a feature and run a block of code. Afterwards, uninstall the feature again if indicated.
- */
- def testWithFeature(uninstall: Boolean, names: String*)(block: => Unit) : Unit = testWithFeature(uninstall, false, names:_*)(block)
-
- /**
- * Install a feature and run a block of code. Install features separately if indicated.
- * Afterwards, uninstall the feature again if indicated.
- */
- def testWithFeature(uninstall: Boolean, separateInstall: Boolean, names: String*)(block: => Unit) =
- try {
- //TODO: Get this working without the extra options - enabling bundle refresh here will mess up the test container
- if (separateInstall) {
- names foreach {featuresService.installFeature(_, util.EnumSet.of(FeaturesService.Option.NoAutoRefreshBundles))}
- } else {
- val features : Set[String] = (names toSet)
- featuresService.installFeatures(features, util.EnumSet.of(FeaturesService.Option.NoAutoRefreshBundles))
- }
- block
- } finally {
- if(uninstall) names foreach { featuresService.uninstallFeature }
- }
-
- /**
- * Expect a certain condition to occur within the allotted waiting time.
- */
- def expect[T](block: => Option[T]) : Unit = await(block) match {
- case None => fail(s"Gave up waiting for test condition")
- case _ => //graciously ignore
- }
-
- /**
- * Registers and return a logging appender
- */
- lazy val logging = {
- val appender = new PaxLoggingAppender
-
- val props = new Hashtable[String, String]()
- props.put("org.ops4j.pax.logging.appender.name", "ITestLogAppender")
-
- Option(context.registerService(classOf[PaxAppender], appender, props)) match {
- case Some(registration) => (registrations += registration)
- case None => throw new RuntimeException("Error setting up logging appender for testing")
- }
-
- appender
- }
-
- /**
- * Simple PaxAppender implementation that buffers logging events for the integration
- */
- class PaxLoggingAppender extends PaxAppender {
-
- val buffer = ArrayBuffer.empty[PaxLoggingEvent]
-
- def doAppend(event: PaxLoggingEvent) = buffer += event
-
- def clear = buffer.clear
-
- def containsMessage(predicate: String => Boolean) : Option[String] = containsEvent(event => if(event != null) predicate(event.getMessage) else false) map ( _.getMessage )
-
- def containsEvent(predicate: PaxLoggingEvent => Boolean) : Option[PaxLoggingEvent] = buffer find (predicate)
-
- }
-
-}
diff --git a/parent/pom.xml b/parent/pom.xml
index 7a947e1..7d6aef0 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -80,7 +80,7 @@
<mvel2.version>2.2.1.Final</mvel2.version>
<mybatis.version>3.3.0</mybatis.version>
<osgi.version>6.0.0</osgi.version>
- <pax.exam.version>4.8.0</pax.exam.version>
+ <pax.exam.version>4.9.0-SNAPSHOT</pax.exam.version>
<pax.logging.version>1.8.5</pax.logging.version>
<pax.url.version>2.4.5</pax.url.version>
<postgresql.version>9.1-901</postgresql.version>