Search in sources :

Example 1 with QueueQueryResult

use of org.apache.qpid.server.protocol.v0_10.transport.QueueQueryResult 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 2 with QueueQueryResult

use of org.apache.qpid.server.protocol.v0_10.transport.QueueQueryResult 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)

Aggregations

ExecutionResult (org.apache.qpid.server.protocol.v0_10.transport.ExecutionResult)2 SpecificationTest (org.apache.qpid.tests.protocol.SpecificationTest)2 Test (org.junit.Test)2 QueueQueryResult (org.apache.qpid.server.protocol.v0_10.transport.QueueQueryResult)1 SessionCompleted (org.apache.qpid.server.protocol.v0_10.transport.SessionCompleted)1 SessionFlush (org.apache.qpid.server.protocol.v0_10.transport.SessionFlush)1