Search in sources :

Example 1 with QueueDeclareOkBody

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

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

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

the class QueueTest method queueDeclare.

@Test
@SpecificationTest(section = "1.7.2.1", description = "declare queue, create if needed")
public void queueDeclare() throws Exception {
    try (FrameTransport transport = new FrameTransport(getBrokerAdmin()).connect()) {
        final Interaction interaction = transport.newInteraction();
        QueueDeclareOkBody response = interaction.negotiateOpen().channel().open().consumeResponse(ChannelOpenOkBody.class).queue().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)));
    }
}
Also used : QueueDeclareOkBody(org.apache.qpid.server.protocol.v0_8.transport.QueueDeclareOkBody) ChannelOpenOkBody(org.apache.qpid.server.protocol.v0_8.transport.ChannelOpenOkBody) Test(org.junit.Test) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest)

Example 4 with QueueDeclareOkBody

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

the class QueueTest method queuePurge.

@Test
@SpecificationTest(section = "1.7.2.7", description = "purge a queue")
public void queuePurge() throws Exception {
    getBrokerAdmin().createQueue(BrokerAdmin.TEST_QUEUE_NAME);
    getBrokerAdmin().putMessageOnQueue(BrokerAdmin.TEST_QUEUE_NAME, "message");
    try (FrameTransport transport = new FrameTransport(getBrokerAdmin()).connect()) {
        final Interaction interaction = transport.newInteraction();
        QueuePurgeOkBody response = interaction.negotiateOpen().channel().open().consumeResponse(ChannelOpenOkBody.class).queue().purgeName(BrokerAdmin.TEST_QUEUE_NAME).purge().consumeResponse().getLatestResponse(QueuePurgeOkBody.class);
        assertThat(response.getMessageCount(), is(equalTo(1L)));
        QueueDeclareOkBody passive = interaction.queue().declareName(BrokerAdmin.TEST_QUEUE_NAME).declarePassive(true).declare().consumeResponse().getLatestResponse(QueueDeclareOkBody.class);
        assertThat(passive.getQueue(), is(equalTo(AMQShortString.valueOf(BrokerAdmin.TEST_QUEUE_NAME))));
        assertThat(passive.getMessageCount(), is(equalTo(0L)));
    }
}
Also used : QueuePurgeOkBody(org.apache.qpid.server.protocol.v0_8.transport.QueuePurgeOkBody) QueueDeclareOkBody(org.apache.qpid.server.protocol.v0_8.transport.QueueDeclareOkBody) ChannelOpenOkBody(org.apache.qpid.server.protocol.v0_8.transport.ChannelOpenOkBody) Test(org.junit.Test) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest)

Example 5 with QueueDeclareOkBody

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

the class QueueDeclareInvalidOptionBehaviourTest method queueDeclareInvalidWireArguments.

@Test
public void queueDeclareInvalidWireArguments() throws Exception {
    try (FrameTransport transport = new FrameTransport(getBrokerAdmin()).connect()) {
        final Interaction interaction = transport.newInteraction();
        QueueDeclareOkBody response = interaction.negotiateOpen().channel().open().consumeResponse(ChannelOpenOkBody.class).queue().declareName(TEST_QUEUE).declareArguments(Collections.singletonMap("foo", "bar")).declare().consumeResponse().getLatestResponse(QueueDeclareOkBody.class);
        assertThat(response.getQueue(), is(equalTo(AMQShortString.valueOf(TEST_QUEUE))));
        assertThat(response.getMessageCount(), is(equalTo(0L)));
        assertThat(response.getConsumerCount(), is(equalTo(0L)));
    }
}
Also used : FrameTransport(org.apache.qpid.tests.protocol.v0_8.FrameTransport) Interaction(org.apache.qpid.tests.protocol.v0_8.Interaction) QueueDeclareOkBody(org.apache.qpid.server.protocol.v0_8.transport.QueueDeclareOkBody) Test(org.junit.Test)

Aggregations

QueueDeclareOkBody (org.apache.qpid.server.protocol.v0_8.transport.QueueDeclareOkBody)11 Test (org.junit.Test)11 SpecificationTest (org.apache.qpid.tests.protocol.SpecificationTest)9 ChannelOpenOkBody (org.apache.qpid.server.protocol.v0_8.transport.ChannelOpenOkBody)5 AMQShortString (org.apache.qpid.server.protocol.v0_8.AMQShortString)3 ChannelCloseBody (org.apache.qpid.server.protocol.v0_8.transport.ChannelCloseBody)3 BasicConsumeOkBody (org.apache.qpid.server.protocol.v0_8.transport.BasicConsumeOkBody)2 FrameTransport (org.apache.qpid.tests.protocol.v0_8.FrameTransport)2 Interaction (org.apache.qpid.tests.protocol.v0_8.Interaction)2 Matchers.emptyString (org.hamcrest.Matchers.emptyString)2 HashMap (java.util.HashMap)1 QpidByteBuffer (org.apache.qpid.server.bytebuffer.QpidByteBuffer)1 BasicContentHeaderProperties (org.apache.qpid.server.protocol.v0_8.transport.BasicContentHeaderProperties)1 BasicDeliverBody (org.apache.qpid.server.protocol.v0_8.transport.BasicDeliverBody)1 ConnectionCloseBody (org.apache.qpid.server.protocol.v0_8.transport.ConnectionCloseBody)1 ContentBody (org.apache.qpid.server.protocol.v0_8.transport.ContentBody)1 ContentHeaderBody (org.apache.qpid.server.protocol.v0_8.transport.ContentHeaderBody)1 QueuePurgeOkBody (org.apache.qpid.server.protocol.v0_8.transport.QueuePurgeOkBody)1 Ignore (org.junit.Ignore)1