activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Elliotte Harold" <>
Subject Unit testing, stup and tearDown
Date Tue, 03 Jul 2007 16:09:32 GMT
I have a bunch of ActiveMQ tests that are exhibiting weird behavior. That
is, sometimes they pass and sometimes they fail. I can run a suite and see
seven failures. Then run those tests individually and watch them all pass.

This suggests to me that I'm not properly initializing the queue in setUp or
clearing it out in tearDown. The relevant chunks of code look like this:

public class FooSchedulerTest extends TestCase {

    private ConnectionFactory factory;
    private FooScheduler scheduler;
    private MessageConsumer consumer;
    private MessageProducer producer;
    private Connection connection;
    private FooConfig config;
    private int fooID = 10;
    private Session session;

    protected void setUp() throws Exception {
        factory = new

        config = new FooConfig();
        Foo foo = new Foo(config, null);
        scheduler = new FooScheduler(factory, foo, new
        connection = factory.createConnection();
        Destination dispatcher = new ActiveMQQueue(
        Destination callback = new ActiveMQQueue(
        session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
        consumer = session.createConsumer(dispatcher);
        producer = session.createProducer(callback);

    protected void tearDown() throws Exception {

Can anyone see anything I might be doing wrong or forgetting to do?

Elliotte Rusty Harold

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