Search in sources :

Example 6 with ChannelCloseBody

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

the class QueueTest method queueDeclareEquivalent.

@Test
@SpecificationTest(section = "1.7.2.1", description = "If not set and the queue exists, the server MUST check " + "that the existing queue has the same values for durable, " + "exclusive, auto-delete, and arguments fields.")
public void queueDeclareEquivalent() throws Exception {
    try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
        final Interaction interaction = transport.newInteraction();
        QueueInteraction queueInteraction = interaction.openAnonymousConnection().channel().open().consumeResponse(ChannelOpenOkBody.class).queue();
        QueueDeclareOkBody response = queueInteraction.declareName(BrokerAdmin.TEST_QUEUE_NAME).declareExclusive(false).declare().consumeResponse().getLatestResponse(QueueDeclareOkBody.class);
        assertThat(response.getQueue(), is(equalTo(AMQShortString.valueOf(BrokerAdmin.TEST_QUEUE_NAME))));
        QueueDeclareOkBody equalDeclareResponse = queueInteraction.declareName(BrokerAdmin.TEST_QUEUE_NAME).declareExclusive(false).declare().consumeResponse().getLatestResponse(QueueDeclareOkBody.class);
        assertThat(equalDeclareResponse.getQueue(), is(equalTo(AMQShortString.valueOf(BrokerAdmin.TEST_QUEUE_NAME))));
        ChannelCloseBody unequalDeclareResponse = queueInteraction.declareName(BrokerAdmin.TEST_QUEUE_NAME).declareExclusive(true).declare().consumeResponse().getLatestResponse(ChannelCloseBody.class);
        assertThat(unequalDeclareResponse.getReplyCode(), is(equalTo(ErrorCodes.ALREADY_EXISTS)));
        interaction.channel().closeOk();
    }
}
Also used : QueueDeclareOkBody(org.apache.qpid.server.protocol.v0_8.transport.QueueDeclareOkBody) 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 7 with ChannelCloseBody

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

the class QueueTest method queueDeclarePassive.

@Test
@SpecificationTest(section = "1.7.2.1", description = "If [declarePassive is] set, the server will reply with Declare-Ok if the queue already exists" + "with the same name, and raise an error if not.")
public void queueDeclarePassive() throws Exception {
    getBrokerAdmin().createQueue(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))));
        assertThat(response.getMessageCount(), is(equalTo(0L)));
        assertThat(response.getConsumerCount(), is(equalTo(0L)));
        getBrokerAdmin().deleteQueue(BrokerAdmin.TEST_QUEUE_NAME);
        ChannelCloseBody closeResponse = interaction.queue().deleteName(BrokerAdmin.TEST_QUEUE_NAME).delete().consumeResponse().getLatestResponse(ChannelCloseBody.class);
        assertThat(closeResponse.getReplyCode(), is(equalTo(ErrorCodes.NOT_FOUND)));
    }
}
Also used : QueueDeclareOkBody(org.apache.qpid.server.protocol.v0_8.transport.QueueDeclareOkBody) 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 8 with ChannelCloseBody

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

the class QueueTest method queueBindUnknownQueue.

@Test
@SpecificationTest(section = "1.7.2.3", description = "The client MUST NOT attempt to bind a queue that does not exist.")
public void queueBindUnknownQueue() throws Exception {
    try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
        String testExchange = "testExchange";
        final Interaction interaction = transport.newInteraction();
        ChannelCloseBody response = interaction.openAnonymousConnection().channel().open().consumeResponse(ChannelOpenOkBody.class).exchange().declareName(testExchange).declare().consumeResponse(ExchangeDeclareOkBody.class).queue().bindName(testExchange).bindQueueName(BrokerAdmin.TEST_QUEUE_NAME).bind().consumeResponse().getLatestResponse(ChannelCloseBody.class);
        assertThat(response.getReplyCode(), is(equalTo(ErrorCodes.NOT_FOUND)));
    }
}
Also used : 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)

Example 9 with ChannelCloseBody

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

the class ExchangeTest method exchangeDeleteExchangeNotFound.

@Test
@SpecificationTest(section = "1.6.2.3", description = "The client MUST NOT attempt to delete an exchange that does not exist.")
public void exchangeDeleteExchangeNotFound() throws Exception {
    try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
        final Interaction interaction = transport.newInteraction();
        ChannelCloseBody unknownExchange = interaction.openAnonymousConnection().channel().open().consumeResponse(ChannelOpenOkBody.class).exchange().deleteExchangeName("unknownExchange").delete().consumeResponse().getLatestResponse(ChannelCloseBody.class);
        assertThat(unknownExchange.getReplyCode(), is(equalTo(ErrorCodes.NOT_FOUND)));
        interaction.channel().closeOk();
    }
}
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 10 with ChannelCloseBody

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

the class ExchangeTest method exchangeDeleteInUse.

@Test
@SpecificationTest(section = "1.6.2.3", description = "If [if-unused is] set, the server will only delete the exchange if it has no queue" + "bindings. If the exchange has queue bindings the server does not delete it but raises a " + "channel exception instead.")
public void exchangeDeleteInUse() throws Exception {
    getBrokerAdmin().createQueue(BrokerAdmin.TEST_QUEUE_NAME);
    try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
        final Interaction interaction = transport.newInteraction();
        interaction.openAnonymousConnection().channel().open().consumeResponse(ChannelOpenOkBody.class).exchange().declareName(TEST_EXCHANGE).declare().consumeResponse(ExchangeDeclareOkBody.class).queue().bindName(TEST_EXCHANGE).bindQueueName(BrokerAdmin.TEST_QUEUE_NAME).bind().consumeResponse(QueueBindOkBody.class);
        ChannelCloseBody response = interaction.exchange().deleteExchangeName(TEST_EXCHANGE).deleteIfUnused(true).delete().consumeResponse().getLatestResponse(ChannelCloseBody.class);
        assertThat(response.getReplyCode(), is(equalTo(ErrorCodes.IN_USE)));
        interaction.channel().closeOk();
        ExchangeBoundOkBody boundResponse = interaction.channel().open().consumeResponse(ChannelOpenOkBody.class).exchange().boundExchangeName(TEST_EXCHANGE).bound().consumeResponse().getLatestResponse(ExchangeBoundOkBody.class);
        assertThat(boundResponse.getReplyCode(), is(equalTo(ExchangeBoundOkBody.OK)));
        interaction.queue().unbindName(TEST_EXCHANGE).unbindQueueName(BrokerAdmin.TEST_QUEUE_NAME).unbind().consumeResponse(QueueUnbindOkBody.class).exchange().deleteIfUnused(true).deleteExchangeName(TEST_EXCHANGE).delete().consumeResponse(ExchangeDeleteOkBody.class);
    }
}
Also used : ExchangeDeclareOkBody(org.apache.qpid.server.protocol.v0_8.transport.ExchangeDeclareOkBody) ChannelOpenOkBody(org.apache.qpid.server.protocol.v0_8.transport.ChannelOpenOkBody) ChannelCloseBody(org.apache.qpid.server.protocol.v0_8.transport.ChannelCloseBody) QueueUnbindOkBody(org.apache.qpid.server.protocol.v0_8.transport.QueueUnbindOkBody) ExchangeBoundOkBody(org.apache.qpid.server.protocol.v0_8.transport.ExchangeBoundOkBody) 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