use of org.apache.qpid.server.protocol.v1_0.type.UnsignedInteger in project qpid-broker-j by apache.
the class TransferTest method assertDeliveries.
private void assertDeliveries(final Interaction interaction, final TreeSet<UnsignedInteger> expectedDeliveryIds) throws Exception {
do {
Response<?> response = interaction.consumeResponse(Disposition.class, Flow.class).getLatestResponse();
if (response.getBody() instanceof Disposition) {
Disposition disposition = (Disposition) response.getBody();
LongStream.rangeClosed(disposition.getFirst().longValue(), disposition.getLast() == null ? disposition.getFirst().longValue() : disposition.getLast().longValue()).forEach(value -> {
UnsignedInteger deliveryId = expectedDeliveryIds.first();
assertThat(value, is(equalTo(deliveryId.longValue())));
expectedDeliveryIds.remove(deliveryId);
});
}
} while (!expectedDeliveryIds.isEmpty());
}
use of org.apache.qpid.server.protocol.v1_0.type.UnsignedInteger in project qpid-broker-j by apache.
the class DischargeTest method dischargeSettledAfterReceiverDetach.
@Test
@SpecificationTest(section = "4.4.2", description = "Transactional Retirement [...]" + " To associate an outcome with a transaction the controller sends a disposition" + " performative which sets the state of the delivery to a transactional-state with the" + " desired transaction identifier and the outcome to be applied upon a successful discharge.")
public void dischargeSettledAfterReceiverDetach() throws Exception {
assumeThat(getBrokerAdmin().isQueueDepthSupported(), is(true));
getBrokerAdmin().putMessageOnQueue(BrokerAdmin.TEST_QUEUE_NAME, "test message");
try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
final Interaction interaction = transport.newInteraction();
final InteractionTransactionalState txnState = interaction.createTransactionalState(UnsignedInteger.ZERO);
List<Transfer> transfers = interaction.negotiateProtocol().consumeResponse().open().consumeResponse(Open.class).begin().consumeResponse(Begin.class).txnAttachCoordinatorLink(txnState).txnDeclare(txnState).attachRole(Role.RECEIVER).attachHandle(UnsignedInteger.ONE).attachSourceAddress(BrokerAdmin.TEST_QUEUE_NAME).attachRcvSettleMode(ReceiverSettleMode.FIRST).attach().consumeResponse(Attach.class).flowIncomingWindow(UnsignedInteger.ONE).flowLinkCredit(UnsignedInteger.ONE).flowHandleFromLinkHandle().flow().receiveDelivery().getLatestDelivery();
assertThat(transfers, is(notNullValue()));
assertThat(transfers, is(not(empty())));
final UnsignedInteger deliveryId = transfers.get(0).getDeliveryId();
interaction.detach().consumeResponse(Detach.class).dispositionFirst(deliveryId).dispositionTransactionalState(txnState.getCurrentTransactionId(), new Accepted()).dispositionRole(Role.RECEIVER).disposition().txnDischarge(txnState, false);
assertThat(getBrokerAdmin().getQueueDepthMessages(BrokerAdmin.TEST_QUEUE_NAME), is(equalTo(0)));
}
}
use of org.apache.qpid.server.protocol.v1_0.type.UnsignedInteger in project qpid-broker-j by apache.
the class TransactionalTransferTest method sendTransactionalPostingTransferFailsDueToUnknownTransactionId.
@Test
@SpecificationTest(section = "4.4.1", description = "If the transaction controller wishes to associate an outgoing transfer with a transaction," + " it MUST set the state of the transfer with a transactional-state carrying the appropriate" + " transaction identifier.")
public void sendTransactionalPostingTransferFailsDueToUnknownTransactionId() throws Exception {
try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
final UnsignedInteger linkHandle = UnsignedInteger.ONE;
final Interaction interaction = transport.newInteraction();
final InteractionTransactionalState txnState = interaction.createTransactionalState(UnsignedInteger.ZERO);
Response<?> response = interaction.negotiateProtocol().consumeResponse().open().consumeResponse(Open.class).begin().consumeResponse(Begin.class).txnAttachCoordinatorLink(txnState).txnDeclare(txnState).attachRole(Role.SENDER).attachTargetAddress(BrokerAdmin.TEST_QUEUE_NAME).attachHandle(linkHandle).attach().consumeResponse(Attach.class).consumeResponse(Flow.class).transferHandle(linkHandle).transferPayloadData(TEST_MESSAGE_CONTENT).transferTransactionalState(integerToBinary(Integer.MAX_VALUE)).transfer().consumeResponse().getLatestResponse();
assertUnknownTransactionIdError(response);
}
}
use of org.apache.qpid.server.protocol.v1_0.type.UnsignedInteger in project qpid-broker-j by apache.
the class TransactionalTransferTest method receiveTransactionalRetirementDispositionFailsDueToUnknownTransactionId.
@Test
@SpecificationTest(section = "4.4.2", description = "Transactional Retirement[...]" + " To associate an outcome with a transaction the controller" + " sends a disposition performative which sets the state" + " of the delivery to a transactional-state with the desired" + " transaction identifier and the outcome to be applied" + " upon a successful discharge.")
public void receiveTransactionalRetirementDispositionFailsDueToUnknownTransactionId() throws Exception {
getBrokerAdmin().putMessageOnQueue(BrokerAdmin.TEST_QUEUE_NAME, TEST_MESSAGE_CONTENT);
try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
final Interaction interaction = transport.newInteraction();
final InteractionTransactionalState txnState = interaction.createTransactionalState(UnsignedInteger.ZERO);
List<Transfer> transfers = interaction.negotiateProtocol().consumeResponse().open().consumeResponse(Open.class).begin().consumeResponse(Begin.class).txnAttachCoordinatorLink(txnState).txnDeclare(txnState).attachRole(Role.RECEIVER).attachHandle(UnsignedInteger.ONE).attachSourceAddress(BrokerAdmin.TEST_QUEUE_NAME).attachRcvSettleMode(ReceiverSettleMode.FIRST).attach().consumeResponse(Attach.class).flowIncomingWindow(UnsignedInteger.ONE).flowNextIncomingId(UnsignedInteger.ZERO).flowOutgoingWindow(UnsignedInteger.ZERO).flowNextOutgoingId(UnsignedInteger.ZERO).flowLinkCredit(UnsignedInteger.ONE).flowHandleFromLinkHandle().flow().receiveDelivery().getLatestDelivery();
UnsignedInteger deliveryId = transfers.get(0).getDeliveryId();
assertThat(deliveryId, is(notNullValue()));
Object data = interaction.decodeLatestDelivery().getDecodedLatestDelivery();
assertThat(data, is(equalTo(TEST_MESSAGE_CONTENT)));
Response<?> response = interaction.dispositionSettled(true).dispositionRole(Role.RECEIVER).dispositionTransactionalState(integerToBinary(Integer.MAX_VALUE), new Accepted()).dispositionFirst(deliveryId).disposition().consumeResponse().getLatestResponse();
assertUnknownTransactionIdError(response);
}
}
use of org.apache.qpid.server.protocol.v1_0.type.UnsignedInteger in project qpid-broker-j by apache.
the class FlowTest method synchronousGetWithTimeoutEmptyQueue.
@Test
@SpecificationTest(section = "2.6.8", description = "Synchronous get with a timeout is accomplished by incrementing the link-credit," + " sending the updated flow state and waiting for the link-credit to be consumed." + " When the desired time has elapsed the receiver then sets the drain flag and sends" + " the newly updated flow state again, while continuing to wait for the link-credit" + " to be consumed.")
public void synchronousGetWithTimeoutEmptyQueue() throws Exception {
getBrokerAdmin().createQueue(BrokerAdmin.TEST_QUEUE_NAME);
final InetSocketAddress addr = getBrokerAdmin().getBrokerAddress(BrokerAdmin.PortType.ANONYMOUS_AMQP);
try (FrameTransport transport = new FrameTransport(addr).connect()) {
Interaction interaction = transport.newInteraction().negotiateProtocol().consumeResponse().open().consumeResponse(Open.class).begin().consumeResponse(Begin.class).attachRole(Role.RECEIVER).attachSourceAddress(BrokerAdmin.TEST_QUEUE_NAME).attach().consumeResponse(Attach.class);
Attach remoteAttach = interaction.getLatestResponse(Attach.class);
UnsignedInteger remoteHandle = remoteAttach.getHandle();
assertThat(remoteHandle, is(notNullValue()));
Flow responseFlow = interaction.flowIncomingWindow(UnsignedInteger.valueOf(1)).flowNextIncomingId(UnsignedInteger.ZERO).flowLinkCredit(UnsignedInteger.ONE).flowDrain(Boolean.FALSE).flowEcho(Boolean.TRUE).flowHandleFromLinkHandle().flow().consumeResponse().getLatestResponse(Flow.class);
assertThat(responseFlow.getHandle(), is(equalTo(remoteHandle)));
assertThat(responseFlow.getLinkCredit(), is(equalTo(UnsignedInteger.ONE)));
assertThat(responseFlow.getDrain(), is(equalTo(Boolean.FALSE)));
responseFlow = interaction.flowLinkCredit(UnsignedInteger.ONE).flowDrain(Boolean.TRUE).flowEcho(Boolean.FALSE).flowHandleFromLinkHandle().flow().consumeResponse().getLatestResponse(Flow.class);
assertThat(responseFlow.getHandle(), is(equalTo(remoteHandle)));
assertThat(responseFlow.getLinkCredit(), is(equalTo(UnsignedInteger.ZERO)));
}
}
Aggregations