From 0b0b118a3b8d9b207484bc63dbae9691dc2f9332 Mon Sep 17 00:00:00 2001 From: Radek Davidek Date: Fri, 27 Feb 2026 15:58:20 +0100 Subject: [PATCH] send MQ message draft --- test-harness/pom.xml | 16 +- .../connectors/messaging/IbmMqConnector.java | 67 ++- .../endpoints/messaging/IbmMqEndpoint.java | 4 +- tests/pom.xml | 544 ++++++++++-------- .../test/system/messaging/SendMQMessage.java | 24 + 5 files changed, 365 insertions(+), 290 deletions(-) create mode 100644 tests/src/test/java/cz/moneta/test/system/messaging/SendMQMessage.java diff --git a/test-harness/pom.xml b/test-harness/pom.xml index 329e85d..d9a0128 100644 --- a/test-harness/pom.xml +++ b/test-harness/pom.xml @@ -461,16 +461,16 @@ false true - central - libs-release - https://artifactory-aws.ux.mbid.cz/artifactory/libs-release + mcentral + Maven Central + https://repo1.maven.org/maven2/ - true - false - snapshots - libs-snapshot - https://artifactory-aws.ux.mbid.cz/artifactory/libs-snapshot + false + true + mvnrepo + MVN Repository + https://mvnrepository.com/artifact/ diff --git a/test-harness/src/main/java/cz/moneta/test/harness/connectors/messaging/IbmMqConnector.java b/test-harness/src/main/java/cz/moneta/test/harness/connectors/messaging/IbmMqConnector.java index 9f79254..6bc3e0b 100644 --- a/test-harness/src/main/java/cz/moneta/test/harness/connectors/messaging/IbmMqConnector.java +++ b/test-harness/src/main/java/cz/moneta/test/harness/connectors/messaging/IbmMqConnector.java @@ -1,23 +1,5 @@ package cz.moneta.test.harness.connectors.messaging; -import com.ibm.msg.client.jms.JmsConnectionFactory; -import com.ibm.msg.client.jms.JmsFactoryFactory; -import com.ibm.msg.client.wmq.WMQConstants; -import cz.moneta.test.harness.connectors.Connector; -import cz.moneta.test.harness.exception.MessagingTimeoutException; -import cz.moneta.test.harness.messaging.model.MessageContentType; -import cz.moneta.test.harness.messaging.model.MqMessageFormat; -import cz.moneta.test.harness.messaging.model.ReceivedMessage; -import javax.jms.BytesMessage; -import javax.jms.JMSConsumer; -import javax.jms.JMSContext; -import javax.jms.JMSException; -import javax.jms.JMSProducer; -import javax.jms.Message; -import javax.jms.Queue; -import javax.jms.QueueBrowser; -import javax.jms.TextMessage; - import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; import java.time.Duration; @@ -32,11 +14,30 @@ import java.util.Optional; import java.util.concurrent.TimeUnit; import java.util.function.Predicate; +import javax.jms.BytesMessage; +import javax.jms.JMSConsumer; +import javax.jms.JMSContext; +import javax.jms.JMSException; +import javax.jms.JMSProducer; +import javax.jms.Message; +import javax.jms.Queue; +import javax.jms.QueueBrowser; +import javax.jms.TextMessage; + +import com.ibm.mq.jms.MQConnectionFactory; +import com.ibm.msg.client.wmq.WMQConstants; + +import cz.moneta.test.harness.connectors.Connector; +import cz.moneta.test.harness.exception.MessagingTimeoutException; +import cz.moneta.test.harness.messaging.model.MessageContentType; +import cz.moneta.test.harness.messaging.model.MqMessageFormat; +import cz.moneta.test.harness.messaging.model.ReceivedMessage; + public class IbmMqConnector implements Connector { private static final Charset EBCDIC_870 = Charset.forName("IBM870"); private static final Charset UTF_8 = StandardCharsets.UTF_8; - private final JmsConnectionFactory connectionFactory; + private final MQConnectionFactory connectionFactory; private final String user; private final String password; private final Object contextLock = new Object(); @@ -49,7 +50,8 @@ public class IbmMqConnector implements Connector { String user, String password, String keystorePath, - String keystorePassword) { + String keystorePassword, + String cipherSuite) { this.user = user; this.password = password; try { @@ -60,15 +62,22 @@ public class IbmMqConnector implements Connector { } } - JmsFactoryFactory factoryFactory = JmsFactoryFactory.getInstance(WMQConstants.WMQ_PROVIDER); - connectionFactory = factoryFactory.createConnectionFactory(); - connectionFactory.setStringProperty(WMQConstants.WMQ_HOST_NAME, host); - connectionFactory.setIntProperty(WMQConstants.WMQ_PORT, port); - connectionFactory.setStringProperty(WMQConstants.WMQ_CHANNEL, channel); - connectionFactory.setStringProperty(WMQConstants.WMQ_QUEUE_MANAGER, queueManager); - connectionFactory.setIntProperty(WMQConstants.WMQ_CONNECTION_MODE, WMQConstants.WMQ_CM_CLIENT); - connectionFactory.setStringProperty(WMQConstants.USERID, user); - connectionFactory.setStringProperty(WMQConstants.PASSWORD, password); + connectionFactory = new MQConnectionFactory(); + connectionFactory.setHostName(host); + connectionFactory.setPort(port); + connectionFactory.setQueueManager(queueManager); + connectionFactory.setChannel(channel); + connectionFactory.setTransportType(WMQConstants.WMQ_CM_CLIENT); + if (user != null && !user.isBlank()) { + connectionFactory.setStringProperty(WMQConstants.USERID, user); + } + if (password != null && !password.isBlank()) { + connectionFactory.setStringProperty(WMQConstants.PASSWORD, password); + } + + if (cipherSuite != null && !cipherSuite.isBlank()) { + connectionFactory.setSSLCipherSuite(cipherSuite); + } } catch (Exception e) { throw new IllegalStateException("Failed to initialize IBM MQ connection factory", e); } diff --git a/test-harness/src/main/java/cz/moneta/test/harness/endpoints/messaging/IbmMqEndpoint.java b/test-harness/src/main/java/cz/moneta/test/harness/endpoints/messaging/IbmMqEndpoint.java index 3bf5757..b5ec76a 100644 --- a/test-harness/src/main/java/cz/moneta/test/harness/endpoints/messaging/IbmMqEndpoint.java +++ b/test-harness/src/main/java/cz/moneta/test/harness/endpoints/messaging/IbmMqEndpoint.java @@ -25,6 +25,7 @@ public class IbmMqEndpoint implements Endpoint { private static final String CONFIG_VAULT_PATH = "vault.path.messaging.ibmmq"; private static final String CONFIG_USERNAME = "messaging.ibmmq.username"; private static final String CONFIG_PASSWORD = "messaging.ibmmq.password"; + private static final String CONFIG_SSL_CYPHER_SUITES = "messaging.ibmmq.ssl-cipher-suite"; private final StoreAccessor store; private volatile IbmMqConnector connector; @@ -86,8 +87,9 @@ public class IbmMqEndpoint implements Endpoint { String password = resolveSecret(CONFIG_PASSWORD, "password"); String keystorePath = store.getConfig(CONFIG_KEYSTORE_PATH); String keystorePassword = store.getConfig(CONFIG_KEYSTORE_PASSWORD); + String sslCipherSuites = store.getConfig(CONFIG_SSL_CYPHER_SUITES); - return new IbmMqConnector(host, port, channel, queueManager, username, password, keystorePath, keystorePassword); + return new IbmMqConnector(host, port, channel, queueManager, username, password, keystorePath, keystorePassword, sslCipherSuites); } private String resolveSecret(String localConfigKey, String vaultKey) { diff --git a/tests/pom.xml b/tests/pom.xml index 91cccba..fc8fa99 100644 --- a/tests/pom.xml +++ b/tests/pom.xml @@ -1,256 +1,296 @@ - - 4.0.0 - cz.moneta.test - tests - 2.28-SNAPSHOT - - 7.55-SNAPSHOT - UTF-8 - 1.5.1 - - - - cz.moneta.test - harness - ${harness.version} - - - org.slf4j - slf4j-api - 1.7.25 - - - com.fasterxml.jackson.dataformat - jackson-dataformat-csv - 2.16.1 - - - com.fasterxml.jackson.datatype - jackson-datatype-jsr310 - 2.16.1 - - - org.projectlombok - lombok - 1.18.30 - provided - - - com.microsoft.sqlserver - mssql-jdbc_auth - 8.2.0.x86 - dll - - - org.jetbrains - annotations - 15.0 - - - org.junit.platform - junit-platform-reporting - ${junit.platform.version} - - - org.junit.platform - junit-platform-console - ${junit.platform.version} - - - org.yaml - snakeyaml - 1.26 - - - - - Moneta Artifactory - - true - - - - - org.apache.maven.plugins - maven-dependency-plugin - 3.9.0 - - - install - - copy-dependencies - + + 4.0.0 + cz.moneta.test + tests + 2.28-SNAPSHOT + + 7.55-SNAPSHOT + UTF-8 + 1.5.1 + 9.4.2.0 + + + + cz.moneta.test + harness + ${harness.version} + + + com.ibm.mq + com.ibm.mq.allclient + ${ibm.mq.version} + + + + javax.jms + javax.jms-api + 2.0.1 + + + org.slf4j + slf4j-api + 1.7.25 + + + com.fasterxml.jackson.dataformat + jackson-dataformat-csv + 2.16.1 + + + com.fasterxml.jackson.datatype + jackson-datatype-jsr310 + 2.16.1 + + + org.projectlombok + lombok + 1.18.30 + provided + + + com.microsoft.sqlserver + mssql-jdbc_auth + 8.2.0.x86 + dll + + + org.jetbrains + annotations + 15.0 + + + org.junit.platform + junit-platform-reporting + ${junit.platform.version} + + + org.junit.platform + junit-platform-console + ${junit.platform.version} + + + org.yaml + snakeyaml + 1.26 + + + + + Moneta Artifactory + + true + + + + + org.apache.maven.plugins + maven-dependency-plugin + 3.9.0 + + + install + + copy-dependencies + + + + ${project.build.directory}/lib + runtime + + + + + + maven-compiler-plugin + 3.13.0 - ${project.build.directory}/lib - runtime + 17 + 17 - - - - - maven-compiler-plugin - 3.13.0 - - 17 - 17 - - - - maven-surefire-plugin - 2.22.2 - - --add-opens java.base/java.lang.invoke=ALL-UNNAMED -Dhttp.proxyHost=wsa-aws.mbid.cz -Dhttp.proxyPort=8008 -Dhttps.proxyHost=wsa-aws.mbid.cz -Dhttps.proxyPort=8008 - -Dhttp.nonProxyHosts="elasticclusterawscoord*|elasticclusterawsingest*|jenkinslivex*|cbltstx|vault|vault.svc.k8s.moneta-containers.net|selenium-hub.svc.k8s.moneta-containers.net|jira*|d000*|x000*|l000*|digdev*|r000|spii-live-significant|mbczvl1dl0ihat3.ux.mbid.cz|mbczvl1dl0ihet3.ux.mbid.cz|wso2-fve-gw.ux.mbid.cz|wso2eifve.lb.mbid.cz|wso2eippe.lb.mbid.cz|wso2-ppe-gw.ux.mbid.cz|mbczvl0bl0enin3.ux.mbid.cz|wso2-tst1-gw.ux.mbid.cz|wso2eitst1.lb.mbid.cz|wso2-edu-gw.ux.mbid.cz|mbczvl0bl0enin5.ux.mbid.cz|mbczvl1dl0enin6.ux.mbid.cz|wso2api01-wso2-02.ux.mbid.cz|api-szr.tst.moneta-containers.net|api-szr.ppe.moneta-containers.net|docker1|mbczvl1dl0mockt.ux.mbid.cz|api.tst.moneta-containers.net|api.ppe.moneta-containers.net" - - cz.moneta.test.sandbox.demo.HarnessDemoTest.java - - false - false - - - - - - - - true - - - false - - central - libs-release - https://artifactory-aws.ux.mbid.cz/artifactory/libs-release - - - - false - - - true - - snapshots - libs-snapshot - https://artifactory-aws.ux.mbid.cz/artifactory/libs-snapshot - - - - - - true - - - false - - central - plugins-release - https://artifactory-aws.ux.mbid.cz/artifactory/plugins-release - - - - false - - - true - - snapshots - plugins-snapshot - https://artifactory-aws.ux.mbid.cz/artifactory/plugins-snapshot - - - - - build.package - - - build.package - true - - - - - - maven-compiler-plugin - 3.13.0 - - 17 - 17 - - - - maven-assembly-plugin - 3.6.0 - - - package - - single - - - - - cz.moneta.test.testrunner.TestRunner - - - - src/assembly/assembly.xml - - - - - - - - - - - true - - - false - - central - libs-release - https://artifactory-aws.ux.mbid.cz/artifactory/libs-release - - - - false - - - true - - snapshots - libs-snapshot - https://artifactory-aws.ux.mbid.cz/artifactory/libs-snapshot - - - - - - true - - - false - - central - plugins-release - https://artifactory-aws.ux.mbid.cz/artifactory/plugins-release - - - - false - - - true - - snapshots - plugins-snapshot - https://artifactory-aws.ux.mbid.cz/artifactory/plugins-snapshot - - - - + + + maven-surefire-plugin + 2.22.2 + + + --add-opens + java.base/java.lang.invoke=ALL-UNNAMED + -Dhttp.proxyHost=wsa-aws.mbid.cz + -Dhttp.proxyPort=8008 + -Dhttps.proxyHost=wsa-aws.mbid.cz + -Dhttps.proxyPort=8008 + -Dhttp.nonProxyHosts="elasticclusterawscoord*|elasticclusterawsingest*|jenkinslivex*|cbltstx|vault|vault.svc.k8s.moneta-containers.net|selenium-hub.svc.k8s.moneta-containers.net|jira*|d000*|x000*|l000*|digdev*|r000|spii-live-significant|mbczvl1dl0ihat3.ux.mbid.cz|mbczvl1dl0ihet3.ux.mbid.cz|wso2-fve-gw.ux.mbid.cz|wso2eifve.lb.mbid.cz|wso2eippe.lb.mbid.cz|wso2-ppe-gw.ux.mbid.cz|mbczvl0bl0enin3.ux.mbid.cz|wso2-tst1-gw.ux.mbid.cz|wso2eitst1.lb.mbid.cz|wso2-edu-gw.ux.mbid.cz|mbczvl0bl0enin5.ux.mbid.cz|mbczvl1dl0enin6.ux.mbid.cz|wso2api01-wso2-02.ux.mbid.cz|api-szr.tst.moneta-containers.net|api-szr.ppe.moneta-containers.net|docker1|mbczvl1dl0mockt.ux.mbid.cz|api.tst.moneta-containers.net|api.ppe.moneta-containers.net" + + + cz.moneta.test.sandbox.demo.HarnessDemoTest.java + + false + false + + + + + + + + false + + + true + + confluent + Confluent Hub + https://packages.confluent.io/maven/ + + + + false + + + true + + mcentral + Maven Central + https://repo1.maven.org/maven2/ + + + + false + + + true + + mvnrepo + MVN Repository + https://mvnrepository.com/artifact/ + + + + + + true + + + false + + central + plugins-release + + https://artifactory-aws.ux.mbid.cz/artifactory/plugins-release + + + + false + + + true + + snapshots + plugins-snapshot + + https://artifactory-aws.ux.mbid.cz/artifactory/plugins-snapshot + + + + + build.package + + + build.package + true + + + + + + maven-compiler-plugin + 3.13.0 + + 17 + 17 + + + + maven-assembly-plugin + 3.6.0 + + + package + + single + + + + + + cz.moneta.test.testrunner.TestRunner + + + + src/assembly/assembly.xml + + + + + + + + + + + true + + + false + + central + libs-release + + https://artifactory-aws.ux.mbid.cz/artifactory/libs-release + + + + false + + + true + + snapshots + libs-snapshot + + https://artifactory-aws.ux.mbid.cz/artifactory/libs-snapshot + + + + + + true + + + false + + central + plugins-release + + https://artifactory-aws.ux.mbid.cz/artifactory/plugins-release + + + + false + + + true + + snapshots + plugins-snapshot + + https://artifactory-aws.ux.mbid.cz/artifactory/plugins-snapshot + + + + diff --git a/tests/src/test/java/cz/moneta/test/system/messaging/SendMQMessage.java b/tests/src/test/java/cz/moneta/test/system/messaging/SendMQMessage.java new file mode 100644 index 0000000..c2e6263 --- /dev/null +++ b/tests/src/test/java/cz/moneta/test/system/messaging/SendMQMessage.java @@ -0,0 +1,24 @@ +package cz.moneta.test.system.messaging; + +import cz.moneta.test.dsl.Harness; +import cz.moneta.test.harness.annotations.TestCase; +import cz.moneta.test.harness.annotations.TestScenario; + +@TestScenario(name = "Send MQ message") +public class SendMQMessage { + + @TestCase(name = "Send MQ message") + public void sendMessage(Harness harness) { + String message = "Hello, this is a test message!"; + String destination = "mainframe-utf8-queue"; + + System.setProperty("javax.net.ssl.trustStore", "/home/kamma/tmp/mq-docker/ibmmq-client.p12"); + System.setProperty("javax.net.ssl.trustStorePassword", "changeit"); + + //System.setProperty("jdk.tls.client.protocols", "TLSv1.2"); + //System.setProperty("javax.net.ssl.trustStoreType", "PKCS12"); + + harness.withMessaging().to(destination).asJson().withPayload(message).send(); + } + +}