Search in sources :

Example 1 with ExchangeBoundOkBody

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

the class ExchangeTest method exchangeDelete.

@Test
@SpecificationTest(section = "1.6.2.3", description = "This method deletes an exchange. When an exchange is deleted all queue bindings on the " + "exchange are cancelled.")
public void exchangeDelete() throws Exception {
    try (FrameTransport transport = new FrameTransport(getBrokerAdmin()).connect()) {
        final Interaction interaction = transport.newInteraction();
        interaction.negotiateOpen().channel().open().consumeResponse(ChannelOpenOkBody.class).exchange().declareName(TEST_EXCHANGE).declare().consumeResponse().getLatestResponse(ExchangeDeclareOkBody.class);
        ExchangeBoundOkBody boundResponse = interaction.exchange().boundExchangeName(TEST_EXCHANGE).bound().consumeResponse().getLatestResponse(ExchangeBoundOkBody.class);
        assertThat(boundResponse.getReplyCode(), is(equalTo(ExchangeBoundOkBody.NO_BINDINGS)));
        interaction.exchange().deleteExchangeName(TEST_EXCHANGE).delete().consumeResponse(ExchangeDeleteOkBody.class);
        ExchangeBoundOkBody boundResponse2 = interaction.exchange().boundExchangeName(TEST_EXCHANGE).bound().consumeResponse().getLatestResponse(ExchangeBoundOkBody.class);
        assertThat(boundResponse2.getReplyCode(), is(equalTo(ExchangeBoundOkBody.EXCHANGE_NOT_FOUND)));
    }
}
Also used : ChannelOpenOkBody(org.apache.qpid.server.protocol.v0_8.transport.ChannelOpenOkBody) 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)

Example 2 with ExchangeBoundOkBody

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

the class ExchangeTest method exchangeDeclareDurable.

@Test
@SpecificationTest(section = "1.6.2.1", description = "If [durable is] set when creating a new exchange, the exchange will be marked as durable. " + "Durable exchanges remain active when a server restarts. Non-durable exchanges (transient " + "exchanges) are purged if/when a server restarts.")
public void exchangeDeclareDurable() throws Exception {
    try (FrameTransport transport = new FrameTransport(getBrokerAdmin()).connect()) {
        final Interaction interaction = transport.newInteraction();
        interaction.negotiateOpen().channel().open().consumeResponse(ChannelOpenOkBody.class).exchange().declareDurable(true).declareName(TEST_EXCHANGE).declare().consumeResponse(ExchangeDeclareOkBody.class);
    }
    assumeThat(getBrokerAdmin().supportsRestart(), Matchers.is(true));
    getBrokerAdmin().restart();
    try (FrameTransport transport = new FrameTransport(getBrokerAdmin()).connect()) {
        final Interaction interaction = transport.newInteraction();
        ExchangeBoundOkBody response = interaction.negotiateOpen().channel().open().consumeResponse(ChannelOpenOkBody.class).exchange().boundExchangeName(TEST_EXCHANGE).bound().consumeResponse().getLatestResponse(ExchangeBoundOkBody.class);
        assertThat(response.getReplyCode(), is(equalTo(ExchangeBoundOkBody.NO_BINDINGS)));
    }
}
Also used : ChannelOpenOkBody(org.apache.qpid.server.protocol.v0_8.transport.ChannelOpenOkBody) 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)

Example 3 with ExchangeBoundOkBody

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

the class QueueTest method queueBindDefaultQueue.

@Test
@SpecificationTest(section = "1.7.2.3", description = "The client MUST either specify a queue name or have previously declared a queue on the same channel")
public void queueBindDefaultQueue() throws Exception {
    try (FrameTransport transport = new FrameTransport(getBrokerAdmin()).connect()) {
        String testExchange = "testExchange";
        final Interaction interaction = transport.newInteraction();
        interaction.negotiateOpen().channel().open().consumeResponse(ChannelOpenOkBody.class).queue().declareName(BrokerAdmin.TEST_QUEUE_NAME).declare().consumeResponse(QueueDeclareOkBody.class).exchange().declareName(testExchange).declare().consumeResponse(ExchangeDeclareOkBody.class).queue().bindName(testExchange).bind().consumeResponse(QueueBindOkBody.class);
        ExchangeBoundOkBody response = interaction.exchange().boundExchangeName(testExchange).boundQueue(BrokerAdmin.TEST_QUEUE_NAME).bound().consumeResponse().getLatestResponse(ExchangeBoundOkBody.class);
        assertThat(response.getReplyCode(), is(equalTo(ExchangeBoundOkBody.OK)));
    }
}
Also used : Matchers.emptyString(org.hamcrest.Matchers.emptyString) AMQShortString(org.apache.qpid.server.protocol.v0_8.AMQShortString) 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)

Example 4 with ExchangeBoundOkBody

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

the class QueueTest method queueBindDurableQueueToTransientExchange.

@Test
@SpecificationTest(section = "1.7.2.3", description = "The server MUST allow a durable queue to bind to a transient exchange.")
public void queueBindDurableQueueToTransientExchange() throws Exception {
    String testExchange = "testExchange";
    String testRoutingKey = "rk1";
    try (FrameTransport transport = new FrameTransport(getBrokerAdmin()).connect()) {
        final Interaction interaction = transport.newInteraction();
        interaction.negotiateOpen().channel().open().consumeResponse(ChannelOpenOkBody.class).queue().declareName(BrokerAdmin.TEST_QUEUE_NAME).declareDurable(true).declare().consumeResponse(QueueDeclareOkBody.class).exchange().declareName(testExchange).declareDurable(false).declare().consumeResponse(ExchangeDeclareOkBody.class).queue().bindName(testExchange).bindQueueName(BrokerAdmin.TEST_QUEUE_NAME).bindRoutingKey(testRoutingKey).bind().consumeResponse(QueueBindOkBody.class);
        ExchangeBoundOkBody response = interaction.exchange().boundExchangeName(testExchange).boundQueue(BrokerAdmin.TEST_QUEUE_NAME).boundRoutingKey(testRoutingKey).bound().consumeResponse().getLatestResponse(ExchangeBoundOkBody.class);
        assertThat(response.getReplyCode(), is(equalTo(ExchangeBoundOkBody.OK)));
    }
}
Also used : Matchers.emptyString(org.hamcrest.Matchers.emptyString) AMQShortString(org.apache.qpid.server.protocol.v0_8.AMQShortString) QueueDeclareOkBody(org.apache.qpid.server.protocol.v0_8.transport.QueueDeclareOkBody) 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)

Example 5 with ExchangeBoundOkBody

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

the class QueueTest method queueBindIgnoreDuplicates.

@Test
@SpecificationTest(section = "1.7.2.3", description = "A server MUST allow ignore duplicate bindings")
public void queueBindIgnoreDuplicates() throws Exception {
    getBrokerAdmin().createQueue(BrokerAdmin.TEST_QUEUE_NAME);
    try (FrameTransport transport = new FrameTransport(getBrokerAdmin()).connect()) {
        final Interaction interaction = transport.newInteraction();
        String testExchange = "testExchange";
        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().bindName(testExchange).bindQueueName(BrokerAdmin.TEST_QUEUE_NAME).bindRoutingKey("rk1").bind().consumeResponse(QueueBindOkBody.class);
        ExchangeBoundOkBody response = interaction.exchange().boundExchangeName(testExchange).bound().consumeResponse().getLatestResponse(ExchangeBoundOkBody.class);
        assertThat(response.getReplyCode(), is(equalTo(ExchangeBoundOkBody.OK)));
        interaction.queue().unbindName(testExchange).unbindQueueName(BrokerAdmin.TEST_QUEUE_NAME).unbindRoutingKey("rk1").unbind().consumeResponse(QueueUnbindOkBody.class);
        response = interaction.exchange().boundExchangeName(testExchange).bound().consumeResponse().getLatestResponse(ExchangeBoundOkBody.class);
        assertThat(response.getReplyCode(), is(equalTo(ExchangeBoundOkBody.NO_BINDINGS)));
    }
}
Also used : Matchers.emptyString(org.hamcrest.Matchers.emptyString) AMQShortString(org.apache.qpid.server.protocol.v0_8.AMQShortString) 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

ExchangeBoundOkBody (org.apache.qpid.server.protocol.v0_8.transport.ExchangeBoundOkBody)11 Test (org.junit.Test)11 SpecificationTest (org.apache.qpid.tests.protocol.SpecificationTest)10 ChannelOpenOkBody (org.apache.qpid.server.protocol.v0_8.transport.ChannelOpenOkBody)6 AMQShortString (org.apache.qpid.server.protocol.v0_8.AMQShortString)5 Matchers.emptyString (org.hamcrest.Matchers.emptyString)5 ExchangeDeclareOkBody (org.apache.qpid.server.protocol.v0_8.transport.ExchangeDeclareOkBody)3 QueueDeclareOkBody (org.apache.qpid.server.protocol.v0_8.transport.QueueDeclareOkBody)2 ChannelCloseBody (org.apache.qpid.server.protocol.v0_8.transport.ChannelCloseBody)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