Search in sources :

Example 46 with AMQMessageHeader

use of org.apache.qpid.server.message.AMQMessageHeader 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 47 with AMQMessageHeader

use of org.apache.qpid.server.message.AMQMessageHeader in project qpid-broker-j by apache.

the class PropertyConverter_Internal_to_v1_0Test method testPriorityConversion.

public void testPriorityConversion() {
    final AMQMessageHeader header = mock(AMQMessageHeader.class);
    byte priority = (byte) 7;
    when(header.getPriority()).thenReturn(priority);
    InternalMessage originalMessage = createTestMessage(header);
    Message_1_0 convertedMessage = _messageConverter.convert(originalMessage, _addressSpace);
    assertEquals("Unexpected priority", priority, convertedMessage.getMessageHeader().getPriority());
}
Also used : InternalMessage(org.apache.qpid.server.message.internal.InternalMessage) AMQMessageHeader(org.apache.qpid.server.message.AMQMessageHeader)

Example 48 with AMQMessageHeader

use of org.apache.qpid.server.message.AMQMessageHeader in project qpid-broker-j by apache.

the class PropertyConverter_Internal_to_v1_0Test method testTimestampConversion.

public void testTimestampConversion() {
    final long timestamp = System.currentTimeMillis();
    final AMQMessageHeader header = mock(AMQMessageHeader.class);
    when(header.getTimestamp()).thenReturn(timestamp);
    InternalMessage originalMessage = createTestMessage(header);
    Message_1_0 convertedMessage = _messageConverter.convert(originalMessage, _addressSpace);
    Date creationTime = MessageConverter_from_1_0.getCreationTime(convertedMessage);
    assertNotNull("timestamp not converted", creationTime);
    assertEquals("Unexpected timestamp", timestamp, creationTime.getTime());
}
Also used : InternalMessage(org.apache.qpid.server.message.internal.InternalMessage) AMQMessageHeader(org.apache.qpid.server.message.AMQMessageHeader) Date(java.util.Date)

Example 49 with AMQMessageHeader

use of org.apache.qpid.server.message.AMQMessageHeader in project qpid-broker-j by apache.

the class PropertyConverter_Internal_to_v1_0Test method testCorrelationIdStringConversion.

public void testCorrelationIdStringConversion() {
    final String correlationId = "testCorrelationId";
    final AMQMessageHeader header = mock(AMQMessageHeader.class);
    when(header.getCorrelationId()).thenReturn(correlationId);
    InternalMessage originalMessage = createTestMessage(header);
    Message_1_0 convertedMessage = _messageConverter.convert(originalMessage, _addressSpace);
    Object convertedCorrelationId = MessageConverter_from_1_0.getCorrelationId(convertedMessage);
    assertEquals("Unexpected messageId", correlationId, convertedCorrelationId);
}
Also used : InternalMessage(org.apache.qpid.server.message.internal.InternalMessage) AMQMessageHeader(org.apache.qpid.server.message.AMQMessageHeader)

Example 50 with AMQMessageHeader

use of org.apache.qpid.server.message.AMQMessageHeader 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)

Aggregations

AMQMessageHeader (org.apache.qpid.server.message.AMQMessageHeader)81 InternalMessage (org.apache.qpid.server.message.internal.InternalMessage)55 Matchers.anyString (org.mockito.Matchers.anyString)28 ServerMessage (org.apache.qpid.server.message.ServerMessage)16 AMQShortString (org.apache.qpid.server.protocol.v0_8.AMQShortString)15 TransactionLogResource (org.apache.qpid.server.store.TransactionLogResource)11 HashMap (java.util.HashMap)10 MessageConversionException (org.apache.qpid.server.protocol.converter.MessageConversionException)8 MessageReference (org.apache.qpid.server.message.MessageReference)5 Queue (org.apache.qpid.server.model.Queue)5 ReplyTo (org.apache.qpid.server.protocol.v0_10.transport.ReplyTo)5 Exchange (org.apache.qpid.server.model.Exchange)4 UUID (java.util.UUID)3 UnsignedLong (org.apache.qpid.server.protocol.v1_0.type.UnsignedLong)3 Date (java.util.Date)2 Set (java.util.Set)2 QpidByteBuffer (org.apache.qpid.server.bytebuffer.QpidByteBuffer)2 InternalMessageHeader (org.apache.qpid.server.message.internal.InternalMessageHeader)2 StoredMessage (org.apache.qpid.server.store.StoredMessage)2 InvocationOnMock (org.mockito.invocation.InvocationOnMock)2