1
votes

enter image description here

with the above consumer.class, when it runs in JUnit , it cannot receive message. but when running via main method directly, it works well. The following is the invoking code:

enter image description here

and the JUnit version is 4.10.

So, would anyone give some point? Thanks a lot in advance!

Of course, when running the two invocation, the JMS server has enough messages waiting for consumption.

1

1 Answers

3
votes

since your testMq() method just registers a listener and doesn't block the test thread, the test case will just stop. try adding Thread.sleep(10000) after the listener is registered but before the test case ends...