http://git-wip-us.apache.org/repos/asf/camel/blob/20401a38/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/CamelSalesforceTest.java ---------------------------------------------------------------------- diff --git a/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/CamelSalesforceTest.java b/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/CamelSalesforceTest.java index f83f131..c122e2d 100644 --- a/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/CamelSalesforceTest.java +++ b/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/CamelSalesforceTest.java @@ -35,6 +35,8 @@ public class CamelSalesforceTest extends AbstractSpringBootTestSupport { public static ITestConfig createTestConfig() { return new ITestConfigBuilder() .module(inferModuleName(CamelSalesforceTest.class)) + .basePath("../../components/camel-salesforce/camel-salesforce-component") + .unitTestExclusionPattern(".*(\\.integration\\..*|IntegrationTest.*|MSPTest$)") .autostart(false) // needs configuration .build(); }
http://git-wip-us.apache.org/repos/asf/camel/blob/20401a38/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/CamelSapNetweaverTest.java ---------------------------------------------------------------------- diff --git a/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/CamelSapNetweaverTest.java b/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/CamelSapNetweaverTest.java index e3f83d2..f7b058c 100644 --- a/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/CamelSapNetweaverTest.java +++ b/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/CamelSapNetweaverTest.java @@ -35,6 +35,8 @@ public class CamelSapNetweaverTest extends AbstractSpringBootTestSupport { public static ITestConfig createTestConfig() { return new ITestConfigBuilder() .module(inferModuleName(CamelSapNetweaverTest.class)) + .unitTestInclusionPattern("^$") // no pure unit-tests + .unitTestExpectedNumber(0) .build(); } http://git-wip-us.apache.org/repos/asf/camel/blob/20401a38/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/CamelScalaTest.java ---------------------------------------------------------------------- diff --git a/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/CamelScalaTest.java b/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/CamelScalaTest.java index ca1a39c..73131b8 100644 --- a/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/CamelScalaTest.java +++ b/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/CamelScalaTest.java @@ -35,6 +35,7 @@ public class CamelScalaTest extends AbstractSpringBootTestSupport { public static ITestConfig createTestConfig() { return new ITestConfigBuilder() .module(inferModuleName(CamelScalaTest.class)) + .unitTestExclusionPattern(".*(\\.integration\\..*|IntegrationTest$|LoopTest$|IdempotentConsumerEagerTest$|AutoStartupTest$)") // no runnable methods on these tests .build(); } http://git-wip-us.apache.org/repos/asf/camel/blob/20401a38/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/CamelServicenowTest.java ---------------------------------------------------------------------- diff --git a/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/CamelServicenowTest.java b/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/CamelServicenowTest.java index 9cf07c7..095fe34 100644 --- a/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/CamelServicenowTest.java +++ b/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/CamelServicenowTest.java @@ -35,6 +35,8 @@ public class CamelServicenowTest extends AbstractSpringBootTestSupport { public static ITestConfig createTestConfig() { return new ITestConfigBuilder() .module(inferModuleName(CamelServicenowTest.class)) + .unitTestInclusionPattern("^$") // no tests + .unitTestExpectedNumber(0) .build(); } http://git-wip-us.apache.org/repos/asf/camel/blob/20401a38/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/CamelServletTest.java ---------------------------------------------------------------------- diff --git a/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/CamelServletTest.java b/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/CamelServletTest.java index aad8988..0b8f3a5 100644 --- a/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/CamelServletTest.java +++ b/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/CamelServletTest.java @@ -35,6 +35,9 @@ public class CamelServletTest extends AbstractSpringBootTestSupport { public static ITestConfig createTestConfig() { return new ITestConfigBuilder() .module(inferModuleName(CamelServletTest.class)) +// .dependency(DependencyResolver.withVersion("org.springframework.boot:spring-boot-starter-web")) +// .dependency(DependencyResolver.withVersion("org.springframework:spring-webmvc")) + .unitTestExclusionPattern(".*ExposedServletEndpointURIToJMXTest") .build(); } http://git-wip-us.apache.org/repos/asf/camel/blob/20401a38/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/CamelSjmsTest.java ---------------------------------------------------------------------- diff --git a/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/CamelSjmsTest.java b/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/CamelSjmsTest.java index fdd69e3..26e6ec2 100644 --- a/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/CamelSjmsTest.java +++ b/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/CamelSjmsTest.java @@ -35,12 +35,16 @@ public class CamelSjmsTest extends AbstractSpringBootTestSupport { public static ITestConfig createTestConfig() { return new ITestConfigBuilder() .module(inferModuleName(CamelSjmsTest.class)) +// .dependency("com.atomikos:transactions-jdbc:3.9.3") +// .dependency("com.atomikos:transactions-jms:3.9.3") +// .dependency("javax.transaction:javax.transaction-api:1.2") +// .disableJmx("org.apache.activemq:*") .build(); } @Test public void componentTests() throws Exception { - this.runComponentTest(config); + //this.runComponentTest(config); this.runModuleUnitTestsIfEnabled(config); } http://git-wip-us.apache.org/repos/asf/camel/blob/20401a38/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/CamelSlackTest.java ---------------------------------------------------------------------- diff --git a/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/CamelSlackTest.java b/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/CamelSlackTest.java index 117bef4..964249a 100644 --- a/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/CamelSlackTest.java +++ b/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/CamelSlackTest.java @@ -35,6 +35,8 @@ public class CamelSlackTest extends AbstractSpringBootTestSupport { public static ITestConfig createTestConfig() { return new ITestConfigBuilder() .module(inferModuleName(CamelSlackTest.class)) + .unitTestExclusionPattern(".*(\\.integration\\..*|IntegrationTest$|SlackProducerTest$)") // excluding blueprint tests + .unitTestExpectedNumber(0) .build(); } http://git-wip-us.apache.org/repos/asf/camel/blob/20401a38/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/CamelSmppTest.java ---------------------------------------------------------------------- diff --git a/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/CamelSmppTest.java b/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/CamelSmppTest.java index fc73d4a..ff22c52 100644 --- a/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/CamelSmppTest.java +++ b/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/CamelSmppTest.java @@ -35,6 +35,9 @@ public class CamelSmppTest extends AbstractSpringBootTestSupport { public static ITestConfig createTestConfig() { return new ITestConfigBuilder() .module(inferModuleName(CamelSmppTest.class)) + .unitTestInclusionPattern("^$") + .unitTestExpectedNumber(0) + // The only unit test that can be run has a log-level dependent outcome... .build(); } http://git-wip-us.apache.org/repos/asf/camel/blob/20401a38/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/CamelSparkRestTest.java ---------------------------------------------------------------------- diff --git a/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/CamelSparkRestTest.java b/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/CamelSparkRestTest.java index fa5c364..8d2baba 100644 --- a/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/CamelSparkRestTest.java +++ b/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/CamelSparkRestTest.java @@ -17,6 +17,7 @@ package org.apache.camel.itest.springboot; import org.apache.camel.itest.springboot.util.ArquillianPackager; +import org.apache.camel.itest.springboot.util.DependencyResolver; import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.junit.Arquillian; import org.jboss.shrinkwrap.api.Archive; @@ -35,6 +36,7 @@ public class CamelSparkRestTest extends AbstractSpringBootTestSupport { public static ITestConfig createTestConfig() { return new ITestConfigBuilder() .module(inferModuleName(CamelSparkRestTest.class)) + .dependency(DependencyResolver.withVersion("org.hibernate:hibernate-validator")) .build(); } http://git-wip-us.apache.org/repos/asf/camel/blob/20401a38/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/CamelSpringRedisTest.java ---------------------------------------------------------------------- diff --git a/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/CamelSpringRedisTest.java b/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/CamelSpringRedisTest.java index 6e77d9f..6ea8a98 100644 --- a/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/CamelSpringRedisTest.java +++ b/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/CamelSpringRedisTest.java @@ -17,6 +17,7 @@ package org.apache.camel.itest.springboot; import org.apache.camel.itest.springboot.util.ArquillianPackager; +import org.apache.camel.itest.springboot.util.DependencyResolver; import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.junit.Arquillian; import org.jboss.shrinkwrap.api.Archive; @@ -27,8 +28,6 @@ import org.junit.runner.RunWith; @RunWith(Arquillian.class) public class CamelSpringRedisTest extends AbstractSpringBootTestSupport { - private static final String SPRING_DATA_REDIS_VERSION = System.getProperty("springDataRedisVersion", "1.6.4.RELEASE"); - @Deployment public static Archive<?> createSpringBootPackage() throws Exception { return ArquillianPackager.springBootPackage(createTestConfig()); @@ -37,7 +36,7 @@ public class CamelSpringRedisTest extends AbstractSpringBootTestSupport { public static ITestConfig createTestConfig() { return new ITestConfigBuilder() .module(inferModuleName(CamelSpringRedisTest.class)) - .dependency("org.springframework.data:spring-data-redis:" + SPRING_DATA_REDIS_VERSION) + .dependency(DependencyResolver.withVersion("org.springframework.data:spring-data-redis")) .build(); } http://git-wip-us.apache.org/repos/asf/camel/blob/20401a38/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/CamelSpringTest.java ---------------------------------------------------------------------- diff --git a/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/CamelSpringTest.java b/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/CamelSpringTest.java index 07616a5..14502c0 100644 --- a/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/CamelSpringTest.java +++ b/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/CamelSpringTest.java @@ -35,6 +35,7 @@ public class CamelSpringTest extends AbstractSpringBootTestSupport { public static ITestConfig createTestConfig() { return new ITestConfigBuilder() .module(inferModuleName(CamelSpringTest.class)) + .unitTestExclusionPattern(".*(\\.integration\\..*|IntegrationTest$|ManagedRefEndpointTest$|SpringLogProcessorWithProvidedLoggerTest$|SpringManagedCamelContextTest$)") .build(); } http://git-wip-us.apache.org/repos/asf/camel/blob/20401a38/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/CamelSpringWsTest.java ---------------------------------------------------------------------- diff --git a/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/CamelSpringWsTest.java b/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/CamelSpringWsTest.java index bf5e2c9..dcfd97e 100644 --- a/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/CamelSpringWsTest.java +++ b/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/CamelSpringWsTest.java @@ -17,6 +17,7 @@ package org.apache.camel.itest.springboot; import org.apache.camel.itest.springboot.util.ArquillianPackager; +import org.apache.camel.itest.springboot.util.DependencyResolver; import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.junit.Arquillian; import org.jboss.shrinkwrap.api.Archive; @@ -35,6 +36,8 @@ public class CamelSpringWsTest extends AbstractSpringBootTestSupport { public static ITestConfig createTestConfig() { return new ITestConfigBuilder() .module(inferModuleName(CamelSpringWsTest.class)) + .dependency(DependencyResolver.withVersion("org.springframework.boot:spring-boot-starter-web")) + .dependency(DependencyResolver.withVersion("org.springframework:spring-webmvc")) .build(); } http://git-wip-us.apache.org/repos/asf/camel/blob/20401a38/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/CamelStreamTest.java ---------------------------------------------------------------------- diff --git a/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/CamelStreamTest.java b/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/CamelStreamTest.java index ecbd44b..fb1fa03 100644 --- a/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/CamelStreamTest.java +++ b/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/CamelStreamTest.java @@ -35,6 +35,9 @@ public class CamelStreamTest extends AbstractSpringBootTestSupport { public static ITestConfig createTestConfig() { return new ITestConfigBuilder() .module(inferModuleName(CamelStreamTest.class)) + .customLog(false) + .unitTestExclusionPattern(".*(\\.integration\\..*|IntegrationTest$|StreamToUrlTest$)") + // Spring provides its own URL handlers for schema "mock:" .build(); } http://git-wip-us.apache.org/repos/asf/camel/blob/20401a38/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/CamelSwaggerJavaTest.java ---------------------------------------------------------------------- diff --git a/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/CamelSwaggerJavaTest.java b/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/CamelSwaggerJavaTest.java index ee4c35a..ef8a043 100644 --- a/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/CamelSwaggerJavaTest.java +++ b/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/CamelSwaggerJavaTest.java @@ -17,6 +17,7 @@ package org.apache.camel.itest.springboot; import org.apache.camel.itest.springboot.util.ArquillianPackager; +import org.apache.camel.itest.springboot.util.DependencyResolver; import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.junit.Arquillian; import org.jboss.shrinkwrap.api.Archive; @@ -27,8 +28,6 @@ import org.junit.runner.RunWith; @RunWith(Arquillian.class) public class CamelSwaggerJavaTest extends AbstractSpringBootTestSupport { - private static final String HIBERNATE_VALIDATOR_VERSION = System.getProperty("hibernateValidatorVersion", "5.2.4.Final"); - @Deployment public static Archive<?> createSpringBootPackage() throws Exception { return ArquillianPackager.springBootPackage(createTestConfig()); @@ -37,7 +36,7 @@ public class CamelSwaggerJavaTest extends AbstractSpringBootTestSupport { public static ITestConfig createTestConfig() { return new ITestConfigBuilder() .module(inferModuleName(CamelSwaggerJavaTest.class)) - .dependency("org.hibernate:hibernate-validator:" + HIBERNATE_VALIDATOR_VERSION) + .dependency(DependencyResolver.withVersion("org.hibernate:hibernate-validator")) .build(); } http://git-wip-us.apache.org/repos/asf/camel/blob/20401a38/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/CamelSwaggerTest.java ---------------------------------------------------------------------- diff --git a/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/CamelSwaggerTest.java b/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/CamelSwaggerTest.java deleted file mode 100644 index 3aacefc..0000000 --- a/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/CamelSwaggerTest.java +++ /dev/null @@ -1,51 +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.camel.itest.springboot; - -import org.apache.camel.itest.springboot.util.ArquillianPackager; -import org.jboss.arquillian.container.test.api.Deployment; -import org.jboss.arquillian.junit.Arquillian; -import org.jboss.shrinkwrap.api.Archive; -import org.junit.Test; -import org.junit.runner.RunWith; - - -@RunWith(Arquillian.class) -public class CamelSwaggerTest extends AbstractSpringBootTestSupport { - - private static final String HIBERNATE_VALIDATOR_VERSION = System.getProperty("hibernateValidatorVersion", "5.2.4.Final"); - - @Deployment - public static Archive<?> createSpringBootPackage() throws Exception { - return ArquillianPackager.springBootPackage(createTestConfig()); - } - - public static ITestConfig createTestConfig() { - return new ITestConfigBuilder() - .module(inferModuleName(CamelSwaggerTest.class)) - .dependency("org.hibernate:hibernate-validator:" + HIBERNATE_VALIDATOR_VERSION) - .build(); - } - - @Test - public void componentTests() throws Exception { - // no component test - this.runModuleUnitTestsIfEnabled(config); - } - - -} http://git-wip-us.apache.org/repos/asf/camel/blob/20401a38/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/CamelTwitterTest.java ---------------------------------------------------------------------- diff --git a/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/CamelTwitterTest.java b/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/CamelTwitterTest.java index 53265b9..441c570 100644 --- a/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/CamelTwitterTest.java +++ b/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/CamelTwitterTest.java @@ -35,7 +35,7 @@ public class CamelTwitterTest extends AbstractSpringBootTestSupport { public static ITestConfig createTestConfig() { return new ITestConfigBuilder() .module(inferModuleName(CamelTwitterTest.class)) - .unitTestExclusionPattern(".*(DirectMessageDirectTest|DirectMessagePollingTest)$") + .unitTestInclusionPattern(".*UriConfigurationTest$") .build(); } http://git-wip-us.apache.org/repos/asf/camel/blob/20401a38/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/CamelUndertowTest.java ---------------------------------------------------------------------- diff --git a/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/CamelUndertowTest.java b/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/CamelUndertowTest.java index 9749630..a7d9e62 100644 --- a/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/CamelUndertowTest.java +++ b/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/CamelUndertowTest.java @@ -17,6 +17,7 @@ package org.apache.camel.itest.springboot; import org.apache.camel.itest.springboot.util.ArquillianPackager; +import org.apache.camel.itest.springboot.util.DependencyResolver; import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.junit.Arquillian; import org.jboss.shrinkwrap.api.Archive; @@ -35,6 +36,8 @@ public class CamelUndertowTest extends AbstractSpringBootTestSupport { public static ITestConfig createTestConfig() { return new ITestConfigBuilder() .module(inferModuleName(CamelUndertowTest.class)) + .dependency(DependencyResolver.withVersion("org.hibernate:hibernate-validator")) + .unitTestExclusionPattern(".*(\\.integration\\..*|IntegrationTest$|BaseUndertowTest$|UndertowHttpsSpringTest$)") .build(); } http://git-wip-us.apache.org/repos/asf/camel/blob/20401a38/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/CamelWeatherTest.java ---------------------------------------------------------------------- diff --git a/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/CamelWeatherTest.java b/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/CamelWeatherTest.java index 6cc023c..05fa69f 100644 --- a/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/CamelWeatherTest.java +++ b/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/CamelWeatherTest.java @@ -35,13 +35,14 @@ public class CamelWeatherTest extends AbstractSpringBootTestSupport { public static ITestConfig createTestConfig() { return new ITestConfigBuilder() .module(inferModuleName(CamelWeatherTest.class)) + .unitTestExclusionPattern(".*(\\.integration\\..*|IntegrationTest$|BaseUndertowTest$)") .build(); } @Test public void componentTests() throws Exception { this.runComponentTest(config); - this.runModuleUnitTestsIfEnabled(config); + // skip tests } } http://git-wip-us.apache.org/repos/asf/camel/blob/20401a38/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/CamelWebsocketTest.java ---------------------------------------------------------------------- diff --git a/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/CamelWebsocketTest.java b/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/CamelWebsocketTest.java index 65c8301..8e12f50 100644 --- a/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/CamelWebsocketTest.java +++ b/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/CamelWebsocketTest.java @@ -35,6 +35,7 @@ public class CamelWebsocketTest extends AbstractSpringBootTestSupport { public static ITestConfig createTestConfig() { return new ITestConfigBuilder() .module(inferModuleName(CamelWebsocketTest.class)) + .unitTestExclusionPattern(".*(WebsocketEndpointTest|WebsocketComponentTest)$") .build(); } http://git-wip-us.apache.org/repos/asf/camel/blob/20401a38/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/CamelXmljsonTest.java ---------------------------------------------------------------------- diff --git a/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/CamelXmljsonTest.java b/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/CamelXmljsonTest.java index 542b88a..ea7a3e4 100644 --- a/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/CamelXmljsonTest.java +++ b/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/CamelXmljsonTest.java @@ -17,6 +17,7 @@ package org.apache.camel.itest.springboot; import org.apache.camel.itest.springboot.util.ArquillianPackager; +import org.apache.camel.itest.springboot.util.DependencyResolver; import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.junit.Arquillian; import org.jboss.shrinkwrap.api.Archive; @@ -35,6 +36,7 @@ public class CamelXmljsonTest extends AbstractSpringBootTestSupport { public static ITestConfig createTestConfig() { return new ITestConfigBuilder() .module(inferModuleName(CamelXmljsonTest.class)) + .dependency(DependencyResolver.withVersion("xom:xom")) .build(); } http://git-wip-us.apache.org/repos/asf/camel/blob/20401a38/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/CamelXmppTest.java ---------------------------------------------------------------------- diff --git a/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/CamelXmppTest.java b/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/CamelXmppTest.java index 8ef4c89..1aa9c64 100644 --- a/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/CamelXmppTest.java +++ b/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/CamelXmppTest.java @@ -16,6 +16,9 @@ */ package org.apache.camel.itest.springboot; +import java.io.File; +import java.io.IOException; + import org.apache.camel.itest.springboot.util.ArquillianPackager; import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.junit.Arquillian; @@ -32,13 +35,15 @@ public class CamelXmppTest extends AbstractSpringBootTestSupport { return ArquillianPackager.springBootPackage(createTestConfig()); } - public static ITestConfig createTestConfig() { + public static ITestConfig createTestConfig() throws IOException { return new ITestConfigBuilder() .module(inferModuleName(CamelXmppTest.class)) + .systemProperty("javax.net.ssl.trustStore", new File("../../components/camel-xmpp/src/test/resources/xmppServer.jks").getCanonicalPath()) .build(); } @Test +// @Ignore public void componentTests() throws Exception { this.runComponentTest(config); this.runModuleUnitTestsIfEnabled(config); http://git-wip-us.apache.org/repos/asf/camel/blob/20401a38/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/arquillian/container/ManagedSEContainerConfiguration.java ---------------------------------------------------------------------- diff --git a/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/arquillian/container/ManagedSEContainerConfiguration.java b/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/arquillian/container/ManagedSEContainerConfiguration.java new file mode 100644 index 0000000..3f3d12c --- /dev/null +++ b/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/arquillian/container/ManagedSEContainerConfiguration.java @@ -0,0 +1,102 @@ +/** + * 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.camel.itest.springboot.arquillian.container; + +import java.util.logging.Level; + +import org.jboss.arquillian.container.spi.ConfigurationException; +import org.jboss.arquillian.container.spi.client.container.ContainerConfiguration; + +public class ManagedSEContainerConfiguration implements ContainerConfiguration { + + private boolean debug; + private String host = "127.0.0.1"; + private int port = 9999; + private String librariesPath; + private Level logLevel = Level.INFO; + private boolean keepDeploymentArchives; + private String additionalJavaOpts; + private int waitTime = 5; + + public void validate() throws ConfigurationException { + } + + public void setWaitTime(int waitTime) { + this.waitTime = waitTime; + } + + public int getWaitTime() { + return waitTime; + } + + public boolean isDebug() { + return debug; + } + + public void setDebug(boolean debug) { + this.debug = debug; + } + + public int getPort() { + return port; + } + + public void setPort(int port) { + this.port = port; + } + + public String getHost() { + return host; + } + + public void setHost(String host) { + this.host = host; + } + + public String getLibrariesPath() { + return librariesPath; + } + + public void setLibrariesPath(String librariesPath) { + this.librariesPath = librariesPath; + } + + public Level getLogLevel() { + return logLevel; + } + + public void setLogLevel(String logLevel) { + this.logLevel = Level.parse(logLevel); + } + + public boolean isKeepDeploymentArchives() { + return keepDeploymentArchives; + } + + public void setKeepDeploymentArchives(boolean keepDeploymentArchives) { + this.keepDeploymentArchives = keepDeploymentArchives; + } + + public String getAdditionalJavaOpts() { + return additionalJavaOpts; + } + + public void setAdditionalJavaOpts(String additionalJavaOpts) { + this.additionalJavaOpts = additionalJavaOpts; + } + +} http://git-wip-us.apache.org/repos/asf/camel/blob/20401a38/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/arquillian/container/ManagedSEContainerExtension.java ---------------------------------------------------------------------- diff --git a/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/arquillian/container/ManagedSEContainerExtension.java b/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/arquillian/container/ManagedSEContainerExtension.java new file mode 100644 index 0000000..f870d24 --- /dev/null +++ b/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/arquillian/container/ManagedSEContainerExtension.java @@ -0,0 +1,33 @@ +/** + * 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.camel.itest.springboot.arquillian.container; + +import org.apache.camel.itest.springboot.arquillian.container.jmx.CustomJMXProtocol; +import org.jboss.arquillian.container.spi.client.container.DeployableContainer; +import org.jboss.arquillian.container.test.spi.client.deployment.AuxiliaryArchiveAppender; +import org.jboss.arquillian.container.test.spi.client.protocol.Protocol; +import org.jboss.arquillian.core.spi.LoadableExtension; + +public class ManagedSEContainerExtension implements LoadableExtension { + + @Override + public void register(final ExtensionBuilder builder) { + builder.service(DeployableContainer.class, ManagedSEDeployableContainer.class); + builder.service(Protocol.class, CustomJMXProtocol.class); + builder.service(AuxiliaryArchiveAppender.class, SEContainerAppender.class); + } +} http://git-wip-us.apache.org/repos/asf/camel/blob/20401a38/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/arquillian/container/ManagedSEDeployableContainer.java ---------------------------------------------------------------------- diff --git a/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/arquillian/container/ManagedSEDeployableContainer.java b/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/arquillian/container/ManagedSEDeployableContainer.java new file mode 100644 index 0000000..3503be9 --- /dev/null +++ b/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/arquillian/container/ManagedSEDeployableContainer.java @@ -0,0 +1,397 @@ +/** + * 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.camel.itest.springboot.arquillian.container; + +import java.io.File; +import java.io.FilenameFilter; +import java.io.IOException; +import java.io.InputStream; +import java.net.Socket; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Properties; +import java.util.Set; +import java.util.concurrent.Callable; +import java.util.logging.ConsoleHandler; +import java.util.logging.Level; +import java.util.logging.Logger; +import javax.management.MBeanServerConnection; +import javax.management.ObjectName; +import javax.management.remote.JMXConnector; +import javax.management.remote.JMXConnectorFactory; +import javax.management.remote.JMXServiceURL; + +import org.apache.camel.itest.springboot.arquillian.container.jmx.CustomJMXProtocol; +import org.apache.camel.itest.springboot.arquillian.container.util.Await; +import org.apache.camel.itest.springboot.arquillian.container.util.FileDeploymentUtils; +import org.jboss.arquillian.container.se.api.ClassPath; +import org.jboss.arquillian.container.se.api.ClassPathDirectory; +import org.jboss.arquillian.container.spi.client.container.DeployableContainer; +import org.jboss.arquillian.container.spi.client.container.DeploymentException; +import org.jboss.arquillian.container.spi.client.container.LifecycleException; +import org.jboss.arquillian.container.spi.client.protocol.ProtocolDescription; +import org.jboss.arquillian.container.spi.client.protocol.metadata.JMXContext; +import org.jboss.arquillian.container.spi.client.protocol.metadata.ProtocolMetaData; +import org.jboss.arquillian.protocol.jmx.JMXTestRunnerMBean; +import org.jboss.shrinkwrap.api.Archive; +import org.jboss.shrinkwrap.api.Node; +import org.jboss.shrinkwrap.api.asset.ArchiveAsset; +import org.jboss.shrinkwrap.api.asset.Asset; +import org.jboss.shrinkwrap.api.asset.ClassAsset; +import org.jboss.shrinkwrap.api.exporter.ZipExporter; +import org.jboss.shrinkwrap.descriptor.api.Descriptor; + +public class ManagedSEDeployableContainer implements DeployableContainer<ManagedSEContainerConfiguration> { + + private static final Logger LOGGER = Logger.getLogger(ManagedSEDeployableContainer.class.getName()); + private static final String SYSPROP_KEY_JAVA_HOME = "java.home"; + private static final String DEBUG_AGENT_STRING = "-agentlib:jdwp=transport=dt_socket,address=8787,server=y,suspend=y"; + private static final String TARGET = "target"; + private static final String SERVER_MAIN_CLASS_FQN = "org.jboss.arquillian.container.se.server.Main"; + private static final String SYSTEM_PROPERTY_SWITCH = "-D"; + private static final String EQUALS = "="; + + private boolean debugModeEnabled; + private boolean keepDeploymentArchives; + private Process process; + private List<File> materializedFiles; + private List<File> classpathDependencies; + private String host; + private int port; + private String librariesPath; + private List<String> additionalJavaOpts; + private int waitTime; + + @Override + public Class<ManagedSEContainerConfiguration> getConfigurationClass() { + return ManagedSEContainerConfiguration.class; + } + + public void setup(ManagedSEContainerConfiguration configuration) { + debugModeEnabled = configuration.isDebug(); + host = configuration.getHost(); + port = configuration.getPort(); + materializedFiles = new ArrayList<>(); + classpathDependencies = new ArrayList<>(); + librariesPath = configuration.getLibrariesPath(); + keepDeploymentArchives = configuration.isKeepDeploymentArchives(); + additionalJavaOpts = initAdditionalJavaOpts(configuration.getAdditionalJavaOpts()); + configureLogging(configuration); + waitTime = configuration.getWaitTime() > 0 ? configuration.getWaitTime() : 10; + } + + private List<String> initAdditionalJavaOpts(String opts) { + if (opts == null || opts.isEmpty()) { + return Collections.emptyList(); + } + List<String> additionalOpts = new ArrayList<>(); + + for (String option : opts.split("\\s+")) { + additionalOpts.add(option); + } + return additionalOpts; + } + + private void configureLogging(ManagedSEContainerConfiguration configuration) { + ConsoleHandler consoleHandler = new ConsoleHandler(); + consoleHandler.setLevel(configuration.getLogLevel()); + LOGGER.setUseParentHandlers(false); + LOGGER.addHandler(consoleHandler); + LOGGER.setLevel(configuration.getLogLevel()); + } + + @Override + public void start() throws LifecycleException { + } + + @Override + public void stop() throws LifecycleException { + } + + @Override + public ProtocolDescription getDefaultProtocol() { + return new ProtocolDescription(CustomJMXProtocol.NAME); + } + + @Override + public void deploy(Descriptor descriptor) throws DeploymentException { + throw new UnsupportedOperationException(); + } + + @Override + public void undeploy(Descriptor descriptor) throws DeploymentException { + throw new UnsupportedOperationException(); + } + + @Override + public void undeploy(Archive<?> archive) throws DeploymentException { + LOGGER.info("Undeploying " + archive.getName()); + if (!keepDeploymentArchives) { + for (File materializedFile : materializedFiles) { + if (materializedFile.isDirectory()) { + try { + FileDeploymentUtils.deleteRecursively(materializedFile.toPath()); + } catch (IOException e) { + LOGGER.warning("Could not delete materialized directory: " + materializedFile); + } + } else { + materializedFile.delete(); + } + } + } + // Kill the subprocess (test JVM) + if (process != null) { + process.destroy(); + try { + process.waitFor(); + } catch (final InterruptedException e) { + Thread.interrupted(); + throw new RuntimeException("Interrupted while awaiting server daemon process termination", e); + } + } + } + + @Override + public ProtocolMetaData deploy(final Archive<?> archive) throws DeploymentException { + LOGGER.info("Deploying " + archive.getName()); + + // First of all clear the list of previously materialized deployments - otherwise the class path would grow indefinitely + materializedFiles.clear(); + + // Create a new classpath + classpathDependencies.clear(); + + if (ClassPath.isRepresentedBy(archive)) { + for (Node child : archive.get(ClassPath.ROOT_ARCHIVE_PATH).getChildren()) { + Asset asset = child.getAsset(); + if (asset instanceof ArchiveAsset) { + Archive<?> assetArchive = ((ArchiveAsset) asset).getArchive(); + if (ClassPathDirectory.isRepresentedBy(assetArchive)) { + materializeDirectory(assetArchive); + } else { + materializeArchive(assetArchive); + } + } + } + } else { + materializeArchive(archive); + } + + Properties systemProperties = getSystemProperties(archive); + readJarFilesFromDirectory(); + addTestResourcesDirectory(systemProperties); + + List<String> processCommand = buildProcessCommand(systemProperties); + logExecutedCommand(processCommand); + // Launch the process + final ProcessBuilder processBuilder = new ProcessBuilder(processCommand); + + String path = systemProperties.getProperty("container.user.dir"); + if (path != null) { + processBuilder.directory(new File(path)); + } + + processBuilder.environment().put("JAVA_HOME", new File(System.getProperty(SYSPROP_KEY_JAVA_HOME)).getAbsolutePath()); + + processBuilder.redirectErrorStream(true); + processBuilder.redirectError(ProcessBuilder.Redirect.INHERIT); + processBuilder.redirectOutput(ProcessBuilder.Redirect.INHERIT); + + try { + process = processBuilder.start(); + } catch (final IOException e) { + throw new DeploymentException("Could not start process", e); + } + + int finalWaitTime = debugModeEnabled ? (3 * waitTime) : waitTime; + + // Wait for socket connection + if (!isServerStarted(host, port, finalWaitTime)) { + throw new DeploymentException("Child JVM process failed to start within " + finalWaitTime + " seconds."); + } + if (!isJMXTestRunnerMBeanRegistered(host, port, finalWaitTime)) { + throw new DeploymentException("JMXTestRunnerMBean not registered within " + finalWaitTime + " seconds."); + } + + ProtocolMetaData protocolMetaData = new ProtocolMetaData(); + protocolMetaData.addContext(new JMXContext(host, port)); + return protocolMetaData; + } + + private Properties getSystemProperties(final Archive<?> archive) throws DeploymentException { + Node systemPropertiesNode = archive.get(ClassPath.SYSTEM_PROPERTIES_ARCHIVE_PATH); + if (systemPropertiesNode != null) { + try (InputStream in = systemPropertiesNode.getAsset().openStream()) { + Properties systemProperties = new Properties(); + systemProperties.load(in); + return systemProperties; + } catch (IOException e) { + throw new DeploymentException("Could not load system properties", e); + } + } + return null; + } + + private boolean isServerStarted(final String host, final int port, int waitTime) { + return new Await(waitTime, new Callable<Boolean>() { + @Override + public Boolean call() throws Exception { + try (Socket ignored = new Socket(host, port)) { + return true; + } + } + }).start(); + } + + private boolean isJMXTestRunnerMBeanRegistered(final String host, final int port, int waitTime) throws DeploymentException { + // Taken from org.jboss.arquillian.container.spi.client.protocol.metadata.JMXContext + final String jmxServiceUrl = "service:jmx:rmi:///jndi/rmi://" + host + ":" + port + "/jmxrmi"; + try (JMXConnector jmxc = JMXConnectorFactory.connect(new JMXServiceURL(jmxServiceUrl), null)) { + final MBeanServerConnection mbsc = jmxc.getMBeanServerConnection(); + return new Await(waitTime, new Callable<Boolean>() { + @Override + public Boolean call() throws Exception { + mbsc.getObjectInstance(new ObjectName(JMXTestRunnerMBean.OBJECT_NAME)); + LOGGER.fine("JMXTestRunnerMBean registered with the remote MBean server at: " + jmxServiceUrl); + return true; + } + }).start(); + } catch (IOException e) { + throw new DeploymentException("Could not verify JMXTestRunnerMBean registration", e); + } + } + + private void materializeArchive(Archive<?> archive) { + File deploymentFile = new File(TARGET.concat(File.separator).concat(archive.getName())); + archive.as(ZipExporter.class).exportTo(deploymentFile, true); + materializedFiles.add(deploymentFile); + } + + private void materializeDirectory(Archive<?> archive) throws DeploymentException { + if (archive.getContent().isEmpty()) { + // Do not materialize an empty directory + return; + } + File entryDirectory = new File(TARGET.concat(File.separator).concat(archive.getName())); + try { + if (entryDirectory.exists()) { + // Always delete previous content + FileDeploymentUtils.deleteContent(entryDirectory.toPath()); + } else { + if (!entryDirectory.mkdirs()) { + throw new DeploymentException("Could not create class path directory: " + entryDirectory); + } + } + for (Node child : archive.get(ClassPath.ROOT_ARCHIVE_PATH).getChildren()) { + Asset asset = child.getAsset(); + if (asset instanceof ClassAsset) { + FileDeploymentUtils.materializeClass(entryDirectory, (ClassAsset) asset); + } else if (asset == null) { + FileDeploymentUtils.materializeSubdirectories(entryDirectory, child); + } + } + } catch (IOException e) { + throw new DeploymentException("Could not materialize class path directory: " + archive.getName(), e); + } + materializedFiles.add(entryDirectory); + } + + private List<String> buildProcessCommand(Properties properties) { + final List<String> command = new ArrayList<String>(); + final File javaHome = new File(System.getProperty(SYSPROP_KEY_JAVA_HOME)); + command.add(javaHome.getAbsolutePath() + File.separator + "bin" + File.separator + "java"); + command.add("-cp"); + StringBuilder builder = new StringBuilder(); + Set<File> classPathEntries = new HashSet<>(materializedFiles); + classPathEntries.addAll(classpathDependencies); + for (Iterator<File> iterator = classPathEntries.iterator(); iterator.hasNext();) { + builder.append(iterator.next().getPath()); + if (iterator.hasNext()) { + builder.append(File.pathSeparator); + } + } + command.add(builder.toString()); + command.add("-Dcom.sun.management.jmxremote"); + command.add("-Dcom.sun.management.jmxremote.port=" + port); + command.add("-Dcom.sun.management.jmxremote.authenticate=false"); + command.add("-Dcom.sun.management.jmxremote.ssl=false"); + + if (debugModeEnabled) { + command.add(DEBUG_AGENT_STRING); + } + for (String option : additionalJavaOpts) { + command.add(option); + } + if (properties != null) { + for (Map.Entry<Object, Object> entry : properties.entrySet()) { + addSystemProperty(command, entry.getKey().toString(), entry.getValue().toString()); + } + } + command.add(SERVER_MAIN_CLASS_FQN); + return command; + } + + private void addSystemProperty(List<String> command, String key, String value) { + command.add(SYSTEM_PROPERTY_SWITCH + key + EQUALS + value); + } + + private void readJarFilesFromDirectory() throws DeploymentException { + if (librariesPath == null) { + return; + } + File lib = new File(librariesPath); + if (!lib.exists() || lib.isFile()) { + throw new DeploymentException("Cannot read files from " + librariesPath); + } + + File[] dep = lib.listFiles(new FilenameFilter() { + @Override + public boolean accept(File dir, String name) { + return name.endsWith(".jar"); + } + }); + classpathDependencies.addAll(Arrays.asList(dep)); + + } + + private void addTestResourcesDirectory(Properties properties) throws DeploymentException { + String testResources = properties.getProperty("container.test.resources.dir"); + if (testResources != null) { + File testDir = new File(testResources); + if (testDir.exists() && testDir.isDirectory()) { + classpathDependencies.add(testDir); + } + } + } + + private void logExecutedCommand(List<String> processCommand) { + if (LOGGER.isLoggable(Level.FINE)) { + StringBuilder builder = new StringBuilder(); + for (String s : processCommand) { + builder.append(s); + builder.append(" "); + } + LOGGER.log(Level.FINE, "Executing command: " + builder); + } + } + +} http://git-wip-us.apache.org/repos/asf/camel/blob/20401a38/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/arquillian/container/SEContainerAppender.java ---------------------------------------------------------------------- diff --git a/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/arquillian/container/SEContainerAppender.java b/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/arquillian/container/SEContainerAppender.java new file mode 100644 index 0000000..795a93a --- /dev/null +++ b/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/arquillian/container/SEContainerAppender.java @@ -0,0 +1,36 @@ +/** + * 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.camel.itest.springboot.arquillian.container; + +import org.jboss.arquillian.container.se.api.LaunchServices; +import org.jboss.arquillian.container.se.server.Main; +import org.jboss.arquillian.container.test.spi.client.deployment.CachedAuxilliaryArchiveAppender; +import org.jboss.shrinkwrap.api.Archive; +import org.jboss.shrinkwrap.api.ShrinkWrap; +import org.jboss.shrinkwrap.api.spec.JavaArchive; + +public class SEContainerAppender extends CachedAuxilliaryArchiveAppender { + + @Override + protected Archive<?> buildArchive() { + return ShrinkWrap.create(JavaArchive.class, "arquillian-container-se.jar") + .addPackage(Main.class.getPackage()) + .addClass(LaunchServices.class) + .addPackage("org.jboss.arquillian.protocol.jmx"); + } + +} http://git-wip-us.apache.org/repos/asf/camel/blob/20401a38/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/arquillian/container/jmx/CustomJMXProtocol.java ---------------------------------------------------------------------- diff --git a/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/arquillian/container/jmx/CustomJMXProtocol.java b/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/arquillian/container/jmx/CustomJMXProtocol.java new file mode 100644 index 0000000..72066c1 --- /dev/null +++ b/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/arquillian/container/jmx/CustomJMXProtocol.java @@ -0,0 +1,36 @@ +/** + * 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.camel.itest.springboot.arquillian.container.jmx; + +import org.jboss.arquillian.container.test.spi.client.deployment.DeploymentPackager; +import org.jboss.arquillian.protocol.jmx.AbstractJMXProtocol; + +public class CustomJMXProtocol extends AbstractJMXProtocol { + + public static final String NAME = "simple-jmx"; + + @Override + public String getProtocolName() { + return NAME; + } + + @Override + public DeploymentPackager getPackager() { + return new TestDeploymentPackager(); + } + +} http://git-wip-us.apache.org/repos/asf/camel/blob/20401a38/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/arquillian/container/jmx/TestDeploymentPackager.java ---------------------------------------------------------------------- diff --git a/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/arquillian/container/jmx/TestDeploymentPackager.java b/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/arquillian/container/jmx/TestDeploymentPackager.java new file mode 100644 index 0000000..1bca3e9 --- /dev/null +++ b/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/arquillian/container/jmx/TestDeploymentPackager.java @@ -0,0 +1,43 @@ +/** + * 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.camel.itest.springboot.arquillian.container.jmx; + +import java.util.Collection; + +import org.jboss.arquillian.container.se.api.ClassPath; +import org.jboss.arquillian.container.test.spi.TestDeployment; +import org.jboss.arquillian.container.test.spi.client.deployment.DeploymentPackager; +import org.jboss.arquillian.container.test.spi.client.deployment.ProtocolArchiveProcessor; +import org.jboss.shrinkwrap.api.Archive; +import org.jboss.shrinkwrap.api.exporter.ZipExporter; + +public class TestDeploymentPackager implements DeploymentPackager { + + @Override + public Archive<?> generateDeployment(TestDeployment testDeployment, Collection<ProtocolArchiveProcessor> collection) { + Archive<?> applicationArchive = testDeployment.getApplicationArchive(); + boolean isClassPath = ClassPath.isRepresentedBy(applicationArchive); + for (Archive<?> auxiliaryArchive : testDeployment.getAuxiliaryArchives()) { + if (isClassPath) { + applicationArchive.add(auxiliaryArchive, ClassPath.ROOT_ARCHIVE_PATH, ZipExporter.class); + } else { + applicationArchive.merge(auxiliaryArchive); + } + } + return applicationArchive; + } +} http://git-wip-us.apache.org/repos/asf/camel/blob/20401a38/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/arquillian/container/util/Await.java ---------------------------------------------------------------------- diff --git a/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/arquillian/container/util/Await.java b/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/arquillian/container/util/Await.java new file mode 100644 index 0000000..c9a2173 --- /dev/null +++ b/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/arquillian/container/util/Await.java @@ -0,0 +1,76 @@ +/** + * 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.camel.itest.springboot.arquillian.container.util; + +import java.util.concurrent.Callable; +import java.util.concurrent.TimeUnit; + +public class Await { + + private static final long DEFAULT_SLEEP_INTERVAL = 100L; + + private final long delay; + + private final long sleepInterval; + + private final Callable<Boolean> condition; + + /** + * + * @param delay + * @param condition + */ + public Await(long delay, Callable<Boolean> condition) { + this(DEFAULT_SLEEP_INTERVAL, delay, condition); + } + + /** + * + * @param delay The delay in seconds + * @param sleepInterval Thread sleep interval in ms + * @param condition + */ + public Await(long sleepInterval, long delay, Callable<Boolean> condition) { + this.delay = TimeUnit.SECONDS.toMillis(delay); + this.sleepInterval = sleepInterval; + this.condition = condition; + } + + public boolean start() { + long start = System.currentTimeMillis(); + do { + try { + if (condition.call()) { + return true; + } + } catch (Exception ignored) { + } + try { + Thread.sleep(sleepInterval); + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + return false; + } + } while (!isTimeoutExpired(start)); + return false; + } + + private boolean isTimeoutExpired(long start) { + return (System.currentTimeMillis() - start) >= delay; + } + +} http://git-wip-us.apache.org/repos/asf/camel/blob/20401a38/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/arquillian/container/util/FileDeploymentUtils.java ---------------------------------------------------------------------- diff --git a/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/arquillian/container/util/FileDeploymentUtils.java b/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/arquillian/container/util/FileDeploymentUtils.java new file mode 100644 index 0000000..d84541b --- /dev/null +++ b/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/arquillian/container/util/FileDeploymentUtils.java @@ -0,0 +1,119 @@ +/** + * 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.camel.itest.springboot.arquillian.container.util; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.nio.file.FileVisitResult; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.SimpleFileVisitor; +import java.nio.file.attribute.BasicFileAttributes; + +import org.jboss.arquillian.container.se.api.ClassPathDirectory; +import org.jboss.arquillian.container.spi.client.container.DeploymentException; +import org.jboss.shrinkwrap.api.Node; +import org.jboss.shrinkwrap.api.asset.ClassAsset; + +public final class FileDeploymentUtils { + + private static final char DELIMITER_RESOURCE_PATH = '/'; + private static final char DELIMITER_CLASS_NAME_PATH = '.'; + private static final String EXTENSION_CLASS = ".class"; + + private FileDeploymentUtils() { + } + + public static void materializeClass(File entryDirectory, ClassAsset classAsset) throws DeploymentException, IOException { + File classDirectory; + if (classAsset.getSource().getPackage() != null) { + classDirectory = new File(entryDirectory, classAsset.getSource().getPackage().getName().replace(DELIMITER_CLASS_NAME_PATH, File.separatorChar)); + if (!classDirectory.mkdirs()) { + throw new DeploymentException("Could not create class package directory: " + classDirectory); + } + } else { + classDirectory = entryDirectory; + } + File classFile = new File(classDirectory, classAsset.getSource().getSimpleName().concat(EXTENSION_CLASS)); + classFile.createNewFile(); + try (InputStream in = classAsset.openStream(); OutputStream out = new FileOutputStream(classFile)) { + copy(in, out); + } + } + + public static void materializeSubdirectories(File entryDirectory, Node node) throws DeploymentException, IOException { + for (Node child : node.getChildren()) { + if (child.getAsset() == null) { + materializeSubdirectories(entryDirectory, child); + } else { + if (ClassPathDirectory.isMarkerFileArchivePath(child.getPath())) { + // Do not materialize the marker file + continue; + } + // E.g. META-INF/my-super-descriptor.xml + File resourceFile = new File(entryDirectory, child.getPath().get().replace(DELIMITER_RESOURCE_PATH, File.separatorChar)); + File resoureDirectory = resourceFile.getParentFile(); + if (!resoureDirectory.exists() && !resoureDirectory.mkdirs()) { + throw new DeploymentException("Could not create class path directory: " + entryDirectory); + } + resourceFile.createNewFile(); + try (InputStream in = child.getAsset().openStream(); OutputStream out = new FileOutputStream(resourceFile)) { + copy(in, out); + } + child.getPath().get(); + } + } + } + + public static void copy(InputStream in, OutputStream out) throws IOException { + final byte[] buffer = new byte[8192]; + int n = 0; + while (-1 != (n = in.read(buffer))) { + out.write(buffer, 0, n); + } + out.flush(); + } + + public static void deleteRecursively(Path directory) throws IOException { + Files.walkFileTree(directory, new SimpleFileVisitor<Path>() { + @Override + public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { + Files.delete(file); + return FileVisitResult.CONTINUE; + } + + @Override + public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException { + Files.delete(dir); + return FileVisitResult.CONTINUE; + } + }); + } + + public static void deleteContent(Path directory) throws IOException { + Files.walkFileTree(directory, new SimpleFileVisitor<Path>() { + @Override + public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { + Files.delete(file); + return FileVisitResult.CONTINUE; + } + }); + } +} http://git-wip-us.apache.org/repos/asf/camel/blob/20401a38/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/util/ArquillianPackager.java ---------------------------------------------------------------------- diff --git a/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/util/ArquillianPackager.java b/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/util/ArquillianPackager.java index 7293812..071b496 100644 --- a/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/util/ArquillianPackager.java +++ b/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/util/ArquillianPackager.java @@ -41,11 +41,13 @@ import org.jboss.shrinkwrap.api.Configuration; import org.jboss.shrinkwrap.api.ConfigurationBuilder; import org.jboss.shrinkwrap.api.Domain; import org.jboss.shrinkwrap.api.ExtensionLoader; +import org.jboss.shrinkwrap.api.GenericArchive; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.asset.FileAsset; import org.jboss.shrinkwrap.api.exporter.ZipExporter; import org.jboss.shrinkwrap.api.spec.JavaArchive; import org.jboss.shrinkwrap.impl.base.ServiceExtensionLoader; +import org.jboss.shrinkwrap.resolver.api.maven.ConfigurableMavenResolverSystem; import org.jboss.shrinkwrap.resolver.api.maven.Maven; import org.jboss.shrinkwrap.resolver.api.maven.MavenResolvedArtifact; import org.jboss.shrinkwrap.resolver.api.maven.PackagingType; @@ -85,19 +87,23 @@ public final class ArquillianPackager { ark = ark.addAsManifestResource("BOOT-MANIFEST.MF", "MANIFEST.MF"); ark = ark.addAsResource("spring-boot-itest.properties"); + if (config.getUseCustomLog()) { + ark = ark.addAsResource("spring-logback.xml"); + } + for (Map.Entry<String, String> res : config.getResources().entrySet()) { ark = ark.addAsResource(res.getKey(), res.getValue()); } ark = ark.addAsDirectories("/lib"); - String version = System.getProperty("itestComponentVersion"); + String version = System.getProperty("version_org.apache.camel:camel-core"); if (version == null) { config.getMavenVersion(); } if (version == null) { // It is missing when launching from IDE - List<MavenResolvedArtifact> resolved = Arrays.asList(Maven.resolver().loadPomFromFile("pom.xml").importRuntimeDependencies().resolve().withTransitivity().asResolvedArtifact()); + List<MavenResolvedArtifact> resolved = Arrays.asList(resolver(config).loadPomFromFile("pom.xml").importRuntimeDependencies().resolve().withoutTransitivity().asResolvedArtifact()); for (MavenResolvedArtifact dep : resolved) { if (dep.getCoordinate().getGroupId().equals("org.apache.camel")) { version = dep.getCoordinate().getVersion(); @@ -111,14 +117,25 @@ public final class ArquillianPackager { throw new IllegalStateException("Cannot determine the current version of the camel component"); } - MavenDependencyExclusion[] loggingHellExclusions = new MavenDependencyExclusion[]{MavenDependencies.createExclusion("org.slf4j", "slf4j-log4j12"), MavenDependencies.createExclusion("log4j", - "log4j"), MavenDependencies.createExclusion("org.slf4j", "slf4j-simple")}; + List<MavenDependencyExclusion> commonExclusions = new LinkedList<>(); + commonExclusions.add(MavenDependencies.createExclusion("org.slf4j", "slf4j-log4j12")); + commonExclusions.add(MavenDependencies.createExclusion("log4j", "log4j")); + commonExclusions.add(MavenDependencies.createExclusion("org.slf4j", "slf4j-simple")); + commonExclusions.add(MavenDependencies.createExclusion("org.slf4j", "slf4j-simple")); + commonExclusions.add(MavenDependencies.createExclusion("org.slf4j", "slf4j-jdk14")); + + for (String ex : config.getMavenExclusions()) { + commonExclusions.add(MavenDependencies.createExclusion(ex)); + } + + MavenDependencyExclusion[] commonExclutionArray = commonExclusions.toArray(new MavenDependencyExclusion[]{}); + // Module dependencies List<MavenDependency> moduleDependencies = new LinkedList<>(); MavenCoordinate mainJar = MavenCoordinates.createCoordinate(config.getMavenGroup(), config.getModuleName(), version, PackagingType.JAR, null); - MavenDependency mainDep = MavenDependencies.createDependency(mainJar, ScopeType.COMPILE, false, loggingHellExclusions); + MavenDependency mainDep = MavenDependencies.createDependency(mainJar, ScopeType.COMPILE, false, commonExclutionArray); moduleDependencies.add(mainDep); for (String canonicalForm : config.getAdditionalDependencies()) { @@ -137,8 +154,8 @@ public final class ArquillianPackager { scopes.add(ScopeType.PROVIDED); } - List<MavenResolvedArtifact> moduleArtifacts = Arrays.asList(Maven.resolver() - .loadPomFromFile(config.getModulesPath() + config.getModuleName() + "/pom.xml") + List<MavenResolvedArtifact> moduleArtifacts = Arrays.asList(resolver(config) + .loadPomFromFile(config.getModuleBasePath() + "/pom.xml") .importDependencies(scopes.toArray(new ScopeType[]{})) .resolve().withoutTransitivity().asResolvedArtifact()); @@ -148,13 +165,13 @@ public final class ArquillianPackager { if (!validTestDependency(c)) { continue; } - MavenDependency dep = MavenDependencies.createDependency(c, ScopeType.RUNTIME, false, loggingHellExclusions); + MavenDependency dep = MavenDependencies.createDependency(c, ScopeType.RUNTIME, false, commonExclutionArray); moduleDependencies.add(dep); } } List<File> dependencies = new LinkedList<>(); - dependencies.addAll(Arrays.asList(Maven.resolver() + dependencies.addAll(Arrays.asList(resolver(config) .loadPomFromFile("pom.xml") .importRuntimeDependencies() .addDependencies(moduleDependencies) @@ -163,23 +180,58 @@ public final class ArquillianPackager { .asFile())); + boolean needsSpringTest = excludeDependencyRegex(dependencies, "^camel-test-spring3-.*"); + if (needsSpringTest) { + // Adding spring4 version of the test library + MavenDependency dep = MavenDependencies.createDependency("org.apache.camel:camel-test-spring:" + version, ScopeType.RUNTIME, false); + + dependencies = new LinkedList<>(); + dependencies.addAll(Arrays.asList(resolver(config) + .loadPomFromFile("pom.xml") + .importRuntimeDependencies() + .addDependencies(moduleDependencies) + .addDependencies(dep) + .resolve() + .withTransitivity() + .asFile())); + } + // The spring boot-loader dependency will be added to the main jar, so it should be excluded from the embedded ones excludeDependencyRegex(dependencies, "^spring-boot-loader-[0-9].*"); + excludeDependencyRegex(dependencies, "^camel-test-spring3-.*"); + // Add all dependencies as spring-boot nested jars ark = addDependencies(ark, dependencies); - if (config.getUnitTestEnabled()) { - // Add unit test classes of the module under test - ark = addTestResources(ark, config); - } - // Add common packages to main jar ark = ark.addPackages(true, "org.apache.camel.itest.springboot"); ark = ark.addPackages(true, "org.springframework.boot.loader"); ark = ark.addPackages(true, "org.jboss.shrinkwrap"); - return ClassPath.builder().add(ark).build(); + ark = ark.addPackages(true, "org.apache.camel.converter.myconverter"); // to overcome CAMEL-10060 + ark = ark.addPackages(true, "org.apache.camel.osgi.test"); // to overcome CAMEL-10060 + + ClassPath.Builder external = ClassPath.builder().add(ark); + + // overcome limitations of some JDKs + external.addSystemProperty("javax.xml.accessExternalDTD", "all"); + external.addSystemProperty("javax.xml.accessExternalSchema", "all"); + + if (config.getUnitTestEnabled()) { + external.addSystemProperty("container.user.dir", new File(config.getModuleBasePath()).getCanonicalPath()); + external.addSystemProperty("container.test.resources.dir", new File(config.getModuleBasePath()).getCanonicalPath() + "/target/test-classes"); + } + + for (Map.Entry<String, String> e : config.getSystemProperties().entrySet()) { + external.addSystemProperty(e.getKey(), e.getValue()); + } + + return external.build(); + } + + private static ConfigurableMavenResolverSystem resolver(ITestConfig config) { + return Maven.configureResolver().workOffline(config.getMavenOfflineResolution()); } public static void copyResource(String folder, String fileNameRegex, String targetFolder) throws IOException { @@ -217,7 +269,7 @@ public final class ArquillianPackager { private static boolean validTestDependency(MavenCoordinate coordinate) { - Pattern[] patterns = new Pattern[]{Pattern.compile("^log4j$"), Pattern.compile("^slf4j-log4j12$"), Pattern.compile("^slf4j-simple")}; + Pattern[] patterns = new Pattern[]{Pattern.compile("^log4j$"), Pattern.compile("^slf4j-log4j12$"), Pattern.compile("^slf4j-simple$"), Pattern.compile("^slf4j-jdk14$")}; boolean valid = true; for (Pattern p : patterns) { @@ -234,15 +286,18 @@ public final class ArquillianPackager { return valid; } - private static void excludeDependencyRegex(List<File> dependencies, String regex) { + private static boolean excludeDependencyRegex(List<File> dependencies, String regex) { Pattern pattern = Pattern.compile(regex); + int count = 0; for (Iterator<File> it = dependencies.iterator(); it.hasNext();) { File f = it.next(); if (pattern.matcher(f.getName()).matches()) { it.remove(); + count++; break; } } + return count > 0; } private static JavaArchive addDependencies(JavaArchive ark, Collection<File> deps) { @@ -255,8 +310,9 @@ public final class ArquillianPackager { return ark; } - private static JavaArchive addTestResources(JavaArchive ark, ITestConfig config) throws IOException { - File test = new File(config.getModulesPath() + config.getModuleName() + "/target/test-classes/"); + private static JavaArchive addTestClasses(JavaArchive mainArk, Domain domain, ITestConfig config) throws IOException { + + File test = new File(config.getModuleBasePath() + "/target/test-classes/"); File[] fs = test.listFiles(); if (fs == null) { fs = new File[]{}; @@ -266,9 +322,11 @@ public final class ArquillianPackager { File f = testFiles.pop(); String relative = test.getCanonicalFile().toURI().relativize(f.getCanonicalFile().toURI()).getPath(); if (f.isFile()) { - ark = ark.addAsResource(f, relative); + if (f.getName().endsWith(".class")) { + mainArk = mainArk.addAsResource(f, relative); + } } else { - ark = ark.addAsDirectory(relative); + mainArk = mainArk.addAsDirectory(relative); File[] files = f.listFiles(); if (files == null) { files = new File[]{}; @@ -277,6 +335,33 @@ public final class ArquillianPackager { } } + return mainArk; + } + + private static GenericArchive addSources(GenericArchive ark, ITestConfig config) throws IOException { + File sources = new File(config.getModuleBasePath() + "/src/"); + ark.addAsDirectory("src"); + + File[] fs = sources.listFiles(); + if (fs == null) { + fs = new File[]{}; + } + LinkedList<File> sourceFiles = new LinkedList<>(Arrays.asList(fs)); + while (!sourceFiles.isEmpty()) { + File f = sourceFiles.pop(); + String relative = sources.getParentFile().getCanonicalFile().toURI().relativize(f.getCanonicalFile().toURI()).getPath(); + if (f.isFile()) { + ark.add(new FileAsset(f), relative); + } else { + ark = ark.addAsDirectory(relative); + File[] files = f.listFiles(); + if (files == null) { + files = new File[]{}; + } + sourceFiles.addAll(Arrays.asList(files)); + } + } + return ark; }