Search in sources :

Example 36 with Header

use of org.apache.qpid.server.protocol.v1_0.type.messaging.Header in project qpid-broker-j by apache.

the class PropertyConverter_0_10_to_1_0Test method testTTLConversion.

@Test
public void testTTLConversion() {
    long timestamp = System.currentTimeMillis();
    int ttl = 100000;
    final DeliveryProperties deliveryProperties = new DeliveryProperties();
    deliveryProperties.setTtl(ttl);
    MessageTransferMessage message = createTestMessage(deliveryProperties, new MessageProperties(), null, timestamp);
    final Message_1_0 convertedMessage = _messageConverter.convert(message, _namedAddressSpace);
    Header header = convertedMessage.getHeaderSection().getValue();
    assertEquals("Unexpected TTL", (long) ttl, header.getTtl().longValue());
    Properties properties = convertedMessage.getPropertiesSection().getValue();
    assertNull("Unexpected expiration", properties.getAbsoluteExpiryTime());
}
Also used : Header(org.apache.qpid.server.protocol.v1_0.type.messaging.Header) MessageTransferMessage(org.apache.qpid.server.protocol.v0_10.MessageTransferMessage) MessageProperties(org.apache.qpid.server.protocol.v0_10.transport.MessageProperties) Message_1_0(org.apache.qpid.server.protocol.v1_0.Message_1_0) DeliveryProperties(org.apache.qpid.server.protocol.v0_10.transport.DeliveryProperties) Properties(org.apache.qpid.server.protocol.v1_0.type.messaging.Properties) DeliveryProperties(org.apache.qpid.server.protocol.v0_10.transport.DeliveryProperties) MessageProperties(org.apache.qpid.server.protocol.v0_10.transport.MessageProperties) Test(org.junit.Test)

Example 37 with Header

use of org.apache.qpid.server.protocol.v1_0.type.messaging.Header in project qpid-broker-j by apache.

the class PropertyConverter_0_10_to_1_0Test method testPriorityConversion.

@Test
public void testPriorityConversion() {
    final byte priority = 5;
    final DeliveryProperties deliveryProperties = new DeliveryProperties();
    deliveryProperties.setPriority(MessageDeliveryPriority.get(priority));
    MessageTransferMessage message = createTestMessage(deliveryProperties);
    final Message_1_0 convertedMessage = _messageConverter.convert(message, _namedAddressSpace);
    Header header = convertedMessage.getHeaderSection().getValue();
    assertEquals("Unexpected priority", (long) priority, (long) header.getPriority().byteValue());
}
Also used : Header(org.apache.qpid.server.protocol.v1_0.type.messaging.Header) MessageTransferMessage(org.apache.qpid.server.protocol.v0_10.MessageTransferMessage) Message_1_0(org.apache.qpid.server.protocol.v1_0.Message_1_0) DeliveryProperties(org.apache.qpid.server.protocol.v0_10.transport.DeliveryProperties) Test(org.junit.Test)

Example 38 with Header

use of org.apache.qpid.server.protocol.v1_0.type.messaging.Header in project qpid-broker-j by apache.

the class PropertyConverter_1_0_to_0_10Test method testSubjectDoesNoReplaceApplicationPropertyXJMSType.

@Test
public void testSubjectDoesNoReplaceApplicationPropertyXJMSType() {
    final String subject = "testSubject";
    Properties properties = new Properties();
    properties.setSubject(subject);
    final String jmsType = "testJmsType";
    Map<String, Object> applicationPropertiesMap = Collections.singletonMap("x-jms-type", jmsType);
    ApplicationProperties applicationProperties = new ApplicationProperties(applicationPropertiesMap);
    Message_1_0 message = createTestMessage(new Header(), new DeliveryAnnotations(Collections.emptyMap()), new MessageAnnotations(Collections.emptyMap()), properties, applicationProperties, 0, null);
    final MessageTransferMessage convertedMessage = _messageConverter.convert(message, _namedAddressSpace);
    final MessageProperties messageProperties = convertedMessage.getStoredMessage().getMetaData().getMessageProperties();
    final Map<String, Object> headers = messageProperties.getApplicationHeaders();
    assertEquals("Unexpected qpid.subject is missing from headers", subject, headers.get("qpid.subject"));
    assertEquals("Unexpected type", jmsType, headers.get("x-jms-type"));
    final DeliveryProperties deliveryProperties = convertedMessage.getStoredMessage().getMetaData().getDeliveryProperties();
    assertEquals("Unexpected routing-key", subject, deliveryProperties.getRoutingKey());
}
Also used : Header(org.apache.qpid.server.protocol.v1_0.type.messaging.Header) MessageTransferMessage(org.apache.qpid.server.protocol.v0_10.MessageTransferMessage) MessageProperties(org.apache.qpid.server.protocol.v0_10.transport.MessageProperties) MessageAnnotations(org.apache.qpid.server.protocol.v1_0.type.messaging.MessageAnnotations) DeliveryAnnotations(org.apache.qpid.server.protocol.v1_0.type.messaging.DeliveryAnnotations) ApplicationProperties(org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationProperties) Message_1_0(org.apache.qpid.server.protocol.v1_0.Message_1_0) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) DeliveryProperties(org.apache.qpid.server.protocol.v0_10.transport.DeliveryProperties) ApplicationProperties(org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationProperties) DeliveryProperties(org.apache.qpid.server.protocol.v0_10.transport.DeliveryProperties) Properties(org.apache.qpid.server.protocol.v1_0.type.messaging.Properties) MessageProperties(org.apache.qpid.server.protocol.v0_10.transport.MessageProperties) Test(org.junit.Test)

Example 39 with Header

use of org.apache.qpid.server.protocol.v1_0.type.messaging.Header in project qpid-broker-j by apache.

the class PropertyConverter_1_0_to_0_10Test method testGroupSequenceDoesNotReplaceApplicationPropertiesJMSXGroupSeq.

@Test
public void testGroupSequenceDoesNotReplaceApplicationPropertiesJMSXGroupSeq() {
    int testGroupSequence = 1;
    Properties properties = new Properties();
    properties.setGroupSequence(UnsignedInteger.valueOf(testGroupSequence));
    final int JMSXGroupSeq = 2;
    Map<String, Object> applicationPropertiesMap = Collections.singletonMap("JMSXGroupSeq", JMSXGroupSeq);
    ApplicationProperties applicationProperties = new ApplicationProperties(applicationPropertiesMap);
    Message_1_0 message = createTestMessage(new Header(), new DeliveryAnnotations(Collections.emptyMap()), new MessageAnnotations(Collections.emptyMap()), properties, applicationProperties, 0, null);
    final MessageTransferMessage convertedMessage = _messageConverter.convert(message, _namedAddressSpace);
    final MessageProperties messageProperties = convertedMessage.getStoredMessage().getMetaData().getMessageProperties();
    final Map<String, Object> applicationHeaders = messageProperties.getApplicationHeaders();
    assertEquals("Unexpected JMSXGroupSeq", JMSXGroupSeq, applicationHeaders.get("JMSXGroupSeq"));
}
Also used : Header(org.apache.qpid.server.protocol.v1_0.type.messaging.Header) MessageTransferMessage(org.apache.qpid.server.protocol.v0_10.MessageTransferMessage) MessageProperties(org.apache.qpid.server.protocol.v0_10.transport.MessageProperties) MessageAnnotations(org.apache.qpid.server.protocol.v1_0.type.messaging.MessageAnnotations) DeliveryAnnotations(org.apache.qpid.server.protocol.v1_0.type.messaging.DeliveryAnnotations) ApplicationProperties(org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationProperties) Message_1_0(org.apache.qpid.server.protocol.v1_0.Message_1_0) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) ApplicationProperties(org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationProperties) DeliveryProperties(org.apache.qpid.server.protocol.v0_10.transport.DeliveryProperties) Properties(org.apache.qpid.server.protocol.v1_0.type.messaging.Properties) MessageProperties(org.apache.qpid.server.protocol.v0_10.transport.MessageProperties) Test(org.junit.Test)

Example 40 with Header

use of org.apache.qpid.server.protocol.v1_0.type.messaging.Header in project qpid-broker-j by apache.

the class PropertyConverter_1_0_to_0_10Test method testConversionOfTtlTakesPrecedenceOverAbsoluteExpiryTime.

@Test
public void testConversionOfTtlTakesPrecedenceOverAbsoluteExpiryTime() {
    long ttl = 10000;
    final long time = System.currentTimeMillis();
    long absoluteExpiryTime = time + ttl;
    long arrivalTime = time + 1;
    Header header = new Header();
    header.setTtl(UnsignedInteger.valueOf(ttl));
    Properties properties = new Properties();
    properties.setAbsoluteExpiryTime(new Date(absoluteExpiryTime));
    Message_1_0 message = createTestMessage(header, new DeliveryAnnotations(Collections.emptyMap()), new MessageAnnotations(Collections.emptyMap()), properties, new ApplicationProperties(Collections.emptyMap()), arrivalTime, null);
    final MessageTransferMessage convertedMessage = _messageConverter.convert(message, _namedAddressSpace);
    final DeliveryProperties deliveryProperties = convertedMessage.getStoredMessage().getMetaData().getDeliveryProperties();
    assertEquals("Unexpected ttl", ttl, deliveryProperties.getTtl());
    assertEquals("Unexpected expiration", arrivalTime + ttl, deliveryProperties.getExpiration());
}
Also used : Header(org.apache.qpid.server.protocol.v1_0.type.messaging.Header) MessageTransferMessage(org.apache.qpid.server.protocol.v0_10.MessageTransferMessage) MessageAnnotations(org.apache.qpid.server.protocol.v1_0.type.messaging.MessageAnnotations) DeliveryAnnotations(org.apache.qpid.server.protocol.v1_0.type.messaging.DeliveryAnnotations) Message_1_0(org.apache.qpid.server.protocol.v1_0.Message_1_0) ApplicationProperties(org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationProperties) DeliveryProperties(org.apache.qpid.server.protocol.v0_10.transport.DeliveryProperties) ApplicationProperties(org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationProperties) DeliveryProperties(org.apache.qpid.server.protocol.v0_10.transport.DeliveryProperties) Properties(org.apache.qpid.server.protocol.v1_0.type.messaging.Properties) MessageProperties(org.apache.qpid.server.protocol.v0_10.transport.MessageProperties) Date(java.util.Date) Test(org.junit.Test)

Aggregations

Header (org.apache.qpid.server.protocol.v1_0.type.messaging.Header)45 Test (org.junit.Test)44 Message_1_0 (org.apache.qpid.server.protocol.v1_0.Message_1_0)32 DeliveryProperties (org.apache.qpid.server.protocol.v0_10.transport.DeliveryProperties)19 MessageTransferMessage (org.apache.qpid.server.protocol.v0_10.MessageTransferMessage)18 Properties (org.apache.qpid.server.protocol.v1_0.type.messaging.Properties)17 QpidByteBuffer (org.apache.qpid.server.bytebuffer.QpidByteBuffer)16 ApplicationProperties (org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationProperties)14 BasicContentHeaderProperties (org.apache.qpid.server.protocol.v0_8.transport.BasicContentHeaderProperties)13 MessageAnnotations (org.apache.qpid.server.protocol.v1_0.type.messaging.MessageAnnotations)13 DeliveryAnnotations (org.apache.qpid.server.protocol.v1_0.type.messaging.DeliveryAnnotations)12 MessageProperties (org.apache.qpid.server.protocol.v0_10.transport.MessageProperties)11 AMQMessage (org.apache.qpid.server.protocol.v0_8.AMQMessage)11 Date (java.util.Date)9 InternalMessage (org.apache.qpid.server.message.internal.InternalMessage)8 MessageMetaData_1_0 (org.apache.qpid.server.protocol.v1_0.MessageMetaData_1_0)8 Binary (org.apache.qpid.server.protocol.v1_0.type.Binary)8 Footer (org.apache.qpid.server.protocol.v1_0.type.messaging.Footer)7 ArrayList (java.util.ArrayList)6 Symbol (org.apache.qpid.server.protocol.v1_0.type.Symbol)6