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"));
}
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));
}
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());
}
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());
}
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());
}
Aggregations