Search in sources :

Example 6 with BrokerSpecific

use of org.apache.qpid.tests.utils.BrokerSpecific 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)

Aggregations

SpecificationTest (org.apache.qpid.tests.protocol.SpecificationTest)6 FrameTransport (org.apache.qpid.tests.protocol.v1_0.FrameTransport)6 BrokerSpecific (org.apache.qpid.tests.utils.BrokerSpecific)6 Test (org.junit.Test)6 Begin (org.apache.qpid.server.protocol.v1_0.type.transport.Begin)4 Detach (org.apache.qpid.server.protocol.v1_0.type.transport.Detach)4 Interaction (org.apache.qpid.tests.protocol.v1_0.Interaction)4 Attach (org.apache.qpid.server.protocol.v1_0.type.transport.Attach)3 Header (org.apache.qpid.server.protocol.v1_0.type.messaging.Header)2 Disposition (org.apache.qpid.server.protocol.v1_0.type.transport.Disposition)2 End (org.apache.qpid.server.protocol.v1_0.type.transport.End)2 Flow (org.apache.qpid.server.protocol.v1_0.type.transport.Flow)2 MessageEncoder (org.apache.qpid.tests.protocol.v1_0.MessageEncoder)2 Close (org.apache.qpid.server.protocol.v1_0.type.transport.Close)1 Open (org.apache.qpid.server.protocol.v1_0.type.transport.Open)1