Search in sources :

Example 41 with SpecificationTest

use of org.apache.qpid.tests.protocol.SpecificationTest 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(_brokerAddress).connect()) {
        final Interaction interaction = transport.newInteraction();
        interaction.openAnonymousConnection().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 42 with SpecificationTest

use of org.apache.qpid.tests.protocol.SpecificationTest in project qpid-broker-j by apache.

the class ExchangeTest method exchangeUnsupportedExchangeType.

@Test
@SpecificationTest(section = "1.6.2.1", description = "The client MUST NOT attempt to declare an exchange with a type that the server does not " + "support.")
public void exchangeUnsupportedExchangeType() throws Exception {
    try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
        final Interaction interaction = transport.newInteraction();
        interaction.openAnonymousConnection().channel().open().consumeResponse(ChannelOpenOkBody.class).exchange().declareType(ExchangeDefaults.DIRECT_EXCHANGE_CLASS).declareName(TEST_EXCHANGE).declare().consumeResponse(ExchangeDeclareOkBody.class);
        ConnectionCloseBody response = interaction.exchange().declarePassive(true).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 43 with SpecificationTest

use of org.apache.qpid.tests.protocol.SpecificationTest 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(_brokerAddress).connect()) {
        final Interaction interaction = transport.newInteraction();
        interaction.openAnonymousConnection().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 44 with SpecificationTest

use of org.apache.qpid.tests.protocol.SpecificationTest 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(_brokerAddress).connect()) {
        final Interaction interaction = transport.newInteraction();
        interaction.openAnonymousConnection().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(_brokerAddress).connect()) {
        final Interaction interaction = transport.newInteraction();
        ExchangeBoundOkBody response = interaction.openAnonymousConnection().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 45 with SpecificationTest

use of org.apache.qpid.tests.protocol.SpecificationTest in project qpid-broker-j by apache.

the class ExchangeTest method exchangeDeclarePassive.

@Test
@SpecificationTest(section = "1.6.2.1", description = "If [passive is] set, the server will reply with Declare-Ok if the exchange " + "already exists with the same name, and raise an error if not.  The client can " + "use this to check whether an exchange exists without modifying the server state.")
public void exchangeDeclarePassive() throws Exception {
    try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
        final Interaction interaction = transport.newInteraction();
        interaction.openAnonymousConnection().channel().open().consumeResponse(ChannelOpenOkBody.class).exchange().declareName(TEST_EXCHANGE).declare().consumeResponse(ExchangeDeclareOkBody.class).exchange().declarePassive(true).declareName(TEST_EXCHANGE).declare().consumeResponse(ExchangeDeclareOkBody.class).exchange().deleteExchangeName(TEST_EXCHANGE).delete().consumeResponse(ExchangeDeleteOkBody.class);
        ChannelCloseBody response = interaction.exchange().declarePassive(true).declareName(TEST_EXCHANGE).declare().consumeResponse().getLatestResponse(ChannelCloseBody.class);
        assertThat(response.getReplyCode(), is(equalTo(ErrorCodes.NOT_FOUND)));
    }
}
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) Test(org.junit.Test) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest)

Aggregations

SpecificationTest (org.apache.qpid.tests.protocol.SpecificationTest)209 Test (org.junit.Test)209 FrameTransport (org.apache.qpid.tests.protocol.v1_0.FrameTransport)106 Interaction (org.apache.qpid.tests.protocol.v1_0.Interaction)82 InetSocketAddress (java.net.InetSocketAddress)52 Attach (org.apache.qpid.server.protocol.v1_0.type.transport.Attach)52 Open (org.apache.qpid.server.protocol.v1_0.type.transport.Open)45 Begin (org.apache.qpid.server.protocol.v1_0.type.transport.Begin)37 Flow (org.apache.qpid.server.protocol.v1_0.type.transport.Flow)35 ChannelOpenOkBody (org.apache.qpid.server.protocol.v0_8.transport.ChannelOpenOkBody)29 Binary (org.apache.qpid.server.protocol.v1_0.type.Binary)28 Disposition (org.apache.qpid.server.protocol.v1_0.type.transport.Disposition)28 UnsignedInteger (org.apache.qpid.server.protocol.v1_0.type.UnsignedInteger)26 AMQShortString (org.apache.qpid.server.protocol.v0_8.AMQShortString)22 InteractionTransactionalState (org.apache.qpid.tests.protocol.v1_0.InteractionTransactionalState)19 Detach (org.apache.qpid.server.protocol.v1_0.type.transport.Detach)16 Accepted (org.apache.qpid.server.protocol.v1_0.type.messaging.Accepted)15 ChannelCloseBody (org.apache.qpid.server.protocol.v0_8.transport.ChannelCloseBody)14 ConnectionStartBody (org.apache.qpid.server.protocol.v0_8.transport.ConnectionStartBody)14 Error (org.apache.qpid.server.protocol.v1_0.type.transport.Error)14