Search in sources :

Example 16 with ApplicationProperties

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

the class PropertyConverter_1_0_to_0_10Test method createTestMessage.

private Message_1_0 createTestMessage(final Header header, final DeliveryAnnotations deliveryAnnotations, final MessageAnnotations messageAnnotations, final Properties properties, final ApplicationProperties applicationProperties, final long arrivalTime, final byte[] content) {
    final StoredMessage<MessageMetaData_1_0> storedMessage = mock(StoredMessage.class);
    MessageMetaData_1_0 metaData = new MessageMetaData_1_0(header.createEncodingRetainingSection(), deliveryAnnotations.createEncodingRetainingSection(), messageAnnotations.createEncodingRetainingSection(), properties.createEncodingRetainingSection(), applicationProperties.createEncodingRetainingSection(), new Footer(Collections.emptyMap()).createEncodingRetainingSection(), arrivalTime, content == null ? 0 : content.length);
    when(storedMessage.getMetaData()).thenReturn(metaData);
    if (content != null) {
        Binary binary = new Binary(content);
        DataSection dataSection = new Data(binary).createEncodingRetainingSection();
        QpidByteBuffer qbb = dataSection.getEncodedForm();
        int length = qbb.remaining();
        when(storedMessage.getContentSize()).thenReturn(length);
        when(storedMessage.getContent(0, length)).thenReturn(qbb);
    } else {
        when(storedMessage.getContentSize()).thenReturn(0);
        when(storedMessage.getContent(0, 0)).thenReturn(QpidByteBuffer.emptyQpidByteBuffer());
    }
    return new Message_1_0(storedMessage);
}
Also used : DataSection(org.apache.qpid.server.protocol.v1_0.type.messaging.DataSection) Footer(org.apache.qpid.server.protocol.v1_0.type.messaging.Footer) Message_1_0(org.apache.qpid.server.protocol.v1_0.Message_1_0) MessageMetaData_1_0(org.apache.qpid.server.protocol.v1_0.MessageMetaData_1_0) Data(org.apache.qpid.server.protocol.v1_0.type.messaging.Data) QpidByteBuffer(org.apache.qpid.server.bytebuffer.QpidByteBuffer) Binary(org.apache.qpid.server.protocol.v1_0.type.Binary)

Example 17 with ApplicationProperties

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

the class PropertyConverter_1_0_to_0_10Test method testGroupIdDoesNotReplaceApplicationPropertiesJMSXGroupID.

public void testGroupIdDoesNotReplaceApplicationPropertiesJMSXGroupID() {
    String testGroupId = "group1";
    Properties properties = new Properties();
    properties.setGroupId(testGroupId);
    final String JMSXGroupID = "group2";
    Map<String, Object> applicationPropertiesMap = Collections.singletonMap("JMSXGroupID", JMSXGroupID);
    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 group-id", JMSXGroupID, applicationHeaders.get("JMSXGroupID"));
}
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) Matchers.anyString(org.mockito.Matchers.anyString) ApplicationProperties(org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationProperties) 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)

Example 18 with ApplicationProperties

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

the class PropertyConverter_1_0_to_0_10Test method testApplicationPropertiesConversion.

public void testApplicationPropertiesConversion() {
    Map<String, Object> properties = new HashMap<>();
    properties.put("testProperty1", "testProperty1Value");
    properties.put("intProperty", 1);
    ApplicationProperties applicationProperties = new ApplicationProperties(properties);
    Message_1_0 message = createTestMessage(applicationProperties);
    final MessageTransferMessage convertedMessage = _messageConverter.convert(message, _namedAddressSpace);
    final MessageProperties messageProperties = convertedMessage.getStoredMessage().getMetaData().getMessageProperties();
    final Map<String, Object> headers = messageProperties.getApplicationHeaders();
    assertEquals("Unexpected headers", properties, new HashMap<>(headers));
}
Also used : HashMap(java.util.HashMap) MessageTransferMessage(org.apache.qpid.server.protocol.v0_10.MessageTransferMessage) MessageProperties(org.apache.qpid.server.protocol.v0_10.transport.MessageProperties) ApplicationProperties(org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationProperties) Message_1_0(org.apache.qpid.server.protocol.v1_0.Message_1_0) Matchers.anyString(org.mockito.Matchers.anyString)

Example 19 with ApplicationProperties

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

the class PropertyConverter_1_0_to_0_10Test method testSubjectDoesNoReplaceApplicationPropertyQpidSubject.

public void testSubjectDoesNoReplaceApplicationPropertyQpidSubject() {
    final String subject = "testSubject";
    Properties properties = new Properties();
    properties.setSubject(subject);
    final String qpidSubject = "testSubject2";
    Map<String, Object> applicationPropertiesMap = Collections.singletonMap("qpid.subject", qpidSubject);
    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", qpidSubject, headers.get("qpid.subject"));
    assertEquals("Unexpected type", subject, 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) Matchers.anyString(org.mockito.Matchers.anyString) DeliveryProperties(org.apache.qpid.server.protocol.v0_10.transport.DeliveryProperties) ApplicationProperties(org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationProperties) 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)

Example 20 with ApplicationProperties

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

the class PropertyConverter_1_0_to_0_10Test method testCreationTimeConversion.

public void testCreationTimeConversion() {
    final long timestamp = System.currentTimeMillis() - 10000;
    final long arrivalTime = timestamp + 1;
    Properties properties = new Properties();
    properties.setCreationTime(new Date(timestamp));
    Message_1_0 message = createTestMessage(new 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 timestamp", timestamp, deliveryProperties.getTimestamp());
}
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) 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) Date(java.util.Date)

Aggregations

Message_1_0 (org.apache.qpid.server.protocol.v1_0.Message_1_0)31 Properties (org.apache.qpid.server.protocol.v1_0.type.messaging.Properties)23 ApplicationProperties (org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationProperties)21 MessageProperties (org.apache.qpid.server.protocol.v0_10.transport.MessageProperties)16 HashMap (java.util.HashMap)15 MessageTransferMessage (org.apache.qpid.server.protocol.v0_10.MessageTransferMessage)15 DeliveryProperties (org.apache.qpid.server.protocol.v0_10.transport.DeliveryProperties)14 MessageAnnotations (org.apache.qpid.server.protocol.v1_0.type.messaging.MessageAnnotations)13 Header (org.apache.qpid.server.protocol.v1_0.type.messaging.Header)12 BasicContentHeaderProperties (org.apache.qpid.server.protocol.v0_8.transport.BasicContentHeaderProperties)11 AMQMessage (org.apache.qpid.server.protocol.v0_8.AMQMessage)10 AMQShortString (org.apache.qpid.server.protocol.v0_8.AMQShortString)10 DeliveryAnnotations (org.apache.qpid.server.protocol.v1_0.type.messaging.DeliveryAnnotations)10 Matchers.anyString (org.mockito.Matchers.anyString)10 Date (java.util.Date)8 QpidByteBuffer (org.apache.qpid.server.bytebuffer.QpidByteBuffer)7 MessageMetaData_1_0 (org.apache.qpid.server.protocol.v1_0.MessageMetaData_1_0)7 Footer (org.apache.qpid.server.protocol.v1_0.type.messaging.Footer)7 MessageConversionException (org.apache.qpid.server.protocol.converter.MessageConversionException)5 Binary (org.apache.qpid.server.protocol.v1_0.type.Binary)5