Search in sources :

Example 6 with MessageConverter_from_1_0.getAmqp0xConvertedContentAndMimeType

use of org.apache.qpid.server.protocol.v1_0.MessageConverter_from_1_0.getAmqp0xConvertedContentAndMimeType 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 MessageConverter_from_1_0.getAmqp0xConvertedContentAndMimeType

use of org.apache.qpid.server.protocol.v1_0.MessageConverter_from_1_0.getAmqp0xConvertedContentAndMimeType in project qpid-broker-j by apache.

the class PropertyConverter_Internal_to_v1_0Test method testExpirationConversion.

public void testExpirationConversion() throws InterruptedException {
    long ttl = 10000;
    long expiryTime = System.currentTimeMillis() + ttl;
    final AMQMessageHeader header = mock(AMQMessageHeader.class);
    when(header.getExpiration()).thenReturn(expiryTime);
    InternalMessage originalMessage = createTestMessage(header);
    Thread.sleep(1L);
    Message_1_0 convertedMessage = _messageConverter.convert(originalMessage, _addressSpace);
    Long convertedTtl = MessageConverter_from_1_0.getTtl(convertedMessage);
    assertEquals("Unexpected TTL", expiryTime - originalMessage.getArrivalTime(), convertedTtl.longValue());
}
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 8 with MessageConverter_from_1_0.getAmqp0xConvertedContentAndMimeType

use of org.apache.qpid.server.protocol.v1_0.MessageConverter_from_1_0.getAmqp0xConvertedContentAndMimeType in project qpid-broker-j by apache.

the class PropertyConverter_Internal_to_v1_0Test method testUserIdConversion.

public void testUserIdConversion() {
    final String userId = "testUserId";
    final AMQMessageHeader header = mock(AMQMessageHeader.class);
    when(header.getUserId()).thenReturn(userId);
    InternalMessage originalMessage = createTestMessage(header);
    Message_1_0 convertedMessage = _messageConverter.convert(originalMessage, _addressSpace);
    Binary convertedUserId = MessageConverter_from_1_0.getUserId(convertedMessage);
    assertTrue("Unexpected userId", Arrays.equals(userId.getBytes(UTF_8), convertedUserId.getArray()));
}
Also used : InternalMessage(org.apache.qpid.server.message.internal.InternalMessage) AMQMessageHeader(org.apache.qpid.server.message.AMQMessageHeader) Binary(org.apache.qpid.server.protocol.v1_0.type.Binary)

Aggregations

AMQMessageHeader (org.apache.qpid.server.message.AMQMessageHeader)5 InternalMessage (org.apache.qpid.server.message.internal.InternalMessage)5 UnsignedLong (org.apache.qpid.server.protocol.v1_0.type.UnsignedLong)3 ConvertedContentAndMimeType (org.apache.qpid.server.protocol.v1_0.MessageConverter_from_1_0.ConvertedContentAndMimeType)2 MessageConverter_from_1_0.getAmqp0xConvertedContentAndMimeType (org.apache.qpid.server.protocol.v1_0.MessageConverter_from_1_0.getAmqp0xConvertedContentAndMimeType)2 Symbol (org.apache.qpid.server.protocol.v1_0.type.Symbol)2 StoredMessage (org.apache.qpid.server.store.StoredMessage)2 Serializable (java.io.Serializable)1 Map (java.util.Map)1 MessageMetaData_0_10 (org.apache.qpid.server.protocol.v0_10.MessageMetaData_0_10)1 MessageMetaData (org.apache.qpid.server.protocol.v0_8.MessageMetaData)1 Binary (org.apache.qpid.server.protocol.v1_0.type.Binary)1