Search in sources :

Example 46 with Transfer

use of org.apache.qpid.server.protocol.v1_0.type.transport.Transfer in project qpid-broker-j by apache.

the class MultiTransferTest method multiTransferMessageOmittingOptionalTagAndID.

@Test
@SpecificationTest(section = "2.7.5", description = "[delivery-id] On continuation transfers the delivery-id MAY be omitted..." + "[delivery-tag] field MUST be specified for the first transfer of a multi-transfer" + " message and can only be omitted for continuation transfers.")
public void multiTransferMessageOmittingOptionalTagAndID() throws Exception {
    try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
        QpidByteBuffer[] payloads = Utils.splitPayload("testData", 4);
        final UnsignedInteger deliveryId = UnsignedInteger.ZERO;
        final Binary deliveryTag = new Binary("testTransfer".getBytes(UTF_8));
        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(deliveryId).transferDeliveryTag(deliveryTag).transferMore(true).transferPayload(payloads[0]).transfer().sync().transferDeliveryId(deliveryId).transferDeliveryTag(null).transferMore(true).transferPayload(payloads[1]).transfer().sync().transferDeliveryId(null).transferDeliveryTag(deliveryTag).transferMore(true).transferPayload(payloads[2]).transfer().sync().transferDeliveryId(null).transferDeliveryTag(null).transferMore(false).transferPayload(payloads[3]).transfer().consumeResponse();
        Disposition disposition = interaction.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)));
        assertThat(disposition.getState(), is(instanceOf(Accepted.class)));
    }
}
Also used : FrameTransport(org.apache.qpid.tests.protocol.v1_0.FrameTransport) Interaction(org.apache.qpid.tests.protocol.v1_0.Interaction) Attach(org.apache.qpid.server.protocol.v1_0.type.transport.Attach) Begin(org.apache.qpid.server.protocol.v1_0.type.transport.Begin) Disposition(org.apache.qpid.server.protocol.v1_0.type.transport.Disposition) QpidByteBuffer(org.apache.qpid.server.bytebuffer.QpidByteBuffer) Binary(org.apache.qpid.server.protocol.v1_0.type.Binary) UnsignedInteger(org.apache.qpid.server.protocol.v1_0.type.UnsignedInteger) Open(org.apache.qpid.server.protocol.v1_0.type.transport.Open) Test(org.junit.Test) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest)

Example 47 with Transfer

use of org.apache.qpid.server.protocol.v1_0.type.transport.Transfer 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)));
    }
}
Also used : FrameTransport(org.apache.qpid.tests.protocol.v1_0.FrameTransport) Interaction(org.apache.qpid.tests.protocol.v1_0.Interaction) Disposition(org.apache.qpid.server.protocol.v1_0.type.transport.Disposition) QpidByteBuffer(org.apache.qpid.server.bytebuffer.QpidByteBuffer) Binary(org.apache.qpid.server.protocol.v1_0.type.Binary) UnsignedInteger(org.apache.qpid.server.protocol.v1_0.type.UnsignedInteger) Flow(org.apache.qpid.server.protocol.v1_0.type.transport.Flow) Test(org.junit.Test) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest)

Example 48 with Transfer

use of org.apache.qpid.server.protocol.v1_0.type.transport.Transfer 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);
    }
}
Also used : FrameTransport(org.apache.qpid.tests.protocol.v1_0.FrameTransport) Interaction(org.apache.qpid.tests.protocol.v1_0.Interaction) Attach(org.apache.qpid.server.protocol.v1_0.type.transport.Attach) Begin(org.apache.qpid.server.protocol.v1_0.type.transport.Begin) QpidByteBuffer(org.apache.qpid.server.bytebuffer.QpidByteBuffer) Binary(org.apache.qpid.server.protocol.v1_0.type.Binary) UnsignedInteger(org.apache.qpid.server.protocol.v1_0.type.UnsignedInteger) Open(org.apache.qpid.server.protocol.v1_0.type.transport.Open) Test(org.junit.Test) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest)

Example 49 with Transfer

use of org.apache.qpid.server.protocol.v1_0.type.transport.Transfer 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))));
    }
}
Also used : FrameTransport(org.apache.qpid.tests.protocol.v1_0.FrameTransport) InteractionTransactionalState(org.apache.qpid.tests.protocol.v1_0.InteractionTransactionalState) Interaction(org.apache.qpid.tests.protocol.v1_0.Interaction) Attach(org.apache.qpid.server.protocol.v1_0.type.transport.Attach) Begin(org.apache.qpid.server.protocol.v1_0.type.transport.Begin) Binary(org.apache.qpid.server.protocol.v1_0.type.Binary) Discharge(org.apache.qpid.server.protocol.v1_0.type.transaction.Discharge) Open(org.apache.qpid.server.protocol.v1_0.type.transport.Open) Flow(org.apache.qpid.server.protocol.v1_0.type.transport.Flow) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest) Test(org.junit.Test) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest)

Example 50 with Transfer

use of org.apache.qpid.server.protocol.v1_0.type.transport.Transfer in project qpid-broker-j by apache.

the class TransferTest method transferReceiverSettleModeFirst.

@Test
@SpecificationTest(section = "2.7.5", description = "If first, this indicates that the receiver MUST settle the delivery once it has arrived without waiting for the sender to settle first")
public void transferReceiverSettleModeFirst() throws Exception {
    try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
        Disposition responseDisposition = transport.newInteraction().negotiateProtocol().consumeResponse().open().consumeResponse(Open.class).begin().consumeResponse(Begin.class).attachRole(Role.SENDER).attachTargetAddress(BrokerAdmin.TEST_QUEUE_NAME).attachRcvSettleMode(ReceiverSettleMode.SECOND).attach().consumeResponse(Attach.class).consumeResponse(Flow.class).transferPayloadData("testData").transferRcvSettleMode(ReceiverSettleMode.FIRST).transfer().consumeResponse().getLatestResponse(Disposition.class);
        assertThat(responseDisposition.getRole(), is(Role.RECEIVER));
        assertThat(responseDisposition.getSettled(), is(Boolean.TRUE));
        assertThat(responseDisposition.getState(), is(instanceOf(Accepted.class)));
    }
}
Also used : FrameTransport(org.apache.qpid.tests.protocol.v1_0.FrameTransport) Disposition(org.apache.qpid.server.protocol.v1_0.type.transport.Disposition) Begin(org.apache.qpid.server.protocol.v1_0.type.transport.Begin) Open(org.apache.qpid.server.protocol.v1_0.type.transport.Open) Flow(org.apache.qpid.server.protocol.v1_0.type.transport.Flow) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest) Test(org.junit.Test) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest)

Aggregations

Test (org.junit.Test)54 SpecificationTest (org.apache.qpid.tests.protocol.SpecificationTest)53 FrameTransport (org.apache.qpid.tests.protocol.v1_0.FrameTransport)53 Interaction (org.apache.qpid.tests.protocol.v1_0.Interaction)46 Attach (org.apache.qpid.server.protocol.v1_0.type.transport.Attach)36 UnsignedInteger (org.apache.qpid.server.protocol.v1_0.type.UnsignedInteger)29 Disposition (org.apache.qpid.server.protocol.v1_0.type.transport.Disposition)29 Binary (org.apache.qpid.server.protocol.v1_0.type.Binary)26 Flow (org.apache.qpid.server.protocol.v1_0.type.transport.Flow)26 Transfer (org.apache.qpid.server.protocol.v1_0.type.transport.Transfer)24 Begin (org.apache.qpid.server.protocol.v1_0.type.transport.Begin)21 QpidByteBuffer (org.apache.qpid.server.bytebuffer.QpidByteBuffer)20 Open (org.apache.qpid.server.protocol.v1_0.type.transport.Open)19 InteractionTransactionalState (org.apache.qpid.tests.protocol.v1_0.InteractionTransactionalState)19 Error (org.apache.qpid.server.protocol.v1_0.type.transport.Error)18 AmqpError (org.apache.qpid.server.protocol.v1_0.type.transport.AmqpError)14 Detach (org.apache.qpid.server.protocol.v1_0.type.transport.Detach)13 DeliveryState (org.apache.qpid.server.protocol.v1_0.type.DeliveryState)11 Accepted (org.apache.qpid.server.protocol.v1_0.type.messaging.Accepted)11 TransactionError (org.apache.qpid.server.protocol.v1_0.type.transaction.TransactionError)11