AMQMessage message = createMessage("a.b.c");
try
{
_exchange.route(message);
message.routingComplete(_store, _context, new MessageHandleFactory());
}
catch (AMQException nre)
{
fail("Message has route and should be routed");
}
Assert.assertEquals(1, queue.getMessageCount());
Assert.assertEquals("Wrong message recevied", message, queue.getMessagesOnTheQueue().get(0));
queue.deleteMessageFromTop(_context);
Assert.assertEquals(0, queue.getMessageCount());
message = createMessage("a.b");
try
{
_exchange.route(message);
message.routingComplete(_store, _context, new MessageHandleFactory());
}
catch (AMQException nre)
{
fail("Message has route and should be routed");
}
Assert.assertEquals(1, queue.getMessageCount());
Assert.assertEquals("Wrong message recevied", message, queue.getMessagesOnTheQueue().get(0));
queue.deleteMessageFromTop(_context);
Assert.assertEquals(0, queue.getMessageCount());
message = createMessage("a.c");
try
{
_exchange.route(message);
message.routingComplete(_store, _context, new MessageHandleFactory());
}
catch (AMQException nre)
{
fail("Message has route and should be routed");
}
Assert.assertEquals(1, queue.getMessageCount());
Assert.assertEquals("Wrong message recevied", message, queue.getMessagesOnTheQueue().get(0));
queue.deleteMessageFromTop(_context);
Assert.assertEquals(0, queue.getMessageCount());
message = createMessage("a");
try
{
_exchange.route(message);
message.routingComplete(_store, _context, new MessageHandleFactory());
}
catch (AMQException nre)
{
fail("Message has route and should be routed");
}
Assert.assertEquals(1, queue.getMessageCount());
Assert.assertEquals("Wrong message recevied", message, queue.getMessagesOnTheQueue().get(0));
queue.deleteMessageFromTop(_context);
Assert.assertEquals(0, queue.getMessageCount());
message = createMessage("b");
try
{
_exchange.route(message);
message.routingComplete(_store, _context, new MessageHandleFactory());
fail("Message has no route and should fail to be routed");
}
catch (AMQException nre)
{
}