Search in sources :

Example 6 with ExecutionResult

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

the class QueueTest method queuePurge.

@Test
@SpecificationTest(section = "10.queue.purge", description = "This command removes all messages from a queue.")
public void queuePurge() throws Exception {
    getBrokerAdmin().createQueue(BrokerAdmin.TEST_QUEUE_NAME);
    getBrokerAdmin().putMessageOnQueue(BrokerAdmin.TEST_QUEUE_NAME, "message");
    try (FrameTransport transport = new FrameTransport(getBrokerAdmin()).connect()) {
        final Interaction interaction = transport.newInteraction();
        ExecutionResult result = interaction.negotiateOpen().channelId(1).attachSession(SESSION_NAME).queue().queryQueue(BrokerAdmin.TEST_QUEUE_NAME).queryId(1).query().session().flushCompleted().flush().consumeResponse(SessionCommandPoint.class).consumeResponse().getLatestResponse(ExecutionResult.class);
        assertThat(((QueueQueryResult) result.getValue()).getMessageCount(), is(1L));
        interaction.queue().purgeQueue(BrokerAdmin.TEST_QUEUE_NAME).purgeId(0).purge().session().flushCompleted().flush().consumeResponse(SessionFlush.class).consumeResponse(SessionCompleted.class);
        result = interaction.queue().queryQueue(BrokerAdmin.TEST_QUEUE_NAME).queryId(1).query().session().flushCompleted().flush().consumeResponse(SessionCompleted.class).consumeResponse().getLatestResponse(ExecutionResult.class);
        assertThat(((QueueQueryResult) result.getValue()).getMessageCount(), is(0L));
    }
}
Also used : SessionCompleted(org.apache.qpid.server.protocol.v0_10.transport.SessionCompleted) ExecutionResult(org.apache.qpid.server.protocol.v0_10.transport.ExecutionResult) SessionFlush(org.apache.qpid.server.protocol.v0_10.transport.SessionFlush) Test(org.junit.Test) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest)

Example 7 with ExecutionResult

use of org.apache.qpid.server.protocol.v0_10.transport.ExecutionResult 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(getBrokerAdmin()).connect()) {
        final Interaction interaction = transport.newInteraction();
        ExecutionResult result = interaction.negotiateOpen().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)

Example 8 with ExecutionResult

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

the class ExchangeTest method exchangeBind.

@Test
@SpecificationTest(section = "10.exchange.bind", description = "This command binds a queue to an exchange." + " Until a queue is bound it will not receive any messages.")
public void exchangeBind() throws Exception {
    getBrokerAdmin().createQueue(BrokerAdmin.TEST_QUEUE_NAME);
    try (FrameTransport transport = new FrameTransport(getBrokerAdmin()).connect()) {
        final Interaction interaction = transport.newInteraction();
        interaction.negotiateOpen().channelId(1).attachSession(SESSION_NAME).exchange().bindId(0).bindExchange("amq.direct").bindQueue(BrokerAdmin.TEST_QUEUE_NAME).bindBindingKey("bk").bind().session().flushCompleted().flush().consumeResponse(SessionCompleted.class);
        ExecutionResult execResult = interaction.exchange().boundId(2).boundExchange("amq.direct").boundQueue(BrokerAdmin.TEST_QUEUE_NAME).boundBindingKey("bk").bound().session().flushCompleted().flush().consumeResponse(SessionCommandPoint.class).consumeResponse().getLatestResponse(ExecutionResult.class);
        assertThat(execResult.getValue(), is(instanceOf(ExchangeBoundResult.class)));
        ExchangeBoundResult result = (ExchangeBoundResult) execResult.getValue();
        assertThat(result.getExchangeNotFound(), is(equalTo(false)));
        assertThat(result.getQueueNotFound(), is(equalTo(false)));
        assertThat(result.getKeyNotMatched(), is(equalTo(false)));
    }
}
Also used : ExecutionResult(org.apache.qpid.server.protocol.v0_10.transport.ExecutionResult) ExchangeBoundResult(org.apache.qpid.server.protocol.v0_10.transport.ExchangeBoundResult) Test(org.junit.Test) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest)

Example 9 with ExecutionResult

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

the class ExchangeTest method exchangeUnbind.

@Test
@SpecificationTest(section = "11.exchange.unbind", description = "This command unbinds a queue from an exchange.")
public void exchangeUnbind() throws Exception {
    getBrokerAdmin().createQueue(BrokerAdmin.TEST_QUEUE_NAME);
    try (FrameTransport transport = new FrameTransport(getBrokerAdmin()).connect()) {
        final Interaction interaction = transport.newInteraction();
        interaction.negotiateOpen().channelId(1).attachSession(SESSION_NAME).exchange().bindId(0).bindExchange("amq.direct").bindQueue(BrokerAdmin.TEST_QUEUE_NAME).bindBindingKey("bk").bind().session().flushCompleted().flush().consumeResponse(SessionCompleted.class).exchange().unbindId(1).unbindExchange("amq.direct").unbindQueue(BrokerAdmin.TEST_QUEUE_NAME).unbindBindingKey("bk").unbind().session().flushCompleted().flush().consumeResponse(SessionCompleted.class);
        ExecutionResult execResult = interaction.exchange().boundId(2).boundExchange("amq.direct").boundQueue(BrokerAdmin.TEST_QUEUE_NAME).boundBindingKey("bk").bound().session().flushCompleted().flush().consumeResponse(SessionCommandPoint.class).consumeResponse().getLatestResponse(ExecutionResult.class);
        assertThat(execResult.getValue(), is(instanceOf(ExchangeBoundResult.class)));
        ExchangeBoundResult result = (ExchangeBoundResult) execResult.getValue();
        assertThat(result.getExchangeNotFound(), is(equalTo(false)));
        assertThat(result.getQueueNotFound(), is(equalTo(false)));
        assertThat(result.getKeyNotMatched(), is(equalTo(true)));
    }
}
Also used : ExecutionResult(org.apache.qpid.server.protocol.v0_10.transport.ExecutionResult) ExchangeBoundResult(org.apache.qpid.server.protocol.v0_10.transport.ExchangeBoundResult) Test(org.junit.Test) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest)

Aggregations

ExecutionResult (org.apache.qpid.server.protocol.v0_10.transport.ExecutionResult)9 SpecificationTest (org.apache.qpid.tests.protocol.SpecificationTest)9 Test (org.junit.Test)9 ExchangeBoundResult (org.apache.qpid.server.protocol.v0_10.transport.ExchangeBoundResult)4 SessionCompleted (org.apache.qpid.server.protocol.v0_10.transport.SessionCompleted)3 ExchangeQueryResult (org.apache.qpid.server.protocol.v0_10.transport.ExchangeQueryResult)2 Acquired (org.apache.qpid.server.protocol.v0_10.transport.Acquired)1 MessageTransfer (org.apache.qpid.server.protocol.v0_10.transport.MessageTransfer)1 QueueQueryResult (org.apache.qpid.server.protocol.v0_10.transport.QueueQueryResult)1 RangeSet (org.apache.qpid.server.protocol.v0_10.transport.RangeSet)1 SessionFlush (org.apache.qpid.server.protocol.v0_10.transport.SessionFlush)1