Search in sources :

Example 21 with org.apache.qpid.server.protocol.v0_8.transport

use of org.apache.qpid.server.protocol.v0_8.transport 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 22 with org.apache.qpid.server.protocol.v0_8.transport

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

the class PublisherConfirmsTest method publishUnrouteableMandatoryMessage.

@Test
@SpecificationTest(section = "https://www.rabbitmq.com/confirms.html", description = "[...] when the broker is unable to handle messages successfully, instead of a basic.ack," + "the broker will send a basic.nack.")
public void publishUnrouteableMandatoryMessage() throws Exception {
    try (FrameTransport transport = new FrameTransport(getBrokerAdmin()).connect()) {
        final Interaction interaction = transport.newInteraction();
        BasicNackBody nackBody = interaction.negotiateOpen().channel().open().consumeResponse(ChannelOpenOkBody.class).basic().confirmSelect().consumeResponse(ConfirmSelectOkBody.class).basic().publishExchange("").publishRoutingKey("unrouteable").publishMandatory(true).content("Test").publishMessage().consumeResponse().getLatestResponse(BasicNackBody.class);
        assertThat(nackBody.getDeliveryTag(), is(equalTo(1L)));
    }
}
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) BasicNackBody(org.apache.qpid.server.protocol.v0_8.transport.BasicNackBody) Test(org.junit.Test) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest)

Example 23 with org.apache.qpid.server.protocol.v0_8.transport

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

the class PublisherConfirmsTest method publishUnrouteableMessage.

@Test
@SpecificationTest(section = "https://www.rabbitmq.com/confirms.html", description = "After a channel is put into confirm mode, all subsequently published messages will be " + "confirmed or nack'd once")
public void publishUnrouteableMessage() throws Exception {
    try (FrameTransport transport = new FrameTransport(getBrokerAdmin()).connect()) {
        final Interaction interaction = transport.newInteraction();
        interaction.negotiateOpen().channel().open().consumeResponse(ChannelOpenOkBody.class).basic().confirmSelect().consumeResponse(ConfirmSelectOkBody.class).basic().publishExchange("").publishRoutingKey("unrouteable").publishMandatory(false).content("Test").publishMessage().consumeResponse(BasicAckBody.class);
    }
}
Also used : FrameTransport(org.apache.qpid.tests.protocol.v0_8.FrameTransport) ConfirmSelectOkBody(org.apache.qpid.server.protocol.v0_8.transport.ConfirmSelectOkBody) Interaction(org.apache.qpid.tests.protocol.v0_8.Interaction) Test(org.junit.Test) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest)

Example 24 with org.apache.qpid.server.protocol.v0_8.transport

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

the class PublisherConfirmsTest method publishWithTransactionalConfirms.

/**
 * Qpid allows publisher confirms to be used with transactions.  This is beyond what RabbitMQ supports.
 */
@Test
public void publishWithTransactionalConfirms() throws Exception {
    try (FrameTransport transport = new FrameTransport(getBrokerAdmin()).connect()) {
        final Interaction interaction = transport.newInteraction();
        final BasicAckBody ackBody = interaction.negotiateOpen().channel().open().consumeResponse(ChannelOpenOkBody.class).tx().select().consumeResponse(TxSelectOkBody.class).basic().confirmSelect().consumeResponse(ConfirmSelectOkBody.class).basic().publishExchange("").publishRoutingKey(BrokerAdmin.TEST_QUEUE_NAME).content("Test").publishMessage().consumeResponse().getLatestResponse(BasicAckBody.class);
        assertThat(ackBody.getDeliveryTag(), is(equalTo(1L)));
        assertThat(getBrokerAdmin().getQueueDepthMessages(BrokerAdmin.TEST_QUEUE_NAME), is(equalTo(0)));
        interaction.tx().commit().consumeResponse(TxCommitOkBody.class);
        assertThat(getBrokerAdmin().getQueueDepthMessages(BrokerAdmin.TEST_QUEUE_NAME), is(equalTo(1)));
    }
}
Also used : FrameTransport(org.apache.qpid.tests.protocol.v0_8.FrameTransport) ConfirmSelectOkBody(org.apache.qpid.server.protocol.v0_8.transport.ConfirmSelectOkBody) Interaction(org.apache.qpid.tests.protocol.v0_8.Interaction) BasicAckBody(org.apache.qpid.server.protocol.v0_8.transport.BasicAckBody) ChannelOpenOkBody(org.apache.qpid.server.protocol.v0_8.transport.ChannelOpenOkBody) Test(org.junit.Test) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest)

Example 25 with org.apache.qpid.server.protocol.v0_8.transport

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

the class PublisherConfirmsTest method publishUnroutableMessageWithTransactionalConfirms.

@Test
public void publishUnroutableMessageWithTransactionalConfirms() throws Exception {
    try (FrameTransport transport = new FrameTransport(getBrokerAdmin()).connect()) {
        final Interaction interaction = transport.newInteraction();
        interaction.negotiateOpen().channel().open().consumeResponse(ChannelOpenOkBody.class).tx().select().consumeResponse(TxSelectOkBody.class).basic().confirmSelect().consumeResponse(ConfirmSelectOkBody.class).basic().publishExchange("").publishRoutingKey("unrouteable").publishMandatory(true).publishMessage().basic().publishExchange("").publishRoutingKey(BrokerAdmin.TEST_QUEUE_NAME).publishMandatory(true).publishMessage();
        final BasicNackBody nackBody = interaction.consumeResponse().getLatestResponse(BasicNackBody.class);
        assertThat(nackBody.getDeliveryTag(), is(equalTo(1L)));
        final BasicAckBody ackBody = interaction.consumeResponse().getLatestResponse(BasicAckBody.class);
        assertThat(ackBody.getDeliveryTag(), is(equalTo(2L)));
        assertThat(getBrokerAdmin().getQueueDepthMessages(BrokerAdmin.TEST_QUEUE_NAME), is(equalTo(0)));
        interaction.tx().commit();
        final Set<Class<?>> outstanding = Sets.newHashSet(TxCommitOkBody.class, BasicReturnBody.class, ContentHeaderBody.class);
        while (!outstanding.isEmpty()) {
            final Response<?> response = interaction.consumeResponse(outstanding.toArray(new Class<?>[outstanding.size()])).getLatestResponse();
            final boolean remove = outstanding.remove(response.getBody().getClass());
            assertThat("" + response, remove, is(equalTo(true)));
        }
        assertThat(getBrokerAdmin().getQueueDepthMessages(BrokerAdmin.TEST_QUEUE_NAME), is(equalTo(1)));
    }
}
Also used : FrameTransport(org.apache.qpid.tests.protocol.v0_8.FrameTransport) Interaction(org.apache.qpid.tests.protocol.v0_8.Interaction) TxSelectOkBody(org.apache.qpid.server.protocol.v0_8.transport.TxSelectOkBody) BasicAckBody(org.apache.qpid.server.protocol.v0_8.transport.BasicAckBody) BasicNackBody(org.apache.qpid.server.protocol.v0_8.transport.BasicNackBody) Test(org.junit.Test) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest)

Aggregations

Test (org.junit.Test)88 SpecificationTest (org.apache.qpid.tests.protocol.SpecificationTest)72 ChannelOpenOkBody (org.apache.qpid.server.protocol.v0_8.transport.ChannelOpenOkBody)44 AMQShortString (org.apache.qpid.server.protocol.v0_8.AMQShortString)32 Interaction (org.apache.qpid.tests.protocol.v0_8.Interaction)21 FrameTransport (org.apache.qpid.tests.protocol.v0_8.FrameTransport)20 Matchers.emptyString (org.hamcrest.Matchers.emptyString)18 ChannelCloseBody (org.apache.qpid.server.protocol.v0_8.transport.ChannelCloseBody)17 QueueDeclareOkBody (org.apache.qpid.server.protocol.v0_8.transport.QueueDeclareOkBody)15 ConnectionCloseBody (org.apache.qpid.server.protocol.v0_8.transport.ConnectionCloseBody)13 ConnectionTuneBody (org.apache.qpid.server.protocol.v0_8.transport.ConnectionTuneBody)12 ExchangeBoundOkBody (org.apache.qpid.server.protocol.v0_8.transport.ExchangeBoundOkBody)11 ExchangeDeclareOkBody (org.apache.qpid.server.protocol.v0_8.transport.ExchangeDeclareOkBody)11 ContentBody (org.apache.qpid.server.protocol.v0_8.transport.ContentBody)9 BasicConsumeOkBody (org.apache.qpid.server.protocol.v0_8.transport.BasicConsumeOkBody)8 BasicDeliverBody (org.apache.qpid.server.protocol.v0_8.transport.BasicDeliverBody)8 ContentHeaderBody (org.apache.qpid.server.protocol.v0_8.transport.ContentHeaderBody)8 BasicContentHeaderProperties (org.apache.qpid.server.protocol.v0_8.transport.BasicContentHeaderProperties)7 ConnectionStartBody (org.apache.qpid.server.protocol.v0_8.transport.ConnectionStartBody)7 BasicQosOkBody (org.apache.qpid.server.protocol.v0_8.transport.BasicQosOkBody)6