Search in sources :

Example 6 with ExchangeBoundOkBody

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

the class QueueTest method queueDurableBind.

@Test
@SpecificationTest(section = "1.7.2.3", description = "Bindings of durable queues to durable exchanges are automatically durable and the server " + "MUST restore such bindings after a server restart.")
public void queueDurableBind() 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(true).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)));
    }
    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(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) 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 7 with ExchangeBoundOkBody

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

the class ExchangeTest method exchangeDeclare.

@Test
@SpecificationTest(section = "1.6.2.1", description = "verify exchange exists, create if needed")
public void exchangeDeclare() 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(ExchangeDeclareOkBody.class);
        ExchangeBoundOkBody response = interaction.exchange().boundExchangeName(TEST_EXCHANGE).bound().consumeResponse().getLatestResponse(ExchangeBoundOkBody.class);
        assertThat(response.getReplyCode(), is(equalTo(ExchangeBoundOkBody.NO_BINDINGS)));
    }
}
Also used : 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 8 with ExchangeBoundOkBody

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

the class QueueTest method queueBindWithoutRoutingKey.

@Test
@SpecificationTest(section = "1.7.2.3", description = "If the queue name is provided but the routing key is empty," + " the server does the binding with that empty routing key.")
public void queueBindWithoutRoutingKey() 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).bind().consumeResponse(QueueBindOkBody.class);
        ExchangeBoundOkBody response = interaction.exchange().boundExchangeName(testExchange).boundQueue(BrokerAdmin.TEST_QUEUE_NAME).boundRoutingKey("").bound().consumeResponse().getLatestResponse(ExchangeBoundOkBody.class);
        assertThat(response.getReplyCode(), is(equalTo(ExchangeBoundOkBody.OK)));
    }
}
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) 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 9 with ExchangeBoundOkBody

use of org.apache.qpid.server.protocol.v0_8.transport.ExchangeBoundOkBody 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(getBrokerAdmin()).connect()) {
        final Interaction interaction = transport.newInteraction();
        interaction.negotiateOpen().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)

Example 10 with ExchangeBoundOkBody

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

the class ExchangeTest method exchangeDeclareValidWireArguments.

@Test
public void exchangeDeclareValidWireArguments() 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).declareArguments(Collections.singletonMap("unroutableMessageBehaviour", "REJECT")).declare().consumeResponse(ExchangeDeclareOkBody.class);
        ExchangeBoundOkBody response = interaction.exchange().boundExchangeName(TEST_EXCHANGE).bound().consumeResponse().getLatestResponse(ExchangeBoundOkBody.class);
        assertThat(response.getReplyCode(), is(equalTo(ExchangeBoundOkBody.NO_BINDINGS)));
    }
}
Also used : FrameTransport(org.apache.qpid.tests.protocol.v0_8.FrameTransport) Interaction(org.apache.qpid.tests.protocol.v0_8.Interaction) ChannelOpenOkBody(org.apache.qpid.server.protocol.v0_8.transport.ChannelOpenOkBody) ExchangeBoundOkBody(org.apache.qpid.server.protocol.v0_8.transport.ExchangeBoundOkBody) Test(org.junit.Test)

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