use of org.apache.qpid.tests.protocol.SpecificationTest 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.tests.protocol.SpecificationTest 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.tests.protocol.SpecificationTest in project qpid-broker-j by apache.
the class PublisherConfirmsTest method publishUnrouteableMessage.
@Test
@SpecificationTest(section = "https://www.rabbitmq.com/confirms.html", description = "After a channel is put into confirm mode, all subsequently published messages will be " + "confirmed or nack'd once")
public void publishUnrouteableMessage() throws Exception {
try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
final Interaction interaction = transport.newInteraction();
interaction.openAnonymousConnection().channel().open().consumeResponse(ChannelOpenOkBody.class).basic().confirmSelect().consumeResponse(ConfirmSelectOkBody.class).basic().publishExchange("").publishRoutingKey("unrouteable").publishMandatory(false).content("Test").publishMessage().consumeResponse(BasicAckBody.class);
}
}
use of org.apache.qpid.tests.protocol.SpecificationTest in project qpid-broker-j by apache.
the class PublisherConfirmsTest method publishUnrouteableMandatoryMessage.
@Test
@SpecificationTest(section = "https://www.rabbitmq.com/confirms.html", description = "[...] when the broker is unable to handle messages successfully, instead of a basic.ack," + "the broker will send a basic.nack.")
public void publishUnrouteableMandatoryMessage() throws Exception {
try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
final Interaction interaction = transport.newInteraction();
BasicNackBody nackBody = interaction.openAnonymousConnection().channel().open().consumeResponse(ChannelOpenOkBody.class).basic().confirmSelect().consumeResponse(ConfirmSelectOkBody.class).basic().publishExchange("").publishRoutingKey("unrouteable").publishMandatory(true).content("Test").publishMessage().consumeResponse().getLatestResponse(BasicNackBody.class);
assertThat(nackBody.getDeliveryTag(), is(equalTo(1L)));
}
}
use of org.apache.qpid.tests.protocol.SpecificationTest in project qpid-broker-j by apache.
the class DecodeErrorTest method nodePropertiesSupportedDistributionModes.
@Test
@SpecificationTest(section = "3.5.9", description = "The value of this entry MUST be of a type which provides the lifetime-policy archetype.")
public void nodePropertiesSupportedDistributionModes() throws Exception {
try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
final Target target = new Target();
target.setDynamic(Boolean.TRUE);
target.setDynamicNodeProperties(Collections.singletonMap(Symbol.valueOf("supported-dist-modes"), UnsignedInteger.ZERO));
final Response<?> latestResponse = transport.newInteraction().negotiateProtocol().consumeResponse().open().consumeResponse(Open.class).begin().consumeResponse(Begin.class).attachTarget(target).attachRole(Role.SENDER).attach().consumeResponse().getLatestResponse();
assertThat(latestResponse, is(notNullValue()));
final Object responseBody = latestResponse.getBody();
final Error error;
if (responseBody instanceof End) {
error = ((End) responseBody).getError();
} else if (responseBody instanceof Close) {
error = ((Close) responseBody).getError();
} else {
fail(String.format("Expected response of either Detach, End, or Close. Got '%s'", responseBody));
error = null;
}
assertThat(error, is(notNullValue()));
assertThat(error.getCondition(), is(equalTo(DECODE_ERROR)));
}
}
Aggregations