Search in sources :

Example 31 with AMQMessageHeader

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

the class PropertyConverter_Internal_to_v0_8Test method testReplyToConversionWhenExchangeIsSpecified.

public void testReplyToConversionWhenExchangeIsSpecified() {
    final String replyTo = "testExchange";
    final AMQMessageHeader header = mock(AMQMessageHeader.class);
    when(header.getReplyTo()).thenReturn(replyTo);
    Exchange exchange = mock(Exchange.class);
    when(exchange.getName()).thenReturn(replyTo);
    when(exchange.getType()).thenReturn(ExchangeDefaults.FANOUT_EXCHANGE_CLASS);
    when(_addressSpace.getAttainedMessageDestination(replyTo)).thenReturn(exchange);
    InternalMessage originalMessage = createTestMessage(header);
    AMQMessage convertedMessage = _messageConverter.convert(originalMessage, _addressSpace);
    assertEquals("Unexpected reply-to", "fanout://" + replyTo + "//", convertedMessage.getContentHeaderBody().getProperties().getReplyToAsString());
}
Also used : Exchange(org.apache.qpid.server.model.Exchange) InternalMessage(org.apache.qpid.server.message.internal.InternalMessage) Matchers.anyString(org.mockito.Matchers.anyString) AMQMessageHeader(org.apache.qpid.server.message.AMQMessageHeader)

Example 32 with AMQMessageHeader

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

the class PropertyConverter_Internal_to_v0_8Test 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);
    AMQMessage convertedMessage = _messageConverter.convert(originalMessage, _addressSpace);
    assertEquals("Unexpected timestamp", timestamp, convertedMessage.getContentHeaderBody().getProperties().getTimestamp());
}
Also used : InternalMessage(org.apache.qpid.server.message.internal.InternalMessage) AMQMessageHeader(org.apache.qpid.server.message.AMQMessageHeader)

Example 33 with AMQMessageHeader

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

the class PropertyConverter_Internal_to_v0_8Test method testMessageIdConversionWhenLengthExceeds255.

public void testMessageIdConversionWhenLengthExceeds255() {
    final String messageId = generateLongString();
    final AMQMessageHeader header = mock(AMQMessageHeader.class);
    when(header.getMessageId()).thenReturn(messageId);
    InternalMessage originalMessage = createTestMessage(header);
    AMQMessage convertedMessage = _messageConverter.convert(originalMessage, _addressSpace);
    assertNull("Unexpected messageId", convertedMessage.getContentHeaderBody().getProperties().getMessageId());
}
Also used : InternalMessage(org.apache.qpid.server.message.internal.InternalMessage) Matchers.anyString(org.mockito.Matchers.anyString) AMQMessageHeader(org.apache.qpid.server.message.AMQMessageHeader)

Example 34 with AMQMessageHeader

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

the class PropertyConverter_Internal_to_v0_8Test method testPriorityConversion.

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

Example 35 with AMQMessageHeader

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

the class PropertyConverter_Internal_to_v0_8Test method testReplyToConversionWhenQueueIsSpecified.

public void testReplyToConversionWhenQueueIsSpecified() {
    final String replyTo = "testQueue";
    final AMQMessageHeader header = mock(AMQMessageHeader.class);
    when(header.getReplyTo()).thenReturn(replyTo);
    Queue queue = mock(Queue.class);
    when(queue.getName()).thenReturn(replyTo);
    when(_addressSpace.getAttainedMessageDestination(replyTo)).thenReturn(queue);
    InternalMessage originalMessage = createTestMessage(header);
    AMQMessage convertedMessage = _messageConverter.convert(originalMessage, _addressSpace);
    assertEquals("Unexpected reply-to", "direct:////" + replyTo, convertedMessage.getContentHeaderBody().getProperties().getReplyToAsString());
}
Also used : InternalMessage(org.apache.qpid.server.message.internal.InternalMessage) Matchers.anyString(org.mockito.Matchers.anyString) AMQMessageHeader(org.apache.qpid.server.message.AMQMessageHeader) Queue(org.apache.qpid.server.model.Queue)

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