use of org.apache.qpid.tests.protocol.v0_10.FrameTransport in project qpid-broker-j by apache.
the class TemporaryDestinationTest method deleteOnCloseWithConnectionClose.
private void deleteOnCloseWithConnectionClose(final Symbol[] targetCapabilities) throws Exception {
String newTemporaryNodeAddress = null;
try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
Target target = new Target();
target.setDynamicNodeProperties(Collections.singletonMap(Session_1_0.LIFETIME_POLICY, new DeleteOnClose()));
target.setExpiryPolicy(TerminusExpiryPolicy.LINK_DETACH);
target.setDynamic(true);
target.setCapabilities(targetCapabilities);
final Interaction interaction = transport.newInteraction();
final Attach attachResponse = interaction.negotiateProtocol().consumeResponse().open().consumeResponse(Open.class).begin().consumeResponse(Begin.class).attachRole(Role.SENDER).attachTarget(target).attach().consumeResponse().getLatestResponse(Attach.class);
assertThat(attachResponse.getSource(), is(notNullValue()));
assertThat(attachResponse.getTarget(), is(notNullValue()));
newTemporaryNodeAddress = ((Target) attachResponse.getTarget()).getAddress();
assertThat(newTemporaryNodeAddress, is(notNullValue()));
assertThat(Utils.doesNodeExist(_brokerAddress, newTemporaryNodeAddress), is(true));
interaction.consumeResponse().getLatestResponse(Flow.class);
interaction.doCloseConnection();
}
assertThat(Utils.doesNodeExist(_brokerAddress, newTemporaryNodeAddress), is(false));
}
use of org.apache.qpid.tests.protocol.v0_10.FrameTransport in project qpid-broker-j by apache.
the class ManagementTest method drainTemporaryMessageSource.
@Test
@SpecificationTest(section = "2.6.7", description = "The drain flag indicates how the sender SHOULD behave when insufficient messages" + " are available to consume the current link-credit. If set, the sender will" + " (after sending all available messages) advance the delivery-count as much as possible," + " consuming all link-credit, and send the flow state to the receiver.")
public void drainTemporaryMessageSource() throws Exception {
assumeThat(getBrokerAdmin().isManagementSupported(), is(equalTo(true)));
try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
Target target = new Target();
target.setDynamicNodeProperties(Collections.singletonMap(Session_1_0.LIFETIME_POLICY, new DeleteOnClose()));
target.setExpiryPolicy(TerminusExpiryPolicy.LINK_DETACH);
target.setDynamic(true);
target.setCapabilities(new Symbol[] { Symbol.valueOf("temporary-queue") });
final Interaction interaction = transport.newInteraction();
final Attach attachResponse = interaction.negotiateProtocol().consumeResponse().openHostname("$management").open().consumeResponse(Open.class).begin().consumeResponse(Begin.class).attachRole(Role.SENDER).attachTarget(target).attach().consumeResponse().getLatestResponse(Attach.class);
assertThat(attachResponse.getSource(), is(notNullValue()));
assertThat(attachResponse.getTarget(), is(notNullValue()));
String newTemporaryNodeAddress = ((Target) attachResponse.getTarget()).getAddress();
assertThat(newTemporaryNodeAddress, is(notNullValue()));
interaction.consumeResponse().getLatestResponse(Flow.class);
final Attach receiverResponse = interaction.attachHandle(UnsignedInteger.ONE).attachRole(Role.RECEIVER).attachSourceAddress(newTemporaryNodeAddress).attachRcvSettleMode(ReceiverSettleMode.FIRST).attach().consumeResponse().getLatestResponse(Attach.class);
assertThat(receiverResponse.getSource(), is(instanceOf(Source.class)));
assertThat(((Source) receiverResponse.getSource()).getAddress(), is(equalTo(newTemporaryNodeAddress)));
// 2.6.8 Synchronous Get
// grant credit of 1
interaction.flowIncomingWindow(UnsignedInteger.ONE).flowNextIncomingId(UnsignedInteger.ZERO).flowOutgoingWindow(UnsignedInteger.ZERO).flowNextOutgoingId(UnsignedInteger.ZERO).flowLinkCredit(UnsignedInteger.ONE).flowHandleFromLinkHandle().flow();
// send drain to ensure the sender promptly advances the delivery-count until link-credit is consumed
interaction.flowDrain(true).flow();
Flow flow = interaction.consumeResponse().getLatestResponse(Flow.class);
assertThat(flow.getLinkCredit(), is(equalTo(UnsignedInteger.ZERO)));
assertThat(flow.getHandle(), is(equalTo(receiverResponse.getHandle())));
interaction.doCloseConnection();
}
}
use of org.apache.qpid.tests.protocol.v0_10.FrameTransport in project qpid-broker-j by apache.
the class TransactionTimeoutTest method transactionalPostingTimeout.
@Test
public void transactionalPostingTimeout() throws Exception {
try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
final UnsignedInteger linkHandle = UnsignedInteger.ONE;
final Interaction interaction = transport.newInteraction();
final InteractionTransactionalState txnState = interaction.createTransactionalState(UnsignedInteger.ZERO);
Disposition responseDisposition = interaction.negotiateProtocol().consumeResponse().open().consumeResponse(Open.class).begin().consumeResponse(Begin.class).txnAttachCoordinatorLink(txnState).txnDeclare(txnState).attachRole(Role.SENDER).attachTargetAddress(BrokerAdmin.TEST_QUEUE_NAME).attachHandle(linkHandle).attach().consumeResponse(Attach.class).consumeResponse(Flow.class).transferHandle(linkHandle).transferPayloadData(TEST_MESSAGE_CONTENT).transferTransactionalState(txnState.getCurrentTransactionId()).transfer().consumeResponse(Disposition.class).getLatestResponse(Disposition.class);
assertThat(responseDisposition.getRole(), is(Role.RECEIVER));
assertThat(responseDisposition.getSettled(), is(Boolean.TRUE));
assertThat(responseDisposition.getState(), is(instanceOf(TransactionalState.class)));
assertThat(((TransactionalState) responseDisposition.getState()).getOutcome(), is(instanceOf(Accepted.class)));
Close responseClose = interaction.consumeResponse().getLatestResponse(Close.class);
assertThat(responseClose.getError(), is(Matchers.notNullValue()));
assertThat(responseClose.getError().getCondition(), equalTo(TransactionError.TRANSACTION_TIMEOUT));
}
}
use of org.apache.qpid.tests.protocol.v0_10.FrameTransport in project qpid-broker-j by apache.
the class CloseExistingPolicy method basicNegotiation.
@Test
public void basicNegotiation() throws Exception {
try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
Open responseOpen = transport.newInteraction().negotiateProtocol().consumeResponse().openContainerId("testContainerId").openDesiredCapabilities(SOLE_CONNECTION_FOR_CONTAINER).openProperties(Collections.singletonMap(SOLE_CONNECTION_ENFORCEMENT_POLICY, CLOSE_EXISTING)).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.apache.qpid.tests.protocol.v0_10.FrameTransport in project qpid-broker-j by apache.
the class MixedPolicy method firstRefuseThenClose.
@Test
public void firstRefuseThenClose() throws Exception {
try (FrameTransport transport1 = new FrameTransport(_brokerAddress).connect()) {
final Interaction interaction1 = transport1.newInteraction();
interaction1.negotiateProtocol().consumeResponse().openContainerId("testContainerId").openDesiredCapabilities(SOLE_CONNECTION_FOR_CONTAINER).openProperties(Collections.singletonMap(SOLE_CONNECTION_ENFORCEMENT_POLICY, REFUSE_CONNECTION)).open().consumeResponse(Open.class);
try (FrameTransport transport2 = new FrameTransport(_brokerAddress).connect()) {
final Interaction interaction2 = transport2.newInteraction();
interaction2.negotiateProtocol().consumeResponse().openContainerId("testContainerId").openDesiredCapabilities(SOLE_CONNECTION_FOR_CONTAINER).openProperties(Collections.singletonMap(SOLE_CONNECTION_ENFORCEMENT_POLICY, CLOSE_EXISTING)).open().consumeResponse(Open.class).consumeResponse(Close.class);
}
}
}
Aggregations