use of org.sbolstandard.core2.Interaction in project qpid-broker-j by apache.
the class MultiTransferTest method multiTransferMessage.
@Test
@SpecificationTest(section = "2.6.14", description = "For messages that are too large to fit within the maximum frame size, additional data MAY" + " be transferred in additional transfer frames by setting the more flag on all" + " but the last transfer frame")
public void multiTransferMessage() throws Exception {
try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
QpidByteBuffer[] payloads = Utils.splitPayload("testData", 2);
final UnsignedInteger deliveryId = UnsignedInteger.ZERO;
final Binary deliveryTag = new Binary("testTransfer".getBytes(UTF_8));
Interaction interaction = transport.newInteraction();
Disposition disposition = interaction.negotiateProtocol().consumeResponse().open().consumeResponse(Open.class).begin().consumeResponse(Begin.class).attachRole(Role.SENDER).attachTargetAddress(BrokerAdmin.TEST_QUEUE_NAME).attachRcvSettleMode(ReceiverSettleMode.SECOND).attachSourceOutcomes(Accepted.ACCEPTED_SYMBOL).attach().consumeResponse(Attach.class).consumeResponse(Flow.class).transferPayload(payloads[0]).transferDeliveryId(deliveryId).transferDeliveryTag(deliveryTag).transferMore(true).transfer().sync().transferMore(false).transferPayload(payloads[1]).transfer().consumeResponse().getLatestResponse(Disposition.class);
for (final QpidByteBuffer payload : payloads) {
payload.dispose();
}
assertThat(disposition.getFirst(), is(equalTo(deliveryId)));
assertThat(disposition.getLast(), isOneOf(null, deliveryId));
assertThat(disposition.getSettled(), is(equalTo(false)));
}
}
use of org.sbolstandard.core2.Interaction in project qpid-broker-j by apache.
the class MultiTransferTest method illegallyInterleavedMultiTransferOnSingleLink.
@Test
@SpecificationTest(section = "2.6.14", description = "[...]messages transferred along a single link MUST NOT be interleaved")
public void illegallyInterleavedMultiTransferOnSingleLink() throws Exception {
try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
QpidByteBuffer[] messagePayload1 = Utils.splitPayload("testData1", 2);
QpidByteBuffer[] messagePayload2 = Utils.splitPayload("testData2", 2);
Binary deliveryTag1 = new Binary("testTransfer1".getBytes(UTF_8));
Binary deliveryTag2 = new Binary("testTransfer2".getBytes(UTF_8));
UnsignedInteger deliverId1 = UnsignedInteger.ZERO;
UnsignedInteger deliveryId2 = UnsignedInteger.ONE;
Interaction interaction = transport.newInteraction();
interaction.negotiateProtocol().consumeResponse().open().consumeResponse(Open.class).begin().consumeResponse(Begin.class).attachRole(Role.SENDER).attachTargetAddress(BrokerAdmin.TEST_QUEUE_NAME).attachRcvSettleMode(ReceiverSettleMode.SECOND).attachSourceOutcomes(Accepted.ACCEPTED_SYMBOL).attach().consumeResponse(Attach.class).consumeResponse(Flow.class).transferDeliveryId(deliverId1).transferDeliveryTag(deliveryTag1).transferMore(true).transferPayload(messagePayload1[0]).transfer().sync().transferDeliveryId(deliveryId2).transferDeliveryTag(deliveryTag2).transferMore(true).transferPayload(messagePayload2[0]).transfer().sync();
for (final QpidByteBuffer payload : messagePayload1) {
payload.dispose();
}
for (final QpidByteBuffer payload : messagePayload2) {
payload.dispose();
}
interaction.consumeResponse(Detach.class, End.class, Close.class);
}
}
use of org.sbolstandard.core2.Interaction in project qpid-broker-j by apache.
the class OutcomeTest method modifiedOutcomeWithUndeliverableHere.
@Test
@SpecificationTest(section = "3.4.5", description = "If the undeliverable-here is set, then any messages released" + " MUST NOT be redelivered to the modifying link endpoint.")
public void modifiedOutcomeWithUndeliverableHere() throws Exception {
getBrokerAdmin().putMessageOnQueue(BrokerAdmin.TEST_QUEUE_NAME, "message1");
getBrokerAdmin().putMessageOnQueue(BrokerAdmin.TEST_QUEUE_NAME, "message2");
try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
final 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).flowIncomingWindow(UnsignedInteger.ONE).flowLinkCredit(UnsignedInteger.ONE).flowHandleFromLinkHandle().flow().receiveDelivery().decodeLatestDelivery();
Object firstDeliveryPayload = interaction.getDecodedLatestDelivery();
assertThat(firstDeliveryPayload, is(equalTo("message1")));
Modified modifiedOutcome = new Modified();
modifiedOutcome.setUndeliverableHere(Boolean.TRUE);
interaction.dispositionSettled(true).dispositionRole(Role.RECEIVER).dispositionFirstFromLatestDelivery().dispositionState(modifiedOutcome).disposition().flowIncomingWindow(UnsignedInteger.valueOf(2)).flowLinkCredit(UnsignedInteger.valueOf(2)).flowNextIncomingIdFromLatestDelivery().flow().receiveDelivery().decodeLatestDelivery();
Object secondDeliveryPayload = interaction.getDecodedLatestDelivery();
assertThat(secondDeliveryPayload, is(equalTo("message2")));
// verify that no unexpected performative is received by closing
interaction.doCloseConnection();
}
}
use of org.sbolstandard.core2.Interaction in project qpid-broker-j by apache.
the class TransferTest method transferMixtureOfTransactionalAndNonTransactionalDeliveries.
@Test
@SpecificationTest(section = "2.6.12", description = "Transferring A Message.")
public void transferMixtureOfTransactionalAndNonTransactionalDeliveries() throws Exception {
try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
final Interaction interaction = transport.newInteraction().negotiateProtocol().consumeResponse().open().consumeResponse(Open.class).begin().consumeResponse(Begin.class).attachRole(Role.SENDER).attachTargetAddress(BrokerAdmin.TEST_QUEUE_NAME).attach().consumeResponse(Attach.class).consumeResponse(Flow.class);
Flow flow = interaction.getLatestResponse(Flow.class);
assumeThat("insufficient credit for the test", flow.getLinkCredit().intValue(), is(greaterThan(2)));
final InteractionTransactionalState txnState = interaction.createTransactionalState(UnsignedInteger.ONE);
interaction.txnAttachCoordinatorLink(txnState).txnDeclare(txnState);
interaction.transferDeliveryId(UnsignedInteger.ONE).transferDeliveryTag(new Binary("A".getBytes(StandardCharsets.UTF_8))).transferPayloadData("test").transfer().transferDeliveryId(UnsignedInteger.valueOf(2)).transferDeliveryTag(new Binary("B".getBytes(StandardCharsets.UTF_8))).transferPayloadData("test").transfer().transferDeliveryId(UnsignedInteger.valueOf(3)).transferDeliveryTag(new Binary("C".getBytes(StandardCharsets.UTF_8))).transferTransactionalState(txnState.getCurrentTransactionId()).transferPayloadData("test").transfer();
final Discharge discharge = new Discharge();
discharge.setTxnId(txnState.getCurrentTransactionId());
discharge.setFail(false);
interaction.transferHandle(txnState.getHandle()).transferDeliveryId(UnsignedInteger.valueOf(4)).transferDeliveryTag(new Binary(("transaction-" + 4).getBytes(StandardCharsets.UTF_8))).transferPayloadData(discharge).transfer();
assertDeliveries(interaction, Sets.newTreeSet(Arrays.asList(UnsignedInteger.ONE, UnsignedInteger.valueOf(2), UnsignedInteger.valueOf(3), UnsignedInteger.valueOf(4))));
}
}
use of org.sbolstandard.core2.Interaction in project qpid-broker-j by apache.
the class TransferTest method receiveMultipleDeliveries.
@Test
@SpecificationTest(section = "2.6.12", description = "Transferring A Message.")
public void receiveMultipleDeliveries() throws Exception {
int numberOfMessages = 4;
for (int i = 0; i < numberOfMessages; i++) {
getBrokerAdmin().putMessageOnQueue(BrokerAdmin.TEST_QUEUE_NAME, TEST_MESSAGE_DATA + "_" + i);
}
try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
final Interaction interaction = transport.newInteraction().negotiateProtocol().consumeResponse().open().consumeResponse().begin().consumeResponse().attachRole(Role.RECEIVER).attachSourceAddress(BrokerAdmin.TEST_QUEUE_NAME).attachRcvSettleMode(ReceiverSettleMode.FIRST).attach().consumeResponse().flowIncomingWindow(UnsignedInteger.valueOf(numberOfMessages)).flowNextIncomingId(UnsignedInteger.ZERO).flowOutgoingWindow(UnsignedInteger.ZERO).flowNextOutgoingId(UnsignedInteger.ZERO).flowLinkCredit(UnsignedInteger.valueOf(numberOfMessages)).flowHandleFromLinkHandle().flow();
for (int i = 0; i < numberOfMessages; i++) {
interaction.receiveDelivery(Flow.class).decodeLatestDelivery();
Object data = interaction.getDecodedLatestDelivery();
assertThat(data, Is.is(CoreMatchers.equalTo(TEST_MESSAGE_DATA + "_" + i)));
assertThat(interaction.getLatestDeliveryId(), Is.is(equalTo(UnsignedInteger.valueOf(i))));
}
interaction.dispositionSettled(true).dispositionRole(Role.RECEIVER).dispositionFirst(UnsignedInteger.ZERO).dispositionLast(interaction.getLatestDeliveryId()).dispositionState(new Accepted()).disposition();
// make sure sure the disposition is handled by making drain request
interaction.flowLinkCredit(UnsignedInteger.ONE).flowNextIncomingId(UnsignedInteger.valueOf(numberOfMessages)).flowDrain(Boolean.TRUE).flow().consumeResponse(Flow.class);
if (getBrokerAdmin().isQueueDepthSupported()) {
assertThat(getBrokerAdmin().getQueueDepthMessages(BrokerAdmin.TEST_QUEUE_NAME), is(equalTo(0)));
}
}
String messageText = TEST_MESSAGE_DATA + "_" + 4;
getBrokerAdmin().putMessageOnQueue(BrokerAdmin.TEST_QUEUE_NAME, messageText);
Object receivedMessage = Utils.receiveMessage(_brokerAddress, BrokerAdmin.TEST_QUEUE_NAME);
assertThat(receivedMessage, is(equalTo(messageText)));
}
Aggregations