Search in sources :

Example 11 with ConnectionCloseBody

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

the class TransactionTimeoutTest method consumeTransactionTimeout.

@Test
public void consumeTransactionTimeout() throws Exception {
    getBrokerAdmin().putMessageOnQueue(BrokerAdmin.TEST_QUEUE_NAME, "message");
    try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
        final Interaction interaction = transport.newInteraction();
        assertThat(getBrokerAdmin().getQueueDepthMessages(BrokerAdmin.TEST_QUEUE_NAME), is(equalTo(1)));
        interaction.openAnonymousConnection().channel().open().consumeResponse(ChannelOpenOkBody.class).tx().select().consumeResponse(TxSelectOkBody.class).basic().qosPrefetchCount(1).qos().consumeResponse(BasicQosOkBody.class).channel().flow(true).consumeResponse(ChannelFlowOkBody.class).basic().consumeConsumerTag("A").consumeQueue(BrokerAdmin.TEST_QUEUE_NAME).consume().consumeResponse(BasicConsumeOkBody.class).consumeResponse(BasicDeliverBody.class);
        BasicDeliverBody delivery = interaction.getLatestResponse(BasicDeliverBody.class);
        interaction.consumeResponse(ContentHeaderBody.class).consumeResponse(ContentBody.class);
        interaction.basic().ackDeliveryTag(delivery.getDeliveryTag()).ack().exchange().declarePassive(true).declare().consumeResponse(ExchangeDeclareOkBody.class);
        assertThat(getBrokerAdmin().getQueueDepthMessages(BrokerAdmin.TEST_QUEUE_NAME), is(equalTo(1)));
        final ConnectionCloseBody close = interaction.consumeResponse().getLatestResponse(ConnectionCloseBody.class);
        assertThat(close.getReplyCode(), is(equalTo(ErrorCodes.RESOURCE_ERROR)));
        assertThat(close.getReplyText().toString(), containsString("transaction timed out"));
        interaction.connection().closeOk();
        assertThat(getBrokerAdmin().getQueueDepthMessages(BrokerAdmin.TEST_QUEUE_NAME), is(equalTo(1)));
    }
}
Also used : FrameTransport(org.apache.qpid.tests.protocol.v0_8.FrameTransport) ContentHeaderBody(org.apache.qpid.server.protocol.v0_8.transport.ContentHeaderBody) Interaction(org.apache.qpid.tests.protocol.v0_8.Interaction) TxSelectOkBody(org.apache.qpid.server.protocol.v0_8.transport.TxSelectOkBody) BasicQosOkBody(org.apache.qpid.server.protocol.v0_8.transport.BasicQosOkBody) ConnectionCloseBody(org.apache.qpid.server.protocol.v0_8.transport.ConnectionCloseBody) BasicConsumeOkBody(org.apache.qpid.server.protocol.v0_8.transport.BasicConsumeOkBody) BasicDeliverBody(org.apache.qpid.server.protocol.v0_8.transport.BasicDeliverBody) Test(org.junit.Test)

Aggregations

ConnectionCloseBody (org.apache.qpid.server.protocol.v0_8.transport.ConnectionCloseBody)11 Test (org.junit.Test)11 SpecificationTest (org.apache.qpid.tests.protocol.SpecificationTest)9 ChannelOpenOkBody (org.apache.qpid.server.protocol.v0_8.transport.ChannelOpenOkBody)3 ConnectionStartBody (org.apache.qpid.server.protocol.v0_8.transport.ConnectionStartBody)3 TxSelectOkBody (org.apache.qpid.server.protocol.v0_8.transport.TxSelectOkBody)2 FrameTransport (org.apache.qpid.tests.protocol.v0_8.FrameTransport)2 Interaction (org.apache.qpid.tests.protocol.v0_8.Interaction)2 InetSocketAddress (java.net.InetSocketAddress)1 BasicConsumeOkBody (org.apache.qpid.server.protocol.v0_8.transport.BasicConsumeOkBody)1 BasicDeliverBody (org.apache.qpid.server.protocol.v0_8.transport.BasicDeliverBody)1 BasicQosOkBody (org.apache.qpid.server.protocol.v0_8.transport.BasicQosOkBody)1 ConnectionTuneBody (org.apache.qpid.server.protocol.v0_8.transport.ConnectionTuneBody)1 ContentHeaderBody (org.apache.qpid.server.protocol.v0_8.transport.ContentHeaderBody)1 ExchangeDeclareOkBody (org.apache.qpid.server.protocol.v0_8.transport.ExchangeDeclareOkBody)1 QueueDeclareOkBody (org.apache.qpid.server.protocol.v0_8.transport.QueueDeclareOkBody)1 Matchers.containsString (org.hamcrest.Matchers.containsString)1