use of org.apache.qpid.server.protocol.v0_8.transport in project qpid-broker-j by apache.
the class QueueTest method queuePurgeQueueNotFound.
@Test
@SpecificationTest(section = "1.7.2.7", description = "The client MUST NOT attempt to purge a queue that does not exist.")
public void queuePurgeQueueNotFound() throws Exception {
try (FrameTransport transport = new FrameTransport(getBrokerAdmin()).connect()) {
final Interaction interaction = transport.newInteraction();
ChannelCloseBody response = interaction.negotiateOpen().channel().open().consumeResponse(ChannelOpenOkBody.class).queue().purgeName(BrokerAdmin.TEST_QUEUE_NAME).purge().consumeResponse().getLatestResponse(ChannelCloseBody.class);
assertThat(response.getReplyCode(), is(equalTo(ErrorCodes.NOT_FOUND)));
}
}
use of org.apache.qpid.server.protocol.v0_8.transport in project qpid-broker-j by apache.
the class QueueTest method queueDeclareAutoDelete.
@Test
@SpecificationTest(section = "1.7.2.1", description = "If [auto-delete] set, the queue is deleted when all consumers have finished using it. The " + "last consumer can be cancelled either explicitly or because its channel is closed. " + "If there was no consumer ever on the queue, it won't be deleted.")
public void queueDeclareAutoDelete() throws Exception {
try (FrameTransport transport = new FrameTransport(getBrokerAdmin()).connect()) {
final Interaction interaction = transport.newInteraction();
QueueDeclareOkBody response = interaction.negotiateOpen().channel().open().consumeResponse(ChannelOpenOkBody.class).queue().declareAutoDelete(true).declareName(BrokerAdmin.TEST_QUEUE_NAME).declare().consumeResponse().getLatestResponse(QueueDeclareOkBody.class);
assertThat(response.getQueue(), is(equalTo(AMQShortString.valueOf(BrokerAdmin.TEST_QUEUE_NAME))));
}
try (FrameTransport transport = new FrameTransport(getBrokerAdmin()).connect()) {
final Interaction interaction = transport.newInteraction();
QueueDeclareOkBody response = interaction.negotiateOpen().channel().open().consumeResponse(ChannelOpenOkBody.class).queue().declarePassive(true).declareName(BrokerAdmin.TEST_QUEUE_NAME).declare().consumeResponse().getLatestResponse(QueueDeclareOkBody.class);
assertThat(response.getQueue(), is(equalTo(AMQShortString.valueOf(BrokerAdmin.TEST_QUEUE_NAME))));
final String consumerTag = "lastConsumer";
interaction.basic().consumeConsumerTag(consumerTag).consumeQueue(BrokerAdmin.TEST_QUEUE_NAME).consume().consumeResponse(BasicConsumeOkBody.class).basic().consumeCancelTag(consumerTag).cancel().consumeResponse().getLatestResponse(BasicCancelOkBody.class);
ChannelCloseBody closeResponse = interaction.queue().declarePassive(true).declareName(BrokerAdmin.TEST_QUEUE_NAME).declare().consumeResponse().getLatestResponse(ChannelCloseBody.class);
assertThat(closeResponse.getReplyCode(), is(equalTo(ErrorCodes.NOT_FOUND)));
}
}
use of org.apache.qpid.server.protocol.v0_8.transport in project qpid-broker-j by apache.
the class QueueTest method queueUnbindUnknownQueue.
@Test
@SpecificationTest(section = "1.7.2.5", description = "The client MUST NOT attempt to unbind a queue that does " + "not exist.")
public void queueUnbindUnknownQueue() throws Exception {
getBrokerAdmin().createQueue(BrokerAdmin.TEST_QUEUE_NAME);
try (FrameTransport transport = new FrameTransport(getBrokerAdmin()).connect()) {
final Interaction interaction = transport.newInteraction();
String testExchange = "testExchange";
ChannelCloseBody response = interaction.negotiateOpen().channel().open().consumeResponse(ChannelOpenOkBody.class).exchange().declareName(testExchange).declare().consumeResponse(ExchangeDeclareOkBody.class).queue().bindName(testExchange).bindQueueName(BrokerAdmin.TEST_QUEUE_NAME).bindRoutingKey("rk1").bind().consumeResponse(QueueBindOkBody.class).queue().unbindName(testExchange).unbindQueueName("unknownQueue").unbindRoutingKey("rk1").unbind().consumeResponse().getLatestResponse(ChannelCloseBody.class);
assertThat(response.getReplyCode(), is(equalTo(ErrorCodes.NOT_FOUND)));
}
}
use of org.apache.qpid.server.protocol.v0_8.transport in project qpid-broker-j by apache.
the class QueueTest method queueDeleteDefaultQueue.
@Test
@SpecificationTest(section = "1.7.2.9", description = "The client MUST either specify a queue name or have previously declared a queue on the " + "same channel")
public void queueDeleteDefaultQueue() 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();
QueueDeleteOkBody deleteResponse = interaction.negotiateOpen().channel().open().consumeResponse(ChannelOpenOkBody.class).queue().declareName(BrokerAdmin.TEST_QUEUE_NAME).declare().consumeResponse(QueueDeclareOkBody.class).queue().delete().consumeResponse().getLatestResponse(QueueDeleteOkBody.class);
assertThat(deleteResponse.getMessageCount(), is(equalTo(1L)));
}
}
use of org.apache.qpid.server.protocol.v0_8.transport in project qpid-broker-j by apache.
the class QueueTest method queuePurge.
@Test
@SpecificationTest(section = "1.7.2.7", description = "purge 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();
QueuePurgeOkBody response = interaction.negotiateOpen().channel().open().consumeResponse(ChannelOpenOkBody.class).queue().purgeName(BrokerAdmin.TEST_QUEUE_NAME).purge().consumeResponse().getLatestResponse(QueuePurgeOkBody.class);
assertThat(response.getMessageCount(), is(equalTo(1L)));
QueueDeclareOkBody passive = interaction.queue().declareName(BrokerAdmin.TEST_QUEUE_NAME).declarePassive(true).declare().consumeResponse().getLatestResponse(QueueDeclareOkBody.class);
assertThat(passive.getQueue(), is(equalTo(AMQShortString.valueOf(BrokerAdmin.TEST_QUEUE_NAME))));
assertThat(passive.getMessageCount(), is(equalTo(0L)));
}
}
Aggregations