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)));
}
}
Aggregations