Search in sources :

Example 86 with FrameTransport

use of org.apache.qpid.tests.protocol.v1_0.FrameTransport in project qpid-broker-j by apache.

the class DeleteOnCloseTest method deleteOnCloseOnSource.

@Test
@SpecificationTest(section = "3.5.10", description = "A node dynamically created with this lifetime policy will be deleted at the point that the link which caused its\n" + "creation ceases to exist.")
public void deleteOnCloseOnSource() throws Exception {
    try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
        Source source = new Source();
        source.setDynamicNodeProperties(Collections.singletonMap(Session_1_0.LIFETIME_POLICY, new DeleteOnClose()));
        source.setDynamic(true);
        final Interaction interaction = transport.newInteraction();
        final Attach attachResponse = interaction.negotiateProtocol().consumeResponse().open().consumeResponse(Open.class).begin().consumeResponse(Begin.class).attachRole(Role.RECEIVER).attachSource(source).attach().consumeResponse().getLatestResponse(Attach.class);
        assertThat(attachResponse.getSource(), is(notNullValue()));
        final String newTempQueueAddress = ((Source) attachResponse.getSource()).getAddress();
        assertThat(Utils.doesNodeExist(_brokerAddress, newTempQueueAddress), is(true));
        interaction.detachClose(true).detach().consumeResponse().getLatestResponse(Detach.class);
        assertThat(Utils.doesNodeExist(_brokerAddress, newTempQueueAddress), is(false));
    }
}
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) DeleteOnClose(org.apache.qpid.server.protocol.v1_0.type.messaging.DeleteOnClose) Begin(org.apache.qpid.server.protocol.v1_0.type.transport.Begin) Source(org.apache.qpid.server.protocol.v1_0.type.messaging.Source) 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 87 with FrameTransport

use of org.apache.qpid.tests.protocol.v1_0.FrameTransport in project qpid-broker-j by apache.

the class MessageFormat method differentMessageFormatOnSameDeliveryFails.

@Test
@SpecificationTest(section = "2.7.5", description = "message-format: " + "This field MUST be specified for the first transfer of a multi-transfer message and can " + "only be omitted for continuation transfers. It is an error if the message-format on a " + "continuation transfer differs from the message-format on the first transfer of a delivery.")
public void differentMessageFormatOnSameDeliveryFails() throws Exception {
    try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
        QpidByteBuffer[] payloads = Utils.splitPayload("testData", 2);
        final Response<?> latestResponse = 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).transferMore(true).transferMessageFormat(UnsignedInteger.ZERO).transferPayload(payloads[0]).transfer().consumeResponse(null, Flow.class, Disposition.class).transferDeliveryTag(null).transferDeliveryId(null).transferMore(false).transferMessageFormat(UnsignedInteger.ONE).transferPayload(payloads[1]).transfer().consumeResponse(Detach.class, End.class, Close.class).getLatestResponse();
        for (final QpidByteBuffer payload : payloads) {
            payload.dispose();
        }
        assertThat(latestResponse, is(notNullValue()));
        final Object responseBody = latestResponse.getBody();
        final Error error;
        if (responseBody instanceof Detach) {
            error = ((Detach) responseBody).getError();
        } else if (responseBody instanceof End) {
            error = ((End) responseBody).getError();
        } else if (responseBody instanceof Close) {
            error = ((Close) responseBody).getError();
        } else {
            fail(String.format("Expected response of either Detach, End, or Close. Got '%s'", responseBody));
            error = null;
        }
        assertThat(error, is(notNullValue()));
    }
}
Also used : FrameTransport(org.apache.qpid.tests.protocol.v1_0.FrameTransport) Error(org.apache.qpid.server.protocol.v1_0.type.transport.Error) QpidByteBuffer(org.apache.qpid.server.bytebuffer.QpidByteBuffer) End(org.apache.qpid.server.protocol.v1_0.type.transport.End) Close(org.apache.qpid.server.protocol.v1_0.type.transport.Close) Detach(org.apache.qpid.server.protocol.v1_0.type.transport.Detach) 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 88 with FrameTransport

use of org.apache.qpid.tests.protocol.v1_0.FrameTransport 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 89 with FrameTransport

use of org.apache.qpid.tests.protocol.v1_0.FrameTransport 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 90 with FrameTransport

use of org.apache.qpid.tests.protocol.v1_0.FrameTransport 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)

Aggregations

Test (org.junit.Test)136 FrameTransport (org.apache.qpid.tests.protocol.v1_0.FrameTransport)125 SpecificationTest (org.apache.qpid.tests.protocol.SpecificationTest)116 Interaction (org.apache.qpid.tests.protocol.v1_0.Interaction)101 Attach (org.apache.qpid.server.protocol.v1_0.type.transport.Attach)57 Open (org.apache.qpid.server.protocol.v1_0.type.transport.Open)57 InetSocketAddress (java.net.InetSocketAddress)45 Begin (org.apache.qpid.server.protocol.v1_0.type.transport.Begin)39 Flow (org.apache.qpid.server.protocol.v1_0.type.transport.Flow)37 UnsignedInteger (org.apache.qpid.server.protocol.v1_0.type.UnsignedInteger)35 Disposition (org.apache.qpid.server.protocol.v1_0.type.transport.Disposition)32 Binary (org.apache.qpid.server.protocol.v1_0.type.Binary)29 InteractionTransactionalState (org.apache.qpid.tests.protocol.v1_0.InteractionTransactionalState)24 Close (org.apache.qpid.server.protocol.v1_0.type.transport.Close)18 Accepted (org.apache.qpid.server.protocol.v1_0.type.messaging.Accepted)16 Detach (org.apache.qpid.server.protocol.v1_0.type.transport.Detach)16 Error (org.apache.qpid.server.protocol.v1_0.type.transport.Error)14 DeliveryState (org.apache.qpid.server.protocol.v1_0.type.DeliveryState)11 AmqpError (org.apache.qpid.server.protocol.v1_0.type.transport.AmqpError)11 Transfer (org.apache.qpid.server.protocol.v1_0.type.transport.Transfer)10