MessageConsumer cons;
// default (create never, assert never) -------------------
// create never --------------------------------------------
String addr1 = "ADDR:testQueue1";
AMQDestination dest = new AMQAnyDestination(addr1);
try
{
cons = jmsSession.createConsumer(dest);
}
catch(JMSException e)
{
assertTrue(e.getMessage().contains("The name 'testQueue1' supplied in the address " +
"doesn't resolve to an exchange or a queue"));
}
try
{
prod = jmsSession.createProducer(dest);
}
catch(JMSException e)
{
assertTrue(e.getCause().getCause().getMessage().contains("The name 'testQueue1' supplied in the address " +
"doesn't resolve to an exchange or a queue"));
}
assertFalse("Queue should not be created",(
(AMQSession_0_10)jmsSession).isQueueExist(dest, (QueueNode)dest.getSourceNode() ,true));
// create always -------------------------------------------
addr1 = "ADDR:testQueue1; { create: always }";
dest = new AMQAnyDestination(addr1);
cons = jmsSession.createConsumer(dest);
assertTrue("Queue not created as expected",(
(AMQSession_0_10)jmsSession).isQueueExist(dest,(QueueNode)dest.getSourceNode(), true));
assertTrue("Queue not bound as expected",(
(AMQSession_0_10)jmsSession).isQueueBound("",
dest.getAddressName(),dest.getAddressName(), dest.getSourceNode().getDeclareArgs()));
// create receiver -----------------------------------------
addr1 = "ADDR:testQueue2; { create: receiver }";
dest = new AMQAnyDestination(addr1);
try
{
prod = jmsSession.createProducer(dest);
}
catch(JMSException e)
{
assertTrue(e.getCause().getCause().getMessage().contains("The name 'testQueue2' supplied in the address " +
"doesn't resolve to an exchange or a queue"));
}
assertFalse("Queue should not be created",(
(AMQSession_0_10)jmsSession).isQueueExist(dest,(QueueNode)dest.getSourceNode(), true));
cons = jmsSession.createConsumer(dest);
assertTrue("Queue not created as expected",(
(AMQSession_0_10)jmsSession).isQueueExist(dest,(QueueNode)dest.getSourceNode(), true));
assertTrue("Queue not bound as expected",(
(AMQSession_0_10)jmsSession).isQueueBound("",
dest.getAddressName(),dest.getAddressName(), dest.getSourceNode().getDeclareArgs()));
// create never --------------------------------------------
addr1 = "ADDR:testQueue3; { create: never }";
dest = new AMQAnyDestination(addr1);
try
{
cons = jmsSession.createConsumer(dest);
}
catch(JMSException e)
{
assertTrue(e.getMessage().contains("The name 'testQueue3' supplied in the address " +
"doesn't resolve to an exchange or a queue"));
}
try
{
prod = jmsSession.createProducer(dest);
}
catch(JMSException e)
{
assertTrue(e.getCause().getCause().getMessage().contains("The name 'testQueue3' supplied in the address " +
"doesn't resolve to an exchange or a queue"));
}
assertFalse("Queue should not be created",(
(AMQSession_0_10)jmsSession).isQueueExist(dest,(QueueNode)dest.getSourceNode(), true));
// create sender ------------------------------------------
addr1 = "ADDR:testQueue3; { create: sender }";
dest = new AMQAnyDestination(addr1);
try
{
cons = jmsSession.createConsumer(dest);
}
catch(JMSException e)
{
assertTrue(e.getMessage().contains("The name 'testQueue3' supplied in the address " +
"doesn't resolve to an exchange or a queue"));
}
assertFalse("Queue should not be created",(
(AMQSession_0_10)jmsSession).isQueueExist(dest,(QueueNode)dest.getSourceNode(), true));
prod = jmsSession.createProducer(dest);
assertTrue("Queue not created as expected",(
(AMQSession_0_10)jmsSession).isQueueExist(dest,(QueueNode)dest.getSourceNode(), true));
assertTrue("Queue not bound as expected",(
(AMQSession_0_10)jmsSession).isQueueBound("",
dest.getAddressName(),dest.getAddressName(), dest.getSourceNode().getDeclareArgs()));
}