Search in sources :

Example 1 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(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))));
        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 2 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(getBrokerAdmin()).connect()) {
        final Interaction interaction = transport.newInteraction();
        QueueInteraction queueInteraction = interaction.negotiateOpen().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 3 with ChannelCloseBody

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

the class QueueTest method queueDeclareWithAlternateExchange.

/**
 * Qpid specific extension
 */
@Test
public void queueDeclareWithAlternateExchange() throws Exception {
    try (FrameTransport transport = new FrameTransport(getBrokerAdmin()).connect()) {
        final String altExchName = "altExchange";
        final Interaction interaction = transport.newInteraction();
        interaction.negotiateOpen().channel().open().consumeResponse(ChannelOpenOkBody.class).exchange().declareName(altExchName).declare().consumeResponse(ExchangeDeclareOkBody.class).queue().declareName(BrokerAdmin.TEST_QUEUE_NAME).declareArguments(Collections.singletonMap("alternateExchange", altExchName)).declare().consumeResponse(QueueDeclareOkBody.class);
        ChannelCloseBody inUseResponse = interaction.exchange().deleteExchangeName(altExchName).delete().consumeResponse().getLatestResponse(ChannelCloseBody.class);
        assertThat(inUseResponse.getReplyCode(), is(equalTo(ErrorCodes.NOT_ALLOWED)));
        interaction.channel().closeOk();
        interaction.channel().open().consumeResponse(ChannelOpenOkBody.class).queue().deleteName(BrokerAdmin.TEST_QUEUE_NAME).delete().consumeResponse(QueueDeleteOkBody.class).exchange().deleteExchangeName(altExchName).delete().consumeResponse(ExchangeDeleteOkBody.class);
    }
}
Also used : 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)

Example 4 with ChannelCloseBody

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

the class QueueTest method queueUnbindUnknownExchange.

@Test
@SpecificationTest(section = "1.7.2.5", description = "The client MUST NOT attempt to unbind a queue from an " + "exchange that does not exist.")
public void queueUnbindUnknownExchange() 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("unknownExchange").unbindQueueName(BrokerAdmin.TEST_QUEUE_NAME).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 5 with ChannelCloseBody

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

the class QueueTest method queueDeleteWithConsumer.

@Test
@SpecificationTest(section = "1.7.2.9", description = "If [if-unused is] set, the server will only delete the queue if it has no consumers. " + "If the queue has consumers the server does does not delete it but raises a channel " + "exception instead..")
public void queueDeleteWithConsumer() throws Exception {
    getBrokerAdmin().createQueue(BrokerAdmin.TEST_QUEUE_NAME);
    try (FrameTransport consumerTransport = new FrameTransport(getBrokerAdmin()).connect();
        FrameTransport transport = new FrameTransport(getBrokerAdmin()).connect()) {
        final String consumerTag = "A";
        final Interaction consumerInteraction = consumerTransport.newInteraction();
        final BasicInteraction basicInteraction = consumerInteraction.negotiateOpen().channel().open().consumeResponse(ChannelOpenOkBody.class).basic();
        basicInteraction.consumeConsumerTag(consumerTag).consumeQueue(BrokerAdmin.TEST_QUEUE_NAME).consume().consumeResponse(BasicConsumeOkBody.class);
        final Interaction deleterInteraction = transport.newInteraction();
        ChannelCloseBody response = deleterInteraction.negotiateOpen().channel().open().consumeResponse(ChannelOpenOkBody.class).queue().deleteName(BrokerAdmin.TEST_QUEUE_NAME).deleteIfUnused(true).delete().consumeResponse().getLatestResponse(ChannelCloseBody.class);
        assertThat(response.getReplyCode(), is(equalTo(ErrorCodes.IN_USE)));
        deleterInteraction.channel().closeOk();
        basicInteraction.consumeCancelTag(consumerTag).cancel().consumeResponse().getLatestResponse(BasicCancelOkBody.class);
        deleterInteraction.channel().open().consumeResponse(ChannelOpenOkBody.class).queue().deleteName(BrokerAdmin.TEST_QUEUE_NAME).delete().consumeResponse().getLatestResponse(QueueDeleteOkBody.class);
    }
}
Also used : 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)

Aggregations

ChannelCloseBody (org.apache.qpid.server.protocol.v0_8.transport.ChannelCloseBody)17 Test (org.junit.Test)17 SpecificationTest (org.apache.qpid.tests.protocol.SpecificationTest)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.emptyString (org.hamcrest.Matchers.emptyString)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 FrameTransport (org.apache.qpid.tests.protocol.v0_8.FrameTransport)1 Interaction (org.apache.qpid.tests.protocol.v0_8.Interaction)1