Search in sources :

Example 66 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 testDurableTrueConversion.

public void testDurableTrueConversion() {
    final AMQMessageHeader header = mock(AMQMessageHeader.class);
    InternalMessage originalMessage = createTestMessage(header, null, true);
    AMQMessage convertedMessage = _messageConverter.convert(originalMessage, _addressSpace);
    assertEquals("Unexpected delivery mode", BasicContentHeaderProperties.PERSISTENT, convertedMessage.getContentHeaderBody().getProperties().getDeliveryMode());
    assertTrue("Unexpected persistence of message", convertedMessage.isPersistent());
    assertTrue("Unexpected persistence of meta data", convertedMessage.getStoredMessage().getMetaData().isPersistent());
}
Also used : InternalMessage(org.apache.qpid.server.message.internal.InternalMessage) AMQMessageHeader(org.apache.qpid.server.message.AMQMessageHeader)

Example 67 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 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);
    AMQMessage convertedMessage = _messageConverter.convert(originalMessage, _addressSpace);
    assertEquals("Unexpected expiration time", expiryTime, convertedMessage.getContentHeaderBody().getProperties().getExpiration());
}
Also used : InternalMessage(org.apache.qpid.server.message.internal.InternalMessage) AMQMessageHeader(org.apache.qpid.server.message.AMQMessageHeader)

Example 68 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 testDurableFalseConversion.

public void testDurableFalseConversion() {
    final AMQMessageHeader header = mock(AMQMessageHeader.class);
    InternalMessage originalMessage = createTestMessage(header, null, false);
    AMQMessage convertedMessage = _messageConverter.convert(originalMessage, _addressSpace);
    assertEquals("Unexpected delivery mode", BasicContentHeaderProperties.NON_PERSISTENT, convertedMessage.getContentHeaderBody().getProperties().getDeliveryMode());
    assertFalse("Unexpected persistence of message", convertedMessage.isPersistent());
    assertFalse("Unexpected persistence of meta data", convertedMessage.getStoredMessage().getMetaData().isPersistent());
}
Also used : InternalMessage(org.apache.qpid.server.message.internal.InternalMessage) AMQMessageHeader(org.apache.qpid.server.message.AMQMessageHeader)

Example 69 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 testHeadersConversionWhenKeyLengthExceeds255.

public void testHeadersConversionWhenKeyLengthExceeds255() {
    final Map<String, Object> properties = Collections.singletonMap(generateLongString(), "test");
    final AMQMessageHeader header = mock(AMQMessageHeader.class);
    when(header.getHeaderNames()).thenReturn(properties.keySet());
    doAnswer(invocation -> {
        final String originalArgument = (String) (invocation.getArguments())[0];
        return properties.get(originalArgument);
    }).when(header).getHeader(any(String.class));
    InternalMessage originalMessage = createTestMessage(header);
    try {
        _messageConverter.convert(originalMessage, _addressSpace);
        fail("Expected exception not thrown");
    } catch (MessageConversionException e) {
    // pass
    }
}
Also used : InternalMessage(org.apache.qpid.server.message.internal.InternalMessage) MessageConversionException(org.apache.qpid.server.protocol.converter.MessageConversionException) Matchers.anyString(org.mockito.Matchers.anyString) AMQMessageHeader(org.apache.qpid.server.message.AMQMessageHeader)

Example 70 with AMQMessageHeader

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

the class ReportRunnerTest method createMockMessageForQueue.

protected ServerMessage createMockMessageForQueue() {
    final ServerMessage message = mock(ServerMessage.class);
    final AMQMessageHeader header = mock(AMQMessageHeader.class);
    when(message.getMessageHeader()).thenReturn(header);
    when(message.getContent()).thenReturn(QpidByteBuffer.emptyQpidByteBuffer());
    return message;
}
Also used : ServerMessage(org.apache.qpid.server.message.ServerMessage) 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