Search in sources :

Example 1 with ErrorCarryingFrameBody

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);
    }
}
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) ErrorCarryingFrameBody(org.apache.qpid.server.protocol.v1_0.type.ErrorCarryingFrameBody) Disposition(org.apache.qpid.server.protocol.v1_0.type.transport.Disposition) Error(org.apache.qpid.server.protocol.v1_0.type.transport.Error) AmqpError(org.apache.qpid.server.protocol.v1_0.type.transport.AmqpError) LinkError(org.apache.qpid.server.protocol.v1_0.type.transport.LinkError) Binary(org.apache.qpid.server.protocol.v1_0.type.Binary) 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

Binary (org.apache.qpid.server.protocol.v1_0.type.Binary)1 ErrorCarryingFrameBody (org.apache.qpid.server.protocol.v1_0.type.ErrorCarryingFrameBody)1 AmqpError (org.apache.qpid.server.protocol.v1_0.type.transport.AmqpError)1 Attach (org.apache.qpid.server.protocol.v1_0.type.transport.Attach)1 Begin (org.apache.qpid.server.protocol.v1_0.type.transport.Begin)1 Disposition (org.apache.qpid.server.protocol.v1_0.type.transport.Disposition)1 Error (org.apache.qpid.server.protocol.v1_0.type.transport.Error)1 Flow (org.apache.qpid.server.protocol.v1_0.type.transport.Flow)1 LinkError (org.apache.qpid.server.protocol.v1_0.type.transport.LinkError)1 Open (org.apache.qpid.server.protocol.v1_0.type.transport.Open)1 SpecificationTest (org.apache.qpid.tests.protocol.SpecificationTest)1 FrameTransport (org.apache.qpid.tests.protocol.v1_0.FrameTransport)1 Interaction (org.apache.qpid.tests.protocol.v1_0.Interaction)1 Test (org.junit.Test)1