use of org.sbolstandard.core2.Interaction in project qpid-broker-j by apache.
the class RefuseConnectionPolicy method basicNegotiation.
@Test
public void basicNegotiation() throws Exception {
try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
final Interaction interaction = transport.newInteraction();
final Open responseOpen = interaction.negotiateProtocol().consumeResponse().openContainerId("testContainerId").openDesiredCapabilities(SOLE_CONNECTION_FOR_CONTAINER).openProperties(Collections.singletonMap(SOLE_CONNECTION_ENFORCEMENT_POLICY, REFUSE_CONNECTION)).open().consumeResponse().getLatestResponse(Open.class);
assertThat(Arrays.asList(responseOpen.getOfferedCapabilities()), hasItem(SOLE_CONNECTION_FOR_CONTAINER));
if (responseOpen.getProperties().containsKey(SOLE_CONNECTION_DETECTION_POLICY)) {
assertThat(responseOpen.getProperties().get(SOLE_CONNECTION_DETECTION_POLICY), isIn(new UnsignedInteger[] { SoleConnectionDetectionPolicy.STRONG.getValue(), SoleConnectionDetectionPolicy.WEAK.getValue() }));
}
}
}
use of org.sbolstandard.core2.Interaction in project qpid-broker-j by apache.
the class WebSocketTest method successfulOpen.
@Test
@SpecificationTest(section = "2.1", description = "Opening a WebSocket Connection")
public void successfulOpen() throws Exception {
assumeThat(getBrokerAdmin().isWebSocketSupported(), is(true));
final InetSocketAddress addr = getBrokerAdmin().getBrokerAddress(BrokerAdmin.PortType.ANONYMOUS_AMQPWS);
try (FrameTransport transport = new WebSocketFrameTransport(addr).connect()) {
Interaction interaction = transport.newInteraction();
final Open responseOpen = interaction.negotiateProtocol().consumeResponse().open().consumeResponse().getLatestResponse(Open.class);
assertThat(responseOpen.getContainerId(), is(notNullValue()));
assertThat(responseOpen.getMaxFrameSize().longValue(), is(both(greaterThanOrEqualTo(0L)).and(lessThan(UnsignedInteger.MAX_VALUE.longValue()))));
assertThat(responseOpen.getChannelMax().intValue(), is(both(greaterThanOrEqualTo(0)).and(lessThan(UnsignedShort.MAX_VALUE.intValue()))));
interaction.doCloseConnection();
}
}
use of org.sbolstandard.core2.Interaction in project qpid-broker-j by apache.
the class DeleteOnCloseTest method dynamicNodeIsPersisted.
@Test
public void dynamicNodeIsPersisted() throws Exception {
assumeThat(getBrokerAdmin().supportsRestart(), is(true));
final String newTempQueueAddress;
try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
Source source = new Source();
source.setDynamicNodeProperties(Collections.singletonMap(Session_1_0.LIFETIME_POLICY, new DeleteOnClose()));
source.setExpiryPolicy(TerminusExpiryPolicy.NEVER);
source.setDynamic(true);
final Interaction interaction = transport.newInteraction();
final Attach attachResponse = interaction.negotiateProtocol().consumeResponse().open().consumeResponse(Open.class).begin().consumeResponse(Begin.class).attachRole(Role.RECEIVER).attachSource(source).attach().consumeResponse().getLatestResponse(Attach.class);
assertThat(attachResponse.getSource(), is(notNullValue()));
newTempQueueAddress = ((Source) attachResponse.getSource()).getAddress();
assertThat(Utils.doesNodeExist(_brokerAddress, newTempQueueAddress), is(true));
}
final ListenableFuture<Void> restart = getBrokerAdmin().restart();
restart.get(BrokerAdmin.RESTART_TIMEOUT, TimeUnit.MILLISECONDS);
_brokerAddress = getBrokerAdmin().getBrokerAddress(BrokerAdmin.PortType.ANONYMOUS_AMQP);
assertThat(Utils.doesNodeExist(_brokerAddress, newTempQueueAddress), is(true));
}
use of org.sbolstandard.core2.Interaction in project qpid-broker-j by apache.
the class DeleteOnCloseTest method deleteOnCloseOnSource.
@Test
@SpecificationTest(section = "3.5.10", description = "A node dynamically created with this lifetime policy will be deleted at the point that the link which caused its\n" + "creation ceases to exist.")
public void deleteOnCloseOnSource() throws Exception {
try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
Source source = new Source();
source.setDynamicNodeProperties(Collections.singletonMap(Session_1_0.LIFETIME_POLICY, new DeleteOnClose()));
source.setDynamic(true);
final Interaction interaction = transport.newInteraction();
final Attach attachResponse = interaction.negotiateProtocol().consumeResponse().open().consumeResponse(Open.class).begin().consumeResponse(Begin.class).attachRole(Role.RECEIVER).attachSource(source).attach().consumeResponse().getLatestResponse(Attach.class);
assertThat(attachResponse.getSource(), is(notNullValue()));
final String newTempQueueAddress = ((Source) attachResponse.getSource()).getAddress();
assertThat(Utils.doesNodeExist(_brokerAddress, newTempQueueAddress), is(true));
interaction.detachClose(true).detach().consumeResponse().getLatestResponse(Detach.class);
assertThat(Utils.doesNodeExist(_brokerAddress, newTempQueueAddress), is(false));
}
}
use of org.sbolstandard.core2.Interaction in project qpid-broker-j by apache.
the class MultiTransferTest method multiTransferMessageOmittingOptionalTagAndID.
@Test
@SpecificationTest(section = "2.7.5", description = "[delivery-id] On continuation transfers the delivery-id MAY be omitted..." + "[delivery-tag] field MUST be specified for the first transfer of a multi-transfer" + " message and can only be omitted for continuation transfers.")
public void multiTransferMessageOmittingOptionalTagAndID() throws Exception {
try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
QpidByteBuffer[] payloads = Utils.splitPayload("testData", 4);
final UnsignedInteger deliveryId = UnsignedInteger.ZERO;
final Binary deliveryTag = new Binary("testTransfer".getBytes(UTF_8));
Interaction interaction = transport.newInteraction();
interaction.negotiateProtocol().consumeResponse().open().consumeResponse(Open.class).begin().consumeResponse(Begin.class).attachRole(Role.SENDER).attachTargetAddress(BrokerAdmin.TEST_QUEUE_NAME).attachRcvSettleMode(ReceiverSettleMode.SECOND).attachSourceOutcomes(Accepted.ACCEPTED_SYMBOL).attach().consumeResponse(Attach.class).consumeResponse(Flow.class).transferDeliveryId(deliveryId).transferDeliveryTag(deliveryTag).transferMore(true).transferPayload(payloads[0]).transfer().sync().transferDeliveryId(deliveryId).transferDeliveryTag(null).transferMore(true).transferPayload(payloads[1]).transfer().sync().transferDeliveryId(null).transferDeliveryTag(deliveryTag).transferMore(true).transferPayload(payloads[2]).transfer().sync().transferDeliveryId(null).transferDeliveryTag(null).transferMore(false).transferPayload(payloads[3]).transfer().consumeResponse();
Disposition disposition = interaction.getLatestResponse(Disposition.class);
for (final QpidByteBuffer payload : payloads) {
payload.dispose();
}
assertThat(disposition.getFirst(), is(equalTo(deliveryId)));
assertThat(disposition.getLast(), isOneOf(null, deliveryId));
assertThat(disposition.getSettled(), is(equalTo(false)));
assertThat(disposition.getState(), is(instanceOf(Accepted.class)));
}
}
Aggregations