Search in sources :

Example 6 with UnsignedLong

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);
}
Also used : InternalMessage(org.apache.qpid.server.message.internal.InternalMessage) UnsignedLong(org.apache.qpid.server.protocol.v1_0.type.UnsignedLong) AMQMessageHeader(org.apache.qpid.server.message.AMQMessageHeader)

Example 7 with UnsignedLong

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());
}
Also used : InternalMessage(org.apache.qpid.server.message.internal.InternalMessage) UnsignedLong(org.apache.qpid.server.protocol.v1_0.type.UnsignedLong) ApplicationProperties(org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationProperties) Properties(org.apache.qpid.server.protocol.v1_0.type.messaging.Properties)

Example 8 with UnsignedLong

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());
}
Also used : UnsignedLong(org.apache.qpid.server.protocol.v1_0.type.UnsignedLong) MessageTransferMessage(org.apache.qpid.server.protocol.v0_10.MessageTransferMessage) MessageProperties(org.apache.qpid.server.protocol.v0_10.transport.MessageProperties) Message_1_0(org.apache.qpid.server.protocol.v1_0.Message_1_0) ApplicationProperties(org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationProperties) Properties(org.apache.qpid.server.protocol.v1_0.type.messaging.Properties) DeliveryProperties(org.apache.qpid.server.protocol.v0_10.transport.DeliveryProperties) MessageProperties(org.apache.qpid.server.protocol.v0_10.transport.MessageProperties)

Example 9 with UnsignedLong

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)));
    }
}
Also used : FrameTransport(org.apache.qpid.tests.protocol.v1_0.FrameTransport) UnsignedLong(org.apache.qpid.server.protocol.v1_0.type.UnsignedLong) Interaction(org.apache.qpid.tests.protocol.v1_0.Interaction) Attach(org.apache.qpid.server.protocol.v1_0.type.transport.Attach) Rejected(org.apache.qpid.server.protocol.v1_0.type.messaging.Rejected) Open(org.apache.qpid.server.protocol.v1_0.type.transport.Open) Flow(org.apache.qpid.server.protocol.v1_0.type.transport.Flow) Begin(org.apache.qpid.server.protocol.v1_0.type.transport.Begin) Disposition(org.apache.qpid.server.protocol.v1_0.type.transport.Disposition) Binary(org.apache.qpid.server.protocol.v1_0.type.Binary) Detach(org.apache.qpid.server.protocol.v1_0.type.transport.Detach) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest) Test(org.junit.Test) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest)

Aggregations

UnsignedLong (org.apache.qpid.server.protocol.v1_0.type.UnsignedLong)9 ApplicationProperties (org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationProperties)6 Properties (org.apache.qpid.server.protocol.v1_0.type.messaging.Properties)6 InternalMessage (org.apache.qpid.server.message.internal.InternalMessage)4 Message_1_0 (org.apache.qpid.server.protocol.v1_0.Message_1_0)4 AMQMessageHeader (org.apache.qpid.server.message.AMQMessageHeader)2 MessageTransferMessage (org.apache.qpid.server.protocol.v0_10.MessageTransferMessage)2 DeliveryProperties (org.apache.qpid.server.protocol.v0_10.transport.DeliveryProperties)2 MessageProperties (org.apache.qpid.server.protocol.v0_10.transport.MessageProperties)2 AMQMessage (org.apache.qpid.server.protocol.v0_8.AMQMessage)2 BasicContentHeaderProperties (org.apache.qpid.server.protocol.v0_8.transport.BasicContentHeaderProperties)2 Binary (org.apache.qpid.server.protocol.v1_0.type.Binary)1 Rejected (org.apache.qpid.server.protocol.v1_0.type.messaging.Rejected)1 Attach (org.apache.qpid.server.protocol.v1_0.type.transport.Attach)1 Begin (org.apache.qpid.server.protocol.v1_0.type.transport.Begin)1 Detach (org.apache.qpid.server.protocol.v1_0.type.transport.Detach)1 Disposition (org.apache.qpid.server.protocol.v1_0.type.transport.Disposition)1 Flow (org.apache.qpid.server.protocol.v1_0.type.transport.Flow)1 Open (org.apache.qpid.server.protocol.v1_0.type.transport.Open)1 SpecificationTest (org.apache.qpid.tests.protocol.SpecificationTest)1