Search in sources :

Example 11 with InvalidDestinationException

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 + "'"));
}
Also used : Connection(javax.jms.Connection) InvalidDestinationException(javax.jms.InvalidDestinationException) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) Topic(javax.jms.Topic) InvalidDestinationException(javax.jms.InvalidDestinationException) Session(javax.jms.Session) ClientSession(org.apache.activemq.artemis.api.core.client.ClientSession) Test(org.junit.Test)

Example 12 with InvalidDestinationException

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();
        }
    }
}
Also used : Connection(javax.jms.Connection) InvalidDestinationException(javax.jms.InvalidDestinationException) Topic(javax.jms.Topic) Session(javax.jms.Session) Test(org.junit.Test)

Example 13 with InvalidDestinationException

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();
        }
    }
}
Also used : Connection(javax.jms.Connection) TopicConnection(javax.jms.TopicConnection) InvalidDestinationException(javax.jms.InvalidDestinationException) JMSException(javax.jms.JMSException) Queue(javax.jms.Queue) Session(javax.jms.Session) TopicSession(javax.jms.TopicSession) Test(org.junit.Test)

Example 14 with InvalidDestinationException

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();
        }
    }
}
Also used : Connection(javax.jms.Connection) TopicConnection(javax.jms.TopicConnection) InvalidDestinationException(javax.jms.InvalidDestinationException) JMSException(javax.jms.JMSException) Topic(javax.jms.Topic) Session(javax.jms.Session) TopicSession(javax.jms.TopicSession) Test(org.junit.Test)

Example 15 with InvalidDestinationException

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();
        }
    }
}
Also used : Connection(javax.jms.Connection) InvalidDestinationException(javax.jms.InvalidDestinationException) JMSException(javax.jms.JMSException) Queue(javax.jms.Queue) ClientSession(org.apache.activemq.artemis.api.core.client.ClientSession) Session(javax.jms.Session) Test(org.junit.Test)

Aggregations

InvalidDestinationException (javax.jms.InvalidDestinationException)38 Test (org.junit.Test)20 Session (javax.jms.Session)18 Connection (javax.jms.Connection)17 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)13 JMSException (javax.jms.JMSException)11 Topic (javax.jms.Topic)11 MessageProducer (javax.jms.MessageProducer)10 Queue (javax.jms.Queue)9 ClientSession (org.apache.activemq.artemis.api.core.client.ClientSession)9 TextMessage (javax.jms.TextMessage)8 TopicSession (javax.jms.TopicSession)7 ActiveMQException (org.apache.activemq.artemis.api.core.ActiveMQException)7 IllegalStateException (javax.jms.IllegalStateException)5 QueueSession (javax.jms.QueueSession)5 TopicConnection (javax.jms.TopicConnection)5 ActiveMQQueueExistsException (org.apache.activemq.artemis.api.core.ActiveMQQueueExistsException)4 AddressQuery (org.apache.activemq.artemis.api.core.client.ClientSession.AddressQuery)4 BytesMessage (javax.jms.BytesMessage)3 MessageConsumer (javax.jms.MessageConsumer)3