Search in sources :

Example 71 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_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 72 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 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)

Example 73 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 testTTLConversion.

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)

Example 74 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 testToConversionWhenExchangeIsSpecifiedAndSubjectIsSet.

public void testToConversionWhenExchangeIsSpecifiedAndSubjectIsSet() {
    final String testExchange = "testExchange";
    final String testRoutingKey = "testRoutingKey";
    Properties properties = new Properties();
    properties.setTo(testExchange);
    properties.setSubject(testRoutingKey);
    Message_1_0 message = createTestMessage(properties);
    final Exchange exchange = mock(Exchange.class);
    when(exchange.getName()).thenReturn(testExchange);
    when(_namedAddressSpace.getAttainedMessageDestination(testExchange)).thenReturn(exchange);
    final AMQMessage convertedMessage = _messageConverter.convert(message, _namedAddressSpace);
    final MessagePublishInfo messagePublishInfo = convertedMessage.getMessagePublishInfo();
    assertEquals("Unexpected exchange", testExchange, messagePublishInfo.getExchange().toString());
    assertEquals("Unexpected routing key", testRoutingKey, messagePublishInfo.getRoutingKey().toString());
}
Also used : Exchange(org.apache.qpid.server.model.Exchange) MessagePublishInfo(org.apache.qpid.server.protocol.v0_8.transport.MessagePublishInfo) 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) 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) AMQMessage(org.apache.qpid.server.protocol.v0_8.AMQMessage)

Example 75 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 testToConversionWhenExchangeAndRoutingKeyIsSpecified.

public void testToConversionWhenExchangeAndRoutingKeyIsSpecified() {
    final String testExchange = "testExchange";
    final String testRoutingKey = "testRoutingKey";
    String to = testExchange + "/" + testRoutingKey;
    Properties properties = new Properties();
    properties.setTo(to);
    Message_1_0 message = createTestMessage(properties);
    Exchange<?> exchange = mock(Exchange.class);
    when(exchange.getName()).thenReturn(testExchange);
    when(_namedAddressSpace.getAttainedMessageDestination(testExchange)).thenReturn(exchange);
    final AMQMessage convertedMessage = _messageConverter.convert(message, _namedAddressSpace);
    final MessagePublishInfo messagePublishInfo = convertedMessage.getMessagePublishInfo();
    assertEquals("Unexpected exchange", testExchange, messagePublishInfo.getExchange().toString());
    assertEquals("Unexpected routing key", testRoutingKey, messagePublishInfo.getRoutingKey().toString());
}
Also used : MessagePublishInfo(org.apache.qpid.server.protocol.v0_8.transport.MessagePublishInfo) 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) 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) AMQMessage(org.apache.qpid.server.protocol.v0_8.AMQMessage)

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