use of org.apache.qpid.server.protocol.v0_8.transport.QueueDeclareOkBody in project qpid-broker-j by apache.
the class QueueTest method queueDeclarePassive.
@Test
@SpecificationTest(section = "1.7.2.1", description = "If [declarePassive is] set, the server will reply with Declare-Ok if the queue already exists" + "with the same name, and raise an error if not.")
public void queueDeclarePassive() throws Exception {
getBrokerAdmin().createQueue(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))));
assertThat(response.getMessageCount(), is(equalTo(0L)));
assertThat(response.getConsumerCount(), is(equalTo(0L)));
getBrokerAdmin().deleteQueue(BrokerAdmin.TEST_QUEUE_NAME);
ChannelCloseBody closeResponse = interaction.queue().deleteName(BrokerAdmin.TEST_QUEUE_NAME).delete().consumeResponse().getLatestResponse(ChannelCloseBody.class);
assertThat(closeResponse.getReplyCode(), is(equalTo(ErrorCodes.NOT_FOUND)));
}
}
use of org.apache.qpid.server.protocol.v0_8.transport.QueueDeclareOkBody in project qpid-broker-j by apache.
the class QueueTest method queueDeclareEquivalent.
@Test
@SpecificationTest(section = "1.7.2.1", description = "If not set and the queue exists, the server MUST check " + "that the existing queue has the same values for durable, " + "exclusive, auto-delete, and arguments fields.")
public void queueDeclareEquivalent() throws Exception {
try (FrameTransport transport = new FrameTransport(getBrokerAdmin()).connect()) {
final Interaction interaction = transport.newInteraction();
QueueInteraction queueInteraction = interaction.negotiateOpen().channel().open().consumeResponse(ChannelOpenOkBody.class).queue();
QueueDeclareOkBody response = queueInteraction.declareName(BrokerAdmin.TEST_QUEUE_NAME).declareExclusive(false).declare().consumeResponse().getLatestResponse(QueueDeclareOkBody.class);
assertThat(response.getQueue(), is(equalTo(AMQShortString.valueOf(BrokerAdmin.TEST_QUEUE_NAME))));
QueueDeclareOkBody equalDeclareResponse = queueInteraction.declareName(BrokerAdmin.TEST_QUEUE_NAME).declareExclusive(false).declare().consumeResponse().getLatestResponse(QueueDeclareOkBody.class);
assertThat(equalDeclareResponse.getQueue(), is(equalTo(AMQShortString.valueOf(BrokerAdmin.TEST_QUEUE_NAME))));
ChannelCloseBody unequalDeclareResponse = queueInteraction.declareName(BrokerAdmin.TEST_QUEUE_NAME).declareExclusive(true).declare().consumeResponse().getLatestResponse(ChannelCloseBody.class);
assertThat(unequalDeclareResponse.getReplyCode(), is(equalTo(ErrorCodes.ALREADY_EXISTS)));
interaction.channel().closeOk();
}
}
use of org.apache.qpid.server.protocol.v0_8.transport.QueueDeclareOkBody in project qpid-broker-j by apache.
the class QueueTest method queueDeclare.
@Test
@SpecificationTest(section = "1.7.2.1", description = "declare queue, create if needed")
public void queueDeclare() throws Exception {
try (FrameTransport transport = new FrameTransport(getBrokerAdmin()).connect()) {
final Interaction interaction = transport.newInteraction();
QueueDeclareOkBody response = interaction.negotiateOpen().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))));
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 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)));
}
}
use of org.apache.qpid.server.protocol.v0_8.transport.QueueDeclareOkBody in project qpid-broker-j by apache.
the class QueueDeclareInvalidOptionBehaviourTest method queueDeclareInvalidWireArguments.
@Test
public void queueDeclareInvalidWireArguments() throws Exception {
try (FrameTransport transport = new FrameTransport(getBrokerAdmin()).connect()) {
final Interaction interaction = transport.newInteraction();
QueueDeclareOkBody response = interaction.negotiateOpen().channel().open().consumeResponse(ChannelOpenOkBody.class).queue().declareName(TEST_QUEUE).declareArguments(Collections.singletonMap("foo", "bar")).declare().consumeResponse().getLatestResponse(QueueDeclareOkBody.class);
assertThat(response.getQueue(), is(equalTo(AMQShortString.valueOf(TEST_QUEUE))));
assertThat(response.getMessageCount(), is(equalTo(0L)));
assertThat(response.getConsumerCount(), is(equalTo(0L)));
}
}
Aggregations