diff --git a/components/camel-arangodb/pom.xml b/components/camel-arangodb/pom.xml index 9c216074f329a..cc8af8fe8d1a5 100644 --- a/components/camel-arangodb/pom.xml +++ b/components/camel-arangodb/pom.xml @@ -78,6 +78,12 @@ test-jar test + + org.apache.camel + camel-test-infra-arangodb + ${project.version} + test + diff --git a/test-infra/camel-test-infra-arangodb/pom.xml b/test-infra/camel-test-infra-arangodb/pom.xml index 36225b3b840f4..0c7af237d6c32 100644 --- a/test-infra/camel-test-infra-arangodb/pom.xml +++ b/test-infra/camel-test-infra-arangodb/pom.xml @@ -31,6 +31,11 @@ Camel :: Test Infra :: ArangoDB + + org.apache.camel + camel-test-infra-common + ${project.version} + org.apache.camel camel-test-infra-common diff --git a/test-infra/camel-test-infra-arangodb/src/test/java/org/apache/camel/test/infra/arangodb/common/ArangoDBProperties.java b/test-infra/camel-test-infra-arangodb/src/main/java/org/apache/camel/test/infra/arangodb/common/ArangoDBProperties.java similarity index 100% rename from test-infra/camel-test-infra-arangodb/src/test/java/org/apache/camel/test/infra/arangodb/common/ArangoDBProperties.java rename to test-infra/camel-test-infra-arangodb/src/main/java/org/apache/camel/test/infra/arangodb/common/ArangoDBProperties.java diff --git a/test-infra/camel-test-infra-arangodb/src/test/java/org/apache/camel/test/infra/arangodb/services/ArangoDBLocalContainerService.java b/test-infra/camel-test-infra-arangodb/src/main/java/org/apache/camel/test/infra/arangodb/services/ArangoDBLocalContainerService.java similarity index 100% rename from test-infra/camel-test-infra-arangodb/src/test/java/org/apache/camel/test/infra/arangodb/services/ArangoDBLocalContainerService.java rename to test-infra/camel-test-infra-arangodb/src/main/java/org/apache/camel/test/infra/arangodb/services/ArangoDBLocalContainerService.java diff --git a/test-infra/camel-test-infra-arangodb/src/test/java/org/apache/camel/test/infra/arangodb/services/ArangoDBRemoteService.java b/test-infra/camel-test-infra-arangodb/src/main/java/org/apache/camel/test/infra/arangodb/services/ArangoDBRemoteService.java similarity index 100% rename from test-infra/camel-test-infra-arangodb/src/test/java/org/apache/camel/test/infra/arangodb/services/ArangoDBRemoteService.java rename to test-infra/camel-test-infra-arangodb/src/main/java/org/apache/camel/test/infra/arangodb/services/ArangoDBRemoteService.java diff --git a/test-infra/camel-test-infra-arangodb/src/test/java/org/apache/camel/test/infra/arangodb/services/ArangoDBService.java b/test-infra/camel-test-infra-arangodb/src/main/java/org/apache/camel/test/infra/arangodb/services/ArangoDBService.java similarity index 86% rename from test-infra/camel-test-infra-arangodb/src/test/java/org/apache/camel/test/infra/arangodb/services/ArangoDBService.java rename to test-infra/camel-test-infra-arangodb/src/main/java/org/apache/camel/test/infra/arangodb/services/ArangoDBService.java index 06f9fcfea3ec7..7a08c4f3a945b 100644 --- a/test-infra/camel-test-infra-arangodb/src/test/java/org/apache/camel/test/infra/arangodb/services/ArangoDBService.java +++ b/test-infra/camel-test-infra-arangodb/src/main/java/org/apache/camel/test/infra/arangodb/services/ArangoDBService.java @@ -16,12 +16,9 @@ */ package org.apache.camel.test.infra.arangodb.services; -import org.apache.camel.test.infra.common.services.TestService; +import org.apache.camel.test.infra.common.services.InfrastructureService; -/** - * Test infra service for ArangoDB - */ -public interface ArangoDBService extends TestService { +public interface ArangoDBService extends InfrastructureService { int getPort(); diff --git a/test-infra/camel-test-infra-arangodb/src/test/java/org/apache/camel/test/infra/arangodb/services/ArangoDbContainer.java b/test-infra/camel-test-infra-arangodb/src/main/java/org/apache/camel/test/infra/arangodb/services/ArangoDbContainer.java similarity index 100% rename from test-infra/camel-test-infra-arangodb/src/test/java/org/apache/camel/test/infra/arangodb/services/ArangoDbContainer.java rename to test-infra/camel-test-infra-arangodb/src/main/java/org/apache/camel/test/infra/arangodb/services/ArangoDbContainer.java diff --git a/test-infra/camel-test-infra-arangodb/src/test/java/org/apache/camel/test/infra/arangodb/services/ArangoDBServiceFactory.java b/test-infra/camel-test-infra-arangodb/src/test/java/org/apache/camel/test/infra/arangodb/services/ArangoDBServiceFactory.java index 11d1d16101724..5f138177d8987 100644 --- a/test-infra/camel-test-infra-arangodb/src/test/java/org/apache/camel/test/infra/arangodb/services/ArangoDBServiceFactory.java +++ b/test-infra/camel-test-infra-arangodb/src/test/java/org/apache/camel/test/infra/arangodb/services/ArangoDBServiceFactory.java @@ -16,12 +16,13 @@ */ package org.apache.camel.test.infra.arangodb.services; +import org.apache.camel.test.infra.common.services.ContainerTestService; import org.apache.camel.test.infra.common.services.SimpleTestServiceBuilder; import org.apache.camel.test.infra.common.services.SingletonService; public final class ArangoDBServiceFactory { - private static class SingletonArangoDBService extends SingletonService implements ArangoDBService { - public SingletonArangoDBService(ArangoDBService service, String name) { + private static class SingletonArangoDBService extends SingletonService implements ArangoDBTestService { + public SingletonArangoDBService(ArangoDBTestService service, String name) { super(service, name); } @@ -40,30 +41,37 @@ private ArangoDBServiceFactory() { } - public static SimpleTestServiceBuilder builder() { + public static SimpleTestServiceBuilder builder() { return new SimpleTestServiceBuilder<>("arangodb"); } - public static ArangoDBService createService() { + public static ArangoDBTestService createService() { return builder() - .addLocalMapping(ArangoDBLocalContainerService::new) - .addRemoteMapping(ArangoDBRemoteService::new) + .addLocalMapping(ArangoDBLocalContainerTestService::new) + .addRemoteMapping(ArangoDBRemoteTestService::new) .build(); } - public static ArangoDBService createSingletonService() { + public static ArangoDBTestService createSingletonService() { return SingletonServiceHolder.INSTANCE; } private static class SingletonServiceHolder { - static final ArangoDBService INSTANCE; + static final ArangoDBTestService INSTANCE; static { - SimpleTestServiceBuilder instance = builder(); - instance.addLocalMapping(() -> new SingletonArangoDBService(new ArangoDBLocalContainerService(), "arangoDB")) - .addRemoteMapping(ArangoDBRemoteService::new) + SimpleTestServiceBuilder instance = builder(); + instance.addLocalMapping(() -> new SingletonArangoDBService(new ArangoDBLocalContainerTestService(), "arangoDB")) + .addRemoteMapping(ArangoDBRemoteTestService::new) .build(); INSTANCE = instance.build(); } } } + +class ArangoDBLocalContainerTestService extends ArangoDBLocalContainerService + implements ArangoDBTestService, ContainerTestService { +} + +class ArangoDBRemoteTestService extends ArangoDBRemoteService implements ArangoDBTestService { +} diff --git a/test-infra/camel-test-infra-arangodb/src/test/java/org/apache/camel/test/infra/arangodb/services/ArangoDBTestService.java b/test-infra/camel-test-infra-arangodb/src/test/java/org/apache/camel/test/infra/arangodb/services/ArangoDBTestService.java new file mode 100644 index 0000000000000..139928f55a8cb --- /dev/null +++ b/test-infra/camel-test-infra-arangodb/src/test/java/org/apache/camel/test/infra/arangodb/services/ArangoDBTestService.java @@ -0,0 +1,25 @@ +/* + * 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.test.infra.arangodb.services; + +import org.apache.camel.test.infra.common.services.TestService; + +/** + * Test infra service for ArangoDB + */ +public interface ArangoDBTestService extends TestService, ArangoDBService { +} diff --git a/test-infra/camel-test-infra-common/src/test/java/org/apache/camel/test/infra/common/LocalPropertyResolver.java b/test-infra/camel-test-infra-common/src/main/java/org/apache/camel/test/infra/common/LocalPropertyResolver.java similarity index 100% rename from test-infra/camel-test-infra-common/src/test/java/org/apache/camel/test/infra/common/LocalPropertyResolver.java rename to test-infra/camel-test-infra-common/src/main/java/org/apache/camel/test/infra/common/LocalPropertyResolver.java diff --git a/test-infra/camel-test-infra-common/src/test/java/org/apache/camel/test/infra/common/services/ContainerEnvironmentUtil.java b/test-infra/camel-test-infra-common/src/main/java/org/apache/camel/test/infra/common/services/ContainerEnvironmentUtil.java similarity index 100% rename from test-infra/camel-test-infra-common/src/test/java/org/apache/camel/test/infra/common/services/ContainerEnvironmentUtil.java rename to test-infra/camel-test-infra-common/src/main/java/org/apache/camel/test/infra/common/services/ContainerEnvironmentUtil.java diff --git a/test-infra/camel-test-infra-common/src/main/java/org/apache/camel/test/infra/common/services/ContainerService.java b/test-infra/camel-test-infra-common/src/main/java/org/apache/camel/test/infra/common/services/ContainerService.java new file mode 100644 index 0000000000000..f2358ddc26be2 --- /dev/null +++ b/test-infra/camel-test-infra-common/src/main/java/org/apache/camel/test/infra/common/services/ContainerService.java @@ -0,0 +1,25 @@ +/* + * 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.test.infra.common.services; + +import org.testcontainers.containers.GenericContainer; + +public interface ContainerService { + + T getContainer(); +} diff --git a/test-infra/camel-test-infra-common/src/main/java/org/apache/camel/test/infra/common/services/InfrastructureService.java b/test-infra/camel-test-infra-common/src/main/java/org/apache/camel/test/infra/common/services/InfrastructureService.java new file mode 100644 index 0000000000000..a996ff73a1c9f --- /dev/null +++ b/test-infra/camel-test-infra-common/src/main/java/org/apache/camel/test/infra/common/services/InfrastructureService.java @@ -0,0 +1,42 @@ +/* + * 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.test.infra.common.services; + +public interface InfrastructureService extends AutoCloseable { + + /** + * Register service properties (such as using System.setProperties) so that they can be resolved at distance (ie.: + * when using Spring's PropertySourcesPlaceholderConfigurer or simply when trying to collect test infra information + * outside of the test class itself). + */ + void registerProperties(); + + /** + * Perform any initialization necessary + */ + void initialize(); + + /** + * Shuts down the service after the test has completed + */ + void shutdown(); + + @Override + default void close() { + shutdown(); + } +} diff --git a/test-infra/camel-test-infra-common/src/test/java/org/apache/camel/test/infra/common/services/ContainerService.java b/test-infra/camel-test-infra-common/src/test/java/org/apache/camel/test/infra/common/services/ContainerTestService.java similarity index 91% rename from test-infra/camel-test-infra-common/src/test/java/org/apache/camel/test/infra/common/services/ContainerService.java rename to test-infra/camel-test-infra-common/src/test/java/org/apache/camel/test/infra/common/services/ContainerTestService.java index 0d01af29b472e..3b537e3c74f5f 100644 --- a/test-infra/camel-test-infra-common/src/test/java/org/apache/camel/test/infra/common/services/ContainerService.java +++ b/test-infra/camel-test-infra-common/src/test/java/org/apache/camel/test/infra/common/services/ContainerTestService.java @@ -22,13 +22,11 @@ import org.junit.jupiter.api.extension.ExtensionContext; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.testcontainers.containers.GenericContainer; -public interface ContainerService extends ExecutionCondition { +public interface ContainerTestService extends ExecutionCondition { @Override default ConditionEvaluationResult evaluateExecutionCondition(ExtensionContext extensionContext) { - if (ContainerEnvironmentUtil.isDockerAvailable()) { return ConditionEvaluationResult.enabled("Docker is available"); } @@ -40,6 +38,4 @@ default ConditionEvaluationResult evaluateExecutionCondition(ExtensionContext ex "Container-based tests were disabled because Docker is NOT available. Check the log files on target/failsafe-reports"); return ConditionEvaluationResult.disabled("Docker is NOT available"); } - - T getContainer(); } diff --git a/test-infra/camel-test-infra-common/src/test/java/org/apache/camel/test/infra/common/services/SimpleTestServiceBuilder.java b/test-infra/camel-test-infra-common/src/test/java/org/apache/camel/test/infra/common/services/SimpleTestServiceBuilder.java index 284b7e8ac296a..2e3cc06e2c857 100644 --- a/test-infra/camel-test-infra-common/src/test/java/org/apache/camel/test/infra/common/services/SimpleTestServiceBuilder.java +++ b/test-infra/camel-test-infra-common/src/test/java/org/apache/camel/test/infra/common/services/SimpleTestServiceBuilder.java @@ -24,7 +24,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class SimpleTestServiceBuilder implements TestServiceBuilder { +public class SimpleTestServiceBuilder implements TestServiceBuilder { private static final Logger LOG = LoggerFactory.getLogger(SimpleTestServiceBuilder.class); private final Map> mappings = new HashMap<>(); diff --git a/test-infra/camel-test-infra-common/src/test/java/org/apache/camel/test/infra/common/services/SingletonService.java b/test-infra/camel-test-infra-common/src/test/java/org/apache/camel/test/infra/common/services/SingletonService.java index f63ce1bdbeafe..57652d6f15d15 100644 --- a/test-infra/camel-test-infra-common/src/test/java/org/apache/camel/test/infra/common/services/SingletonService.java +++ b/test-infra/camel-test-infra-common/src/test/java/org/apache/camel/test/infra/common/services/SingletonService.java @@ -26,7 +26,8 @@ * * @param The type of the service to be wrapped */ -public class SingletonService implements ExtensionContext.Store.CloseableResource, TestService { +public class SingletonService + implements ExtensionContext.Store.CloseableResource, TestService { private static final Logger LOG = LoggerFactory.getLogger(SingletonService.class); private final T service; diff --git a/test-infra/camel-test-infra-common/src/test/java/org/apache/camel/test/infra/common/services/TestService.java b/test-infra/camel-test-infra-common/src/test/java/org/apache/camel/test/infra/common/services/TestService.java index 552489b3deb63..5dff36b0b94bf 100644 --- a/test-infra/camel-test-infra-common/src/test/java/org/apache/camel/test/infra/common/services/TestService.java +++ b/test-infra/camel-test-infra-common/src/test/java/org/apache/camel/test/infra/common/services/TestService.java @@ -21,29 +21,7 @@ import org.junit.jupiter.api.extension.BeforeAllCallback; import org.junit.jupiter.api.extension.ExtensionContext; -public interface TestService extends AutoCloseable, BeforeAllCallback, AfterAllCallback { - - /** - * Register service properties (such as using System.setProperties) so that they can be resolved at distance (ie.: - * when using Spring's PropertySourcesPlaceholderConfigurer or simply when trying to collect test infra information - * outside of the test class itself). - */ - void registerProperties(); - - /** - * Perform any initialization necessary - */ - void initialize(); - - /** - * Shuts down the service after the test has completed - */ - void shutdown(); - - @Override - default void close() { - shutdown(); - } +public interface TestService extends AutoCloseable, BeforeAllCallback, AfterAllCallback, InfrastructureService { @Override default void beforeAll(ExtensionContext extensionContext) throws Exception { diff --git a/test-infra/camel-test-infra-common/src/test/java/org/apache/camel/test/infra/common/services/TestServiceBuilder.java b/test-infra/camel-test-infra-common/src/test/java/org/apache/camel/test/infra/common/services/TestServiceBuilder.java index 3d021f2e500a5..205fa57e271d9 100644 --- a/test-infra/camel-test-infra-common/src/test/java/org/apache/camel/test/infra/common/services/TestServiceBuilder.java +++ b/test-infra/camel-test-infra-common/src/test/java/org/apache/camel/test/infra/common/services/TestServiceBuilder.java @@ -17,7 +17,7 @@ package org.apache.camel.test.infra.common.services; -public interface TestServiceBuilder { +public interface TestServiceBuilder { T build(); }