use of org.apache.qpid.server.protocol.v0_8.transport.BasicContentHeaderProperties in project qpid-broker-j by apache.
the class PropertyConverter_0_8_to_1_0Test method testHeaderConversion.
public void testHeaderConversion() {
Map<String, Object> headers = new HashMap<>();
headers.put("testProperty1", "testProperty1Value");
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);
Map<String, Object> applicationProperties = convertedMessage.getApplicationPropertiesSection().getValue();
assertEquals("Unexpected applicationProperties", headers, new HashMap<>(applicationProperties));
}
use of org.apache.qpid.server.protocol.v0_8.transport.BasicContentHeaderProperties in project qpid-broker-j by apache.
the class PropertyConverter_0_8_to_1_0Test method testExchangeRoutingKeyConversion.
public void testExchangeRoutingKeyConversion() {
final String testExchange = "testExchange";
final String testRoutingKey = "testRoutingKey";
AMQMessage message = createTestMessage(new BasicContentHeaderProperties());
message.getMessagePublishInfo().setExchange(AMQShortString.valueOf(testExchange));
message.getMessagePublishInfo().setRoutingKey(AMQShortString.valueOf(testRoutingKey));
final Message_1_0 convertedMessage = _messageConverter.convert(message, _namedAddressSpace);
Properties properties = convertedMessage.getPropertiesSection().getValue();
assertEquals("Unexpected to", testExchange + "/" + testRoutingKey, properties.getTo());
}
use of org.apache.qpid.server.protocol.v0_8.transport.BasicContentHeaderProperties in project qpid-broker-j by apache.
the class PropertyConverter_0_8_to_1_0Test method testHeaderJMSXGroupSeqConversionWhenWrongType.
public void testHeaderJMSXGroupSeqConversionWhenWrongType() {
Map<String, Object> headers = new HashMap<>();
short testGroupSequenceNumber = (short) 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", null, properties.getGroupSequence());
Map<String, Object> applicationProperties = convertedMessage.getApplicationPropertiesSection().getValue();
assertTrue("JMSXGroupSeq was removed from application properties", applicationProperties.containsKey("JMSXGroupSeq"));
}
use of org.apache.qpid.server.protocol.v0_8.transport.BasicContentHeaderProperties in project qpid-broker-j by apache.
the class PropertyConverter_0_8_to_1_0Test method testContentTypeConversion.
public void testContentTypeConversion() {
String contentType = "test-content-type";
BasicContentHeaderProperties basicContentHeaderProperties = new BasicContentHeaderProperties();
basicContentHeaderProperties.setContentType(contentType);
AMQMessage message = createTestMessage(basicContentHeaderProperties);
final Message_1_0 convertedMessage = _messageConverter.convert(message, _namedAddressSpace);
Properties properties = convertedMessage.getPropertiesSection().getValue();
assertEquals("Unexpected content type", contentType, properties.getContentType().toString());
}
use of org.apache.qpid.server.protocol.v0_8.transport.BasicContentHeaderProperties in project qpid-broker-j by apache.
the class PropertyConverter_0_8_to_1_0Test method createTestMessage.
private AMQMessage createTestMessage(final BasicContentHeaderProperties basicContentHeaderProperties, final byte[] content, final long arrivalTime) {
final ContentHeaderBody contentHeaderBody = mock(ContentHeaderBody.class);
when(contentHeaderBody.getProperties()).thenReturn(basicContentHeaderProperties);
final StoredMessage<MessageMetaData> storedMessage = mock(StoredMessage.class);
when(storedMessage.getMetaData()).thenReturn(new MessageMetaData(new MessagePublishInfo(), contentHeaderBody, arrivalTime));
if (content != null) {
when(storedMessage.getContentSize()).thenReturn(content.length);
when(storedMessage.getContent(0, content.length)).thenReturn(QpidByteBuffer.wrap(content));
} else {
when(storedMessage.getContentSize()).thenReturn(0);
when(storedMessage.getContent(0, 0)).thenReturn(QpidByteBuffer.emptyQpidByteBuffer());
}
return new AMQMessage(storedMessage);
}
Aggregations