activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "David Siefert" <siefert.david.mailingl...@gmail.com>
Subject Cannot get unit test to pass....
Date Mon, 11 Feb 2008 09:51:45 GMT
Hi,

I am trying to use ActiveMQ to do 'quick & easy' unit testing for JMS
message listeners.  So far, no luck.  I've tried to reduce my problem as
small as possible to pinpoint the problem.  Here is the code:
public class SimpleActiveMQTest {

private ConnectionFactory factory;

private Destination channel = new ActiveMQTopic("t.test.a");

@Before

public void setUp() throws Exception {

factory = new
ActiveMQConnectionFactory("vm://localhost?broker.persistent=false");

}

@Test

public void testDestinationToDestination() throws Exception {

Connection connection = factory.createConnection();

Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);

MessageProducer producer = session.createProducer(channel);

TextMessage message = session.createTextMessage("TEST");

producer.send(message);

MessageConsumer consumer = session.createConsumer(channel);

TextMessage message2 = (TextMessage) consumer.receive(30 * 1000);

Assert.assertNotNull(message2);

Assert.assertEquals("TEST", message2.getText());

}

}

I've tried quite a few variations including opening separate connections
(one to produce to the channel, the other to consume from the channel).
I've also tried creating the topic prior to producing/consuming--just to
verify whether or not ActiveMQ creates the channels on the fly.

Help?

Thanks,

David

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