use of org.apache.qpid.server.protocol.v1_0.type.ErrorCarryingFrameBody in project qpid-broker-j by apache.
the class TransferTest method transfersWithDuplicateUnsettledDeliveryTag.
@Test
@SpecificationTest(section = "2.7.5", description = "[delivery-tag] uniquely identifies the delivery attempt for a given message on this link.")
public void transfersWithDuplicateUnsettledDeliveryTag() throws Exception {
try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
final Binary deliveryTag = new Binary("testDeliveryTag".getBytes(UTF_8));
Interaction interaction = transport.newInteraction();
interaction.negotiateProtocol().consumeResponse().open().consumeResponse(Open.class).begin().consumeResponse(Begin.class).attachRole(Role.SENDER).attachRcvSettleMode(ReceiverSettleMode.SECOND).attach().consumeResponse(Attach.class).consumeResponse(Flow.class);
Flow flow = interaction.getLatestResponse(Flow.class);
assertThat(flow.getLinkCredit().intValue(), is(greaterThan(1)));
interaction.transferDeliveryId(UnsignedInteger.ZERO).transferDeliveryTag(deliveryTag).transferPayloadData("test").transfer().sync().transferDeliveryTag(deliveryTag).transferDeliveryId(UnsignedInteger.ONE).transferPayloadData("test2").transfer().sync();
do {
interaction.consumeResponse();
Response<?> response = interaction.getLatestResponse();
assertThat(response, is(notNullValue()));
Object body = response.getBody();
if (body instanceof ErrorCarryingFrameBody) {
Error error = ((ErrorCarryingFrameBody) body).getError();
assertThat(error, is(notNullValue()));
break;
} else if (body instanceof Disposition) {
Disposition disposition = (Disposition) body;
assertThat(disposition.getSettled(), is(equalTo(false)));
assertThat(disposition.getFirst(), is(not(equalTo(UnsignedInteger.ONE))));
assertThat(disposition.getLast(), is(not(equalTo(UnsignedInteger.ONE))));
} else if (!(body instanceof Flow)) {
fail("Unexpected response " + body);
}
} while (true);
}
}
Aggregations