Search in sources :

Example 51 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 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)

Example 52 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 testReplyToConversion.

public void testReplyToConversion() {
    final String replyTo = "amq.direct/test";
    final AMQMessageHeader header = mock(AMQMessageHeader.class);
    when(header.getReplyTo()).thenReturn(replyTo);
    InternalMessage originalMessage = createTestMessage(header);
    Message_1_0 convertedMessage = _messageConverter.convert(originalMessage, _addressSpace);
    String convertedReplyTo = MessageConverter_from_1_0.getReplyTo(convertedMessage);
    assertEquals("Unexpected replyTo", replyTo, convertedReplyTo);
}
Also used : InternalMessage(org.apache.qpid.server.message.internal.InternalMessage) AMQMessageHeader(org.apache.qpid.server.message.AMQMessageHeader)

Example 53 with AMQMessageHeader

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

the class PropertyConverter_Internal_to_v0_10Test method testUserIdConversionWhenLengthExceeds16Bits.

public void testUserIdConversionWhenLengthExceeds16Bits() throws IOException {
    final String userId = generateLongLongString();
    final AMQMessageHeader header = mock(AMQMessageHeader.class);
    when(header.getUserId()).thenReturn(userId);
    InternalMessage originalMessage = createTestMessage(header);
    MessageTransferMessage convertedMessage = _messageConverter.convert(originalMessage, _addressSpace);
    assertNull("Unexpected userId", convertedMessage.getHeader().getMessageProperties().getUserId());
}
Also used : InternalMessage(org.apache.qpid.server.message.internal.InternalMessage) Matchers.anyString(org.mockito.Matchers.anyString) AMQShortString(org.apache.qpid.server.protocol.v0_8.AMQShortString) AMQMessageHeader(org.apache.qpid.server.message.AMQMessageHeader)

Example 54 with AMQMessageHeader

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

the class PropertyConverter_Internal_to_v0_10Test method testContentEncodingConversion.

public void testContentEncodingConversion() throws IOException {
    String contentEncoding = "my-test-encoding";
    final AMQMessageHeader header = mock(AMQMessageHeader.class);
    when(header.getEncoding()).thenReturn(contentEncoding);
    InternalMessage originalMessage = createTestMessage(header);
    MessageTransferMessage convertedMessage = _messageConverter.convert(originalMessage, _addressSpace);
    assertEquals("Unexpected content encoding", contentEncoding, convertedMessage.getHeader().getMessageProperties().getContentEncoding());
}
Also used : InternalMessage(org.apache.qpid.server.message.internal.InternalMessage) Matchers.anyString(org.mockito.Matchers.anyString) AMQShortString(org.apache.qpid.server.protocol.v0_8.AMQShortString) AMQMessageHeader(org.apache.qpid.server.message.AMQMessageHeader)

Example 55 with AMQMessageHeader

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

the class PropertyConverter_Internal_to_v0_10Test method testReplyToConversionWhenQueueIsSpecified.

public void testReplyToConversionWhenQueueIsSpecified() throws IOException {
    final AMQMessageHeader header = mock(AMQMessageHeader.class);
    final String replyTo = "myTestQueue";
    final Queue queue = mock(Queue.class);
    when(queue.getName()).thenReturn(replyTo);
    when(_addressSpace.getAttainedMessageDestination(replyTo)).thenReturn(queue);
    when(header.getReplyTo()).thenReturn(replyTo);
    InternalMessage originalMessage = createTestMessage(header);
    MessageTransferMessage convertedMessage = _messageConverter.convert(originalMessage, _addressSpace);
    final ReplyTo convertedReplyTo = convertedMessage.getHeader().getMessageProperties().getReplyTo();
    assertEquals("Unexpected exchange", "", convertedReplyTo.getExchange());
    assertEquals("Unexpected routing key", replyTo, convertedReplyTo.getRoutingKey());
}
Also used : ReplyTo(org.apache.qpid.server.protocol.v0_10.transport.ReplyTo) InternalMessage(org.apache.qpid.server.message.internal.InternalMessage) AMQMessageHeader(org.apache.qpid.server.message.AMQMessageHeader) Matchers.anyString(org.mockito.Matchers.anyString) AMQShortString(org.apache.qpid.server.protocol.v0_8.AMQShortString) 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