Search in sources :

Example 11 with SpecificationTest

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

the class QueueTest method queueDeclareRedeclareOfExclusivelyDeclaredQueue.

@Test
@SpecificationTest(section = "10.queue.declare", description = "If the server receives a declare, bind, consume or get request for a queue that has been" + "declared as exclusive by an existing client session, it MUST raise an exception.")
public void queueDeclareRedeclareOfExclusivelyDeclaredQueue() throws Exception {
    try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
        final Interaction interaction = transport.newInteraction();
        interaction.openAnonymousConnection().channelId(1).attachSession(SESSION_NAME).queue().declareQueue(BrokerAdmin.TEST_QUEUE_NAME).declareId(0).declareExclusive(true).declare().session().flushCompleted().flush().consumeResponse(SessionCompleted.class);
        try (FrameTransport transport2 = new FrameTransport(_brokerAddress).connect()) {
            final Interaction interaction2 = transport2.newInteraction();
            ExecutionException response = interaction2.openAnonymousConnection().channelId(1).attachSession("test2".getBytes(UTF_8)).queue().declareQueue(BrokerAdmin.TEST_QUEUE_NAME).declareId(0).declareExclusive(true).declare().session().flushCompleted().flush().consumeResponse(SessionCommandPoint.class).consumeResponse().getLatestResponse(ExecutionException.class);
            assertThat(response.getErrorCode(), is(equalTo(ExecutionErrorCode.RESOURCE_LOCKED)));
        }
    }
    try (FrameTransport transport2 = new FrameTransport(_brokerAddress).connect()) {
        final Interaction interaction2 = transport2.newInteraction();
        interaction2.openAnonymousConnection().channelId(1).attachSession("test2".getBytes(UTF_8)).queue().declareQueue(BrokerAdmin.TEST_QUEUE_NAME).declareId(0).declareExclusive(true).declare().session().flushCompleted().flush().consumeResponse(SessionCompleted.class);
    }
}
Also used : ExecutionException(org.apache.qpid.server.protocol.v0_10.transport.ExecutionException) Test(org.junit.Test) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest)

Example 12 with SpecificationTest

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

the class QueueTest method queueDeleteQueueNotFound.

@Test
@SpecificationTest(section = "10.queue.delete", description = "The queue must exist. If the client attempts to delete a non-existing queue the server " + "MUST raise an exception.")
public void queueDeleteQueueNotFound() throws Exception {
    try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
        final Interaction interaction = transport.newInteraction();
        ExecutionException response = interaction.openAnonymousConnection().channelId(1).attachSession(SESSION_NAME).queue().deleteQueue(BrokerAdmin.TEST_QUEUE_NAME).deleteId(0).delete().session().flushCompleted().flush().consumeResponse(SessionCommandPoint.class).consumeResponse().getLatestResponse(ExecutionException.class);
        assertThat(response.getErrorCode(), is(equalTo(ExecutionErrorCode.NOT_FOUND)));
    }
}
Also used : ExecutionException(org.apache.qpid.server.protocol.v0_10.transport.ExecutionException) Test(org.junit.Test) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest)

Example 13 with SpecificationTest

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

the class QueueTest method queueDeclareAttemptedConsumeOfExclusivelyDeclaredQueue.

@Test
@SpecificationTest(section = "10.queue.declare", description = "If the server receives a declare, bind, consume or get request for a queue that has been" + "declared as exclusive by an existing client session, it MUST raise an exception.")
public void queueDeclareAttemptedConsumeOfExclusivelyDeclaredQueue() throws Exception {
    try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
        final Interaction interaction = transport.newInteraction();
        interaction.openAnonymousConnection().channelId(1).attachSession(SESSION_NAME).queue().declareQueue(BrokerAdmin.TEST_QUEUE_NAME).declareId(0).declareExclusive(true).declare().session().flushCompleted().flush().consumeResponse(SessionCompleted.class);
        try (FrameTransport transport2 = new FrameTransport(_brokerAddress).connect()) {
            final Interaction interaction2 = transport2.newInteraction();
            ExecutionException response = interaction2.openAnonymousConnection().channelId(1).attachSession("test2".getBytes(UTF_8)).message().subscribeDestination("mysub").subscribeQueue(BrokerAdmin.TEST_QUEUE_NAME).subscribeId(0).subscribe().session().flushCompleted().flush().consumeResponse(SessionCommandPoint.class).consumeResponse().getLatestResponse(ExecutionException.class);
            assertThat(response.getErrorCode(), is(equalTo(ExecutionErrorCode.RESOURCE_LOCKED)));
        }
    }
    try (FrameTransport transport2 = new FrameTransport(_brokerAddress).connect()) {
        final Interaction interaction2 = transport2.newInteraction();
        interaction2.openAnonymousConnection().channelId(1).attachSession("test2".getBytes(UTF_8)).message().subscribeDestination("mysub").subscribeQueue(BrokerAdmin.TEST_QUEUE_NAME).subscribeId(0).subscribe().session().flushCompleted().flush().consumeResponse(SessionCompleted.class);
    }
}
Also used : ExecutionException(org.apache.qpid.server.protocol.v0_10.transport.ExecutionException) Test(org.junit.Test) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest)

Example 14 with SpecificationTest

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

the class QueueTest method queueDeclarePassiveQueueNotFound.

@Test
@SpecificationTest(section = "10.queue.declare", description = "[...] If the queue does not exist, the server treats this as a failure.")
public void queueDeclarePassiveQueueNotFound() throws Exception {
    try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
        final Interaction interaction = transport.newInteraction();
        ExecutionException response = interaction.openAnonymousConnection().channelId(1).attachSession(SESSION_NAME).queue().declareQueue(BrokerAdmin.TEST_QUEUE_NAME).declarePassive(true).declareId(0).declare().session().flushCompleted().flush().consumeResponse(SessionCommandPoint.class).consumeResponse().getLatestResponse(ExecutionException.class);
        assertThat(response.getErrorCode(), is(equalTo(ExecutionErrorCode.NOT_FOUND)));
    }
}
Also used : ExecutionException(org.apache.qpid.server.protocol.v0_10.transport.ExecutionException) Test(org.junit.Test) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest)

Example 15 with SpecificationTest

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

the class QueueTest method queueQuery.

@Test
@SpecificationTest(section = "10.queue.query", description = "This command requests information about a queue.")
public void queueQuery() throws Exception {
    getBrokerAdmin().createQueue(BrokerAdmin.TEST_QUEUE_NAME);
    getBrokerAdmin().putMessageOnQueue(BrokerAdmin.TEST_QUEUE_NAME, "message");
    try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
        final Interaction interaction = transport.newInteraction();
        ExecutionResult result = interaction.openAnonymousConnection().channelId(1).attachSession(SESSION_NAME).queue().queryQueue(BrokerAdmin.TEST_QUEUE_NAME).queryId(0).query().session().flushCompleted().flush().consumeResponse(SessionCommandPoint.class).consumeResponse().getLatestResponse(ExecutionResult.class);
        QueueQueryResult queryResult = (QueueQueryResult) result.getValue();
        assertThat(queryResult.getQueue(), is(equalTo(BrokerAdmin.TEST_QUEUE_NAME)));
        assertThat(queryResult.getAlternateExchange(), is(nullValue()));
        assertThat(queryResult.getMessageCount(), is(1L));
    }
}
Also used : ExecutionResult(org.apache.qpid.server.protocol.v0_10.transport.ExecutionResult) QueueQueryResult(org.apache.qpid.server.protocol.v0_10.transport.QueueQueryResult) 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