This is an automated email from the ASF dual-hosted git repository.
zhfeng pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
The following commit(s) were added to refs/heads/main by this push:
new bc181fa9b8 Fix #6905 to add a test for using artemis jca connector
(#6906)
bc181fa9b8 is described below
commit bc181fa9b8ad9d22924b3d62e92e761cc4cd4de6
Author: Zheng Feng <[email protected]>
AuthorDate: Sat Jan 18 07:51:57 2025 +0800
Fix #6905 to add a test for using artemis jca connector (#6906)
* Fix #6905 to add a test for using artemis jca connector
* Add licenses
* Add artemis-jms-ra in the test-categories
* Replace to use ActiveMQTestResource
---
.../support/activemq/ActiveMQTestResource.java | 9 ++
.../messaging/it/MessagingCommonRoutes.java | 16 ++-
integration-tests/jms-artemis-ra/pom.xml | 155 +++++++++++++++++++++
.../quarkus/component/jms/ra/it/JmsResource.java | 52 +++++++
.../src/main/resources/application.properties | 18 +++
.../camel/quarkus/component/jms/ra/it/JmsRAIT.java | 23 +++
.../quarkus/component/jms/ra/it/JmsRATest.java | 62 +++++++++
integration-tests/pom.xml | 1 +
tooling/scripts/test-categories.yaml | 1 +
9 files changed, 336 insertions(+), 1 deletion(-)
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 36e8876653..2a14daa6c1 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
@@ -39,6 +39,7 @@ public class ActiveMQTestResource implements
QuarkusTestResourceLifecycleManager
private GenericContainer<?> container;
private String[] modules;
private String[] javaArgs = new String[] {};
+ private String protocol = "AMQP";
@Override
public void init(Map<String, String> initArgs) {
@@ -49,6 +50,9 @@ public class ActiveMQTestResource implements
QuarkusTestResourceLifecycleManager
if (name.equals("java-args")) {
javaArgs = value.split(",");
}
+ if (name.equals("protocol")) {
+ protocol = value;
+ }
});
}
@@ -73,6 +77,7 @@ public class ActiveMQTestResource implements
QuarkusTestResourceLifecycleManager
String brokerUrlTcp = String.format("tcp://%s:%d", containerHost,
containerPort);
String brokerUrlWs = String.format("ws://%s:%d", containerHost,
containerPort);
String brokerUrlAmqp = String.format("amqp://%s:%d", containerHost,
containerPort);
+ String connectionParameters =
String.format("host=%s;port=%d;protocols=%s", containerHost, containerPort,
protocol);
Map<String, String> result = new LinkedHashMap<>();
@@ -86,6 +91,10 @@ public class ActiveMQTestResource implements
QuarkusTestResourceLifecycleManager
result.put("quarkus.qpid-jms.url", brokerUrlAmqp);
result.put("quarkus.qpid-jms.username", ACTIVEMQ_USERNAME);
result.put("quarkus.qpid-jms.password", ACTIVEMQ_PASSWORD);
+ } else if (module.equals("quarkus.ironjacamar.ra")) {
+
result.put("quarkus.ironjacamar.ra.config.connection-parameters",
connectionParameters);
+ result.put("quarkus.ironjacamar.ra.config.user",
ACTIVEMQ_USERNAME);
+ result.put("quarkus.ironjacamar.ra.config.password",
ACTIVEMQ_PASSWORD);
} else if (module.startsWith("camel.component")) {
result.put(module + ".brokerUrl", brokerUrlTcp);
result.put(module + ".username", ACTIVEMQ_USERNAME);
diff --git
a/integration-tests-support/messaging/common/src/main/java/org/apache/camel/quarkus/component/messaging/it/MessagingCommonRoutes.java
b/integration-tests-support/messaging/common/src/main/java/org/apache/camel/quarkus/component/messaging/it/MessagingCommonRoutes.java
index 084aa8b12d..9ba2834031 100644
---
a/integration-tests-support/messaging/common/src/main/java/org/apache/camel/quarkus/component/messaging/it/MessagingCommonRoutes.java
+++
b/integration-tests-support/messaging/common/src/main/java/org/apache/camel/quarkus/component/messaging/it/MessagingCommonRoutes.java
@@ -41,7 +41,12 @@ public class MessagingCommonRoutes extends RouteBuilder {
// The routes are later started in AbstractMessagingTest#beforeAll
method
camelContext.setAutoStartup(false);
- fromF("%s:queue:testJmsMessageType?concurrentConsumers=5",
componentScheme)
+ String cacheLevel = "";
+ if (isCacheLevelNone()) {
+ cacheLevel = "&cacheLevelName=CACHE_NONE";
+ }
+
+ fromF("%s:queue:testJmsMessageType?concurrentConsumers=5%s",
componentScheme, cacheLevel)
.toF("%s:queue:testJmsMessageType2", componentScheme);
String disableStreaming = "";
@@ -115,4 +120,13 @@ public class MessagingCommonRoutes extends RouteBuilder {
return false;
}
}
+
+ private boolean isCacheLevelNone() {
+ try {
+
Class.forName("org.apache.activemq.artemis.ra.ActiveMQRAConnectionFactoryImpl");
+ return !componentScheme.getScheme().startsWith("sjms");
+ } catch (ClassNotFoundException e) {
+ return false;
+ }
+ }
}
diff --git a/integration-tests/jms-artemis-ra/pom.xml
b/integration-tests/jms-artemis-ra/pom.xml
new file mode 100644
index 0000000000..0844fad78d
--- /dev/null
+++ b/integration-tests/jms-artemis-ra/pom.xml
@@ -0,0 +1,155 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-build-parent-it</artifactId>
+ <version>3.18.0-SNAPSHOT</version>
+ <relativePath>../../poms/build-parent-it/pom.xml</relativePath>
+ </parent>
+
+ <artifactId>camel-quarkus-integration-test-jms-artemis-jms-ra</artifactId>
+ <name>Camel Quarkus :: Integration Tests :: JMS Artemis RA Connector</name>
+ <description>Integration tests for Camel Quarkus JMS extension with the
Quarkus Artemis JMS RA Connector</description>
+
+ <dependencies>
+ <!-- Messaging extension to test -->
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-jms</artifactId>
+ </dependency>
+
+ <!-- Inherit base messaging routes -->
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+
<artifactId>camel-quarkus-integration-tests-support-messaging-jms</artifactId>
+ </dependency>
+
+ <!-- The JMS client library to test with -->
+ <dependency>
+ <groupId>io.quarkiverse.artemis</groupId>
+ <artifactId>quarkus-artemis-jms-ra</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>jakarta.jms</groupId>
+ <artifactId>jakarta.jms-api</artifactId>
+ </dependency>
+
+ <!-- test dependencies -->
+ <dependency>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-junit5</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>io.rest-assured</groupId>
+ <artifactId>rest-assured</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+
<artifactId>camel-quarkus-integration-tests-support-activemq</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <!-- Inherit base messaging tests -->
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+
<artifactId>camel-quarkus-integration-tests-support-messaging-common</artifactId>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+
<artifactId>camel-quarkus-integration-tests-support-messaging-jms</artifactId>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ <profiles>
+ <profile>
+ <id>native</id>
+ <activation>
+ <property>
+ <name>native</name>
+ </property>
+ </activation>
+ <properties>
+ <quarkus.native.enabled>true</quarkus.native.enabled>
+ </properties>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-failsafe-plugin</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>integration-test</goal>
+ <goal>verify</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ <profile>
+ <id>virtualDependencies</id>
+ <activation>
+ <property>
+ <name>!noVirtualDependencies</name>
+ </property>
+ </activation>
+ <dependencies>
+ <!-- The following dependencies guarantee that this module is
built after them. You can update them by running `mvn process-resources
-Pformat -N` from the source tree root directory -->
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-jms-deployment</artifactId>
+ <version>${project.version}</version>
+ <type>pom</type>
+ <scope>test</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>*</groupId>
+ <artifactId>*</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ </dependencies>
+ </profile>
+ <profile>
+ <id>skip-testcontainers-tests</id>
+ <activation>
+ <property>
+ <name>skip-testcontainers-tests</name>
+ </property>
+ </activation>
+ <properties>
+ <skipTests>true</skipTests>
+ </properties>
+ </profile>
+ </profiles>
+
+</project>
diff --git
a/integration-tests/jms-artemis-ra/src/main/java/org/apache/camel/quarkus/component/jms/ra/it/JmsResource.java
b/integration-tests/jms-artemis-ra/src/main/java/org/apache/camel/quarkus/component/jms/ra/it/JmsResource.java
new file mode 100644
index 0000000000..ed6590396c
--- /dev/null
+++
b/integration-tests/jms-artemis-ra/src/main/java/org/apache/camel/quarkus/component/jms/ra/it/JmsResource.java
@@ -0,0 +1,52 @@
+/*
+ * 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.ra.it;
+
+import jakarta.enterprise.context.ApplicationScoped;
+import jakarta.inject.Inject;
+import jakarta.jms.ConnectionFactory;
+import jakarta.ws.rs.GET;
+import jakarta.ws.rs.POST;
+import jakarta.ws.rs.Path;
+import jakarta.ws.rs.Produces;
+import jakarta.ws.rs.core.MediaType;
+import org.apache.camel.Produce;
+import org.apache.camel.ProducerTemplate;
+
+@ApplicationScoped
+@Path("/messaging/jms/ra")
+public class JmsResource {
+
+ @Inject
+ ConnectionFactory connectionFactory;
+
+ @Produce("jms:queue:pojoProduce")
+ ProducerTemplate pojoProducer;
+
+ @GET
+ @Path("/connection/factory")
+ @Produces(MediaType.TEXT_PLAIN)
+ public String connectionFactoryImplementation() {
+ return connectionFactory.getClass().getName();
+ }
+
+ @POST
+ @Path("/pojo/producer")
+ public void pojoProducer(String message) {
+ pojoProducer.sendBody(message);
+ }
+}
diff --git
a/integration-tests/jms-artemis-ra/src/main/resources/application.properties
b/integration-tests/jms-artemis-ra/src/main/resources/application.properties
new file mode 100644
index 0000000000..8adb8ebc06
--- /dev/null
+++ b/integration-tests/jms-artemis-ra/src/main/resources/application.properties
@@ -0,0 +1,18 @@
+## ---------------------------------------------------------------------------
+## 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.
+## ---------------------------------------------------------------------------
+# JCA Configs
+quarkus.ironjacamar.ra.kind=artemis
diff --git
a/integration-tests/jms-artemis-ra/src/test/java/org/apache/camel/quarkus/component/jms/ra/it/JmsRAIT.java
b/integration-tests/jms-artemis-ra/src/test/java/org/apache/camel/quarkus/component/jms/ra/it/JmsRAIT.java
new file mode 100644
index 0000000000..9bb5743993
--- /dev/null
+++
b/integration-tests/jms-artemis-ra/src/test/java/org/apache/camel/quarkus/component/jms/ra/it/JmsRAIT.java
@@ -0,0 +1,23 @@
+/*
+ * 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.ra.it;
+
+import io.quarkus.test.junit.QuarkusIntegrationTest;
+
+@QuarkusIntegrationTest
+public class JmsRAIT extends JmsRATest {
+}
diff --git
a/integration-tests/jms-artemis-ra/src/test/java/org/apache/camel/quarkus/component/jms/ra/it/JmsRATest.java
b/integration-tests/jms-artemis-ra/src/test/java/org/apache/camel/quarkus/component/jms/ra/it/JmsRATest.java
new file mode 100644
index 0000000000..52709b89a7
--- /dev/null
+++
b/integration-tests/jms-artemis-ra/src/test/java/org/apache/camel/quarkus/component/jms/ra/it/JmsRATest.java
@@ -0,0 +1,62 @@
+/*
+ * 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.ra.it;
+
+import io.quarkus.test.common.QuarkusTestResource;
+import io.quarkus.test.common.ResourceArg;
+import io.quarkus.test.junit.QuarkusTest;
+import io.restassured.RestAssured;
+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
+@QuarkusTestResource(initArgs = {
+ @ResourceArg(name = "modules", value = "quarkus.ironjacamar.ra") },
value = ActiveMQTestResource.class)
+class JmsRATest extends AbstractJmsMessagingTest {
+
+ @Test
+ public void connectionFactoryImplementation() {
+ RestAssured.get("/messaging/jms/ra/connection/factory")
+ .then()
+ .statusCode(200)
+
.body(is("org.apache.activemq.artemis.ra.ActiveMQRAConnectionFactoryImpl"));
+ }
+
+ @Test
+ public void testPojoProducer() {
+ String message = "Camel Quarkus Pojo Producer";
+
+ RestAssured.given()
+ .body(message)
+ .post("/messaging/jms/ra/pojo/producer")
+ .then()
+ .statusCode(204);
+
+ RestAssured.get("/messaging/{queueName}", "pojoProduce")
+ .then()
+ .statusCode(200)
+ .body(is(message));
+ }
+
+ @Override
+ public void testJmsTopic() {
+ //ignore topic test
+ }
+}
diff --git a/integration-tests/pom.xml b/integration-tests/pom.xml
index f3e143a165..11aafa3676 100644
--- a/integration-tests/pom.xml
+++ b/integration-tests/pom.xml
@@ -125,6 +125,7 @@
<module>jfr</module>
<module>jira</module>
<module>jms-artemis-client</module>
+ <module>jms-artemis-ra</module>
<module>jms-ibmmq-client</module>
<module>jms-qpid-amqp-client</module>
<module>jolt</module>
diff --git a/tooling/scripts/test-categories.yaml
b/tooling/scripts/test-categories.yaml
index 03ddf594aa..a1c6419487 100644
--- a/tooling/scripts/test-categories.yaml
+++ b/tooling/scripts/test-categories.yaml
@@ -27,6 +27,7 @@ group-01:
- infinispan-quarkus-client
- jcache
- jms-artemis-client
+ - jms-artemis-ra
- jms-ibmmq-client
- jsch
- microprofile-fault-tolerance