use of org.apache.qpid.tests.protocol.SpecificationTest in project qpid-broker-j by apache.
the class AttachTest method emptyAttach.
@Test
@SpecificationTest(section = "1.3.4", description = "Attach without mandatory fields should result in a decoding error.")
public void emptyAttach() 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).begin().consumeResponse(Begin.class).attachRole(null).attachHandle(null).attachName(null).attach().consumeResponse().getLatestResponse(Close.class);
assertThat(responseClose.getError(), is(notNullValue()));
assertThat(responseClose.getError().getCondition(), equalTo(AmqpError.DECODE_ERROR));
}
}
use of org.apache.qpid.tests.protocol.SpecificationTest in project qpid-broker-j by apache.
the class AttachTest method attachReceiverWithNullTarget.
@Test
@SpecificationTest(section = "2.6.3", description = "Note that if the application chooses not to create a terminus, the session endpoint will" + " still create a link endpoint and issue an attach indicating that the link endpoint has" + " no associated local terminus. In this case, the session endpoint MUST immediately" + " detach the newly created link endpoint.")
public void attachReceiverWithNullTarget() throws Exception {
String queueName = "testQueue";
getBrokerAdmin().createQueue(queueName);
final InetSocketAddress addr = getBrokerAdmin().getBrokerAddress(BrokerAdmin.PortType.ANONYMOUS_AMQP);
try (FrameTransport transport = new FrameTransport(addr).connect()) {
Interaction interaction = transport.newInteraction();
final Attach responseAttach = interaction.negotiateProtocol().consumeResponse().open().consumeResponse(Open.class).begin().consumeResponse(Begin.class).attachRole(Role.RECEIVER).attachSourceAddress(queueName).attachTarget(null).attach().consumeResponse().getLatestResponse(Attach.class);
assertThat(responseAttach.getName(), is(notNullValue()));
assertThat(responseAttach.getHandle().longValue(), is(both(greaterThanOrEqualTo(0L)).and(lessThan(UnsignedInteger.MAX_VALUE.longValue()))));
assertThat(responseAttach.getRole(), is(Role.SENDER));
assertThat(responseAttach.getSource(), is(nullValue()));
assertThat(responseAttach.getTarget(), is(nullValue()));
final Detach responseDetach = interaction.consumeResponse().getLatestResponse(Detach.class);
assertThat(responseDetach.getClosed(), is(true));
assertThat(responseDetach.getError(), is(notNullValue()));
assertThat(responseDetach.getError().getCondition(), is(equalTo(AmqpError.INVALID_FIELD)));
final End endResponse = interaction.flowHandleFromLinkHandle().flowEcho(true).flow().consumeResponse().getLatestResponse(End.class);
assertThat(endResponse.getError(), is(notNullValue()));
// QPID-7954
// assertThat(endResponse.getError().getCondition(), is(equalTo(SessionError.ERRANT_LINK)));
}
}
use of org.apache.qpid.tests.protocol.SpecificationTest in project qpid-broker-j by apache.
the class FlowTest method synchronousGet.
@Test
@SpecificationTest(section = "2.6.8", description = "A synchronous get of a message from a link is accomplished by incrementing the link-credit," + " sending the updated flow state, and waiting indefinitely for a transfer to arrive.")
public void synchronousGet() throws Exception {
getBrokerAdmin().createQueue(BrokerAdmin.TEST_QUEUE_NAME);
getBrokerAdmin().putMessageOnQueue(BrokerAdmin.TEST_QUEUE_NAME, "foo");
final InetSocketAddress addr = getBrokerAdmin().getBrokerAddress(BrokerAdmin.PortType.ANONYMOUS_AMQP);
String data = (String) Utils.receiveMessage(addr, BrokerAdmin.TEST_QUEUE_NAME);
assertThat(data, is(equalTo("foo")));
}
use of org.apache.qpid.tests.protocol.SpecificationTest in project qpid-broker-j by apache.
the class FlowTest method synchronousGetWithTimeoutEmptyQueue.
@Test
@SpecificationTest(section = "2.6.8", description = "Synchronous get with a timeout is accomplished by incrementing the link-credit," + " sending the updated flow state and waiting for the link-credit to be consumed." + " When the desired time has elapsed the receiver then sets the drain flag and sends" + " the newly updated flow state again, while continuing to wait for the link-credit" + " to be consumed.")
public void synchronousGetWithTimeoutEmptyQueue() throws Exception {
getBrokerAdmin().createQueue(BrokerAdmin.TEST_QUEUE_NAME);
final InetSocketAddress addr = getBrokerAdmin().getBrokerAddress(BrokerAdmin.PortType.ANONYMOUS_AMQP);
try (FrameTransport transport = new FrameTransport(addr).connect()) {
Interaction interaction = transport.newInteraction().negotiateProtocol().consumeResponse().open().consumeResponse(Open.class).begin().consumeResponse(Begin.class).attachRole(Role.RECEIVER).attachSourceAddress(BrokerAdmin.TEST_QUEUE_NAME).attach().consumeResponse(Attach.class);
Attach remoteAttach = interaction.getLatestResponse(Attach.class);
UnsignedInteger remoteHandle = remoteAttach.getHandle();
assertThat(remoteHandle, is(notNullValue()));
Flow responseFlow = interaction.flowIncomingWindow(UnsignedInteger.valueOf(1)).flowNextIncomingId(UnsignedInteger.ZERO).flowLinkCredit(UnsignedInteger.ONE).flowDrain(Boolean.FALSE).flowEcho(Boolean.TRUE).flowHandleFromLinkHandle().flow().consumeResponse().getLatestResponse(Flow.class);
assertThat(responseFlow.getHandle(), is(equalTo(remoteHandle)));
assertThat(responseFlow.getLinkCredit(), is(equalTo(UnsignedInteger.ONE)));
assertThat(responseFlow.getDrain(), is(equalTo(Boolean.FALSE)));
responseFlow = interaction.flowLinkCredit(UnsignedInteger.ONE).flowDrain(Boolean.TRUE).flowEcho(Boolean.FALSE).flowHandleFromLinkHandle().flow().consumeResponse().getLatestResponse(Flow.class);
assertThat(responseFlow.getHandle(), is(equalTo(remoteHandle)));
assertThat(responseFlow.getLinkCredit(), is(equalTo(UnsignedInteger.ZERO)));
}
}
use of org.apache.qpid.tests.protocol.SpecificationTest in project qpid-broker-j by apache.
the class FlowTest method synchronousGetWithTimeoutNonEmptyQueue.
@Test
@SpecificationTest(section = "2.6.8", description = "Synchronous get with a timeout is accomplished by incrementing the link-credit," + " sending the updated flow state and waiting for the link-credit to be consumed." + " When the desired time has elapsed the receiver then sets the drain flag and sends" + " the newly updated flow state again, while continuing to wait for the link-credit" + " to be consumed.")
public void synchronousGetWithTimeoutNonEmptyQueue() throws Exception {
BrokerAdmin brokerAdmin = getBrokerAdmin();
brokerAdmin.createQueue(BrokerAdmin.TEST_QUEUE_NAME);
String messageContent = "Test";
brokerAdmin.putMessageOnQueue(BrokerAdmin.TEST_QUEUE_NAME, messageContent);
final InetSocketAddress addr = brokerAdmin.getBrokerAddress(BrokerAdmin.PortType.ANONYMOUS_AMQP);
try (FrameTransport transport = new FrameTransport(addr).connect()) {
Interaction interaction = transport.newInteraction().negotiateProtocol().consumeResponse().open().consumeResponse(Open.class).begin().consumeResponse(Begin.class).attachRole(Role.RECEIVER).attachSourceAddress(BrokerAdmin.TEST_QUEUE_NAME).attach().consumeResponse(Attach.class);
Attach remoteAttach = interaction.getLatestResponse(Attach.class);
UnsignedInteger remoteHandle = remoteAttach.getHandle();
assertThat(remoteHandle, is(notNullValue()));
Object receivedMessageContent = interaction.flowIncomingWindow(UnsignedInteger.valueOf(1)).flowNextIncomingId(UnsignedInteger.ZERO).flowLinkCredit(UnsignedInteger.ONE).flowDrain(Boolean.FALSE).flowEcho(Boolean.FALSE).flowHandleFromLinkHandle().flow().receiveDelivery().decodeLatestDelivery().getDecodedLatestDelivery();
assertThat(receivedMessageContent, is(equalTo(messageContent)));
assertThat(interaction.getLatestDeliveryId(), is(equalTo(UnsignedInteger.ZERO)));
Flow responseFlow = interaction.flowNextIncomingId(UnsignedInteger.ONE).flowLinkCredit(UnsignedInteger.ONE).flowDrain(Boolean.TRUE).flowEcho(Boolean.FALSE).flowHandleFromLinkHandle().flow().consumeResponse().getLatestResponse(Flow.class);
assertThat(responseFlow.getHandle(), is(equalTo(remoteHandle)));
assertThat(responseFlow.getLinkCredit(), is(equalTo(UnsignedInteger.ZERO)));
}
}
Aggregations