Search in sources :

Example 6 with DescribedType

use of org.apache.qpid.proton.amqp.DescribedType in project activemq-artemis by apache.

the class AmqpReceiverTest method testUnsupportedFiltersAreNotListedAsSupported.

@Test(timeout = 60000)
public void testUnsupportedFiltersAreNotListedAsSupported() 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, AmqpUnknownFilterType.UNKNOWN_FILTER_IDS) != null) {
                markAsInvalid("Broker should not return unsupported filter on attach.");
            }
        }
    });
    Map<Symbol, DescribedType> filters = new HashMap<>();
    filters.put(AmqpUnknownFilterType.UNKNOWN_FILTER_NAME, AmqpUnknownFilterType.UNKNOWN_FILTER);
    Source source = new Source();
    source.setAddress(getQueueName());
    source.setFilter(filters);
    source.setDurable(TerminusDurability.NONE);
    source.setExpiryPolicy(TerminusExpiryPolicy.LINK_DETACH);
    AmqpConnection connection = addConnection(client.connect());
    AmqpSession session = connection.createSession();
    assertEquals(0, server.getTotalConsumerCount());
    session.createReceiver(source);
    assertEquals(1, server.getTotalConsumerCount());
    connection.getStateInspector().assertValid();
    connection.close();
}
Also used : AmqpConnection(org.apache.activemq.transport.amqp.client.AmqpConnection) HashMap(java.util.HashMap) Symbol(org.apache.qpid.proton.amqp.Symbol) AmqpClient(org.apache.activemq.transport.amqp.client.AmqpClient) Receiver(org.apache.qpid.proton.engine.Receiver) AmqpReceiver(org.apache.activemq.transport.amqp.client.AmqpReceiver) Source(org.apache.qpid.proton.amqp.messaging.Source) AmqpValidator(org.apache.activemq.transport.amqp.client.AmqpValidator) DescribedType(org.apache.qpid.proton.amqp.DescribedType) AmqpSession(org.apache.activemq.transport.amqp.client.AmqpSession) HashMap(java.util.HashMap) Map(java.util.Map) Test(org.junit.Test)

Example 7 with DescribedType

use of org.apache.qpid.proton.amqp.DescribedType in project activemq-artemis by apache.

the class AmqpReceiverWithFiltersTest method testUnsupportedFiltersAreNotListedAsSupported.

@Test(timeout = 60000)
public void testUnsupportedFiltersAreNotListedAsSupported() 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, AmqpUnknownFilterType.UNKNOWN_FILTER_IDS) != null) {
                markAsInvalid("Broker should not return unsupported filter on attach.");
            }
        }
    });
    Map<Symbol, DescribedType> filters = new HashMap<>();
    filters.put(AmqpUnknownFilterType.UNKNOWN_FILTER_NAME, AmqpUnknownFilterType.UNKNOWN_FILTER);
    Source source = new Source();
    source.setAddress(getQueueName());
    source.setFilter(filters);
    source.setDurable(TerminusDurability.NONE);
    source.setExpiryPolicy(TerminusExpiryPolicy.LINK_DETACH);
    AmqpConnection connection = addConnection(client.connect());
    AmqpSession session = connection.createSession();
    session.createReceiver(source);
    assertEquals(1, server.getTotalConsumerCount());
    connection.getStateInspector().assertValid();
    connection.close();
}
Also used : AmqpConnection(org.apache.activemq.transport.amqp.client.AmqpConnection) HashMap(java.util.HashMap) Symbol(org.apache.qpid.proton.amqp.Symbol) AmqpClient(org.apache.activemq.transport.amqp.client.AmqpClient) Receiver(org.apache.qpid.proton.engine.Receiver) AmqpReceiver(org.apache.activemq.transport.amqp.client.AmqpReceiver) Source(org.apache.qpid.proton.amqp.messaging.Source) AmqpValidator(org.apache.activemq.transport.amqp.client.AmqpValidator) DescribedType(org.apache.qpid.proton.amqp.DescribedType) AmqpSession(org.apache.activemq.transport.amqp.client.AmqpSession) HashMap(java.util.HashMap) Map(java.util.Map) Test(org.junit.Test)

Aggregations

DescribedType (org.apache.qpid.proton.amqp.DescribedType)7 Symbol (org.apache.qpid.proton.amqp.Symbol)6 Map (java.util.Map)5 HashMap (java.util.HashMap)4 Source (org.apache.qpid.proton.amqp.messaging.Source)3 AbstractMap (java.util.AbstractMap)2 AmqpClient (org.apache.activemq.transport.amqp.client.AmqpClient)2 AmqpConnection (org.apache.activemq.transport.amqp.client.AmqpConnection)2 AmqpReceiver (org.apache.activemq.transport.amqp.client.AmqpReceiver)2 AmqpSession (org.apache.activemq.transport.amqp.client.AmqpSession)2 AmqpValidator (org.apache.activemq.transport.amqp.client.AmqpValidator)2 Receiver (org.apache.qpid.proton.engine.Receiver)2 Test (org.junit.Test)2 RuleDescription (com.microsoft.azure.servicebus.rules.RuleDescription)1 Set (java.util.Set)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 ActiveMQQueueExistsException (org.apache.activemq.artemis.api.core.ActiveMQQueueExistsException)1 ActiveMQSecurityException (org.apache.activemq.artemis.api.core.ActiveMQSecurityException)1 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)1 AddressQueryResult (org.apache.activemq.artemis.core.server.AddressQueryResult)1