Search in sources :

Example 66 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 ExchangeTest method exchangeDeclareAutoDelete.

/**
 * Qpid specific extension
 */
@Test
public void exchangeDeclareAutoDelete() 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).declareAutoDelete(true).declare().consumeResponse(ExchangeDeclareOkBody.class).queue().bindName(TEST_EXCHANGE).bindQueueName(BrokerAdmin.TEST_QUEUE_NAME).bind().consumeResponse(QueueBindOkBody.class).queue().deleteName(BrokerAdmin.TEST_QUEUE_NAME).delete().consumeResponse(QueueDeleteOkBody.class);
        ExchangeBoundOkBody boundResponse = interaction.exchange().boundExchangeName(TEST_EXCHANGE).bound().consumeResponse().getLatestResponse(ExchangeBoundOkBody.class);
        assertThat(boundResponse.getReplyCode(), is(equalTo(ExchangeBoundOkBody.EXCHANGE_NOT_FOUND)));
    }
}
Also used : ExchangeDeclareOkBody(org.apache.qpid.server.protocol.v0_8.transport.ExchangeDeclareOkBody) ExchangeBoundOkBody(org.apache.qpid.server.protocol.v0_8.transport.ExchangeBoundOkBody) Test(org.junit.Test) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest)

Example 67 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 ExchangeTest method exchangeRedeclareDifferentType.

@Test
@SpecificationTest(section = "1.6.2.1", description = "The client MUST not attempt to redeclare an existing exchange with a different type than " + "used in the original Exchange.Declare method")
public void exchangeRedeclareDifferentType() throws Exception {
    try (FrameTransport transport = new FrameTransport(getBrokerAdmin()).connect()) {
        final Interaction interaction = transport.newInteraction();
        interaction.negotiateOpen().channel().open().consumeResponse(ChannelOpenOkBody.class).exchange().declareType(ExchangeDefaults.DIRECT_EXCHANGE_CLASS).declareName(TEST_EXCHANGE).declare().consumeResponse(ExchangeDeclareOkBody.class);
        ConnectionCloseBody response = interaction.exchange().declareType(ExchangeDefaults.TOPIC_EXCHANGE_CLASS).declareName(TEST_EXCHANGE).declare().consumeResponse().getLatestResponse(ConnectionCloseBody.class);
        assertThat(response.getReplyCode(), is(equalTo(ErrorCodes.NOT_ALLOWED)));
    }
}
Also used : ConnectionCloseBody(org.apache.qpid.server.protocol.v0_8.transport.ConnectionCloseBody) 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 68 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 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 69 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 ExchangeTest method exchangeDeleteExchangeNotFound.

@Test
@SpecificationTest(section = "1.6.2.3", description = "The client MUST NOT attempt to delete an exchange that does not exist.")
public void exchangeDeleteExchangeNotFound() throws Exception {
    try (FrameTransport transport = new FrameTransport(getBrokerAdmin()).connect()) {
        final Interaction interaction = transport.newInteraction();
        ChannelCloseBody unknownExchange = interaction.negotiateOpen().channel().open().consumeResponse(ChannelOpenOkBody.class).exchange().deleteExchangeName("unknownExchange").delete().consumeResponse().getLatestResponse(ChannelCloseBody.class);
        assertThat(unknownExchange.getReplyCode(), is(equalTo(ErrorCodes.NOT_FOUND)));
        interaction.channel().closeOk();
    }
}
Also used : 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 70 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 ExchangeTest method exchangeDeleteAmqDisallowed.

@Test
@SpecificationTest(section = "1.6.2.3", description = "The server MUST, in each virtual host, pre-declare an exchange instance for each standard " + "exchange type that it implements.")
public void exchangeDeleteAmqDisallowed() throws Exception {
    try (FrameTransport transport = new FrameTransport(getBrokerAdmin()).connect()) {
        final Interaction interaction = transport.newInteraction();
        ChannelCloseBody response = interaction.negotiateOpen().channel().open().consumeResponse(ChannelOpenOkBody.class).exchange().deleteExchangeName(ExchangeDefaults.DIRECT_EXCHANGE_NAME).delete().consumeResponse().getLatestResponse(ChannelCloseBody.class);
        assertThat(response.getReplyCode(), is(equalTo(ErrorCodes.NOT_ALLOWED)));
    }
}
Also used : 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

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