use of org.apache.qpid.server.protocol.v0_8.transport.ChannelCloseBody 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(_brokerAddress).connect()) {
final Interaction interaction = transport.newInteraction();
QueueInteraction queueInteraction = interaction.openAnonymousConnection().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.ChannelCloseBody 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(_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)));
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.ChannelCloseBody in project qpid-broker-j by apache.
the class QueueTest method queueBindUnknownQueue.
@Test
@SpecificationTest(section = "1.7.2.3", description = "The client MUST NOT attempt to bind a queue that does not exist.")
public void queueBindUnknownQueue() throws Exception {
try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
String testExchange = "testExchange";
final Interaction interaction = transport.newInteraction();
ChannelCloseBody response = interaction.openAnonymousConnection().channel().open().consumeResponse(ChannelOpenOkBody.class).exchange().declareName(testExchange).declare().consumeResponse(ExchangeDeclareOkBody.class).queue().bindName(testExchange).bindQueueName(BrokerAdmin.TEST_QUEUE_NAME).bind().consumeResponse().getLatestResponse(ChannelCloseBody.class);
assertThat(response.getReplyCode(), is(equalTo(ErrorCodes.NOT_FOUND)));
}
}
use of org.apache.qpid.server.protocol.v0_8.transport.ChannelCloseBody in project qpid-broker-j by apache.
the class ExchangeTest method exchangeDeleteExchangeNotFound.
@Test
@SpecificationTest(section = "1.6.2.3", description = "The client MUST NOT attempt to delete an exchange that does not exist.")
public void exchangeDeleteExchangeNotFound() throws Exception {
try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
final Interaction interaction = transport.newInteraction();
ChannelCloseBody unknownExchange = interaction.openAnonymousConnection().channel().open().consumeResponse(ChannelOpenOkBody.class).exchange().deleteExchangeName("unknownExchange").delete().consumeResponse().getLatestResponse(ChannelCloseBody.class);
assertThat(unknownExchange.getReplyCode(), is(equalTo(ErrorCodes.NOT_FOUND)));
interaction.channel().closeOk();
}
}
use of org.apache.qpid.server.protocol.v0_8.transport.ChannelCloseBody in project qpid-broker-j by apache.
the class ExchangeTest method exchangeDeleteInUse.
@Test
@SpecificationTest(section = "1.6.2.3", description = "If [if-unused is] set, the server will only delete the exchange if it has no queue" + "bindings. If the exchange has queue bindings the server does not delete it but raises a " + "channel exception instead.")
public void exchangeDeleteInUse() throws Exception {
getBrokerAdmin().createQueue(BrokerAdmin.TEST_QUEUE_NAME);
try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
final Interaction interaction = transport.newInteraction();
interaction.openAnonymousConnection().channel().open().consumeResponse(ChannelOpenOkBody.class).exchange().declareName(TEST_EXCHANGE).declare().consumeResponse(ExchangeDeclareOkBody.class).queue().bindName(TEST_EXCHANGE).bindQueueName(BrokerAdmin.TEST_QUEUE_NAME).bind().consumeResponse(QueueBindOkBody.class);
ChannelCloseBody response = interaction.exchange().deleteExchangeName(TEST_EXCHANGE).deleteIfUnused(true).delete().consumeResponse().getLatestResponse(ChannelCloseBody.class);
assertThat(response.getReplyCode(), is(equalTo(ErrorCodes.IN_USE)));
interaction.channel().closeOk();
ExchangeBoundOkBody boundResponse = interaction.channel().open().consumeResponse(ChannelOpenOkBody.class).exchange().boundExchangeName(TEST_EXCHANGE).bound().consumeResponse().getLatestResponse(ExchangeBoundOkBody.class);
assertThat(boundResponse.getReplyCode(), is(equalTo(ExchangeBoundOkBody.OK)));
interaction.queue().unbindName(TEST_EXCHANGE).unbindQueueName(BrokerAdmin.TEST_QUEUE_NAME).unbind().consumeResponse(QueueUnbindOkBody.class).exchange().deleteIfUnused(true).deleteExchangeName(TEST_EXCHANGE).delete().consumeResponse(ExchangeDeleteOkBody.class);
}
}
Aggregations