use of org.apache.qpid.server.protocol.v1_0.type.transport.Detach in project qpid-broker-j by apache.
the class ResumeDeliveriesTest method resumeSendingLinkSinglePartialDelivery.
@Ignore("QPID-7845")
@Test
@SpecificationTest(section = "2.6.13", description = "When a suspended link having unsettled deliveries is resumed, the unsettled field from the" + " attach frame will carry the delivery-tags and delivery state of all deliveries" + " considered unsettled by the issuing link endpoint.")
public void resumeSendingLinkSinglePartialDelivery() throws Exception {
final String destination = BrokerAdmin.TEST_QUEUE_NAME;
final Binary deliveryTag = new Binary("testDeliveryTag".getBytes(StandardCharsets.UTF_8));
QpidByteBuffer[] messagePayload = Utils.splitPayload("testData1", 2);
try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
final UnsignedInteger linkHandle1 = UnsignedInteger.ZERO;
final Interaction interaction = transport.newInteraction();
interaction.negotiateProtocol().consumeResponse().open().consumeResponse(Open.class).begin().consumeResponse(Begin.class);
// 1. attach with ReceiverSettleMode.SECOND
interaction.attachHandle(linkHandle1).attachRole(Role.SENDER).attachTargetAddress(destination).attach().consumeResponse(Attach.class).consumeResponse(Flow.class);
// 2. send a partial delivery
interaction.transferHandle(linkHandle1).transferDeliveryId(UnsignedInteger.ZERO).transferDeliveryTag(deliveryTag).transferMore(true).transferPayload(messagePayload[0]).transfer();
// 3. detach the link
interaction.detach().consumeResponse(Detach.class);
// 4. resume the link
final UnsignedInteger linkHandle2 = UnsignedInteger.ONE;
final Attach responseAttach2 = interaction.attachHandle(linkHandle2).attachUnsettled(Collections.singletonMap(deliveryTag, null)).attach().consumeResponse().getLatestResponse(Attach.class);
// 5. assert content of unsettled map
assertThat(responseAttach2.getTarget(), is(notNullValue()));
final Map<Binary, DeliveryState> remoteUnsettled = responseAttach2.getUnsettled();
assertThat(remoteUnsettled, is(notNullValue()));
assertThat(remoteUnsettled.keySet(), is(equalTo(Collections.singleton(deliveryTag))));
interaction.transferHandle(linkHandle2).transferResume(true).transfer().sync().transferMore(false).transferPayload(messagePayload[1]).transfer();
for (final QpidByteBuffer payload : messagePayload) {
payload.dispose();
}
boolean settled = false;
do {
interaction.consumeResponse();
Response<?> response = interaction.getLatestResponse();
assertThat(response, is(notNullValue()));
Object body = response.getBody();
if (body instanceof Disposition) {
Disposition disposition = (Disposition) body;
assertThat(disposition.getSettled(), is(Matchers.equalTo(true)));
assertThat(disposition.getFirst(), equalTo(UnsignedInteger.ZERO));
settled = true;
} else if (!(body instanceof Flow)) {
fail("Unexpected response " + body);
}
} while (!settled);
interaction.doCloseConnection();
}
}
use of org.apache.qpid.server.protocol.v1_0.type.transport.Detach in project qpid-broker-j by apache.
the class ResumeDeliveriesTest method resumeSendingLinkSingleUnsettledDelivery.
@Ignore("QPID-7845")
@Test
@SpecificationTest(section = "2.6.13", description = "When a suspended link having unsettled deliveries is resumed, the unsettled field from the" + " attach frame will carry the delivery-tags and delivery state of all deliveries" + " considered unsettled by the issuing link endpoint.")
public void resumeSendingLinkSingleUnsettledDelivery() throws Exception {
final String destination = BrokerAdmin.TEST_QUEUE_NAME;
final Binary deliveryTag = new Binary("testDeliveryTag".getBytes(StandardCharsets.UTF_8));
try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
final UnsignedInteger linkHandle1 = UnsignedInteger.ZERO;
final Interaction interaction = transport.newInteraction();
interaction.negotiateProtocol().consumeResponse().open().consumeResponse(Open.class).begin().consumeResponse(Begin.class);
// 1. attach with ReceiverSettleMode.SECOND
interaction.attachHandle(linkHandle1).attachRole(Role.SENDER).attachRcvSettleMode(ReceiverSettleMode.SECOND).attachTargetAddress(destination).attach().consumeResponse(Attach.class).consumeResponse(Flow.class);
// 2. send a unsettled delivery
final Disposition responseDisposition = interaction.transferHandle(linkHandle1).transferDeliveryId(UnsignedInteger.ZERO).transferDeliveryTag(deliveryTag).transferPayloadData(TEST_MESSAGE_CONTENT).transfer().consumeResponse().getLatestResponse(Disposition.class);
assertThat(responseDisposition.getRole(), is(Role.RECEIVER));
assertThat(responseDisposition.getSettled(), is(Boolean.FALSE));
final DeliveryState remoteDeliveryState = responseDisposition.getState();
// 3. detach the link
interaction.detach().consumeResponse(Detach.class);
// 4. resume the link
final UnsignedInteger linkHandle2 = UnsignedInteger.ONE;
final Attach responseAttach2 = interaction.attachHandle(linkHandle2).attachUnsettled(Collections.singletonMap(deliveryTag, null)).attach().consumeResponse().getLatestResponse(Attach.class);
// 5. assert content of unsettled map
assertThat(responseAttach2.getTarget(), is(notNullValue()));
final Map<Binary, DeliveryState> remoteUnsettled = responseAttach2.getUnsettled();
assertThat(remoteUnsettled, is(notNullValue()));
assertThat(remoteUnsettled.keySet(), is(equalTo(Collections.singleton(deliveryTag))));
assertThat(remoteUnsettled.get(deliveryTag).getClass(), typeCompatibleWith(remoteDeliveryState.getClass()));
assertThat(responseAttach2.getIncompleteUnsettled(), is(anyOf(nullValue(), equalTo(false))));
}
}
Aggregations