Search in sources :

Example 6 with ConnectionCloseBody

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

the class ExchangeTest method exchangeDeclareAmqDisallowed.

@Test
@SpecificationTest(section = "1.6.2.1", description = "Exchange names starting with \"amq.\" are reserved for pre-declared and standardised " + "exchanges. The client MAY declare an exchange starting with  \"amq.\" if the passive " + "option is set, or the exchange already exists.")
public void exchangeDeclareAmqDisallowed() throws Exception {
    try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
        final Interaction interaction = transport.newInteraction();
        interaction.openAnonymousConnection().channel().open().consumeResponse(ChannelOpenOkBody.class).exchange().declarePassive(true).declareName(ExchangeDefaults.DIRECT_EXCHANGE_NAME).declare().consumeResponse(ExchangeDeclareOkBody.class).exchange().declarePassive(false).declareName(ExchangeDefaults.DIRECT_EXCHANGE_NAME).declare().consumeResponse(ExchangeDeclareOkBody.class);
        ConnectionCloseBody response = interaction.exchange().declarePassive(false).declareName("amq.illegal").declare().consumeResponse().getLatestResponse(ConnectionCloseBody.class);
        /* TODO: 0-91 specification requires 'access-refused' (403) but server uses 'not-allowed' (530) */
        assertThat(response.getReplyCode(), anyOf(equalTo(ErrorCodes.NOT_ALLOWED), equalTo(ErrorCodes.ACCESS_REFUSED)));
    }
}
Also used : ExchangeDeclareOkBody(org.apache.qpid.server.protocol.v0_8.transport.ExchangeDeclareOkBody) ConnectionCloseBody(org.apache.qpid.server.protocol.v0_8.transport.ConnectionCloseBody) Test(org.junit.Test) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest)

Example 7 with ConnectionCloseBody

use of org.apache.qpid.server.protocol.v0_8.transport.ConnectionCloseBody 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(_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().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 8 with ConnectionCloseBody

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

the class ExchangeTest method exchangeDeclareWithUnknownAlternateExchange.

/**
 * Qpid specific extension
 */
@Test
public void exchangeDeclareWithUnknownAlternateExchange() throws Exception {
    try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
        final Interaction interaction = transport.newInteraction();
        ConnectionCloseBody response = interaction.openAnonymousConnection().channel().open().consumeResponse(ChannelOpenOkBody.class).exchange().declareName(TEST_EXCHANGE).declareArguments(Collections.singletonMap("alternateExchange", "notKnown")).declare().consumeResponse().getLatestResponse(ConnectionCloseBody.class);
        // TODO server fails - jira required
        assertThat(response.getReplyCode(), is(equalTo(ErrorCodes.NOT_FOUND)));
    }
}
Also used : ConnectionCloseBody(org.apache.qpid.server.protocol.v0_8.transport.ConnectionCloseBody) Test(org.junit.Test) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest)

Example 9 with ConnectionCloseBody

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

the class QueueTest method queueDeclareExclusive.

@Test
@SpecificationTest(section = "1.7.2.1", description = "The client MAY NOT attempt to use a queue that was declared as exclusive by another " + "still-open connection.")
public void queueDeclareExclusive() throws Exception {
    try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
        final Interaction interaction = transport.newInteraction();
        QueueDeclareOkBody response = interaction.openAnonymousConnection().channel().open().consumeResponse(ChannelOpenOkBody.class).queue().declareName(BrokerAdmin.TEST_QUEUE_NAME).declareExclusive(true).declare().consumeResponse().getLatestResponse(QueueDeclareOkBody.class);
        assertThat(response.getQueue(), is(equalTo(AMQShortString.valueOf(BrokerAdmin.TEST_QUEUE_NAME))));
        try (FrameTransport transport2 = new FrameTransport(_brokerAddress).connect()) {
            final Interaction interaction2 = transport2.newInteraction();
            ConnectionCloseBody closeResponse = interaction2.openAnonymousConnection().channel().open().consumeResponse(ChannelOpenOkBody.class).queue().declareName(BrokerAdmin.TEST_QUEUE_NAME).declare().consumeResponse().getLatestResponse(ConnectionCloseBody.class);
            /* TODO: 0-91 specification requires 'resource-locked' (405) but server uses (530) */
            assertThat(closeResponse.getReplyCode(), anyOf(equalTo(ErrorCodes.NOT_ALLOWED), equalTo(405)));
        }
    }
    try (FrameTransport transport2 = new FrameTransport(_brokerAddress).connect()) {
        final Interaction interaction2 = transport2.newInteraction();
        QueueDeclareOkBody response = interaction2.openAnonymousConnection().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))));
    }
}
Also used : ConnectionCloseBody(org.apache.qpid.server.protocol.v0_8.transport.ConnectionCloseBody) 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 10 with ConnectionCloseBody

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

the class QueueTest method queueDeclareWithUnknownAlternateExchange.

/**
 * Qpid specific extension
 */
@Test
public void queueDeclareWithUnknownAlternateExchange() throws Exception {
    try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
        final Interaction interaction = transport.newInteraction();
        ConnectionCloseBody response = interaction.openAnonymousConnection().channel().open().consumeResponse(ChannelOpenOkBody.class).queue().declareName(BrokerAdmin.TEST_QUEUE_NAME).declareArguments(Collections.singletonMap("alternateExchange", "notKnown")).declare().consumeResponse().getLatestResponse(ConnectionCloseBody.class);
        assertThat(response.getReplyCode(), is(equalTo(ErrorCodes.NOT_FOUND)));
    }
}
Also used : ConnectionCloseBody(org.apache.qpid.server.protocol.v0_8.transport.ConnectionCloseBody) Test(org.junit.Test) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest)

Aggregations

ConnectionCloseBody (org.apache.qpid.server.protocol.v0_8.transport.ConnectionCloseBody)11 Test (org.junit.Test)11 SpecificationTest (org.apache.qpid.tests.protocol.SpecificationTest)9 ChannelOpenOkBody (org.apache.qpid.server.protocol.v0_8.transport.ChannelOpenOkBody)3 ConnectionStartBody (org.apache.qpid.server.protocol.v0_8.transport.ConnectionStartBody)3 TxSelectOkBody (org.apache.qpid.server.protocol.v0_8.transport.TxSelectOkBody)2 FrameTransport (org.apache.qpid.tests.protocol.v0_8.FrameTransport)2 Interaction (org.apache.qpid.tests.protocol.v0_8.Interaction)2 InetSocketAddress (java.net.InetSocketAddress)1 BasicConsumeOkBody (org.apache.qpid.server.protocol.v0_8.transport.BasicConsumeOkBody)1 BasicDeliverBody (org.apache.qpid.server.protocol.v0_8.transport.BasicDeliverBody)1 BasicQosOkBody (org.apache.qpid.server.protocol.v0_8.transport.BasicQosOkBody)1 ConnectionTuneBody (org.apache.qpid.server.protocol.v0_8.transport.ConnectionTuneBody)1 ContentHeaderBody (org.apache.qpid.server.protocol.v0_8.transport.ContentHeaderBody)1 ExchangeDeclareOkBody (org.apache.qpid.server.protocol.v0_8.transport.ExchangeDeclareOkBody)1 QueueDeclareOkBody (org.apache.qpid.server.protocol.v0_8.transport.QueueDeclareOkBody)1 Matchers.containsString (org.hamcrest.Matchers.containsString)1