Search in sources :

Example 76 with AMQMessage

use of org.apache.qpid.server.protocol.v0_8.AMQMessage in project qpid-broker-j by apache.

the class PropertyConverter_1_0_to_0_8Test method testTTLConversion.

@Test
public void testTTLConversion() {
    long ttl = 10000;
    long arrivalTime = System.currentTimeMillis();
    long expectedExpiration = arrivalTime + ttl;
    Header header = new Header();
    header.setTtl(UnsignedInteger.valueOf(ttl));
    Message_1_0 message = createTestMessage(header, arrivalTime);
    final AMQMessage convertedMessage = _messageConverter.convert(message, _namedAddressSpace);
    BasicContentHeaderProperties convertedProperties = convertedMessage.getContentHeaderBody().getProperties();
    assertEquals("Unexpected expiration", expectedExpiration, convertedProperties.getExpiration());
}
Also used : Header(org.apache.qpid.server.protocol.v1_0.type.messaging.Header) Message_1_0(org.apache.qpid.server.protocol.v1_0.Message_1_0) BasicContentHeaderProperties(org.apache.qpid.server.protocol.v0_8.transport.BasicContentHeaderProperties) AMQMessage(org.apache.qpid.server.protocol.v0_8.AMQMessage) Test(org.junit.Test)

Example 77 with AMQMessage

use of org.apache.qpid.server.protocol.v0_8.AMQMessage in project qpid-broker-j by apache.

the class PropertyConverter_v0_8_to_InternalTest method testExpirationConversion.

@Test
public void testExpirationConversion() {
    long ttl = 10000;
    long arrivalTime = System.currentTimeMillis();
    long expiryTime = arrivalTime + ttl;
    BasicContentHeaderProperties header = new BasicContentHeaderProperties();
    header.setExpiration(expiryTime);
    final AMQMessage originalMessage = createTestMessage(header, arrivalTime);
    InternalMessage convertedMessage = _messageConverter.convert(originalMessage, _addressSpace);
    assertEquals("Unexpected expiration", expiryTime, convertedMessage.getMessageHeader().getExpiration());
}
Also used : InternalMessage(org.apache.qpid.server.message.internal.InternalMessage) BasicContentHeaderProperties(org.apache.qpid.server.protocol.v0_8.transport.BasicContentHeaderProperties) Test(org.junit.Test)

Example 78 with AMQMessage

use of org.apache.qpid.server.protocol.v0_8.AMQMessage in project qpid-broker-j by apache.

the class PropertyConverter_v0_8_to_InternalTest method testHeadersConversion.

@Test
public void testHeadersConversion() {
    Map<String, Object> properties = new HashMap<>();
    properties.put("testProperty1", "testProperty1Value");
    properties.put("intProperty", 1);
    BasicContentHeaderProperties header = new BasicContentHeaderProperties();
    header.setHeaders(FieldTable.convertToFieldTable(properties));
    final AMQMessage originalMessage = createTestMessage(header);
    final InternalMessage convertedMessage = _messageConverter.convert(originalMessage, _addressSpace);
    final Map<String, Object> headers = convertedMessage.getMessageHeader().getHeaderMap();
    assertEquals("Unexpected headers", properties, new HashMap<>(headers));
}
Also used : InternalMessage(org.apache.qpid.server.message.internal.InternalMessage) HashMap(java.util.HashMap) BasicContentHeaderProperties(org.apache.qpid.server.protocol.v0_8.transport.BasicContentHeaderProperties) Test(org.junit.Test)

Example 79 with AMQMessage

use of org.apache.qpid.server.protocol.v0_8.AMQMessage in project qpid-broker-j by apache.

the class PropertyConverter_v0_8_to_InternalTest method testDeliveryModePersistentConversion.

@Test
public void testDeliveryModePersistentConversion() {
    BasicContentHeaderProperties header = new BasicContentHeaderProperties();
    header.setDeliveryMode(BasicContentHeaderProperties.PERSISTENT);
    final AMQMessage originalMessage = createTestMessage(header);
    InternalMessage convertedMessage = _messageConverter.convert(originalMessage, _addressSpace);
    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) BasicContentHeaderProperties(org.apache.qpid.server.protocol.v0_8.transport.BasicContentHeaderProperties) Test(org.junit.Test)

Example 80 with AMQMessage

use of org.apache.qpid.server.protocol.v0_8.AMQMessage in project qpid-broker-j by apache.

the class PropertyConverter_v0_8_to_InternalTest method testUserIdConversion.

@Test
public void testUserIdConversion() {
    final String userId = "testUserId";
    BasicContentHeaderProperties header = new BasicContentHeaderProperties();
    header.setUserId(userId);
    final AMQMessage originalMessage = createTestMessage(header);
    InternalMessage convertedMessage = _messageConverter.convert(originalMessage, _addressSpace);
    assertEquals("Unexpected userId", userId, convertedMessage.getMessageHeader().getUserId());
}
Also used : InternalMessage(org.apache.qpid.server.message.internal.InternalMessage) BasicContentHeaderProperties(org.apache.qpid.server.protocol.v0_8.transport.BasicContentHeaderProperties) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)198 AMQMessage (org.apache.qpid.server.protocol.v0_8.AMQMessage)176 BasicContentHeaderProperties (org.apache.qpid.server.protocol.v0_8.transport.BasicContentHeaderProperties)143 Message_1_0 (org.apache.qpid.server.protocol.v1_0.Message_1_0)114 AMQShortString (org.apache.qpid.server.protocol.v0_8.AMQShortString)78 Properties (org.apache.qpid.server.protocol.v1_0.type.messaging.Properties)76 MessageTransferMessage (org.apache.qpid.server.protocol.v0_10.MessageTransferMessage)58 ApplicationProperties (org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationProperties)57 NamedAddressSpace (org.apache.qpid.server.model.NamedAddressSpace)46 MessageProperties (org.apache.qpid.server.protocol.v0_10.transport.MessageProperties)38 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)33 QpidByteBuffer (org.apache.qpid.server.bytebuffer.QpidByteBuffer)32 MessagePublishInfo (org.apache.qpid.server.protocol.v0_8.transport.MessagePublishInfo)32 DeliveryProperties (org.apache.qpid.server.protocol.v0_10.transport.DeliveryProperties)26 InternalMessage (org.apache.qpid.server.message.internal.InternalMessage)25 Binary (org.apache.qpid.server.protocol.v1_0.type.Binary)24 AmqpValue (org.apache.qpid.server.protocol.v1_0.type.messaging.AmqpValue)17 HashMap (java.util.HashMap)15 Data (org.apache.qpid.server.protocol.v1_0.type.messaging.Data)14 Header (org.apache.qpid.server.protocol.v1_0.type.messaging.Header)12