use of org.apache.qpid.server.protocol.v0_8.transport.ExchangeBoundOkBody in project qpid-broker-j by apache.
the class QueueTest method queueDurableBind.
@Test
@SpecificationTest(section = "1.7.2.3", description = "Bindings of durable queues to durable exchanges are automatically durable and the server " + "MUST restore such bindings after a server restart.")
public void queueDurableBind() throws Exception {
String testExchange = "testExchange";
String testRoutingKey = "rk1";
try (FrameTransport transport = new FrameTransport(getBrokerAdmin()).connect()) {
final Interaction interaction = transport.newInteraction();
interaction.negotiateOpen().channel().open().consumeResponse(ChannelOpenOkBody.class).queue().declareName(BrokerAdmin.TEST_QUEUE_NAME).declareDurable(true).declare().consumeResponse(QueueDeclareOkBody.class).exchange().declareName(testExchange).declareDurable(true).declare().consumeResponse(ExchangeDeclareOkBody.class).queue().bindName(testExchange).bindQueueName(BrokerAdmin.TEST_QUEUE_NAME).bindRoutingKey(testRoutingKey).bind().consumeResponse(QueueBindOkBody.class);
ExchangeBoundOkBody response = interaction.exchange().boundExchangeName(testExchange).boundQueue(BrokerAdmin.TEST_QUEUE_NAME).boundRoutingKey(testRoutingKey).bound().consumeResponse().getLatestResponse(ExchangeBoundOkBody.class);
assertThat(response.getReplyCode(), is(equalTo(ExchangeBoundOkBody.OK)));
}
assumeThat(getBrokerAdmin().supportsRestart(), Matchers.is(true));
getBrokerAdmin().restart();
try (FrameTransport transport = new FrameTransport(getBrokerAdmin()).connect()) {
final Interaction interaction = transport.newInteraction();
ExchangeBoundOkBody response = interaction.negotiateOpen().channel().open().consumeResponse(ChannelOpenOkBody.class).exchange().boundExchangeName(testExchange).boundQueue(BrokerAdmin.TEST_QUEUE_NAME).boundRoutingKey(testRoutingKey).bound().consumeResponse().getLatestResponse(ExchangeBoundOkBody.class);
assertThat(response.getReplyCode(), is(equalTo(ExchangeBoundOkBody.OK)));
}
}
use of org.apache.qpid.server.protocol.v0_8.transport.ExchangeBoundOkBody in project qpid-broker-j by apache.
the class ExchangeTest method exchangeDeclare.
@Test
@SpecificationTest(section = "1.6.2.1", description = "verify exchange exists, create if needed")
public void exchangeDeclare() throws Exception {
try (FrameTransport transport = new FrameTransport(getBrokerAdmin()).connect()) {
final Interaction interaction = transport.newInteraction();
interaction.negotiateOpen().channel().open().consumeResponse(ChannelOpenOkBody.class).exchange().declareName(TEST_EXCHANGE).declare().consumeResponse(ExchangeDeclareOkBody.class);
ExchangeBoundOkBody response = interaction.exchange().boundExchangeName(TEST_EXCHANGE).bound().consumeResponse().getLatestResponse(ExchangeBoundOkBody.class);
assertThat(response.getReplyCode(), is(equalTo(ExchangeBoundOkBody.NO_BINDINGS)));
}
}
use of org.apache.qpid.server.protocol.v0_8.transport.ExchangeBoundOkBody in project qpid-broker-j by apache.
the class QueueTest method queueBindWithoutRoutingKey.
@Test
@SpecificationTest(section = "1.7.2.3", description = "If the queue name is provided but the routing key is empty," + " the server does the binding with that empty routing key.")
public void queueBindWithoutRoutingKey() throws Exception {
getBrokerAdmin().createQueue(BrokerAdmin.TEST_QUEUE_NAME);
try (FrameTransport transport = new FrameTransport(getBrokerAdmin()).connect()) {
final Interaction interaction = transport.newInteraction();
String testExchange = "testExchange";
interaction.negotiateOpen().channel().open().consumeResponse(ChannelOpenOkBody.class).exchange().declareName(testExchange).declare().consumeResponse(ExchangeDeclareOkBody.class).queue().bindName(testExchange).bindQueueName(BrokerAdmin.TEST_QUEUE_NAME).bind().consumeResponse(QueueBindOkBody.class);
ExchangeBoundOkBody response = interaction.exchange().boundExchangeName(testExchange).boundQueue(BrokerAdmin.TEST_QUEUE_NAME).boundRoutingKey("").bound().consumeResponse().getLatestResponse(ExchangeBoundOkBody.class);
assertThat(response.getReplyCode(), is(equalTo(ExchangeBoundOkBody.OK)));
}
}
use of org.apache.qpid.server.protocol.v0_8.transport.ExchangeBoundOkBody 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(getBrokerAdmin()).connect()) {
final Interaction interaction = transport.newInteraction();
interaction.negotiateOpen().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);
}
}
use of org.apache.qpid.server.protocol.v0_8.transport.ExchangeBoundOkBody in project qpid-broker-j by apache.
the class ExchangeTest method exchangeDeclareValidWireArguments.
@Test
public void exchangeDeclareValidWireArguments() throws Exception {
try (FrameTransport transport = new FrameTransport(getBrokerAdmin()).connect()) {
final Interaction interaction = transport.newInteraction();
interaction.negotiateOpen().channel().open().consumeResponse(ChannelOpenOkBody.class).exchange().declareName(TEST_EXCHANGE).declareArguments(Collections.singletonMap("unroutableMessageBehaviour", "REJECT")).declare().consumeResponse(ExchangeDeclareOkBody.class);
ExchangeBoundOkBody response = interaction.exchange().boundExchangeName(TEST_EXCHANGE).bound().consumeResponse().getLatestResponse(ExchangeBoundOkBody.class);
assertThat(response.getReplyCode(), is(equalTo(ExchangeBoundOkBody.NO_BINDINGS)));
}
}
Aggregations