use of javax.jms.InvalidDestinationException in project activemq-artemis by apache.
the class AmqpFullyQualifiedNameTest method testSubscribeTopicToFQQNWrongQueueAttachedToAnotherAddress.
@Test
public void testSubscribeTopicToFQQNWrongQueueAttachedToAnotherAddress() throws Exception {
// Create 2 Queues: address1::queue1, address2::queue2
String address1 = "a1";
String address2 = "a2";
String queue1 = "q1";
String queue2 = "q2";
server.createQueue(SimpleString.toSimpleString(address1), RoutingType.MULTICAST, SimpleString.toSimpleString(queue1), null, true, false, -1, false, true);
server.createQueue(SimpleString.toSimpleString(address2), RoutingType.MULTICAST, SimpleString.toSimpleString(queue2), null, true, false, -1, false, true);
Exception e = null;
// Wrong FQQN. Attempt to subscribe to a queue belonging to a different address than given in the FQQN.
String wrongFQQN = address1 + "::" + queue2;
Connection connection = createConnection(false);
try {
connection.setClientID("FQQNconn");
connection.start();
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
Topic topic = session.createTopic(wrongFQQN);
session.createConsumer(topic);
} catch (InvalidDestinationException ide) {
e = ide;
} finally {
connection.close();
}
assertNotNull(e);
assertTrue(e.getMessage().contains("Queue: '" + queue2 + "' does not exist for address '" + address1 + "'"));
}
use of javax.jms.InvalidDestinationException in project activemq-artemis by apache.
the class DurableSubscriptionTest method testDurableSubscriptionOnTemporaryTopic.
@Test
public void testDurableSubscriptionOnTemporaryTopic() throws Exception {
Connection conn = null;
conn = createConnection();
try {
conn.setClientID("doesn't actually matter");
Session s = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
Topic temporaryTopic = s.createTemporaryTopic();
try {
s.createDurableSubscriber(temporaryTopic, "mySubscription");
ProxyAssertSupport.fail("this should throw exception");
} catch (InvalidDestinationException e) {
// OK
}
} finally {
if (conn != null) {
conn.close();
}
}
}
use of javax.jms.InvalidDestinationException in project activemq-artemis by apache.
the class MessageConsumerTest method testCreateConsumerOnNonExistentQueue.
@Test
public void testCreateConsumerOnNonExistentQueue() throws Exception {
Connection pconn = null;
try {
pconn = createConnection();
Session ps = pconn.createSession(false, Session.AUTO_ACKNOWLEDGE);
try {
ps.createConsumer(new Queue() {
@Override
public String getQueueName() throws JMSException {
return "NoSuchQueue";
}
});
ProxyAssertSupport.fail("should throw exception");
} catch (InvalidDestinationException e) {
// OK
}
} finally {
if (pconn != null) {
pconn.close();
}
}
}
use of javax.jms.InvalidDestinationException in project activemq-artemis by apache.
the class MessageConsumerTest method testCreateConsumerOnNonExistentTopic.
//
// Invalid destination test
//
@Test
public void testCreateConsumerOnNonExistentTopic() throws Exception {
Connection pconn = null;
try {
pconn = createConnection();
Session ps = pconn.createSession(false, Session.AUTO_ACKNOWLEDGE);
try {
ps.createConsumer(new Topic() {
@Override
public String getTopicName() throws JMSException {
return "NoSuchTopic";
}
});
ProxyAssertSupport.fail("should throw exception");
} catch (InvalidDestinationException e) {
// OK
}
} finally {
if (pconn != null) {
pconn.close();
}
}
}
use of javax.jms.InvalidDestinationException in project activemq-artemis by apache.
the class BrowserTest method testCreateBrowserOnNonExistentQueue.
@Test
public void testCreateBrowserOnNonExistentQueue() throws Exception {
Connection pconn = getConnectionFactory().createConnection();
try {
Session ps = pconn.createSession(false, Session.AUTO_ACKNOWLEDGE);
try {
ps.createBrowser(new Queue() {
@Override
public String getQueueName() throws JMSException {
return "NoSuchQueue";
}
});
ProxyAssertSupport.fail("should throw exception");
} catch (InvalidDestinationException e) {
// OK
}
} finally {
if (pconn != null) {
pconn.close();
}
}
}
Aggregations