use of org.apache.qpid.tests.protocol.v1_0.FrameTransport in project qpid-broker-j by apache.
the class BeginTest method emptyBegin.
@Test
@SpecificationTest(section = "1.3.4", description = "Begin without mandatory fields should result in a decoding error.")
public void emptyBegin() throws Exception {
final InetSocketAddress addr = getBrokerAdmin().getBrokerAddress(BrokerAdmin.PortType.ANONYMOUS_AMQP);
try (FrameTransport transport = new FrameTransport(addr).connect()) {
Close responseClose = transport.newInteraction().negotiateProtocol().consumeResponse().open().consumeResponse(Open.class).beginNextOutgoingId(null).beginIncomingWindow(null).beginOutgoingWindow(null).begin().consumeResponse().getLatestResponse(Close.class);
assertThat(responseClose.getError(), is(notNullValue()));
assertThat(responseClose.getError().getCondition(), equalTo(AmqpError.DECODE_ERROR));
}
}
use of org.apache.qpid.tests.protocol.v1_0.FrameTransport in project qpid-broker-j by apache.
the class PublisherConfirmsTest method publishWithTransactionalConfirms.
/**
* Qpid allows publisher confirms to be used with transactions. This is beyond what RabbitMQ supports.
*/
@Test
public void publishWithTransactionalConfirms() throws Exception {
try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
final Interaction interaction = transport.newInteraction();
final BasicAckBody ackBody = interaction.openAnonymousConnection().channel().open().consumeResponse(ChannelOpenOkBody.class).tx().select().consumeResponse(TxSelectOkBody.class).basic().confirmSelect().consumeResponse(ConfirmSelectOkBody.class).basic().publishExchange("").publishRoutingKey(BrokerAdmin.TEST_QUEUE_NAME).content("Test").publishMessage().consumeResponse().getLatestResponse(BasicAckBody.class);
assertThat(ackBody.getDeliveryTag(), is(equalTo(1L)));
assertThat(getBrokerAdmin().getQueueDepthMessages(BrokerAdmin.TEST_QUEUE_NAME), is(equalTo(0)));
interaction.tx().commit().consumeResponse(TxCommitOkBody.class);
assertThat(getBrokerAdmin().getQueueDepthMessages(BrokerAdmin.TEST_QUEUE_NAME), is(equalTo(1)));
}
}
use of org.apache.qpid.tests.protocol.v1_0.FrameTransport 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.v1_0.FrameTransport 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.v1_0.FrameTransport in project qpid-broker-j by apache.
the class PublisherConfirmsTest method publishUnroutableMessageWithTransactionalConfirms.
@Test
public void publishUnroutableMessageWithTransactionalConfirms() throws Exception {
try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
final Interaction interaction = transport.newInteraction();
interaction.openAnonymousConnection().channel().open().consumeResponse(ChannelOpenOkBody.class).tx().select().consumeResponse(TxSelectOkBody.class).basic().confirmSelect().consumeResponse(ConfirmSelectOkBody.class).basic().publishExchange("").publishRoutingKey("unrouteable").publishMandatory(true).publishMessage().basic().publishExchange("").publishRoutingKey(BrokerAdmin.TEST_QUEUE_NAME).publishMandatory(true).publishMessage();
final BasicNackBody nackBody = interaction.consumeResponse().getLatestResponse(BasicNackBody.class);
assertThat(nackBody.getDeliveryTag(), is(equalTo(1L)));
final BasicAckBody ackBody = interaction.consumeResponse().getLatestResponse(BasicAckBody.class);
assertThat(ackBody.getDeliveryTag(), is(equalTo(2L)));
assertThat(getBrokerAdmin().getQueueDepthMessages(BrokerAdmin.TEST_QUEUE_NAME), is(equalTo(0)));
interaction.tx().commit();
final Set<Class<?>> outstanding = Sets.newHashSet(TxCommitOkBody.class, BasicReturnBody.class, ContentHeaderBody.class);
while (!outstanding.isEmpty()) {
final Response<?> response = interaction.consumeResponse(outstanding.toArray(new Class<?>[outstanding.size()])).getLatestResponse();
final boolean remove = outstanding.remove(response.getBody().getClass());
assertThat("" + response, remove, is(equalTo(true)));
}
assertThat(getBrokerAdmin().getQueueDepthMessages(BrokerAdmin.TEST_QUEUE_NAME), is(equalTo(1)));
}
}
Aggregations