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 0a765ca336 Fix #5016 to add a IBMMQ pooling test with quarkus-pooled-jms (#5017) 0a765ca336 is described below commit 0a765ca336482090e260c918c034320176895ef5 Author: Zheng Feng <zh.f...@gmail.com> AuthorDate: Wed Jun 28 08:43:40 2023 +0800 Fix #5016 to add a IBMMQ pooling test with quarkus-pooled-jms (#5017) --- integration-tests/jms-ibmmq-client/pom.xml | 7 ++++- ...QProducers.java => IBMMQConnectionFactory.java} | 26 ++++++++--------- .../src/main/resources/application.properties | 19 +++++++++++++ .../it/{IBMMQTest.java => IBMMQPoolingTest.java} | 25 ++++++---------- .../quarkus/component/jms/ibmmq/it/IBMMQTest.java | 2 +- .../component/jms/ibmmq/it/JmsPoolingEnabled.java | 33 ++++++++++++++++++++++ 6 files changed, 79 insertions(+), 33 deletions(-) diff --git a/integration-tests/jms-ibmmq-client/pom.xml b/integration-tests/jms-ibmmq-client/pom.xml index 6b2861773e..924a004516 100644 --- a/integration-tests/jms-ibmmq-client/pom.xml +++ b/integration-tests/jms-ibmmq-client/pom.xml @@ -41,6 +41,12 @@ <artifactId>camel-quarkus-jms</artifactId> </dependency> + <!-- Messaging Pooled JMS --> + <dependency> + <groupId>io.quarkiverse.messaginghub</groupId> + <artifactId>quarkus-pooled-jms</artifactId> + </dependency> + <!-- Inherit base messaging routes --> <dependency> <groupId>org.apache.camel.quarkus</groupId> @@ -51,7 +57,6 @@ <dependency> <groupId>com.ibm.mq</groupId> <artifactId>com.ibm.mq.jakarta.client</artifactId> - <scope>provided</scope> </dependency> <!-- test dependencies --> diff --git a/integration-tests/jms-ibmmq-client/src/main/java/org/apache/camel/quarkus/component/jms/ibmmq/it/IBMMQProducers.java b/integration-tests/jms-ibmmq-client/src/main/java/org/apache/camel/quarkus/component/jms/ibmmq/it/IBMMQConnectionFactory.java similarity index 58% rename from integration-tests/jms-ibmmq-client/src/main/java/org/apache/camel/quarkus/component/jms/ibmmq/it/IBMMQProducers.java rename to integration-tests/jms-ibmmq-client/src/main/java/org/apache/camel/quarkus/component/jms/ibmmq/it/IBMMQConnectionFactory.java index 45b246ea69..fd009b9b63 100644 --- a/integration-tests/jms-ibmmq-client/src/main/java/org/apache/camel/quarkus/component/jms/ibmmq/it/IBMMQProducers.java +++ b/integration-tests/jms-ibmmq-client/src/main/java/org/apache/camel/quarkus/component/jms/ibmmq/it/IBMMQConnectionFactory.java @@ -18,27 +18,25 @@ package org.apache.camel.quarkus.component.jms.ibmmq.it; import com.ibm.mq.jakarta.jms.MQConnectionFactory; import com.ibm.msg.client.jakarta.wmq.WMQConstants; -import jakarta.enterprise.inject.Produces; -import jakarta.jms.ConnectionFactory; +import jakarta.enterprise.context.Dependent; import org.eclipse.microprofile.config.ConfigProvider; -public class IBMMQProducers { - @Produces - ConnectionFactory createConnectionFactory() { - MQConnectionFactory connectionFactory = new MQConnectionFactory(); - connectionFactory.setHostName(ConfigProvider.getConfig().getValue("ibm.mq.host", String.class)); +@Dependent +public class IBMMQConnectionFactory extends MQConnectionFactory { + + public IBMMQConnectionFactory() { + setHostName(ConfigProvider.getConfig().getValue("ibm.mq.host", String.class)); try { - connectionFactory.setPort(ConfigProvider.getConfig().getValue("ibm.mq.port", Integer.class)); - connectionFactory.setChannel(ConfigProvider.getConfig().getValue("ibm.mq.channel", String.class)); - connectionFactory.setQueueManager(ConfigProvider.getConfig().getValue("ibm.mq.queueManagerName", String.class)); - connectionFactory.setTransportType(WMQConstants.WMQ_CM_CLIENT); - connectionFactory.setStringProperty(WMQConstants.USERID, + setPort(ConfigProvider.getConfig().getValue("ibm.mq.port", Integer.class)); + setChannel(ConfigProvider.getConfig().getValue("ibm.mq.channel", String.class)); + setQueueManager(ConfigProvider.getConfig().getValue("ibm.mq.queueManagerName", String.class)); + setTransportType(WMQConstants.WMQ_CM_CLIENT); + setStringProperty(WMQConstants.USERID, ConfigProvider.getConfig().getValue("ibm.mq.user", String.class)); - connectionFactory.setStringProperty(WMQConstants.PASSWORD, + setStringProperty(WMQConstants.PASSWORD, ConfigProvider.getConfig().getValue("ibm.mq.password", String.class)); } catch (Exception e) { throw new RuntimeException("Unable to create new IBM MQ connection factory", e); } - return connectionFactory; } } diff --git a/integration-tests/jms-ibmmq-client/src/main/resources/application.properties b/integration-tests/jms-ibmmq-client/src/main/resources/application.properties new file mode 100644 index 0000000000..b32e2e1086 --- /dev/null +++ b/integration-tests/jms-ibmmq-client/src/main/resources/application.properties @@ -0,0 +1,19 @@ +## --------------------------------------------------------------------------- +## 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. +## --------------------------------------------------------------------------- +# +# Only enabled with IBMMQPoolingTest +quarkus.pooled-jms.pooling.enabled=false diff --git a/integration-tests/jms-ibmmq-client/src/test/java/org/apache/camel/quarkus/component/jms/ibmmq/it/IBMMQTest.java b/integration-tests/jms-ibmmq-client/src/test/java/org/apache/camel/quarkus/component/jms/ibmmq/it/IBMMQPoolingTest.java similarity index 82% copy from integration-tests/jms-ibmmq-client/src/test/java/org/apache/camel/quarkus/component/jms/ibmmq/it/IBMMQTest.java copy to integration-tests/jms-ibmmq-client/src/test/java/org/apache/camel/quarkus/component/jms/ibmmq/it/IBMMQPoolingTest.java index eb81e9e3d1..8597e50904 100644 --- a/integration-tests/jms-ibmmq-client/src/test/java/org/apache/camel/quarkus/component/jms/ibmmq/it/IBMMQTest.java +++ b/integration-tests/jms-ibmmq-client/src/test/java/org/apache/camel/quarkus/component/jms/ibmmq/it/IBMMQPoolingTest.java @@ -14,12 +14,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.apache.camel.quarkus.component.jms.ibmmq.it; import java.lang.reflect.Method; import io.quarkus.test.common.QuarkusTestResource; import io.quarkus.test.junit.QuarkusTest; +import io.quarkus.test.junit.TestProfile; import io.restassured.RestAssured; import org.apache.camel.quarkus.component.jms.ibmmq.support.IBMMQDestinations; import org.apache.camel.quarkus.component.jms.ibmmq.support.IBMMQTestResource; @@ -30,14 +32,14 @@ import org.junit.jupiter.api.TestInfo; import org.junit.jupiter.api.TestInstance; import org.junit.jupiter.api.condition.EnabledIfSystemProperty; -import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.startsWith; @QuarkusTest @QuarkusTestResource(IBMMQTestResource.class) @EnabledIfSystemProperty(named = "ibm.mq.container.license", matches = "accept") @TestInstance(TestInstance.Lifecycle.PER_CLASS) -public class IBMMQTest extends AbstractJmsMessagingTest { +@TestProfile(JmsPoolingEnabled.class) +public class IBMMQPoolingTest extends AbstractJmsMessagingTest { private IBMMQDestinations destinations; /** @@ -67,22 +69,11 @@ public class IBMMQTest extends AbstractJmsMessagingTest { RestAssured.get("/messaging/jms/ibmmq/connection/factory") .then() .statusCode(200) - .body(startsWith("com.ibm.mq")); + .body(startsWith("org.apache.camel.quarkus.component.jms.ibmmq.it.IBMMQConnectionFactory")); } - @Test - public void testPojoProducer() { - String message = "Camel Quarkus IBM MQ Pojo Producer"; - - RestAssured.given() - .body(message) - .post("/messaging/jms/ibmmq/pojo/producer") - .then() - .statusCode(204); - - RestAssured.get("/messaging/{queueName}", queue) - .then() - .statusCode(200) - .body(is(message)); + @Override + public void testJmsTopic() { + // Ignore testJmsTopic since it can't use setClientId in a pool connection. } } diff --git a/integration-tests/jms-ibmmq-client/src/test/java/org/apache/camel/quarkus/component/jms/ibmmq/it/IBMMQTest.java b/integration-tests/jms-ibmmq-client/src/test/java/org/apache/camel/quarkus/component/jms/ibmmq/it/IBMMQTest.java index eb81e9e3d1..5dcd0d784d 100644 --- a/integration-tests/jms-ibmmq-client/src/test/java/org/apache/camel/quarkus/component/jms/ibmmq/it/IBMMQTest.java +++ b/integration-tests/jms-ibmmq-client/src/test/java/org/apache/camel/quarkus/component/jms/ibmmq/it/IBMMQTest.java @@ -67,7 +67,7 @@ public class IBMMQTest extends AbstractJmsMessagingTest { RestAssured.get("/messaging/jms/ibmmq/connection/factory") .then() .statusCode(200) - .body(startsWith("com.ibm.mq")); + .body(startsWith("org.apache.camel.quarkus.component.jms.ibmmq.it.IBMMQConnectionFactory")); } @Test diff --git a/integration-tests/jms-ibmmq-client/src/test/java/org/apache/camel/quarkus/component/jms/ibmmq/it/JmsPoolingEnabled.java b/integration-tests/jms-ibmmq-client/src/test/java/org/apache/camel/quarkus/component/jms/ibmmq/it/JmsPoolingEnabled.java new file mode 100644 index 0000000000..e9727a299f --- /dev/null +++ b/integration-tests/jms-ibmmq-client/src/test/java/org/apache/camel/quarkus/component/jms/ibmmq/it/JmsPoolingEnabled.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.quarkus.component.jms.ibmmq.it; + +import java.util.HashMap; +import java.util.Map; + +import io.quarkus.test.junit.QuarkusTestProfile; + +public class JmsPoolingEnabled implements QuarkusTestProfile { + @Override + public Map<String, String> getConfigOverrides() { + Map<String, String> props = new HashMap<>(); + props.put("quarkus.pooled-jms.pooling.enabled", "true"); + props.put("quarkus.pooled-jms.max-connections", "8"); + return props; + } +}