use of org.apache.qpid.server.protocol.v0_8.transport in project qpid-broker-j by apache.
the class ExchangeTest method exchangeDeclareAutoDelete.
/**
* Qpid specific extension
*/
@Test
public void exchangeDeclareAutoDelete() 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).declareAutoDelete(true).declare().consumeResponse(ExchangeDeclareOkBody.class).queue().bindName(TEST_EXCHANGE).bindQueueName(BrokerAdmin.TEST_QUEUE_NAME).bind().consumeResponse(QueueBindOkBody.class).queue().deleteName(BrokerAdmin.TEST_QUEUE_NAME).delete().consumeResponse(QueueDeleteOkBody.class);
ExchangeBoundOkBody boundResponse = interaction.exchange().boundExchangeName(TEST_EXCHANGE).bound().consumeResponse().getLatestResponse(ExchangeBoundOkBody.class);
assertThat(boundResponse.getReplyCode(), is(equalTo(ExchangeBoundOkBody.EXCHANGE_NOT_FOUND)));
}
}
use of org.apache.qpid.server.protocol.v0_8.transport in project qpid-broker-j by apache.
the class ExchangeTest method exchangeRedeclareDifferentType.
@Test
@SpecificationTest(section = "1.6.2.1", description = "The client MUST not attempt to redeclare an existing exchange with a different type than " + "used in the original Exchange.Declare method")
public void exchangeRedeclareDifferentType() throws Exception {
try (FrameTransport transport = new FrameTransport(getBrokerAdmin()).connect()) {
final Interaction interaction = transport.newInteraction();
interaction.negotiateOpen().channel().open().consumeResponse(ChannelOpenOkBody.class).exchange().declareType(ExchangeDefaults.DIRECT_EXCHANGE_CLASS).declareName(TEST_EXCHANGE).declare().consumeResponse(ExchangeDeclareOkBody.class);
ConnectionCloseBody response = interaction.exchange().declareType(ExchangeDefaults.TOPIC_EXCHANGE_CLASS).declareName(TEST_EXCHANGE).declare().consumeResponse().getLatestResponse(ConnectionCloseBody.class);
assertThat(response.getReplyCode(), is(equalTo(ErrorCodes.NOT_ALLOWED)));
}
}
use of org.apache.qpid.server.protocol.v0_8.transport 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 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(getBrokerAdmin()).connect()) {
final Interaction interaction = transport.newInteraction();
ChannelCloseBody unknownExchange = interaction.negotiateOpen().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 in project qpid-broker-j by apache.
the class ExchangeTest method exchangeDeleteAmqDisallowed.
@Test
@SpecificationTest(section = "1.6.2.3", description = "The server MUST, in each virtual host, pre-declare an exchange instance for each standard " + "exchange type that it implements.")
public void exchangeDeleteAmqDisallowed() throws Exception {
try (FrameTransport transport = new FrameTransport(getBrokerAdmin()).connect()) {
final Interaction interaction = transport.newInteraction();
ChannelCloseBody response = interaction.negotiateOpen().channel().open().consumeResponse(ChannelOpenOkBody.class).exchange().deleteExchangeName(ExchangeDefaults.DIRECT_EXCHANGE_NAME).delete().consumeResponse().getLatestResponse(ChannelCloseBody.class);
assertThat(response.getReplyCode(), is(equalTo(ErrorCodes.NOT_ALLOWED)));
}
}
Aggregations