Search in sources :

Example 11 with ExecutionException

use of org.apache.qpid.server.protocol.v0_10.transport.ExecutionException in project qpid-broker-j by apache.

the class QueueTest method queuePurgeQueueNotFound.

@Test
@SpecificationTest(section = "10.queue.purge", description = "The queue must exist. If the client attempts to purge a non-existing queue the server " + "MUST raise an exception.")
public void queuePurgeQueueNotFound() throws Exception {
    try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
        final Interaction interaction = transport.newInteraction();
        ExecutionException response = interaction.openAnonymousConnection().channelId(1).attachSession(SESSION_NAME).queue().purgeQueue(BrokerAdmin.TEST_QUEUE_NAME).purgeId(0).purge().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 12 with ExecutionException

use of org.apache.qpid.server.protocol.v0_10.transport.ExecutionException in project qpid-broker-j by apache.

the class QueueTest method queueDeclareAutoDeleteDeletedByLastConsumerCancelled.

@Test
@SpecificationTest(section = "10.queue.declare", description = "If this field is set and the exclusive field is not set the queue is deleted when all the " + "consumers have finished using it. Last consumer can be cancelled either explicitly or " + "because its session is closed.")
public void queueDeclareAutoDeleteDeletedByLastConsumerCancelled() 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).declareAutoDelete(true).declare().session().flushCompleted().flush().consumeResponse(SessionCompleted.class);
    }
    try (FrameTransport transport2 = new FrameTransport(_brokerAddress).connect()) {
        final Interaction interaction2 = transport2.newInteraction();
        String subscriberName = "mysub";
        interaction2.openAnonymousConnection().channelId(1).attachSession("test2".getBytes(UTF_8)).queue().declareQueue(BrokerAdmin.TEST_QUEUE_NAME).declareId(0).declarePassive(true).declare().message().subscribeDestination(subscriberName).subscribeQueue(BrokerAdmin.TEST_QUEUE_NAME).subscribeId(1).subscribe().session().flushCompleted().flush().consumeResponse(SessionCompleted.class).message().cancelId(2).cancelDestination(subscriberName).cancel().session().flushCompleted().flush().consumeResponse(SessionCompleted.class);
        ExecutionException response = interaction2.queue().declareQueue(BrokerAdmin.TEST_QUEUE_NAME).declareId(3).declarePassive(true).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 13 with ExecutionException

use of org.apache.qpid.server.protocol.v0_10.transport.ExecutionException in project qpid-broker-j by apache.

the class QueueTest method queueDelete.

@Test
@SpecificationTest(section = "10.queue.delete", description = "This command deletes a queue.")
public void queueDelete() throws Exception {
    getBrokerAdmin().createQueue(BrokerAdmin.TEST_QUEUE_NAME);
    try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
        final Interaction interaction = transport.newInteraction();
        interaction.openAnonymousConnection().channelId(1).attachSession(SESSION_NAME).queue().deleteQueue(BrokerAdmin.TEST_QUEUE_NAME).deleteId(0).delete().session().flushCompleted().flush().consumeResponse(SessionCompleted.class);
        ExecutionException response = interaction.queue().declareQueue(BrokerAdmin.TEST_QUEUE_NAME).declarePassive(true).declareId(1).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 14 with ExecutionException

use of org.apache.qpid.server.protocol.v0_10.transport.ExecutionException in project qpid-broker-j by apache.

the class QueueTest method queueDeclareAlternateExchangeNotFound.

@Test
@SpecificationTest(section = "10.queue.declare", description = "if the alternate-exchange does not match the name of any existing exchange on the server, " + "then an exception must be raised.")
public void queueDeclareAlternateExchangeNotFound() 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).declareAlternateExchange("unknownExchange").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 ExecutionException

use of org.apache.qpid.server.protocol.v0_10.transport.ExecutionException in project qpid-broker-j by apache.

the class QueueTest method queueDeleteQueueDeleteWithConsumer.

@Test
@SpecificationTest(section = "10.queue.delete", description = "If set, the server will only delete the queue if it has no consumers. If the queue has " + "consumers the server does does not delete it but raises an exception instead.")
public void queueDeleteQueueDeleteWithConsumer() throws Exception {
    getBrokerAdmin().createQueue(BrokerAdmin.TEST_QUEUE_NAME);
    try (FrameTransport consumerTransport = new FrameTransport(_brokerAddress).connect();
        FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
        final Interaction consumerInteraction = consumerTransport.newInteraction();
        String subscriberName = "mysub";
        consumerInteraction.openAnonymousConnection().channelId(1).attachSession(SESSION_NAME).message().subscribeDestination(subscriberName).subscribeQueue(BrokerAdmin.TEST_QUEUE_NAME).subscribeId(1).subscribe().session().flushCompleted().flush().consumeResponse(SessionCompleted.class);
        final Interaction interaction = transport.newInteraction();
        ExecutionException response = interaction.openAnonymousConnection().channelId(1).attachSession("test2".getBytes(UTF_8)).queue().deleteQueue(BrokerAdmin.TEST_QUEUE_NAME).deleteId(0).deleteIfUnused(true).delete().session().flushCompleted().flush().consumeResponse(SessionCommandPoint.class).consumeResponse().getLatestResponse(ExecutionException.class);
        assertThat(response.getErrorCode(), is(equalTo(ExecutionErrorCode.PRECONDITION_FAILED)));
        consumerInteraction.message().cancelId(2).cancelDestination(subscriberName).cancel().session().flushCompleted().flush().consumeResponse(SessionCompleted.class);
        consumerInteraction.queue().deleteQueue(BrokerAdmin.TEST_QUEUE_NAME).deleteId(0).deleteIfUnused(true).delete().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)

Aggregations

ExecutionException (org.apache.qpid.server.protocol.v0_10.transport.ExecutionException)15 SpecificationTest (org.apache.qpid.tests.protocol.SpecificationTest)12 Test (org.junit.Test)12 ArrayList (java.util.ArrayList)1 Subject (javax.security.auth.Subject)1 EventLogger (org.apache.qpid.server.logging.EventLogger)1 AmqpPort (org.apache.qpid.server.model.port.AmqpPort)1 Binary (org.apache.qpid.server.protocol.v0_10.transport.Binary)1 ExchangeDelete (org.apache.qpid.server.protocol.v0_10.transport.ExchangeDelete)1 ExecutionErrorCode (org.apache.qpid.server.protocol.v0_10.transport.ExecutionErrorCode)1 MessageTransfer (org.apache.qpid.server.protocol.v0_10.transport.MessageTransfer)1 Method (org.apache.qpid.server.protocol.v0_10.transport.Method)1 ArgumentMatcher (org.mockito.ArgumentMatcher)1