Skip to content

Commit 6999d4f

Browse files
Combined JmsPub & JmsSub tests
1 parent a373bff commit 6999d4f

File tree

3 files changed

+13
-96
lines changed

3 files changed

+13
-96
lines changed

JMS/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ To run the samples with TLS you need to provide additional arguments;
354354

355355
*A note on the* `Dcom.ibm.mq.cfg.useIBMCipherMappings=false` property
356356

357-
This is needed as the samples were tested in an enviroment with the Oracle JRE installed. Depending on whether you have Oracle or IBM JRE installed, you also need to name the cipher suite/spec accordingly. See the table here [TLS CipherSpecs and CipherSuites in IBM MQ classes for JMS](https://www.ibm.com/support/knowledgecenter/SSFKSJ_9.1.0/com.ibm.mq.dev.doc/q113220_.htm)
357+
This is needed as the samples were tested in an enviroment with the Oracle JRE installed. Depending on whether you have Oracle or IBM JRE installed, you also need to name the cipher suite/spec accordingly. See the table here [TLS CipherSpecs and CipherSuites in IBM MQ classes for JMS](https://www.ibm.com/docs/en/ibm-mq/latest?topic=jms-tls-cipherspecs-ciphersuites-in-mq-classes)
358358

359359
## Bindings mode
360360

@@ -367,7 +367,7 @@ By default these samples will run in client mode. If you do want to run the samp
367367
to the `env.json` file.
368368

369369
## Unit Test
370-
The samples also contain unit tests in `src/test`. These tests require connection with a Queue Manager and use the default `env.json` present in the repository, hence make sure you have at least one valid endpoint in the `env.json`.
370+
The samples also contain unit tests in `src/test`. These tests require connection with a Queue Manager and use the default `env.json` present in the repository, hence make sure you have at least one valid endpoint in the `env.json`.Also these tests have not been run on a single CPU machine where the behaviour might be different.
371371

372372
To run these tests, Use the following command:
373373

JMS/src/test/java/com/ibm/mq/samples/jms/JmsSubTest.java renamed to JMS/src/test/java/com/ibm/mq/samples/jms/JmsPubSubTest.java

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
1716
package com.ibm.mq.samples.jms;
1817

1918
import org.junit.jupiter.api.Test;
@@ -25,11 +24,9 @@
2524

2625
import org.junit.jupiter.api.BeforeAll;
2726

28-
public class JmsSubTest {
29-
30-
private static TestLogHandler logHandler;
31-
27+
public class JmsPubSubTest {
3228
//Add a custom logHandler to the logger to get the logs
29+
private static TestLogHandler logHandler;
3330
@BeforeAll
3431
public static void setUp(){
3532
Logger logger = Logger.getLogger("com.ibm.mq.samples.jms");
@@ -38,10 +35,9 @@ public static void setUp(){
3835
logger.addHandler(logHandler);
3936
}
4037

41-
//Test to verify JmsSub
38+
//Test to verify JmsPub and JmsSub
4239
@Test
43-
public void testJmsSub(){
44-
40+
public void testJmsPubSub(){
4541
//Create a thread for Subscription using JmsSub
4642
Thread subThread = new Thread(() -> {
4743
try {
@@ -51,19 +47,15 @@ public void testJmsSub(){
5147
}
5248
});
5349

54-
//Create a thread for Publisher
5550
Thread pubThread = new Thread(() -> {
5651
try {
57-
BasicProducer bp = new BasicProducer(BasicProducer.PRODUCER_PUB);
58-
bp.send("This is a published message from JMS Basic Pub", 1);
59-
bp.close();
52+
JmsPub.main(null);
6053
} catch (Exception e) {
6154
e.printStackTrace();
6255
}
6356
});
6457

6558
subThread.start();
66-
6759
//Wait for subscription to take place before publishing
6860
try {
6961
Thread.sleep(2000);
@@ -78,12 +70,15 @@ public void testJmsSub(){
7870
} catch (Exception e) {
7971
e.printStackTrace();
8072
}
81-
73+
8274
//Assert successful subscription using the logs
8375
String logs = logHandler.getLogs();
8476
assertTrue(logs.contains("Sub application is starting"));
8577
assertTrue(logs.contains("consumer created"));
86-
assertTrue(logs.contains("Received message: This is a published message from JMS Basic Pub"));
78+
assertTrue(logs.contains("Pub application is starting"));
79+
assertTrue(logs.contains("Publishing messages."));
80+
assertTrue(logs.contains("message was sent"));
81+
assertTrue(logs.contains("Received message: this is a message 0"));
82+
assertTrue(logs.contains("Received message: this is a message 19"));
8783
}
8884
}
89-

JMS/src/test/java/com/ibm/mq/samples/jms/JmsPubTest.java

Lines changed: 0 additions & 78 deletions
This file was deleted.

0 commit comments

Comments
 (0)