Search in sources :

Example 56 with org.apache.qpid.server.protocol.v0_8.transport

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

the class QueueTest method queuePurgeQueueNotFound.

@Test
@SpecificationTest(section = "1.7.2.7", description = "The client MUST NOT attempt to purge a queue that does not exist.")
public void queuePurgeQueueNotFound() throws Exception {
    try (FrameTransport transport = new FrameTransport(getBrokerAdmin()).connect()) {
        final Interaction interaction = transport.newInteraction();
        ChannelCloseBody response = interaction.negotiateOpen().channel().open().consumeResponse(ChannelOpenOkBody.class).queue().purgeName(BrokerAdmin.TEST_QUEUE_NAME).purge().consumeResponse().getLatestResponse(ChannelCloseBody.class);
        assertThat(response.getReplyCode(), is(equalTo(ErrorCodes.NOT_FOUND)));
    }
}
Also used : ChannelOpenOkBody(org.apache.qpid.server.protocol.v0_8.transport.ChannelOpenOkBody) ChannelCloseBody(org.apache.qpid.server.protocol.v0_8.transport.ChannelCloseBody) Test(org.junit.Test) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest)

Example 57 with org.apache.qpid.server.protocol.v0_8.transport

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

the class QueueTest method queueDeclareAutoDelete.

@Test
@SpecificationTest(section = "1.7.2.1", description = "If [auto-delete] set, the queue is deleted when all consumers have finished using it. The " + "last consumer can be cancelled either explicitly or because its channel is closed. " + "If there was no consumer ever on the queue, it won't be deleted.")
public void queueDeclareAutoDelete() throws Exception {
    try (FrameTransport transport = new FrameTransport(getBrokerAdmin()).connect()) {
        final Interaction interaction = transport.newInteraction();
        QueueDeclareOkBody response = interaction.negotiateOpen().channel().open().consumeResponse(ChannelOpenOkBody.class).queue().declareAutoDelete(true).declareName(BrokerAdmin.TEST_QUEUE_NAME).declare().consumeResponse().getLatestResponse(QueueDeclareOkBody.class);
        assertThat(response.getQueue(), is(equalTo(AMQShortString.valueOf(BrokerAdmin.TEST_QUEUE_NAME))));
    }
    try (FrameTransport transport = new FrameTransport(getBrokerAdmin()).connect()) {
        final Interaction interaction = transport.newInteraction();
        QueueDeclareOkBody response = interaction.negotiateOpen().channel().open().consumeResponse(ChannelOpenOkBody.class).queue().declarePassive(true).declareName(BrokerAdmin.TEST_QUEUE_NAME).declare().consumeResponse().getLatestResponse(QueueDeclareOkBody.class);
        assertThat(response.getQueue(), is(equalTo(AMQShortString.valueOf(BrokerAdmin.TEST_QUEUE_NAME))));
        final String consumerTag = "lastConsumer";
        interaction.basic().consumeConsumerTag(consumerTag).consumeQueue(BrokerAdmin.TEST_QUEUE_NAME).consume().consumeResponse(BasicConsumeOkBody.class).basic().consumeCancelTag(consumerTag).cancel().consumeResponse().getLatestResponse(BasicCancelOkBody.class);
        ChannelCloseBody closeResponse = interaction.queue().declarePassive(true).declareName(BrokerAdmin.TEST_QUEUE_NAME).declare().consumeResponse().getLatestResponse(ChannelCloseBody.class);
        assertThat(closeResponse.getReplyCode(), is(equalTo(ErrorCodes.NOT_FOUND)));
    }
}
Also used : BasicConsumeOkBody(org.apache.qpid.server.protocol.v0_8.transport.BasicConsumeOkBody) QueueDeclareOkBody(org.apache.qpid.server.protocol.v0_8.transport.QueueDeclareOkBody) Matchers.emptyString(org.hamcrest.Matchers.emptyString) AMQShortString(org.apache.qpid.server.protocol.v0_8.AMQShortString) ChannelCloseBody(org.apache.qpid.server.protocol.v0_8.transport.ChannelCloseBody) Test(org.junit.Test) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest)

Example 58 with org.apache.qpid.server.protocol.v0_8.transport

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

the class QueueTest method queueUnbindUnknownQueue.

@Test
@SpecificationTest(section = "1.7.2.5", description = "The client MUST NOT attempt to unbind a queue that does " + "not exist.")
public void queueUnbindUnknownQueue() throws Exception {
    getBrokerAdmin().createQueue(BrokerAdmin.TEST_QUEUE_NAME);
    try (FrameTransport transport = new FrameTransport(getBrokerAdmin()).connect()) {
        final Interaction interaction = transport.newInteraction();
        String testExchange = "testExchange";
        ChannelCloseBody response = interaction.negotiateOpen().channel().open().consumeResponse(ChannelOpenOkBody.class).exchange().declareName(testExchange).declare().consumeResponse(ExchangeDeclareOkBody.class).queue().bindName(testExchange).bindQueueName(BrokerAdmin.TEST_QUEUE_NAME).bindRoutingKey("rk1").bind().consumeResponse(QueueBindOkBody.class).queue().unbindName(testExchange).unbindQueueName("unknownQueue").unbindRoutingKey("rk1").unbind().consumeResponse().getLatestResponse(ChannelCloseBody.class);
        assertThat(response.getReplyCode(), is(equalTo(ErrorCodes.NOT_FOUND)));
    }
}
Also used : QueueBindOkBody(org.apache.qpid.server.protocol.v0_8.transport.QueueBindOkBody) ExchangeDeclareOkBody(org.apache.qpid.server.protocol.v0_8.transport.ExchangeDeclareOkBody) Matchers.emptyString(org.hamcrest.Matchers.emptyString) AMQShortString(org.apache.qpid.server.protocol.v0_8.AMQShortString) ChannelOpenOkBody(org.apache.qpid.server.protocol.v0_8.transport.ChannelOpenOkBody) ChannelCloseBody(org.apache.qpid.server.protocol.v0_8.transport.ChannelCloseBody) Test(org.junit.Test) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest)

Example 59 with org.apache.qpid.server.protocol.v0_8.transport

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

the class QueueTest method queueDeleteDefaultQueue.

@Test
@SpecificationTest(section = "1.7.2.9", description = "The client MUST either specify a queue name or have previously declared a queue on the " + "same channel")
public void queueDeleteDefaultQueue() throws Exception {
    getBrokerAdmin().createQueue(BrokerAdmin.TEST_QUEUE_NAME);
    getBrokerAdmin().putMessageOnQueue(BrokerAdmin.TEST_QUEUE_NAME, "message");
    try (FrameTransport transport = new FrameTransport(getBrokerAdmin()).connect()) {
        final Interaction interaction = transport.newInteraction();
        QueueDeleteOkBody deleteResponse = interaction.negotiateOpen().channel().open().consumeResponse(ChannelOpenOkBody.class).queue().declareName(BrokerAdmin.TEST_QUEUE_NAME).declare().consumeResponse(QueueDeclareOkBody.class).queue().delete().consumeResponse().getLatestResponse(QueueDeleteOkBody.class);
        assertThat(deleteResponse.getMessageCount(), is(equalTo(1L)));
    }
}
Also used : QueueDeleteOkBody(org.apache.qpid.server.protocol.v0_8.transport.QueueDeleteOkBody) Test(org.junit.Test) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest)

Example 60 with org.apache.qpid.server.protocol.v0_8.transport

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

the class QueueTest method queuePurge.

@Test
@SpecificationTest(section = "1.7.2.7", description = "purge a queue")
public void queuePurge() throws Exception {
    getBrokerAdmin().createQueue(BrokerAdmin.TEST_QUEUE_NAME);
    getBrokerAdmin().putMessageOnQueue(BrokerAdmin.TEST_QUEUE_NAME, "message");
    try (FrameTransport transport = new FrameTransport(getBrokerAdmin()).connect()) {
        final Interaction interaction = transport.newInteraction();
        QueuePurgeOkBody response = interaction.negotiateOpen().channel().open().consumeResponse(ChannelOpenOkBody.class).queue().purgeName(BrokerAdmin.TEST_QUEUE_NAME).purge().consumeResponse().getLatestResponse(QueuePurgeOkBody.class);
        assertThat(response.getMessageCount(), is(equalTo(1L)));
        QueueDeclareOkBody passive = interaction.queue().declareName(BrokerAdmin.TEST_QUEUE_NAME).declarePassive(true).declare().consumeResponse().getLatestResponse(QueueDeclareOkBody.class);
        assertThat(passive.getQueue(), is(equalTo(AMQShortString.valueOf(BrokerAdmin.TEST_QUEUE_NAME))));
        assertThat(passive.getMessageCount(), is(equalTo(0L)));
    }
}
Also used : QueuePurgeOkBody(org.apache.qpid.server.protocol.v0_8.transport.QueuePurgeOkBody) QueueDeclareOkBody(org.apache.qpid.server.protocol.v0_8.transport.QueueDeclareOkBody) 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

Test (org.junit.Test)88 SpecificationTest (org.apache.qpid.tests.protocol.SpecificationTest)72 ChannelOpenOkBody (org.apache.qpid.server.protocol.v0_8.transport.ChannelOpenOkBody)44 AMQShortString (org.apache.qpid.server.protocol.v0_8.AMQShortString)32 Interaction (org.apache.qpid.tests.protocol.v0_8.Interaction)21 FrameTransport (org.apache.qpid.tests.protocol.v0_8.FrameTransport)20 Matchers.emptyString (org.hamcrest.Matchers.emptyString)18 ChannelCloseBody (org.apache.qpid.server.protocol.v0_8.transport.ChannelCloseBody)17 QueueDeclareOkBody (org.apache.qpid.server.protocol.v0_8.transport.QueueDeclareOkBody)15 ConnectionCloseBody (org.apache.qpid.server.protocol.v0_8.transport.ConnectionCloseBody)13 ConnectionTuneBody (org.apache.qpid.server.protocol.v0_8.transport.ConnectionTuneBody)12 ExchangeBoundOkBody (org.apache.qpid.server.protocol.v0_8.transport.ExchangeBoundOkBody)11 ExchangeDeclareOkBody (org.apache.qpid.server.protocol.v0_8.transport.ExchangeDeclareOkBody)11 ContentBody (org.apache.qpid.server.protocol.v0_8.transport.ContentBody)9 BasicConsumeOkBody (org.apache.qpid.server.protocol.v0_8.transport.BasicConsumeOkBody)8 BasicDeliverBody (org.apache.qpid.server.protocol.v0_8.transport.BasicDeliverBody)8 ContentHeaderBody (org.apache.qpid.server.protocol.v0_8.transport.ContentHeaderBody)8 BasicContentHeaderProperties (org.apache.qpid.server.protocol.v0_8.transport.BasicContentHeaderProperties)7 ConnectionStartBody (org.apache.qpid.server.protocol.v0_8.transport.ConnectionStartBody)7 BasicQosOkBody (org.apache.qpid.server.protocol.v0_8.transport.BasicQosOkBody)6