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