use of org.apache.qpid.server.protocol.v0_8.transport.QueueDeclareOkBody in project qpid-broker-j by apache.
the class QueueTest method queueDeclareAutoDeletePreexistingQueue.
@Test
@SpecificationTest(section = "1.7.2.1", description = "The server MUST ignore the auto-delete field if the queue already exists.")
@Ignore("The server does not ignore the auto-delete field if the queue already exists.")
public void queueDeclareAutoDeletePreexistingQueue() throws Exception {
try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
final Interaction interaction = transport.newInteraction();
QueueDeclareOkBody response = interaction.openAnonymousConnection().channel().open().consumeResponse(ChannelOpenOkBody.class).queue().declareName(BrokerAdmin.TEST_QUEUE_NAME).declare().consumeResponse().getLatestResponse(QueueDeclareOkBody.class);
assertThat(response.getQueue(), is(equalTo(AMQShortString.valueOf(BrokerAdmin.TEST_QUEUE_NAME))));
QueueDeclareOkBody passiveResponse = interaction.queue().declareAutoDelete(true).declareName(BrokerAdmin.TEST_QUEUE_NAME).declare().consumeResponse().getLatestResponse(QueueDeclareOkBody.class);
assertThat(passiveResponse.getQueue(), is(equalTo(AMQShortString.valueOf(BrokerAdmin.TEST_QUEUE_NAME))));
}
}
use of org.apache.qpid.server.protocol.v0_8.transport.QueueDeclareOkBody 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(_brokerAddress).connect()) {
final Interaction interaction = transport.newInteraction();
QueuePurgeOkBody response = interaction.openAnonymousConnection().channel().open().consumeResponse(ChannelOpenOkBody.class).queue().purgeName(BrokerAdmin.TEST_QUEUE_NAME).purge().consumeResponse().getLatestResponse(QueuePurgeOkBody.class);
/* TODO purge currently always returns 0 */
// 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(response.getMessageCount(), is(equalTo(0L)));
}
}
use of org.apache.qpid.server.protocol.v0_8.transport.QueueDeclareOkBody in project qpid-broker-j by apache.
the class QueueTest method queueDeclareDurable.
@Test
@SpecificationTest(section = "1.7.2.1", description = "If [durable is] set when creating a new queue, the queue will be marked as durable. " + "Durable queues remain active when a server restarts.")
public void queueDeclareDurable() throws Exception {
try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
final Interaction interaction = transport.newInteraction();
QueueDeclareOkBody response = interaction.openAnonymousConnection().channel().open().consumeResponse(ChannelOpenOkBody.class).queue().declareDurable(true).declareName(BrokerAdmin.TEST_QUEUE_NAME).declare().consumeResponse().getLatestResponse(QueueDeclareOkBody.class);
assertThat(response.getQueue(), is(equalTo(AMQShortString.valueOf(BrokerAdmin.TEST_QUEUE_NAME))));
assertThat(response.getMessageCount(), is(equalTo(0L)));
assertThat(response.getConsumerCount(), is(equalTo(0L)));
}
assumeThat(getBrokerAdmin().supportsRestart(), Matchers.is(true));
getBrokerAdmin().restart();
try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
final Interaction interaction = transport.newInteraction();
QueueDeclareOkBody response = interaction.openAnonymousConnection().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))));
assertThat(response.getMessageCount(), is(equalTo(0L)));
assertThat(response.getConsumerCount(), is(equalTo(0L)));
}
}
use of org.apache.qpid.server.protocol.v0_8.transport.QueueDeclareOkBody 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(_brokerAddress).connect()) {
final Interaction interaction = transport.newInteraction();
QueueDeclareOkBody response = interaction.openAnonymousConnection().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(_brokerAddress).connect()) {
final Interaction interaction = transport.newInteraction();
QueueDeclareOkBody response = interaction.openAnonymousConnection().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)));
}
}
Aggregations