Search in sources :

Example 6 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 testReceiveAttachTopicNonDurableNoContainer.

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

Example 7 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 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 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 testReceiveAttachToExistingQueue.

public void testReceiveAttachToExistingQueue() throws Exception {
    final String linkName = "testLink";
    Attach attach = createQueueAttach(false, linkName, QUEUE_NAME);
    Queue<?> queue = _virtualHost.createChild(Queue.class, Collections.singletonMap(Queue.NAME, QUEUE_NAME));
    Exchange<?> exchange = _virtualHost.getChildByName(Exchange.class, "amq.direct");
    exchange.bind(QUEUE_NAME, QUEUE_NAME, Collections.emptyMap(), false);
    _session.receiveAttach(attach);
    assertAttachActions(queue, attach);
}
Also used : Attach(org.apache.qpid.server.protocol.v1_0.type.transport.Attach)

Example 9 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 assertAttachFailed.

private void assertAttachFailed(final AMQPConnection_1_0 connection, final Session_1_0 session, final Attach attach, int invocationOffset) {
    ArgumentCaptor<FrameBody> frameCapture = ArgumentCaptor.forClass(FrameBody.class);
    verify(connection, times(invocationOffset + 2)).sendFrame(eq(session.getChannelId()), frameCapture.capture());
    List<FrameBody> sentFrames = frameCapture.getAllValues();
    assertTrue("unexpected Frame sent", sentFrames.get(invocationOffset) instanceof Attach);
    Attach sentAttach = (Attach) sentFrames.get(invocationOffset);
    assertEquals("Unexpected name", attach.getName(), sentAttach.getName());
    assertEquals("Unexpected role", Role.SENDER, sentAttach.getRole());
    assertEquals("Unexpected source", null, sentAttach.getSource());
    assertTrue("unexpected Frame sent", sentFrames.get(invocationOffset + 1) instanceof Detach);
    Detach sentDetach = (Detach) sentFrames.get(invocationOffset + 1);
    assertTrue("Unexpected closed state", sentDetach.getClosed());
}
Also used : Attach(org.apache.qpid.server.protocol.v1_0.type.transport.Attach) FrameBody(org.apache.qpid.server.protocol.v1_0.type.FrameBody) Detach(org.apache.qpid.server.protocol.v1_0.type.transport.Detach)

Example 10 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 testReceiveAttachToNonExistingQueue.

public void testReceiveAttachToNonExistingQueue() throws Exception {
    final String linkName = "testLink";
    Attach attach = createQueueAttach(false, linkName, QUEUE_NAME);
    _session.receiveAttach(attach);
    assertAttachFailed(_connection, _session, attach);
}
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