use of org.apache.qpid.tests.protocol.v1_0.MessageEncoder in project qpid-broker-j by apache.
the class TransferTest method durableTransferWithoutRejectedOutcome.
@Test
@SpecificationTest(section = "3.2.1", description = "Durable messages MUST NOT be lost even if an intermediary is unexpectedly terminated and " + "restarted. A target which is not capable of fulfilling this guarantee MUST NOT accept messages " + "where the durable header is set to true: if the source allows the rejected outcome then the " + "message SHOULD be rejected with the precondition-failed error, otherwise the link MUST be " + "detached by the receiver with the same error.")
@BrokerSpecific(kind = BrokerAdmin.KIND_BROKER_J)
public void durableTransferWithoutRejectedOutcome() throws Exception {
try (FrameTransport transport = new FrameTransport(getBrokerAdmin()).connect()) {
MessageEncoder messageEncoder = new MessageEncoder();
final Header header = new Header();
header.setDurable(true);
messageEncoder.setHeader(header);
messageEncoder.addData(getTestName());
final Response<?> response = transport.newInteraction().negotiateOpen().begin().consumeResponse(Begin.class).attachRole(Role.SENDER).attachTargetAddress(BrokerAdmin.TEST_QUEUE_NAME).attachSourceOutcomes(Accepted.ACCEPTED_SYMBOL).attach().consumeResponse(Attach.class).consumeResponse(Flow.class).assertLatestResponse(Flow.class, this::assumeSufficientCredits).transferDeliveryId().transferPayload(messageEncoder.getPayload()).transferRcvSettleMode(ReceiverSettleMode.FIRST).transfer().consumeResponse().getLatestResponse();
if (getBrokerAdmin().supportsRestart()) {
assertThat(response, is(notNullValue()));
assertThat(response.getBody(), is(instanceOf(Disposition.class)));
final Disposition receivedDisposition = (Disposition) response.getBody();
assertThat(receivedDisposition.getSettled(), is(true));
assertThat(receivedDisposition.getState(), is(instanceOf(Outcome.class)));
assertThat(((Outcome) receivedDisposition.getState()).getSymbol(), is(Accepted.ACCEPTED_SYMBOL));
} else {
assertThat(response, is(notNullValue()));
assertThat(response.getBody(), is(instanceOf(Detach.class)));
final Detach receivedDetach = (Detach) response.getBody();
assertThat(receivedDetach.getError(), is(notNullValue()));
assertThat(receivedDetach.getError().getCondition(), is(AmqpError.PRECONDITION_FAILED));
}
}
}
use of org.apache.qpid.tests.protocol.v1_0.MessageEncoder in project qpid-broker-j by apache.
the class TransferTest method durableTransferWithRejectedOutcome.
@Test
@SpecificationTest(section = "3.2.1", description = "Durable messages MUST NOT be lost even if an intermediary is unexpectedly terminated and " + "restarted. A target which is not capable of fulfilling this guarantee MUST NOT accept messages " + "where the durable header is set to true: if the source allows the rejected outcome then the " + "message SHOULD be rejected with the precondition-failed error, otherwise the link MUST be " + "detached by the receiver with the same error.")
@BrokerSpecific(kind = BrokerAdmin.KIND_BROKER_J)
public void durableTransferWithRejectedOutcome() throws Exception {
try (FrameTransport transport = new FrameTransport(getBrokerAdmin()).connect()) {
MessageEncoder messageEncoder = new MessageEncoder();
final Header header = new Header();
header.setDurable(true);
messageEncoder.setHeader(header);
messageEncoder.addData(getTestName());
final Disposition receivedDisposition = transport.newInteraction().negotiateOpen().begin().consumeResponse(Begin.class).attachRole(Role.SENDER).attachTargetAddress(BrokerAdmin.TEST_QUEUE_NAME).attachSourceOutcomes(Accepted.ACCEPTED_SYMBOL, Rejected.REJECTED_SYMBOL).attach().consumeResponse(Attach.class).consumeResponse(Flow.class).assertLatestResponse(Flow.class, this::assumeSufficientCredits).transferDeliveryId().transferPayload(messageEncoder.getPayload()).transferRcvSettleMode(ReceiverSettleMode.FIRST).transfer().consumeResponse().getLatestResponse(Disposition.class);
assertThat(receivedDisposition.getSettled(), is(true));
assertThat(receivedDisposition.getState(), is(instanceOf(Outcome.class)));
if (getBrokerAdmin().supportsRestart()) {
assertThat(((Outcome) receivedDisposition.getState()).getSymbol(), is(Accepted.ACCEPTED_SYMBOL));
} else {
assertThat(((Outcome) receivedDisposition.getState()).getSymbol(), is(Rejected.REJECTED_SYMBOL));
}
}
}
use of org.apache.qpid.tests.protocol.v1_0.MessageEncoder in project qpid-broker-j by apache.
the class AnonymousTerminusTest method generateMessagePayloadToDestination.
private QpidByteBuffer generateMessagePayloadToDestination(final String destinationName) {
MessageEncoder messageEncoder = new MessageEncoder();
final Properties properties = new Properties();
properties.setTo(destinationName);
messageEncoder.setProperties(properties);
messageEncoder.addData(getTestName());
return messageEncoder.getPayload();
}
use of org.apache.qpid.tests.protocol.v1_0.MessageEncoder in project qpid-broker-j by apache.
the class FilterTest method generateMessagePayloadWithApplicationProperties.
private QpidByteBuffer generateMessagePayloadWithApplicationProperties(final Map<String, Object> applicationProperties, String content) {
MessageEncoder messageEncoder = new MessageEncoder();
messageEncoder.setApplicationProperties(applicationProperties);
messageEncoder.addData(content);
return messageEncoder.getPayload();
}
Aggregations