Search in sources :

Example 6 with Queue

use of org.apache.qpid.server.model.Queue in project qpid-broker-j by apache.

the class Session_1_0Test method testReceiveAttachTopicNonDurableNoContainerWithInvalidSelector.

public void testReceiveAttachTopicNonDurableNoContainerWithInvalidSelector() throws Exception {
    final String linkName = "testLink";
    final String address = "amq.direct/" + TOPIC_NAME;
    Attach attach = createTopicAttach(false, linkName, address, true);
    setSelector(attach, "invalid selector");
    _session.receiveAttach(attach);
    assertAttachFailed(_connection, _session, attach);
    final Collection<Queue> queues = _virtualHost.getChildren(Queue.class);
    assertEquals("Unexpected number of queues after attach", 0, queues.size());
}
Also used : Attach(org.apache.qpid.server.protocol.v1_0.type.transport.Attach) Queue(org.apache.qpid.server.model.Queue)

Example 7 with Queue

use of org.apache.qpid.server.model.Queue in project qpid-broker-j by apache.

the class Session_1_0Test method testNullSourceLookup.

public void testNullSourceLookup() throws Exception {
    final String linkName = "testLink";
    final String address = "amq.direct/" + TOPIC_NAME;
    Attach attach = createTopicAttach(true, linkName, address, false);
    _session.receiveAttach(attach);
    assertAttachSent(_connection, _session, attach);
    assertQueues(TOPIC_NAME, LifetimePolicy.PERMANENT);
    sendDetach(_session, attach.getHandle(), false);
    Attach nullSourceAttach = createTopicAttach(true, linkName, address, false);
    nullSourceAttach.setSource(null);
    _session.receiveAttach(nullSourceAttach);
    ArgumentCaptor<FrameBody> frameCapture = ArgumentCaptor.forClass(FrameBody.class);
    verify(_connection, times(3)).sendFrame(eq(_session.getChannelId()), frameCapture.capture());
    Attach sentAttach = (Attach) frameCapture.getAllValues().get(2);
    assertEquals("Unexpected name", nullSourceAttach.getName(), sentAttach.getName());
    assertEquals("Unexpected role", Role.SENDER, sentAttach.getRole());
    assertNotNull("Unexpected source", sentAttach.getSource());
    Source source = (Source) sentAttach.getSource();
    assertEquals("Unexpected address", address, source.getAddress());
    assertTrue("Unexpected source capabilities", Arrays.asList(source.getCapabilities()).contains(Symbol.valueOf("topic")));
    Collection<Queue> queues = _virtualHost.getChildren(Queue.class);
    assertEquals("Unexpected number of queues after unsubscribe", 1, queues.size());
}
Also used : Attach(org.apache.qpid.server.protocol.v1_0.type.transport.Attach) FrameBody(org.apache.qpid.server.protocol.v1_0.type.FrameBody) Queue(org.apache.qpid.server.model.Queue) Source(org.apache.qpid.server.protocol.v1_0.type.messaging.Source)

Example 8 with Queue

use of org.apache.qpid.server.model.Queue in project qpid-broker-j by apache.

the class Session_1_0Test method testSeparateSubscriptionNameSpaces.

public void testSeparateSubscriptionNameSpaces() throws Exception {
    AMQPConnection_1_0 secondConnection = createAmqpConnection_1_0();
    Session_1_0 secondSession = createSession_1_0(secondConnection, 0);
    final String linkName = "testLink";
    final String address = "amq.direct/" + TOPIC_NAME;
    Attach durableSharedWithContainerId = createSharedTopicAttach(true, linkName + "|1", address, false);
    _session.receiveAttach(durableSharedWithContainerId);
    assertAttachSent(_connection, _session, durableSharedWithContainerId, 0);
    Collection<Queue> queues = _virtualHost.getChildren(Queue.class);
    assertEquals("Unexpected number of queues after durable non shared with containerId", 1, queues.size());
    Attach durableNonSharedWithContainerId = createTopicAttach(true, linkName, address, false);
    _session.receiveAttach(durableNonSharedWithContainerId);
    assertAttachFailed(_connection, _session, durableNonSharedWithContainerId, 1);
    queues = _virtualHost.getChildren(Queue.class);
    assertEquals("Unexpected number of queues after durable non shared with containerId", 1, queues.size());
    Attach nonDurableSharedWithContainerId = createSharedTopicAttach(false, linkName + "|3", address, false);
    _session.receiveAttach(nonDurableSharedWithContainerId);
    assertAttachSent(_connection, _session, nonDurableSharedWithContainerId, 3);
    queues = _virtualHost.getChildren(Queue.class);
    assertEquals("Unexpected number of queues after durable non shared with containerId", 2, queues.size());
    Attach durableSharedWithoutContainerId = createSharedTopicAttach(true, linkName + "|4", address, true);
    secondSession.receiveAttach(durableSharedWithoutContainerId);
    assertAttachSent(secondConnection, secondSession, durableSharedWithoutContainerId, 0);
    queues = _virtualHost.getChildren(Queue.class);
    assertEquals("Unexpected number of queues after durable non shared with containerId", 3, queues.size());
    Attach nonDurableSharedWithoutContainerId = createSharedTopicAttach(false, linkName + "|5", address, true);
    secondSession.receiveAttach(nonDurableSharedWithoutContainerId);
    assertAttachSent(secondConnection, secondSession, nonDurableSharedWithoutContainerId, 1);
    queues = _virtualHost.getChildren(Queue.class);
    assertEquals("Unexpected number of queues after durable non shared with containerId", 4, queues.size());
    Attach nonDurableNonSharedWithoutContainerId = createTopicAttach(false, linkName + "|6", address, true);
    secondSession.receiveAttach(nonDurableNonSharedWithoutContainerId);
    assertAttachSent(secondConnection, secondSession, nonDurableNonSharedWithoutContainerId, 2);
    queues = _virtualHost.getChildren(Queue.class);
    assertEquals("Unexpected number of queues after durable non shared with containerId", 5, queues.size());
    Attach nonDurableNonSharedWithContainerId = createTopicAttach(false, linkName + "|6", address, false);
    _session.receiveAttach(nonDurableNonSharedWithContainerId);
    assertAttachSent(_connection, _session, nonDurableNonSharedWithContainerId, 4);
    queues = _virtualHost.getChildren(Queue.class);
    assertEquals("Unexpected number of queues after durable non shared with containerId", 6, queues.size());
}
Also used : Attach(org.apache.qpid.server.protocol.v1_0.type.transport.Attach) Queue(org.apache.qpid.server.model.Queue)

Example 9 with Queue

use of org.apache.qpid.server.model.Queue in project qpid-broker-j by apache.

the class MessageConverter_1_0_to_v0_10 method setExchangeAndRoutingKeyOnDeliveryProperties.

private void setExchangeAndRoutingKeyOnDeliveryProperties(final DeliveryProperties deliveryProps, final MessageMetaData_1_0.MessageHeader_1_0 origHeader, final NamedAddressSpace addressSpace) {
    final String to = origHeader.getTo();
    final String subject = origHeader.getSubject() == null ? "" : origHeader.getSubject();
    final String exchangeName;
    final String routingKey;
    if (to != null && !"".equals(to)) {
        DestinationAddress destinationAddress = new DestinationAddress(addressSpace, to);
        MessageDestination messageDestination = destinationAddress.getMessageDestination();
        if (messageDestination instanceof Queue) {
            exchangeName = "";
            routingKey = messageDestination.getName();
        } else if (messageDestination instanceof Exchange) {
            exchangeName = messageDestination.getName();
            routingKey = "".equals(destinationAddress.getRoutingKey()) ? subject : destinationAddress.getRoutingKey();
        } else {
            exchangeName = "";
            routingKey = to;
        }
    } else {
        exchangeName = "";
        routingKey = subject;
    }
    deliveryProps.setRoutingKey(ensureStr8("to' or 'subject", routingKey));
    deliveryProps.setExchange(ensureStr8("to", exchangeName));
}
Also used : Exchange(org.apache.qpid.server.model.Exchange) MessageDestination(org.apache.qpid.server.message.MessageDestination) Queue(org.apache.qpid.server.model.Queue) DestinationAddress(org.apache.qpid.server.model.DestinationAddress)

Example 10 with Queue

use of org.apache.qpid.server.model.Queue in project qpid-broker-j by apache.

the class PropertyConverter_1_0_to_0_8Test method testToConversionWhenQueueIsSpecified.

public void testToConversionWhenQueueIsSpecified() {
    final String testQueue = "testQueue";
    Properties properties = new Properties();
    properties.setTo(testQueue);
    Message_1_0 message = createTestMessage(properties);
    final Queue queue = mock(Queue.class);
    when(queue.getName()).thenReturn(testQueue);
    when(_namedAddressSpace.getAttainedMessageDestination(testQueue)).thenReturn(queue);
    final AMQMessage convertedMessage = _messageConverter.convert(message, _namedAddressSpace);
    final MessagePublishInfo messagePublishInfo = convertedMessage.getMessagePublishInfo();
    assertEquals("Unexpected exchange", "", messagePublishInfo.getExchange().toString());
    assertEquals("Unexpected routing key", testQueue, messagePublishInfo.getRoutingKey().toString());
}
Also used : MessagePublishInfo(org.apache.qpid.server.protocol.v0_8.transport.MessagePublishInfo) Message_1_0(org.apache.qpid.server.protocol.v1_0.Message_1_0) Matchers.anyString(org.mockito.Matchers.anyString) AMQShortString(org.apache.qpid.server.protocol.v0_8.AMQShortString) ApplicationProperties(org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationProperties) BasicContentHeaderProperties(org.apache.qpid.server.protocol.v0_8.transport.BasicContentHeaderProperties) Properties(org.apache.qpid.server.protocol.v1_0.type.messaging.Properties) Queue(org.apache.qpid.server.model.Queue) AMQMessage(org.apache.qpid.server.protocol.v0_8.AMQMessage)

Aggregations

Queue (org.apache.qpid.server.model.Queue)56 HashMap (java.util.HashMap)14 Exchange (org.apache.qpid.server.model.Exchange)12 MessageDestination (org.apache.qpid.server.message.MessageDestination)11 Attach (org.apache.qpid.server.protocol.v1_0.type.transport.Attach)9 DestinationAddress (org.apache.qpid.server.model.DestinationAddress)8 MessageSource (org.apache.qpid.server.message.MessageSource)6 NamedAddressSpace (org.apache.qpid.server.model.NamedAddressSpace)6 Matchers.anyString (org.mockito.Matchers.anyString)6 ConcurrentLinkedQueue (java.util.concurrent.ConcurrentLinkedQueue)5 ServerMessage (org.apache.qpid.server.message.ServerMessage)5 AbstractConfiguredObject (org.apache.qpid.server.model.AbstractConfiguredObject)5 AccessControlException (java.security.AccessControlException)4 QmfAgentData (org.apache.qpid.qmf2.agent.QmfAgentData)4 AMQShortString (org.apache.qpid.server.protocol.v0_8.AMQShortString)4 MessagePublishInfo (org.apache.qpid.server.protocol.v0_8.transport.MessagePublishInfo)4 Map (java.util.Map)3 AMQMessageHeader (org.apache.qpid.server.message.AMQMessageHeader)3 ReplyTo (org.apache.qpid.server.protocol.v0_10.transport.ReplyTo)3 Source (org.apache.qpid.server.protocol.v1_0.type.messaging.Source)3