Search in sources :

Example 6 with ApplicationProperties

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

the class PropertyConverter_0_10_to_1_0Test method testHeaderJMSXGroupSeqConversion.

public void testHeaderJMSXGroupSeqConversion() {
    int testGroupSequenceNumber = 1;
    Map<String, Object> headers = Collections.singletonMap("JMSXGroupSeq", testGroupSequenceNumber);
    final MessageProperties messageProperties = new MessageProperties();
    messageProperties.setApplicationHeaders(headers);
    MessageTransferMessage message = createTestMessage(messageProperties);
    final Message_1_0 convertedMessage = _messageConverter.convert(message, _namedAddressSpace);
    Properties properties = convertedMessage.getPropertiesSection().getValue();
    assertEquals("Unexpected group-sequence", testGroupSequenceNumber, properties.getGroupSequence().intValue());
    Map<String, Object> applicationProperties = convertedMessage.getApplicationPropertiesSection().getValue();
    assertFalse("Unexpected JMSXGroupSeq in application properties", applicationProperties.containsKey("JMSXGroupSeq"));
}
Also used : MessageProperties(org.apache.qpid.server.protocol.v0_10.transport.MessageProperties) MessageTransferMessage(org.apache.qpid.server.protocol.v0_10.MessageTransferMessage) Message_1_0(org.apache.qpid.server.protocol.v1_0.Message_1_0) MessageProperties(org.apache.qpid.server.protocol.v0_10.transport.MessageProperties) Properties(org.apache.qpid.server.protocol.v1_0.type.messaging.Properties) DeliveryProperties(org.apache.qpid.server.protocol.v0_10.transport.DeliveryProperties)

Example 7 with ApplicationProperties

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

the class MessageConverter_1_0_to_v0_8Test 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 EncodingRetainingSection section) {
    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, 0);
    when(storedMessage.getMetaData()).thenReturn(metaData);
    if (section != null) {
        // TODO this seems to leak QBBs
        final QpidByteBuffer combined = section.getEncodedForm();
        when(storedMessage.getContentSize()).thenReturn((int) section.getEncodedSize());
        final ArgumentCaptor<Integer> offsetCaptor = ArgumentCaptor.forClass(Integer.class);
        final ArgumentCaptor<Integer> sizeCaptor = ArgumentCaptor.forClass(Integer.class);
        when(storedMessage.getContent(offsetCaptor.capture(), sizeCaptor.capture())).then(invocation -> combined.view(offsetCaptor.getValue(), sizeCaptor.getValue()));
    } else {
        when(storedMessage.getContent(0, 0)).thenReturn(QpidByteBuffer.emptyQpidByteBuffer());
    }
    return new Message_1_0(storedMessage);
}
Also used : 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) QpidByteBuffer(org.apache.qpid.server.bytebuffer.QpidByteBuffer)

Example 8 with ApplicationProperties

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

the class PropertyConverter_0_8_to_1_0Test method testHeaderConversionWhenQpidSubjectIsPresent.

public void testHeaderConversionWhenQpidSubjectIsPresent() {
    String testSubject = "testSubject";
    Map<String, Object> headers = new HashMap<>();
    headers.put("testProperty1", "testProperty1Value");
    headers.put("qpid.subject", testSubject);
    BasicContentHeaderProperties basicContentHeaderProperties = new BasicContentHeaderProperties();
    basicContentHeaderProperties.setHeaders(FieldTable.convertToFieldTable(headers));
    AMQMessage message = createTestMessage(basicContentHeaderProperties);
    final Message_1_0 convertedMessage = _messageConverter.convert(message, _namedAddressSpace);
    Properties properties = convertedMessage.getPropertiesSection().getValue();
    assertEquals("Unexpected subject", testSubject, properties.getSubject());
    Map<String, Object> applicationProperties = convertedMessage.getApplicationPropertiesSection().getValue();
    assertFalse("Unexpected subject in application properties", applicationProperties.containsKey("qpid.subject"));
}
Also used : HashMap(java.util.HashMap) Message_1_0(org.apache.qpid.server.protocol.v1_0.Message_1_0) AMQShortString(org.apache.qpid.server.protocol.v0_8.AMQShortString) BasicContentHeaderProperties(org.apache.qpid.server.protocol.v0_8.transport.BasicContentHeaderProperties) BasicContentHeaderProperties(org.apache.qpid.server.protocol.v0_8.transport.BasicContentHeaderProperties) Properties(org.apache.qpid.server.protocol.v1_0.type.messaging.Properties) AMQMessage(org.apache.qpid.server.protocol.v0_8.AMQMessage)

Example 9 with ApplicationProperties

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

the class PropertyConverter_0_8_to_1_0Test method testHeaderJMSXGroupSeqConversion.

public void testHeaderJMSXGroupSeqConversion() {
    Map<String, Object> headers = new HashMap<>();
    int testGroupSequenceNumber = 1;
    headers.put("JMSXGroupSeq", testGroupSequenceNumber);
    headers.put("intProperty", 1);
    BasicContentHeaderProperties basicContentHeaderProperties = new BasicContentHeaderProperties();
    basicContentHeaderProperties.setHeaders(FieldTable.convertToFieldTable(headers));
    AMQMessage message = createTestMessage(basicContentHeaderProperties);
    final Message_1_0 convertedMessage = _messageConverter.convert(message, _namedAddressSpace);
    Properties properties = convertedMessage.getPropertiesSection().getValue();
    assertEquals("Unexpected group-sequence", testGroupSequenceNumber, properties.getGroupSequence().intValue());
    Map<String, Object> applicationProperties = convertedMessage.getApplicationPropertiesSection().getValue();
    assertFalse("Unexpected JMSXGroupSeq in application properties", applicationProperties.containsKey("JMSXGroupSeq"));
}
Also used : HashMap(java.util.HashMap) Message_1_0(org.apache.qpid.server.protocol.v1_0.Message_1_0) AMQShortString(org.apache.qpid.server.protocol.v0_8.AMQShortString) BasicContentHeaderProperties(org.apache.qpid.server.protocol.v0_8.transport.BasicContentHeaderProperties) BasicContentHeaderProperties(org.apache.qpid.server.protocol.v0_8.transport.BasicContentHeaderProperties) Properties(org.apache.qpid.server.protocol.v1_0.type.messaging.Properties) AMQMessage(org.apache.qpid.server.protocol.v0_8.AMQMessage)

Example 10 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_8Test 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 AMQMessage convertedMessage = _messageConverter.convert(message, _namedAddressSpace);
    BasicContentHeaderProperties convertedProperties = convertedMessage.getContentHeaderBody().getProperties();
    final Map<String, Object> headers = FieldTable.convertToMap(convertedProperties.getHeaders());
    assertEquals("Unexpected headers", properties, new HashMap<>(headers));
}
Also used : HashMap(java.util.HashMap) 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) AMQShortString(org.apache.qpid.server.protocol.v0_8.AMQShortString) BasicContentHeaderProperties(org.apache.qpid.server.protocol.v0_8.transport.BasicContentHeaderProperties) AMQMessage(org.apache.qpid.server.protocol.v0_8.AMQMessage)

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