use of org.apache.qpid.server.protocol.v1_0.type.messaging.DeliveryAnnotations in project qpid-broker-j by apache.
the class PropertyConverter_1_0_to_0_10Test method testConversionOfTtlTakesPrecedenceOverAbsoluteExpiryTime.
public void testConversionOfTtlTakesPrecedenceOverAbsoluteExpiryTime() {
long ttl = 10000;
final long time = System.currentTimeMillis();
long absoluteExpiryTime = time + ttl;
long arrivalTime = time + 1;
Header header = new Header();
header.setTtl(UnsignedInteger.valueOf(ttl));
Properties properties = new Properties();
properties.setAbsoluteExpiryTime(new Date(absoluteExpiryTime));
Message_1_0 message = createTestMessage(header, new DeliveryAnnotations(Collections.emptyMap()), new MessageAnnotations(Collections.emptyMap()), properties, new ApplicationProperties(Collections.emptyMap()), arrivalTime, null);
final MessageTransferMessage convertedMessage = _messageConverter.convert(message, _namedAddressSpace);
final DeliveryProperties deliveryProperties = convertedMessage.getStoredMessage().getMetaData().getDeliveryProperties();
assertEquals("Unexpected ttl", ttl, deliveryProperties.getTtl());
assertEquals("Unexpected expiration", arrivalTime + ttl, deliveryProperties.getExpiration());
}
use of org.apache.qpid.server.protocol.v1_0.type.messaging.DeliveryAnnotations in project qpid-broker-j by apache.
the class DecodeErrorTest method illegalMessageFormatPayload.
@Test
@SpecificationTest(section = "3.2", description = "Altogether a message consists of the following sections: Zero or one header," + " Zero or one delivery-annotations, [...]")
public void illegalMessageFormatPayload() throws Exception {
try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
List<QpidByteBuffer> payloads = new ArrayList<>();
final HeaderSection headerSection = new Header().createEncodingRetainingSection();
payloads.add(headerSection.getEncodedForm());
headerSection.dispose();
final StringWriter stringWriter = new StringWriter("string in between annotation sections");
QpidByteBuffer encodedString = QpidByteBuffer.allocate(stringWriter.getEncodedSize());
stringWriter.writeToBuffer(encodedString);
encodedString.flip();
payloads.add(encodedString);
final DeliveryAnnotationsSection deliveryAnnotationsSection = new DeliveryAnnotations(Collections.emptyMap()).createEncodingRetainingSection();
payloads.add(deliveryAnnotationsSection.getEncodedForm());
deliveryAnnotationsSection.dispose();
final Detach detachResponse;
try (QpidByteBuffer combinedPayload = QpidByteBuffer.concatenate(payloads)) {
detachResponse = transport.newInteraction().negotiateProtocol().consumeResponse().open().consumeResponse(Open.class).begin().consumeResponse(Begin.class).attachRole(Role.SENDER).attachTargetAddress(BrokerAdmin.TEST_QUEUE_NAME).attach().consumeResponse(Attach.class).consumeResponse(Flow.class).transferMessageFormat(UnsignedInteger.ZERO).transferPayload(combinedPayload).transfer().consumeResponse().getLatestResponse(Detach.class);
}
payloads.forEach(QpidByteBuffer::dispose);
assertThat(detachResponse.getError(), is(notNullValue()));
assertThat(detachResponse.getError().getCondition(), is(equalTo(DECODE_ERROR)));
}
}
Aggregations