Search in sources :

Example 91 with Message_1_0

use of org.apache.qpid.server.protocol.v1_0.Message_1_0 in project qpid-broker-j by apache.

the class PropertyConverter_1_0_to_0_8Test method testUserIdConversionWhenNonUtf8.

public void testUserIdConversionWhenNonUtf8() {
    final byte[] userId = new byte[] { (byte) 0xc3, 0x28 };
    Properties properties = new Properties();
    properties.setUserId(new Binary(userId));
    Message_1_0 message = createTestMessage(properties);
    final AMQMessage convertedMessage = _messageConverter.convert(message, _namedAddressSpace);
    BasicContentHeaderProperties convertedProperties = convertedMessage.getContentHeaderBody().getProperties();
    assertTrue("Unexpected user-id", Arrays.equals(userId, convertedProperties.getUserId().getBytes()));
}
Also used : Message_1_0(org.apache.qpid.server.protocol.v1_0.Message_1_0) Binary(org.apache.qpid.server.protocol.v1_0.type.Binary) ApplicationProperties(org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationProperties) BasicContentHeaderProperties(org.apache.qpid.server.protocol.v0_8.transport.BasicContentHeaderProperties) Properties(org.apache.qpid.server.protocol.v1_0.type.messaging.Properties) BasicContentHeaderProperties(org.apache.qpid.server.protocol.v0_8.transport.BasicContentHeaderProperties) AMQMessage(org.apache.qpid.server.protocol.v0_8.AMQMessage)

Example 92 with Message_1_0

use of org.apache.qpid.server.protocol.v1_0.Message_1_0 in project qpid-broker-j by apache.

the class PropertyConverter_1_0_to_0_8Test method testCorrelationIdBinaryConversion.

public void testCorrelationIdBinaryConversion() {
    final String testCorrelationId = "testCorrelationId";
    final Binary correlationId = new Binary(testCorrelationId.getBytes(UTF_8));
    Properties properties = new Properties();
    properties.setCorrelationId(correlationId);
    Message_1_0 message = createTestMessage(properties);
    final AMQMessage convertedMessage = _messageConverter.convert(message, _namedAddressSpace);
    BasicContentHeaderProperties convertedProperties = convertedMessage.getContentHeaderBody().getProperties();
    assertEquals("Unexpected correlationId", testCorrelationId, convertedProperties.getCorrelationId().toString());
}
Also used : 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) Binary(org.apache.qpid.server.protocol.v1_0.type.Binary) ApplicationProperties(org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationProperties) BasicContentHeaderProperties(org.apache.qpid.server.protocol.v0_8.transport.BasicContentHeaderProperties) Properties(org.apache.qpid.server.protocol.v1_0.type.messaging.Properties) BasicContentHeaderProperties(org.apache.qpid.server.protocol.v0_8.transport.BasicContentHeaderProperties) AMQMessage(org.apache.qpid.server.protocol.v0_8.AMQMessage)

Example 93 with Message_1_0

use of org.apache.qpid.server.protocol.v1_0.Message_1_0 in project qpid-broker-j by apache.

the class PropertyConverter_0_10_to_1_0Test method testQpidSubjectTakesPrecedenceOverJmsType.

public void testQpidSubjectTakesPrecedenceOverJmsType() {
    final String jmsType = "test-jms-type";
    final String qpidSubjectType = "test-qpid-type";
    final Map<String, Object> headers = new HashMap<>();
    headers.put("x-jms-type", jmsType);
    headers.put("qpid.subject", qpidSubjectType);
    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 subject", qpidSubjectType, properties.getSubject());
    Map<String, Object> applicationProperties = convertedMessage.getApplicationPropertiesSection().getValue();
    assertTrue("Unexpected entries in application properties", applicationProperties.isEmpty());
}
Also used : HashMap(java.util.HashMap) 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 94 with Message_1_0

use of org.apache.qpid.server.protocol.v1_0.Message_1_0 in project qpid-broker-j by apache.

the class PropertyConverter_0_10_to_1_0Test method testHeaderJMSXGroupSeqConversionWhenWrongType.

public void testHeaderJMSXGroupSeqConversionWhenWrongType() {
    short testGroupSequenceNumber = (short) 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", null, properties.getGroupSequence());
    Map<String, Object> applicationProperties = convertedMessage.getApplicationPropertiesSection().getValue();
    assertTrue("JMSXGroupSeq was removed from 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 95 with Message_1_0

use of org.apache.qpid.server.protocol.v1_0.Message_1_0 in project qpid-broker-j by apache.

the class PropertyConverter_0_10_to_1_0Test method testCorrelationIdConversion.

public void testCorrelationIdConversion() {
    final String correlationId = "testCorrelationId";
    final MessageProperties messageProperties = new MessageProperties();
    messageProperties.setCorrelationId(correlationId.getBytes(UTF_8));
    MessageTransferMessage message = createTestMessage(messageProperties);
    final Message_1_0 convertedMessage = _messageConverter.convert(message, _namedAddressSpace);
    Properties properties = convertedMessage.getPropertiesSection().getValue();
    assertEquals("Unexpected correlationId", correlationId, properties.getCorrelationId());
}
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)

Aggregations

Message_1_0 (org.apache.qpid.server.protocol.v1_0.Message_1_0)254 Properties (org.apache.qpid.server.protocol.v1_0.type.messaging.Properties)199 ApplicationProperties (org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationProperties)153 NamedAddressSpace (org.apache.qpid.server.model.NamedAddressSpace)125 MessageTransferMessage (org.apache.qpid.server.protocol.v0_10.MessageTransferMessage)116 AMQMessage (org.apache.qpid.server.protocol.v0_8.AMQMessage)112 DeliveryProperties (org.apache.qpid.server.protocol.v0_10.transport.DeliveryProperties)75 BasicContentHeaderProperties (org.apache.qpid.server.protocol.v0_8.transport.BasicContentHeaderProperties)73 MessageProperties (org.apache.qpid.server.protocol.v0_10.transport.MessageProperties)69 QpidByteBuffer (org.apache.qpid.server.bytebuffer.QpidByteBuffer)68 Matchers.anyString (org.mockito.Matchers.anyString)67 Binary (org.apache.qpid.server.protocol.v1_0.type.Binary)58 AmqpValue (org.apache.qpid.server.protocol.v1_0.type.messaging.AmqpValue)55 AMQShortString (org.apache.qpid.server.protocol.v0_8.AMQShortString)52 InternalMessage (org.apache.qpid.server.message.internal.InternalMessage)49 Header (org.apache.qpid.server.protocol.v1_0.type.messaging.Header)35 Data (org.apache.qpid.server.protocol.v1_0.type.messaging.Data)32 MessageConversionException (org.apache.qpid.server.protocol.converter.MessageConversionException)25 HashMap (java.util.HashMap)21 MessageAnnotations (org.apache.qpid.server.protocol.v1_0.type.messaging.MessageAnnotations)17