Search in sources :

Example 56 with Detach

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

the class LinkStealingTest method subsequentAttachOnDifferentSessions.

@Test
@SpecificationTest(section = "2.6.1. Naming a link", description = "Qpid Broker J extended stolen behaviour on sessions")
@BrokerSpecific(kind = BrokerAdmin.KIND_BROKER_J)
public void subsequentAttachOnDifferentSessions() throws Exception {
    getBrokerAdmin().createQueue(BrokerAdmin.TEST_QUEUE_NAME);
    try (FrameTransport transport = new FrameTransport(getBrokerAdmin()).connect()) {
        final Interaction interaction = transport.newInteraction();
        final String linkName = "test";
        final Attach responseAttach = interaction.negotiateOpen().begin().consumeResponse(Begin.class).attachRole(Role.SENDER).attachName(linkName).attachTargetAddress(BrokerAdmin.TEST_QUEUE_NAME).attach().consumeResponse().getLatestResponse(Attach.class);
        assertThat(responseAttach.getName(), is(notNullValue()));
        assertThat(responseAttach.getHandle().longValue(), is(both(greaterThanOrEqualTo(0L)).and(lessThan(UnsignedInteger.MAX_VALUE.longValue()))));
        assertThat(responseAttach.getRole(), is(Role.RECEIVER));
        interaction.consumeResponse(Flow.class);
        final Detach stolenDetach = interaction.sessionChannel(UnsignedShort.valueOf(2)).begin().consumeResponse(Begin.class).attachRole(Role.SENDER).attachName(linkName).attachInitialDeliveryCount(UnsignedInteger.ZERO).attach().consume(Detach.class, Attach.class, Flow.class, Disposition.class);
        assertThat(stolenDetach.getHandle().longValue(), is(equalTo(responseAttach.getHandle().longValue())));
        assertThat(stolenDetach.getError(), is(notNullValue()));
        assertThat(stolenDetach.getError().getCondition(), is(equalTo(LinkError.STOLEN)));
    }
}
Also used : FrameTransport(org.apache.qpid.tests.protocol.v1_0.FrameTransport) Interaction(org.apache.qpid.tests.protocol.v1_0.Interaction) Attach(org.apache.qpid.server.protocol.v1_0.type.transport.Attach) Begin(org.apache.qpid.server.protocol.v1_0.type.transport.Begin) Detach(org.apache.qpid.server.protocol.v1_0.type.transport.Detach) Test(org.junit.Test) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest) BrokerSpecific(org.apache.qpid.tests.utils.BrokerSpecific) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest)

Example 57 with Detach

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

the class Session_1_0Test method testReceiveReattachRebindingQueueNoActiveLinks.

@Test
public void testReceiveReattachRebindingQueueNoActiveLinks() {
    final String linkName = "testLink";
    final String address = "amq.direct/" + TOPIC_NAME;
    Attach attach = createSharedTopicAttach(true, linkName, address, true);
    _session.receiveAttach(attach);
    assertAttachSent(_connection, _session, attach);
    assertQueues(TOPIC_NAME, LifetimePolicy.PERMANENT);
    sendDetach(_session, attach.getHandle(), false);
    ArgumentCaptor<FrameBody> frameCapture = ArgumentCaptor.forClass(FrameBody.class);
    verify(_connection, times(2)).sendFrame(eq(_session.getChannelId()), frameCapture.capture());
    final boolean condition = frameCapture.getAllValues().get(1) instanceof Detach;
    assertTrue(condition);
    assertQueues(TOPIC_NAME, LifetimePolicy.PERMANENT);
    String topicName2 = TOPIC_NAME + "2";
    final String address2 = "amq.direct/" + topicName2;
    Attach attach2 = createSharedTopicAttach(true, linkName, address2, true);
    _session.receiveAttach(attach2);
    assertAttachSent(_connection, _session, attach2, 2);
    assertQueues(topicName2, LifetimePolicy.PERMANENT);
}
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) Test(org.junit.Test)

Aggregations

Detach (org.apache.qpid.server.protocol.v1_0.type.transport.Detach)43 Test (org.junit.Test)41 Attach (org.apache.qpid.server.protocol.v1_0.type.transport.Attach)39 FrameTransport (org.apache.qpid.tests.protocol.v1_0.FrameTransport)39 Interaction (org.apache.qpid.tests.protocol.v1_0.Interaction)37 SpecificationTest (org.apache.qpid.tests.protocol.SpecificationTest)34 Begin (org.apache.qpid.server.protocol.v1_0.type.transport.Begin)19 Flow (org.apache.qpid.server.protocol.v1_0.type.transport.Flow)15 UnsignedInteger (org.apache.qpid.server.protocol.v1_0.type.UnsignedInteger)13 Binary (org.apache.qpid.server.protocol.v1_0.type.Binary)12 Error (org.apache.qpid.server.protocol.v1_0.type.transport.Error)12 DeliveryState (org.apache.qpid.server.protocol.v1_0.type.DeliveryState)10 Disposition (org.apache.qpid.server.protocol.v1_0.type.transport.Disposition)9 Accepted (org.apache.qpid.server.protocol.v1_0.type.messaging.Accepted)8 Source (org.apache.qpid.server.protocol.v1_0.type.messaging.Source)8 TransactionError (org.apache.qpid.server.protocol.v1_0.type.transaction.TransactionError)8 Ignore (org.junit.Ignore)8 HashMap (java.util.HashMap)7 AmqpError (org.apache.qpid.server.protocol.v1_0.type.transport.AmqpError)7 End (org.apache.qpid.server.protocol.v1_0.type.transport.End)7