drjava-

I have heard of people having trouble with JUnit when they start using
multiple threads because JTest relies on the Exception mechanism and is only
watching the main thread. I'm not sure if that applies in your case because
it doesn't look like you're making assertions within a separate thread, but
I thought I'd pass along the information in case it is helpful.

Joshua Smith


On Thu, Jun 12, 2008 at 12:33 PM, drjava <[EMAIL PROTECTED]> wrote:

>
> I am using ActiveMQ embedded in my Junit test.
> I have a JmsMessenger that uses a JmsTemplate to send the messages and a
> MessageReceiver to receive the messages.
> The test goal is to verify that all messages that were sent were also
> received (compare numbers and the actual message objects for equality).
>
> How it works: send out 100 unique messages (using a
> SingleConnectionFactory)
> .
> The MessageReceiver intercepts them and collects them in a List.
> Compare that the total received and sent are equal.
> Compare the received list's items to the sent ones, make sure the messages
> did not get corrupted.
>
> However, on each and every run the test fails on the first assertion -
> comparing the total sent and received numbers.
>
> Moreover this - on each run the total received number is different. (after
> sending is complete the main thread awaits for 1 minute, which I consider a
> long enough time to intercept 100 messages, so that the receiver gets the
> opportunity to catch up)
>
> According to the JmsTemplate all messages are successfully sent (the call
> to
> convertAndSend is surrounded by a try/catch block and no JmsException is
> being caught).
>
> Emvironment details:
> IDE - eclipse 3.3.2
> test runner - Junit 4.4
> ActiveMQ version - 5.1.0
> VM - Java 1.6_0_06
> OS - Windows XP 64bits
> hardware - Dell Intel dual core, 2.66GH, 3.93 GB of RAM
>
> Perhaps I don't fully understand how to best use Active MQ embedded in my
> test. Are there any special settings of the broker's properties I should
> exercise?
>
> I am attaching a few files to support understanding of my test scenario:
>
> spring-config.xml (this configures the jms template and the message
> receiver
> and jms messenger and all the rest)
> http://www.nabble.com/file/p17804229/spring-config.xml spring-config.xml
>
> JmsMessengerTest.java the test class
> http://www.nabble.com/file/p17804229/JmsMessengerTest.java
> JmsMessengerTest.java
>
> MessageReceiver.java
> http://www.nabble.com/file/p17804229/MessageReceiver.java
> MessageReceiver.java
>
> JmsLogMessenger.java
> http://www.nabble.com/file/p17804229/JmsLogMessenger.java
> JmsLogMessenger.java
> --
> View this message in context:
> http://www.nabble.com/Lost-messages----not-all-messages-sent-to-the-queue-are-delivered-to-the-message-receiver-tp17804229p17804229.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>
>

Reply via email to