Search in sources :

Example 11 with ChannelCloseBody

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

the class ExchangeTest method exchangeDeleteAmqDisallowed.

@Test
@SpecificationTest(section = "1.6.2.3", description = "The server MUST, in each virtual host, pre-declare an exchange instance for each standard " + "exchange type that it implements.")
public void exchangeDeleteAmqDisallowed() throws Exception {
    try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
        final Interaction interaction = transport.newInteraction();
        ChannelCloseBody response = interaction.openAnonymousConnection().channel().open().consumeResponse(ChannelOpenOkBody.class).exchange().deleteExchangeName(ExchangeDefaults.DIRECT_EXCHANGE_NAME).delete().consumeResponse().getLatestResponse(ChannelCloseBody.class);
        assertThat(response.getReplyCode(), is(equalTo(ErrorCodes.NOT_ALLOWED)));
    }
}
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 12 with ChannelCloseBody

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

the class QueueTest method queueUnbindUnknownRoutingKey.

@Test
@SpecificationTest(section = "1.7.2.5", description = "If a unbind fails, the server MUST raise a connection " + "exception")
public void queueUnbindUnknownRoutingKey() throws Exception {
    getBrokerAdmin().createQueue(BrokerAdmin.TEST_QUEUE_NAME);
    try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
        final Interaction interaction = transport.newInteraction();
        String testExchange = "testExchange";
        ChannelCloseBody response = interaction.openAnonymousConnection().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(BrokerAdmin.TEST_QUEUE_NAME).unbindRoutingKey("rk2").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) AMQShortString(org.apache.qpid.server.protocol.v0_8.AMQShortString) Matchers.isEmptyString(org.hamcrest.Matchers.isEmptyString) 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 13 with ChannelCloseBody

use of org.apache.qpid.server.protocol.v0_8.transport.ChannelCloseBody 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(_brokerAddress).connect()) {
        final Interaction interaction = transport.newInteraction();
        ChannelCloseBody response = interaction.openAnonymousConnection().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 14 with ChannelCloseBody

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

the class QueueTest method queueDeleteQueueNotFound.

@Test
@SpecificationTest(section = "1.7.2.9", description = "The client MUST NOT attempt to delete a queue that does not exist.")
public void queueDeleteQueueNotFound() throws Exception {
    try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
        final Interaction interaction = transport.newInteraction();
        ChannelCloseBody response = interaction.openAnonymousConnection().channel().open().consumeResponse(ChannelOpenOkBody.class).queue().deleteName(BrokerAdmin.TEST_QUEUE_NAME).delete().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 15 with ChannelCloseBody

use of org.apache.qpid.server.protocol.v0_8.transport.ChannelCloseBody 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(_brokerAddress).connect()) {
        final Interaction interaction = transport.newInteraction();
        QueueDeclareOkBody response = interaction.openAnonymousConnection().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(_brokerAddress).connect()) {
        final Interaction interaction = transport.newInteraction();
        QueueDeclareOkBody response = interaction.openAnonymousConnection().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) AMQShortString(org.apache.qpid.server.protocol.v0_8.AMQShortString) Matchers.isEmptyString(org.hamcrest.Matchers.isEmptyString) 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)

Aggregations

ChannelCloseBody (org.apache.qpid.server.protocol.v0_8.transport.ChannelCloseBody)16 SpecificationTest (org.apache.qpid.tests.protocol.SpecificationTest)16 Test (org.junit.Test)16 ChannelOpenOkBody (org.apache.qpid.server.protocol.v0_8.transport.ChannelOpenOkBody)13 AMQShortString (org.apache.qpid.server.protocol.v0_8.AMQShortString)7 ExchangeDeclareOkBody (org.apache.qpid.server.protocol.v0_8.transport.ExchangeDeclareOkBody)7 Matchers.isEmptyString (org.hamcrest.Matchers.isEmptyString)7 QueueBindOkBody (org.apache.qpid.server.protocol.v0_8.transport.QueueBindOkBody)3 QueueDeclareOkBody (org.apache.qpid.server.protocol.v0_8.transport.QueueDeclareOkBody)3 BasicConsumeOkBody (org.apache.qpid.server.protocol.v0_8.transport.BasicConsumeOkBody)1 ExchangeBoundOkBody (org.apache.qpid.server.protocol.v0_8.transport.ExchangeBoundOkBody)1 QueueUnbindOkBody (org.apache.qpid.server.protocol.v0_8.transport.QueueUnbindOkBody)1