use of org.apache.qpid.server.protocol.v1_0.type.UnsignedLong in project qpid-broker-j by apache.
the class PropertyConverter_Internal_to_v1_0Test method testMessageIdUnsignedLongConversion.
public void testMessageIdUnsignedLongConversion() {
final UnsignedLong messageId = UnsignedLong.valueOf(-1L);
final AMQMessageHeader header = mock(AMQMessageHeader.class);
when(header.getMessageId()).thenReturn(messageId.toString());
InternalMessage originalMessage = createTestMessage(header);
Message_1_0 convertedMessage = _messageConverter.convert(originalMessage, _addressSpace);
Object convertedMessageId = MessageConverter_from_1_0.getMessageId(convertedMessage);
assertEquals("Unexpected messageId", messageId, convertedMessageId);
}
use of org.apache.qpid.server.protocol.v1_0.type.UnsignedLong in project qpid-broker-j by apache.
the class PropertyConverter_v1_0_to_InternalTest method testMessageIdUnsignedLongConversion.
public void testMessageIdUnsignedLongConversion() {
final UnsignedLong messageId = UnsignedLong.valueOf(-1L);
Properties properties = new Properties();
properties.setMessageId(messageId);
Message_1_0 originalMessage = createTestMessage(properties);
InternalMessage convertedMessage = _messageConverter.convert(originalMessage, _addressSpace);
assertEquals("Unexpected messageId", messageId.toString(), convertedMessage.getMessageHeader().getMessageId());
}
use of org.apache.qpid.server.protocol.v1_0.type.UnsignedLong in project qpid-broker-j by apache.
the class PropertyConverter_1_0_to_0_10Test method testMessageIdUnsignedLongConversion.
public void testMessageIdUnsignedLongConversion() {
final UnsignedLong messageId = UnsignedLong.valueOf(-1);
Properties properties = new Properties();
properties.setMessageId(messageId);
Message_1_0 message = createTestMessage(properties);
final MessageTransferMessage convertedMessage = _messageConverter.convert(message, _namedAddressSpace);
final MessageProperties messageProperties = convertedMessage.getStoredMessage().getMetaData().getMessageProperties();
assertEquals("Unexpected messageId", UUID.nameUUIDFromBytes(longToBytes(messageId.longValue())), messageProperties.getMessageId());
}
use of org.apache.qpid.server.protocol.v1_0.type.UnsignedLong in project qpid-broker-j by apache.
the class TransferTest method exceedMaxMessageSizeLimit.
@Test
@SpecificationTest(section = "2.7.3", description = "max-message-size: This field indicates the maximum message size supported by the link" + " endpoint. Any attempt to deliver a message larger than this results in a" + " message-size-exceeded link-error. If this field is zero or unset, there is no maximum" + " size imposed by the link endpoint.")
public void exceedMaxMessageSizeLimit() throws Exception {
try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
final Binary deliveryTag = new Binary("testDeliveryTag".getBytes(UTF_8));
Interaction interaction = transport.newInteraction();
Open open = interaction.negotiateProtocol().consumeResponse().open().consumeResponse(Open.class).getLatestResponse(Open.class);
long maxFrameSize = open.getMaxFrameSize() == null ? Integer.MAX_VALUE : open.getMaxFrameSize().longValue();
Attach attach = interaction.begin().consumeResponse(Begin.class).attachRole(Role.SENDER).attachTargetAddress(BrokerAdmin.TEST_QUEUE_NAME).attach().consumeResponse(Attach.class).getLatestResponse(Attach.class);
final UnsignedLong maxMessageSizeLimit = attach.getMaxMessageSize();
assumeThat(maxMessageSizeLimit, is(notNullValue()));
assumeThat(maxMessageSizeLimit.longValue(), is(both(greaterThan(0L)).and(lessThan(MAX_MAX_MESSAGE_SIZE_WE_ARE_WILLING_TO_TEST))));
Flow flow = interaction.consumeResponse(Flow.class).getLatestResponse(Flow.class);
assertThat(flow.getLinkCredit().intValue(), is(greaterThan(1)));
final long chunkSize = Math.min(1024 * 1024, maxFrameSize - 100);
byte[] payloadChunk = createTestPaload(chunkSize);
interaction.transferDeliveryId(UnsignedInteger.ZERO).transferDeliveryTag(deliveryTag).transferPayloadData(payloadChunk).transferSettled(true).transferMore(true);
int payloadSize = 0;
while (payloadSize < maxMessageSizeLimit.longValue()) {
payloadSize += chunkSize;
interaction.transfer().sync();
}
while (true) {
Response<?> response = interaction.consumeResponse(Flow.class, Disposition.class, Detach.class).getLatestResponse();
if (response != null) {
if (response.getBody() instanceof Detach) {
break;
} else if (response.getBody() instanceof Disposition) {
assertThat(((Disposition) response.getBody()).getState(), is(instanceOf(Rejected.class)));
assertThat(((Rejected) ((Disposition) response.getBody()).getState()).getError(), is(notNullValue()));
assertThat(((Rejected) ((Disposition) response.getBody()).getState()).getError().getCondition(), is(equalTo(LinkError.MESSAGE_SIZE_EXCEEDED)));
}
}
}
Detach detach = interaction.getLatestResponse(Detach.class);
assertThat(detach.getError(), is(notNullValue()));
assertThat(detach.getError().getCondition(), is(equalTo(LinkError.MESSAGE_SIZE_EXCEEDED)));
}
}
Aggregations