Search in sources :

Example 1 with BasicGetOkBody

use of org.apache.qpid.server.protocol.v0_8.transport.BasicGetOkBody in project qpid-broker-j by apache.

the class BasicTest method get.

@Test
@SpecificationTest(section = "1.8.3.10", description = "direct access to a queue")
public void get() throws Exception {
    String messageContent = "message";
    getBrokerAdmin().putMessageOnQueue(BrokerAdmin.TEST_QUEUE_NAME, messageContent);
    try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
        final Interaction interaction = transport.newInteraction();
        BasicGetOkBody response = interaction.openAnonymousConnection().channel().open().consumeResponse(ChannelOpenOkBody.class).basic().getQueueName(BrokerAdmin.TEST_QUEUE_NAME).get().consumeResponse().getLatestResponse(BasicGetOkBody.class);
        long deliveryTag = response.getDeliveryTag();
        ContentBody content = interaction.consumeResponse(ContentHeaderBody.class).consumeResponse().getLatestResponse(ContentBody.class);
        String receivedContent = getContent(content);
        assertThat(receivedContent, is(equalTo(messageContent)));
        assertThat(getBrokerAdmin().getQueueDepthMessages(BrokerAdmin.TEST_QUEUE_NAME), is(equalTo(1)));
        interaction.basic().ackDeliveryTag(deliveryTag).ack().channel().close().consumeResponse(ChannelCloseOkBody.class);
        assertThat(getBrokerAdmin().getQueueDepthMessages(BrokerAdmin.TEST_QUEUE_NAME), is(equalTo(0)));
    }
}
Also used : ContentBody(org.apache.qpid.server.protocol.v0_8.transport.ContentBody) AMQShortString(org.apache.qpid.server.protocol.v0_8.AMQShortString) BasicGetOkBody(org.apache.qpid.server.protocol.v0_8.transport.BasicGetOkBody) ChannelOpenOkBody(org.apache.qpid.server.protocol.v0_8.transport.ChannelOpenOkBody) Test(org.junit.Test) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest)

Aggregations

AMQShortString (org.apache.qpid.server.protocol.v0_8.AMQShortString)1 BasicGetOkBody (org.apache.qpid.server.protocol.v0_8.transport.BasicGetOkBody)1 ChannelOpenOkBody (org.apache.qpid.server.protocol.v0_8.transport.ChannelOpenOkBody)1 ContentBody (org.apache.qpid.server.protocol.v0_8.transport.ContentBody)1 SpecificationTest (org.apache.qpid.tests.protocol.SpecificationTest)1 Test (org.junit.Test)1