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));
}
}
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));
}
}
Aggregations