Search in sources :

Example 66 with Attach

use of org.apache.qpid.server.protocol.v1_0.type.transport.Attach in project qpid-broker-j by apache.

the class Session_1_0Test method assertAttachSent.

private void assertAttachSent(final AMQPConnection_1_0 connection, final Session_1_0 session, final Attach receivedAttach, final int invocationOffset) {
    Attach sentAttach = captureAttach(connection, session, invocationOffset);
    assertEquals("Unexpected name", receivedAttach.getName(), sentAttach.getName());
    assertEquals("Unexpected role", Role.SENDER, sentAttach.getRole());
}
Also used : Attach(org.apache.qpid.server.protocol.v1_0.type.transport.Attach)

Example 67 with Attach

use of org.apache.qpid.server.protocol.v1_0.type.transport.Attach in project qpid-broker-j by apache.

the class Session_1_0Test method testReceiveAttachSharedTopicNonDurableNoContainer.

public void testReceiveAttachSharedTopicNonDurableNoContainer() throws Exception {
    final String linkName = "testLink";
    final String address = "amq.direct/" + TOPIC_NAME;
    Attach attach = createSharedTopicAttach(false, linkName, address, true);
    Attach attach2 = createSharedTopicAttach(false, linkName, address, true);
    _session.receiveAttach(attach);
    assertAttachSent(_connection, _session, attach);
    assertQueues(TOPIC_NAME, LifetimePolicy.DELETE_ON_NO_OUTBOUND_LINKS);
    AMQPConnection_1_0 secondConnection = createAmqpConnection_1_0();
    Session_1_0 secondSession = createSession_1_0(secondConnection, 0);
    secondSession.receiveAttach(attach2);
    assertAttachSent(secondConnection, secondSession, attach2);
    assertQueues(TOPIC_NAME, LifetimePolicy.DELETE_ON_NO_OUTBOUND_LINKS);
    final Collection<Queue> queues = _virtualHost.getChildren(Queue.class);
    assertEquals("Unexpected number of queues after attach", 1, queues.size());
    Queue<?> queue = queues.iterator().next();
    Collection<QueueConsumer<?, ?>> consumers = queue.getConsumers();
    assertEquals("Unexpected number of consumers", 2, consumers.size());
}
Also used : QueueConsumer(org.apache.qpid.server.queue.QueueConsumer) Attach(org.apache.qpid.server.protocol.v1_0.type.transport.Attach) Queue(org.apache.qpid.server.model.Queue)

Example 68 with Attach

use of org.apache.qpid.server.protocol.v1_0.type.transport.Attach in project qpid-broker-j by apache.

the class Session_1_0Test method testReceiveAttachTopicNonDurableNoContainerWithValidSelector.

public void testReceiveAttachTopicNonDurableNoContainerWithValidSelector() throws Exception {
    final String linkName = "testLink";
    final String address = "amq.direct/" + TOPIC_NAME;
    final String selectorExpression = "test='test'";
    Attach attach = createTopicAttach(false, linkName, address, true);
    setSelector(attach, selectorExpression);
    _session.receiveAttach(attach);
    Attach sentAttach = captureAttach(_connection, _session, 0);
    assertEquals("Unexpected name", attach.getName(), sentAttach.getName());
    assertEquals("Unexpected role", Role.SENDER, sentAttach.getRole());
    assertFilter(sentAttach, selectorExpression);
    assertQueues(TOPIC_NAME, LifetimePolicy.DELETE_ON_NO_OUTBOUND_LINKS);
    Binding binding = findBinding("amq.direct", TOPIC_NAME);
    assertNotNull("Binding is not found", binding);
    Map<String, Object> arguments = binding.getArguments();
    assertNotNull("Unexpected arguments", arguments);
    assertEquals("Unexpected filter on binding", selectorExpression, arguments.get(AMQPFilterTypes.JMS_SELECTOR.toString()));
}
Also used : Binding(org.apache.qpid.server.model.Binding) Attach(org.apache.qpid.server.protocol.v1_0.type.transport.Attach)

Example 69 with Attach

use of org.apache.qpid.server.protocol.v1_0.type.transport.Attach in project qpid-broker-j by apache.

the class Session_1_0Test method testReceiveAttachTopicDurableWithContainer.

public void testReceiveAttachTopicDurableWithContainer() throws Exception {
    final String linkName = "testLink";
    final String address = "amq.direct/" + TOPIC_NAME;
    Attach attach = createTopicAttach(true, linkName + "|1", address, false);
    _session.receiveAttach(attach);
    assertAttachSent(_connection, _session, attach);
    assertQueues(TOPIC_NAME, LifetimePolicy.PERMANENT);
    AMQPConnection_1_0 secondConnection = createAmqpConnection_1_0("testContainerId2");
    Session_1_0 secondSession = createSession_1_0(secondConnection, 0);
    Attach attach2 = createTopicAttach(true, linkName + "|2", address, false);
    secondSession.receiveAttach(attach2);
    assertAttachSent(secondConnection, secondSession, attach2);
    Collection<Queue> queues = _virtualHost.getChildren(Queue.class);
    assertEquals("Unexpected number of queues after second subscription with the same subscription name but different container id ", 2, queues.size());
}
Also used : Attach(org.apache.qpid.server.protocol.v1_0.type.transport.Attach) Queue(org.apache.qpid.server.model.Queue)

Example 70 with Attach

use of org.apache.qpid.server.protocol.v1_0.type.transport.Attach in project qpid-broker-j by apache.

the class Session_1_0Test method testReceiveAttachTopicDurableNoContainer.

public void testReceiveAttachTopicDurableNoContainer() throws Exception {
    final String linkName = "testLink";
    final String address = "amq.direct/" + TOPIC_NAME;
    Attach attach = createTopicAttach(true, linkName, address, true);
    _session.receiveAttach(attach);
    assertAttachSent(_connection, _session, attach);
    assertQueues(TOPIC_NAME, LifetimePolicy.PERMANENT);
}
Also used : Attach(org.apache.qpid.server.protocol.v1_0.type.transport.Attach)

Aggregations

Attach (org.apache.qpid.server.protocol.v1_0.type.transport.Attach)85 Test (org.junit.Test)84 SpecificationTest (org.apache.qpid.tests.protocol.SpecificationTest)82 FrameTransport (org.apache.qpid.tests.protocol.v1_0.FrameTransport)82 Interaction (org.apache.qpid.tests.protocol.v1_0.Interaction)70 Begin (org.apache.qpid.server.protocol.v1_0.type.transport.Begin)39 Open (org.apache.qpid.server.protocol.v1_0.type.transport.Open)37 Flow (org.apache.qpid.server.protocol.v1_0.type.transport.Flow)36 UnsignedInteger (org.apache.qpid.server.protocol.v1_0.type.UnsignedInteger)32 Disposition (org.apache.qpid.server.protocol.v1_0.type.transport.Disposition)32 Binary (org.apache.qpid.server.protocol.v1_0.type.Binary)27 InteractionTransactionalState (org.apache.qpid.tests.protocol.v1_0.InteractionTransactionalState)24 Error (org.apache.qpid.server.protocol.v1_0.type.transport.Error)23 Detach (org.apache.qpid.server.protocol.v1_0.type.transport.Detach)20 AmqpError (org.apache.qpid.server.protocol.v1_0.type.transport.AmqpError)18 Accepted (org.apache.qpid.server.protocol.v1_0.type.messaging.Accepted)17 Source (org.apache.qpid.server.protocol.v1_0.type.messaging.Source)17 DeliveryState (org.apache.qpid.server.protocol.v1_0.type.DeliveryState)14 InetSocketAddress (java.net.InetSocketAddress)13 TransactionError (org.apache.qpid.server.protocol.v1_0.type.transaction.TransactionError)11