This is an automated email from the ASF dual-hosted git repository. jamesnetherton pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
commit d6df1c8ea396906935fdcc16d3fae3fd80bd6bc5 Author: James Netherton <[email protected]> AuthorDate: Wed Aug 28 09:25:08 2024 +0100 Replace quarkus-test-artemis with dev services container --- integration-tests-support/activemq/pom.xml | 4 ++ .../support/activemq/ActiveMQTestResource.java | 22 ++++++++--- integration-tests/jms-artemis-client/pom.xml | 10 +---- .../jms/artemis/it/CustomConnectionFactory.java | 2 +- .../src/main/resources/application.properties | 4 ++ .../jms/artemis/it/CustomArtemisTestResource.java | 26 ------------- .../jms/artemis/it/JmsArtemisCustomTest.java | 19 +++++++++- .../src/test/resources/broker-custom.xml | 44 ---------------------- pom.xml | 1 - 9 files changed, 46 insertions(+), 86 deletions(-) diff --git a/integration-tests-support/activemq/pom.xml b/integration-tests-support/activemq/pom.xml index c39f40a24a..8f53e5dd29 100644 --- a/integration-tests-support/activemq/pom.xml +++ b/integration-tests-support/activemq/pom.xml @@ -48,6 +48,10 @@ <groupId>io.quarkus</groupId> <artifactId>quarkus-junit4-mock</artifactId> </dependency> + <dependency> + <groupId>io.quarkiverse.artemis</groupId> + <artifactId>quarkus-artemis-core</artifactId> + </dependency> </dependencies> </project> diff --git a/integration-tests-support/activemq/src/main/java/org/apache/camel/quarkus/test/support/activemq/ActiveMQTestResource.java b/integration-tests-support/activemq/src/main/java/org/apache/camel/quarkus/test/support/activemq/ActiveMQTestResource.java index 8f941191a1..bbeea45043 100644 --- a/integration-tests-support/activemq/src/main/java/org/apache/camel/quarkus/test/support/activemq/ActiveMQTestResource.java +++ b/integration-tests-support/activemq/src/main/java/org/apache/camel/quarkus/test/support/activemq/ActiveMQTestResource.java @@ -21,22 +21,21 @@ import java.util.LinkedHashMap; import java.util.Map; import com.github.dockerjava.api.model.Ulimit; +import io.quarkus.artemis.core.runtime.ArtemisDevServicesBuildTimeConfig; import io.quarkus.test.common.QuarkusTestResourceLifecycleManager; -import org.eclipse.microprofile.config.ConfigProvider; +import io.smallrye.config.SmallRyeConfigBuilder; import org.testcontainers.containers.GenericContainer; import org.testcontainers.containers.wait.strategy.Wait; import org.testcontainers.utility.DockerImageName; public class ActiveMQTestResource implements QuarkusTestResourceLifecycleManager { - - private static final String ACTIVEMQ_IMAGE_NAME = ConfigProvider.getConfig().getValue("activemq-artemis.container.image", - String.class); private static final String ACTIVEMQ_USERNAME = "artemis"; private static final String ACTIVEMQ_PASSWORD = "simetraehcapa"; private static final int ACTIVEMQ_PORT = 61616; private GenericContainer<?> container; private String[] modules; + private String[] javaArgs = new String[] {}; @Override public void init(Map<String, String> initArgs) { @@ -44,17 +43,21 @@ public class ActiveMQTestResource implements QuarkusTestResourceLifecycleManager if (name.equals("modules")) { modules = value.split(","); } + if (name.equals("java-args")) { + javaArgs = value.split(","); + } }); } @Override public Map<String, String> start() { - DockerImageName imageName = DockerImageName.parse(ACTIVEMQ_IMAGE_NAME); + DockerImageName imageName = DockerImageName.parse(getArtemisImageName()); container = new GenericContainer<>(imageName) .withExposedPorts(ACTIVEMQ_PORT) .withLogConsumer(frame -> System.out.print(frame.getUtf8String())) .withEnv("AMQ_USER", ACTIVEMQ_USERNAME) .withEnv("AMQ_PASSWORD", ACTIVEMQ_PASSWORD) + .withEnv("JAVA_ARGS_APPEND", "-Dbrokerconfig.maxDiskUsage=-1 " + String.join(" ", javaArgs)) .waitingFor(Wait.forLogMessage(".*AMQ241001.*", 1)) .withCreateContainerCmdModifier( cmd -> cmd.getHostConfig().withUlimits(new Ulimit[] { new Ulimit("nofile", 2048L, 2048L) })); @@ -99,4 +102,13 @@ public class ActiveMQTestResource implements QuarkusTestResourceLifecycleManager container.stop(); } } + + private String getArtemisImageName() { + // Align to the same image used by quarkus-artemis + return new SmallRyeConfigBuilder() + .withMapping(ArtemisDevServicesBuildTimeConfig.class) + .build() + .getConfigMapping(ArtemisDevServicesBuildTimeConfig.class) + .getImageName(); + } } diff --git a/integration-tests/jms-artemis-client/pom.xml b/integration-tests/jms-artemis-client/pom.xml index 53790a114b..ee8293ae0e 100644 --- a/integration-tests/jms-artemis-client/pom.xml +++ b/integration-tests/jms-artemis-client/pom.xml @@ -72,15 +72,9 @@ <scope>test</scope> </dependency> <dependency> - <groupId>io.quarkiverse.artemis</groupId> - <artifactId>quarkus-test-artemis</artifactId> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-integration-tests-support-activemq</artifactId> <scope>test</scope> - <exclusions> - <exclusion> - <groupId>org.apache.commons</groupId> - <artifactId>commons-pool2</artifactId> - </exclusion> - </exclusions> </dependency> <!-- Inherit base messaging tests --> diff --git a/integration-tests/jms-artemis-client/src/main/java/org/apache/camel/quarkus/component/jms/artemis/it/CustomConnectionFactory.java b/integration-tests/jms-artemis-client/src/main/java/org/apache/camel/quarkus/component/jms/artemis/it/CustomConnectionFactory.java index 0ae7f1e9eb..b77a8bde84 100644 --- a/integration-tests/jms-artemis-client/src/main/java/org/apache/camel/quarkus/component/jms/artemis/it/CustomConnectionFactory.java +++ b/integration-tests/jms-artemis-client/src/main/java/org/apache/camel/quarkus/component/jms/artemis/it/CustomConnectionFactory.java @@ -28,7 +28,7 @@ public class CustomConnectionFactory { @Produces @UnlessBuildProperty(name = "quarkus.artemis.enabled", stringValue = "true") ConnectionFactory createConnectionFactory() { - String url = ConfigProvider.getConfig().getValue("artemis.custom.url", String.class); + String url = ConfigProvider.getConfig().getValue("quarkus.artemis.url", String.class); ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory(url); return cf; } diff --git a/integration-tests/jms-artemis-client/src/main/resources/application.properties b/integration-tests/jms-artemis-client/src/main/resources/application.properties index 2d40acb5aa..9510f8af6b 100644 --- a/integration-tests/jms-artemis-client/src/main/resources/application.properties +++ b/integration-tests/jms-artemis-client/src/main/resources/application.properties @@ -15,9 +15,13 @@ ## limitations under the License. ## --------------------------------------------------------------------------- # + +quarkus.artemis.devservices.extra-args=--no-autotune --mapped --no-fsync --java-options=-Dbrokerconfig.maxDiskUsage=-1 + # Overridden to false via @TestProfile(JmsArtemisDisable.class) for some tests # When false, we produce a custom ConnectionFactory via CustomConnectionFactory producer bean quarkus.artemis.enabled=true + # # Only enabled with JmsArtemisPoolingTest quarkus.pooled-jms.pooling.enabled=false diff --git a/integration-tests/jms-artemis-client/src/test/java/org/apache/camel/quarkus/component/jms/artemis/it/CustomArtemisTestResource.java b/integration-tests/jms-artemis-client/src/test/java/org/apache/camel/quarkus/component/jms/artemis/it/CustomArtemisTestResource.java deleted file mode 100644 index 44f170bd06..0000000000 --- a/integration-tests/jms-artemis-client/src/test/java/org/apache/camel/quarkus/component/jms/artemis/it/CustomArtemisTestResource.java +++ /dev/null @@ -1,26 +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.quarkus.component.jms.artemis.it; - -import io.quarkus.artemis.test.ArtemisTestResource; - -public class CustomArtemisTestResource extends ArtemisTestResource { - public CustomArtemisTestResource() { - super("artemis", "custom"); - } - -} diff --git a/integration-tests/jms-artemis-client/src/test/java/org/apache/camel/quarkus/component/jms/artemis/it/JmsArtemisCustomTest.java b/integration-tests/jms-artemis-client/src/test/java/org/apache/camel/quarkus/component/jms/artemis/it/JmsArtemisCustomTest.java index 3ab4edbd26..5d864eee72 100644 --- a/integration-tests/jms-artemis-client/src/test/java/org/apache/camel/quarkus/component/jms/artemis/it/JmsArtemisCustomTest.java +++ b/integration-tests/jms-artemis-client/src/test/java/org/apache/camel/quarkus/component/jms/artemis/it/JmsArtemisCustomTest.java @@ -16,13 +16,30 @@ */ package org.apache.camel.quarkus.component.jms.artemis.it; +import io.quarkus.test.common.ResourceArg; import io.quarkus.test.common.WithTestResource; import io.quarkus.test.junit.QuarkusTest; import io.quarkus.test.junit.TestProfile; +import io.restassured.RestAssured; +import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory; import org.apache.camel.quarkus.messaging.jms.AbstractJmsMessagingTest; +import org.apache.camel.quarkus.test.support.activemq.ActiveMQTestResource; +import org.junit.jupiter.api.Test; + +import static org.hamcrest.Matchers.is; @QuarkusTest @TestProfile(JmsArtemisDisable.class) -@WithTestResource(CustomArtemisTestResource.class) +@WithTestResource(initArgs = { + @ResourceArg(name = "modules", value = "quarkus.artemis"), + @ResourceArg(name = "java-args", value = "-Dbrokerconfig.securityEnabled=false") +}, value = ActiveMQTestResource.class) public class JmsArtemisCustomTest extends AbstractJmsMessagingTest { + @Test + public void connectionFactoryImplementation() { + RestAssured.get("/messaging/jms/artemis/connection/factory") + .then() + .statusCode(200) + .body(is(ActiveMQConnectionFactory.class.getName())); + } } diff --git a/integration-tests/jms-artemis-client/src/test/resources/broker-custom.xml b/integration-tests/jms-artemis-client/src/test/resources/broker-custom.xml deleted file mode 100644 index c968d52ab0..0000000000 --- a/integration-tests/jms-artemis-client/src/test/resources/broker-custom.xml +++ /dev/null @@ -1,44 +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. - ---> -<configuration xmlns="urn:activemq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:activemq /schema/artemis-configuration.xsd"> - <core xmlns="urn:activemq:core"> - <paging-directory>./target/artemis/default/paging</paging-directory> - <bindings-directory>./target/artemis/default/bindings</bindings-directory> - <journal-directory>./target/artemis/default/journal</journal-directory> - <large-messages-directory>./target/artemis/default/large-messages</large-messages-directory> - - <connectors> - <connector name="activemq">tcp://localhost:61616</connector> - </connectors> - <acceptors> - <acceptor name="activemq">tcp://localhost:61616</acceptor> - </acceptors> - - <max-disk-usage>-1</max-disk-usage> - <security-enabled>false</security-enabled> - - <addresses> - <address name="test-jms-default"> - <anycast> - <queue name="test-jms-default"/> - </anycast> - </address> - </addresses> - </core> -</configuration> diff --git a/pom.xml b/pom.xml index f63c7c7917..34d9063810 100644 --- a/pom.xml +++ b/pom.xml @@ -221,7 +221,6 @@ <!-- Test container image properties --> <activemq.container.image>docker.io/rmohr/activemq:5.15.9-alpine</activemq.container.image> - <activemq-artemis.container.image>quay.io/artemiscloud/activemq-artemis-broker:1.0.20</activemq-artemis.container.image> <arangodb.container.image>docker.io/arangodb:3.12.0</arangodb.container.image> <azurite.container.image>mcr.microsoft.com/azure-storage/azurite:3.30.0</azurite.container.image> <calculator-ws.container.image>quay.io/l2x6/calculator-ws:1.2</calculator-ws.container.image>
