Search in sources :

Example 6 with AmqpValidator

use of org.apache.activemq.transport.amqp.client.AmqpValidator in project activemq-artemis by apache.

the class AmqpInboundConnectionTest method testBrokerConnectionProperties.

@Test(timeout = 60000)
public void testBrokerConnectionProperties() throws Exception {
    AmqpClient client = createAmqpClient();
    client.setValidator(new AmqpValidator() {

        @Override
        public void inspectOpenedResource(Connection connection) {
            Map<Symbol, Object> properties = connection.getRemoteProperties();
            if (!properties.containsKey(PRODUCT)) {
                markAsInvalid("Broker did not send a queue product name value");
                return;
            }
            if (!properties.containsKey(VERSION)) {
                markAsInvalid("Broker did not send a queue version value");
                return;
            }
            if (!PRODUCT_NAME.equals(properties.get(PRODUCT))) {
                markAsInvalid("Broker did not send a the expected product name");
                return;
            }
            String brokerVersion = VersionLoader.getVersion().getFullVersion();
            if (!brokerVersion.equals(properties.get(VERSION))) {
                markAsInvalid("Broker did not send a the expected product version");
                return;
            }
        }
    });
    AmqpConnection connection = addConnection(client.connect());
    try {
        assertNotNull(connection);
        connection.getStateInspector().assertValid();
    } finally {
        connection.close();
    }
}
Also used : AmqpConnection(org.apache.activemq.transport.amqp.client.AmqpConnection) RemotingConnection(org.apache.activemq.artemis.spi.core.protocol.RemotingConnection) AmqpConnection(org.apache.activemq.transport.amqp.client.AmqpConnection) Connection(org.apache.qpid.proton.engine.Connection) AmqpClient(org.apache.activemq.transport.amqp.client.AmqpClient) Map(java.util.Map) AmqpValidator(org.apache.activemq.transport.amqp.client.AmqpValidator) Test(org.junit.Test)

Example 7 with AmqpValidator

use of org.apache.activemq.transport.amqp.client.AmqpValidator in project activemq-artemis by apache.

the class AmqpBrokerReuqestedHearbeatsTest method testBrokerSendsHalfConfiguredIdleTimeout.

@Test(timeout = 60000)
public void testBrokerSendsHalfConfiguredIdleTimeout() throws Exception {
    AmqpClient client = createAmqpClient();
    assertNotNull(client);
    client.setValidator(new AmqpValidator() {

        @Override
        public void inspectOpenedResource(Connection connection) {
            assertEquals("Broker did not send half the idle timeout", TEST_IDLE_TIMEOUT / 2, connection.getTransport().getRemoteIdleTimeout());
        }
    });
    AmqpConnection connection = addConnection(client.connect());
    assertNotNull(connection);
    connection.getStateInspector().assertValid();
    connection.close();
}
Also used : AmqpConnection(org.apache.activemq.transport.amqp.client.AmqpConnection) Connection(org.apache.qpid.proton.engine.Connection) AmqpConnection(org.apache.activemq.transport.amqp.client.AmqpConnection) AmqpClient(org.apache.activemq.transport.amqp.client.AmqpClient) AmqpValidator(org.apache.activemq.transport.amqp.client.AmqpValidator) Test(org.junit.Test)

Example 8 with AmqpValidator

use of org.apache.activemq.transport.amqp.client.AmqpValidator in project activemq-artemis by apache.

the class AmqpReceiverTest method testReceiverCloseSendsRemoteClose.

@Test(timeout = 60000)
public void testReceiverCloseSendsRemoteClose() throws Exception {
    AmqpClient client = createAmqpClient();
    assertNotNull(client);
    final AtomicBoolean closed = new AtomicBoolean();
    client.setValidator(new AmqpValidator() {

        @Override
        public void inspectClosedResource(Session session) {
            IntegrationTestLogger.LOGGER.info("Session closed: " + session.getContext());
        }

        @Override
        public void inspectDetachedResource(Receiver receiver) {
            markAsInvalid("Broker should not detach receiver linked to closed session.");
        }

        @Override
        public void inspectClosedResource(Receiver receiver) {
            IntegrationTestLogger.LOGGER.info("Receiver closed: " + receiver.getContext());
            closed.set(true);
        }
    });
    AmqpConnection connection = addConnection(client.connect());
    assertNotNull(connection);
    AmqpSession session = connection.createSession();
    assertNotNull(session);
    AmqpReceiver receiver = session.createReceiver(getQueueName());
    assertNotNull(receiver);
    receiver.close();
    assertTrue("Did not process remote close as expected", closed.get());
    connection.getStateInspector().assertValid();
    connection.close();
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) AmqpConnection(org.apache.activemq.transport.amqp.client.AmqpConnection) AmqpSession(org.apache.activemq.transport.amqp.client.AmqpSession) AmqpReceiver(org.apache.activemq.transport.amqp.client.AmqpReceiver) AmqpClient(org.apache.activemq.transport.amqp.client.AmqpClient) Receiver(org.apache.qpid.proton.engine.Receiver) AmqpReceiver(org.apache.activemq.transport.amqp.client.AmqpReceiver) AmqpValidator(org.apache.activemq.transport.amqp.client.AmqpValidator) Session(org.apache.qpid.proton.engine.Session) AmqpSession(org.apache.activemq.transport.amqp.client.AmqpSession) Test(org.junit.Test)

Example 9 with AmqpValidator

use of org.apache.activemq.transport.amqp.client.AmqpValidator in project activemq-artemis by apache.

the class AmqpReceiverTest method testCreateQueueReceiverWithJMSSelector.

@Test(timeout = 60000)
public void testCreateQueueReceiverWithJMSSelector() throws Exception {
    AmqpClient client = createAmqpClient();
    client.setValidator(new AmqpValidator() {

        @SuppressWarnings("unchecked")
        @Override
        public void inspectOpenedResource(Receiver receiver) {
            if (receiver.getRemoteSource() == null) {
                markAsInvalid("Link opened with null source.");
            }
            Source source = (Source) receiver.getRemoteSource();
            Map<Symbol, Object> filters = source.getFilter();
            if (findFilter(filters, JMS_SELECTOR_FILTER_IDS) == null) {
                markAsInvalid("Broker did not return the JMS Filter on Attach");
            }
        }
    });
    AmqpConnection connection = addConnection(client.connect());
    AmqpSession session = connection.createSession();
    session.createReceiver(getQueueName(), "JMSPriority > 8");
    connection.getStateInspector().assertValid();
    connection.close();
}
Also used : AmqpConnection(org.apache.activemq.transport.amqp.client.AmqpConnection) AmqpSession(org.apache.activemq.transport.amqp.client.AmqpSession) AmqpClient(org.apache.activemq.transport.amqp.client.AmqpClient) Receiver(org.apache.qpid.proton.engine.Receiver) AmqpReceiver(org.apache.activemq.transport.amqp.client.AmqpReceiver) HashMap(java.util.HashMap) Map(java.util.Map) Source(org.apache.qpid.proton.amqp.messaging.Source) AmqpValidator(org.apache.activemq.transport.amqp.client.AmqpValidator) Test(org.junit.Test)

Example 10 with AmqpValidator

use of org.apache.activemq.transport.amqp.client.AmqpValidator in project activemq-artemis by apache.

the class AmqpReceiverWithFiltersTest method testSupportedFiltersAreListedAsSupported.

@Test(timeout = 60000)
public void testSupportedFiltersAreListedAsSupported() throws Exception {
    AmqpClient client = createAmqpClient();
    client.setValidator(new AmqpValidator() {

        @SuppressWarnings("unchecked")
        @Override
        public void inspectOpenedResource(Receiver receiver) {
            if (receiver.getRemoteSource() == null) {
                markAsInvalid("Link opened with null source.");
            }
            Source source = (Source) receiver.getRemoteSource();
            Map<Symbol, Object> filters = source.getFilter();
            if (findFilter(filters, AmqpSupport.JMS_SELECTOR_FILTER_IDS) == null) {
                markAsInvalid("Broker should return selector filter on attach.");
            }
        }
    });
    AmqpConnection connection = addConnection(client.connect());
    AmqpSession session = connection.createSession();
    session.createReceiver(getQueueName(), "color = red");
    connection.getStateInspector().assertValid();
    connection.close();
}
Also used : AmqpConnection(org.apache.activemq.transport.amqp.client.AmqpConnection) AmqpSession(org.apache.activemq.transport.amqp.client.AmqpSession) AmqpClient(org.apache.activemq.transport.amqp.client.AmqpClient) Receiver(org.apache.qpid.proton.engine.Receiver) AmqpReceiver(org.apache.activemq.transport.amqp.client.AmqpReceiver) HashMap(java.util.HashMap) Map(java.util.Map) Source(org.apache.qpid.proton.amqp.messaging.Source) AmqpValidator(org.apache.activemq.transport.amqp.client.AmqpValidator) Test(org.junit.Test)

Aggregations

AmqpClient (org.apache.activemq.transport.amqp.client.AmqpClient)21 AmqpConnection (org.apache.activemq.transport.amqp.client.AmqpConnection)21 AmqpValidator (org.apache.activemq.transport.amqp.client.AmqpValidator)21 Test (org.junit.Test)21 AmqpSession (org.apache.activemq.transport.amqp.client.AmqpSession)15 AmqpReceiver (org.apache.activemq.transport.amqp.client.AmqpReceiver)8 Receiver (org.apache.qpid.proton.engine.Receiver)8 Map (java.util.Map)7 AmqpSender (org.apache.activemq.transport.amqp.client.AmqpSender)7 Sender (org.apache.qpid.proton.engine.Sender)7 Connection (org.apache.qpid.proton.engine.Connection)6 HashMap (java.util.HashMap)5 Source (org.apache.qpid.proton.amqp.messaging.Source)5 ErrorCondition (org.apache.qpid.proton.amqp.transport.ErrorCondition)5 RemotingConnection (org.apache.activemq.artemis.spi.core.protocol.RemotingConnection)4 AmqpMessage (org.apache.activemq.transport.amqp.client.AmqpMessage)4 Delivery (org.apache.qpid.proton.engine.Delivery)4 Symbol (org.apache.qpid.proton.amqp.Symbol)3 CountDownLatch (java.util.concurrent.CountDownLatch)2 DescribedType (org.apache.qpid.proton.amqp.DescribedType)2