use of org.apache.qpid.tests.protocol.v0_8.FrameTransport in project qpid-broker-j by apache.
the class AttachTest method attachSenderWithNullSource.
@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 attachSenderWithNullSource() 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.SENDER).attachSource(null).attachTargetAddress(queueName).attachInitialDeliveryCount(UnsignedInteger.ZERO).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.RECEIVER));
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.v0_8.FrameTransport in project qpid-broker-j by apache.
the class AttachTest method successfulAttachAsReceiver.
@Test
@SpecificationTest(section = "2.6.3", description = "Links are established and/or resumed by creating a link endpoint associated with a local terminus, " + "assigning it to an unused handle, and sending an attach frame.")
public void successfulAttachAsReceiver() throws Exception {
String queueName = "testQueue";
getBrokerAdmin().createQueue(queueName);
final InetSocketAddress addr = getBrokerAdmin().getBrokerAddress(BrokerAdmin.PortType.ANONYMOUS_AMQP);
try (FrameTransport transport = new FrameTransport(addr).connect()) {
final Attach responseAttach = transport.newInteraction().negotiateProtocol().consumeResponse().open().consumeResponse(Open.class).begin().consumeResponse(Begin.class).attachRole(Role.RECEIVER).attachSourceAddress(queueName).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(notNullValue()));
}
}
use of org.apache.qpid.tests.protocol.v0_8.FrameTransport in project qpid-broker-j by apache.
the class AttachTest method successfulAttachAsSender.
@Test
@SpecificationTest(section = "2.6.3", description = "Links are established and/or resumed by creating a link endpoint associated with a local terminus, " + "assigning it to an unused handle, and sending an attach frame.")
public void successfulAttachAsSender() throws Exception {
final InetSocketAddress addr = getBrokerAdmin().getBrokerAddress(BrokerAdmin.PortType.ANONYMOUS_AMQP);
try (FrameTransport transport = new FrameTransport(addr).connect()) {
final Attach responseAttach = transport.newInteraction().negotiateProtocol().consumeResponse().open().consumeResponse(Open.class).begin().consumeResponse(Begin.class).attachRole(Role.SENDER).attachInitialDeliveryCount(UnsignedInteger.ZERO).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.RECEIVER));
assertThat(responseAttach.getTarget(), is(notNullValue()));
assertThat(responseAttach.getSource(), is(notNullValue()));
}
}
use of org.apache.qpid.tests.protocol.v0_8.FrameTransport 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.v0_8.FrameTransport 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)));
}
}
Aggregations