activemq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From James Strachan <james.strac...@gmail.com>
Subject [HeadsUp] writing test cases for ActiveMQ
Date Thu, 29 Dec 2005 16:51:07 GMT
Its extremely common to write test cases in ActiveMQ that tests that a
certain consumer receives a certain number of messages; or that one of the
available consumers receives enough messages etc. Its also surprisingly hard
to write good test cases that don't :-

* block forever if they fail
* have timing issues in them - on some platforms the concurrency issues and
exact time taken to do things cause tests to fail.

A common gotcha is the use of sleep() inside test cases that work on some
platforms but not on others etc.

To help simplify these kinds of tests we've got a handy utility class called
MessageList which can be used as a MessageListener. They can be chained
together in a parent/child relationship to make assertions about all
messages received across all consumers versus numbers of messages received
per individual consumer. The class is thread safe and uses semaphores to
avoid waiting too long.

I'd recommend folks try use the MessageList class when these kinds of tests
are required - and fix/enhance it where necessary - as its quite common for
us to spend a long time trying to figure out why a particular test case
fails when it turns out to just be a timing issue or a bug in the test
cases's concurrency code.

--

James
-------
http://radio.weblogs.com/0112098/

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message