use of org.apache.qpid.server.protocol.v1_0.type.transport.Close in project qpid-broker-j by apache.
the class DecodeErrorTest method nodePropertiesSupportedDistributionModes.
@Test
@SpecificationTest(section = "3.5.9", description = "The value of this entry MUST be of a type which provides the lifetime-policy archetype.")
public void nodePropertiesSupportedDistributionModes() throws Exception {
try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
final Target target = new Target();
target.setDynamic(Boolean.TRUE);
target.setDynamicNodeProperties(Collections.singletonMap(Symbol.valueOf("supported-dist-modes"), UnsignedInteger.ZERO));
final Response<?> latestResponse = transport.newInteraction().negotiateProtocol().consumeResponse().open().consumeResponse(Open.class).begin().consumeResponse(Begin.class).attachTarget(target).attachRole(Role.SENDER).attach().consumeResponse().getLatestResponse();
assertThat(latestResponse, is(notNullValue()));
final Object responseBody = latestResponse.getBody();
final Error error;
if (responseBody instanceof End) {
error = ((End) responseBody).getError();
} else if (responseBody instanceof Close) {
error = ((Close) responseBody).getError();
} else {
fail(String.format("Expected response of either Detach, End, or Close. Got '%s'", responseBody));
error = null;
}
assertThat(error, is(notNullValue()));
assertThat(error.getCondition(), is(equalTo(DECODE_ERROR)));
}
}
use of org.apache.qpid.server.protocol.v1_0.type.transport.Close in project qpid-broker-j by apache.
the class DecodeErrorTest method nodePropertiesLifetimePolicy.
@Test
@SpecificationTest(section = "3.5.9", description = "The value of this entry MUST be of a type which provides the lifetime-policy archetype.")
public void nodePropertiesLifetimePolicy() throws Exception {
try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
final Source source = new Source();
source.setDynamic(Boolean.TRUE);
source.setDynamicNodeProperties(Collections.singletonMap(Symbol.valueOf("lifetime-policy"), UnsignedInteger.MAX_VALUE));
final Response<?> latestResponse = transport.newInteraction().negotiateProtocol().consumeResponse().open().consumeResponse(Open.class).begin().consumeResponse(Begin.class).attachSource(source).attachRole(Role.SENDER).attach().consumeResponse().getLatestResponse();
assertThat(latestResponse, is(notNullValue()));
final Object responseBody = latestResponse.getBody();
final Error error;
if (responseBody instanceof End) {
error = ((End) responseBody).getError();
} else if (responseBody instanceof Close) {
error = ((Close) responseBody).getError();
} else {
fail(String.format("Expected response of either Detach, End, or Close. Got '%s'", responseBody));
error = null;
}
assertThat(error, is(notNullValue()));
assertThat(error.getCondition(), is(equalTo(DECODE_ERROR)));
}
}
use of org.apache.qpid.server.protocol.v1_0.type.transport.Close 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.server.protocol.v1_0.type.transport.Close in project qpid-broker-j by apache.
the class RefuseConnectionPolicy method strongDetection.
@Test
public void strongDetection() throws Exception {
try (FrameTransport transport1 = new FrameTransport(_brokerAddress).connect()) {
final Interaction interaction1 = transport1.newInteraction();
final Open responseOpen = interaction1.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)) {
assumeThat(responseOpen.getProperties().get(SOLE_CONNECTION_DETECTION_POLICY), is(equalTo(SoleConnectionDetectionPolicy.STRONG.getValue())));
}
try (FrameTransport transport2 = new FrameTransport(_brokerAddress).connect()) {
final Interaction interaction2 = transport2.newInteraction();
// Omit setting the desired capability to test strong detection
final Open responseOpen2 = interaction2.negotiateProtocol().consumeResponse().openContainerId("testContainerId").open().consumeResponse().getLatestResponse(Open.class);
assertThat(Arrays.asList(responseOpen2.getOfferedCapabilities()), hasItem(SOLE_CONNECTION_FOR_CONTAINER));
assertThat(responseOpen2.getProperties(), hasKey(Symbol.valueOf("amqp:connection-establishment-failed")));
assertThat(responseOpen2.getProperties().get(Symbol.valueOf("amqp:connection-establishment-failed")), is(true));
final Close close2 = interaction2.consumeResponse().getLatestResponse(Close.class);
assertThat(close2.getError(), is(notNullValue()));
assertThat(close2.getError().getCondition(), is(equalTo(AmqpError.INVALID_FIELD)));
assertThat(close2.getError().getInfo(), is(equalTo(Collections.singletonMap(Symbol.valueOf("invalid-field"), Symbol.valueOf("container-id")))));
}
}
}
use of org.apache.qpid.server.protocol.v1_0.type.transport.Close in project qpid-broker-j by apache.
the class RefuseConnectionPolicy method newConnectionRefused.
@Test
public void newConnectionRefused() 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();
final Open responseOpen2 = interaction2.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(responseOpen2.getOfferedCapabilities()), hasItem(SOLE_CONNECTION_FOR_CONTAINER));
assertThat(responseOpen2.getProperties(), hasKey(Symbol.valueOf("amqp:connection-establishment-failed")));
assertThat(responseOpen2.getProperties().get(Symbol.valueOf("amqp:connection-establishment-failed")), is(true));
final Close close2 = interaction2.consumeResponse().getLatestResponse(Close.class);
assertThat(close2.getError(), is(notNullValue()));
assertThat(close2.getError().getCondition(), is(equalTo(AmqpError.INVALID_FIELD)));
assertThat(close2.getError().getInfo(), is(equalTo(Collections.singletonMap(Symbol.valueOf("invalid-field"), Symbol.valueOf("container-id")))));
}
}
}
Aggregations