activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Elliotte Harold" <erhar...@gmail.com>
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
ActiveMQConnectionFactory("vm://localhost?broker.persistent=false");

        config = new FooConfig();
        config.setFooID(fooID);
        Foo foo = new Foo(config, null);
        scheduler = new FooScheduler(factory, foo, new
LinkedBlockingQueue());
        connection = factory.createConnection();
        Destination dispatcher = new ActiveMQQueue(
FooScheduler.DISPATCHER_QUEUE_NAME );
        Destination callback = new ActiveMQQueue(
FooScheduler.COMPLETED_JOBS_QUEUE_NAME );
        connection.start();
        session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
        consumer = session.createConsumer(dispatcher);
        producer = session.createProducer(callback);
        super.setUp();
    }

    protected void tearDown() throws Exception {
        connection.close();
        super.tearDown();
    }

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

-- 
Elliotte Rusty Harold
erharold@gmail.com

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