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