use of org.apache.qpid.server.protocol.v0_8.AMQMessage in project qpid-broker-j by apache.
the class PropertyConverter_1_0_to_0_8Test method testCorrelationIdBinaryConversion.
@Test
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());
}
use of org.apache.qpid.server.protocol.v0_8.AMQMessage in project qpid-broker-j by apache.
the class PropertyConverter_1_0_to_0_8Test method testReplyToConversionWhenExchangeAndRoutingKeyAreSpecifiedAndGlobalPrefixIsUsed.
@Test
public void testReplyToConversionWhenExchangeAndRoutingKeyAreSpecifiedAndGlobalPrefixIsUsed() throws IOException {
final String exchangeName = "testExchnageName";
final String routingKey = "testRoutingKey";
final String globalPrefix = "/testPrefix";
final String replyTo = String.format("%s/%s/%s", globalPrefix, exchangeName, routingKey);
when(_namedAddressSpace.getLocalAddress(replyTo)).thenReturn(exchangeName + "/" + routingKey);
final Exchange exchange = mock(Exchange.class);
when(exchange.getName()).thenReturn(exchangeName);
when(exchange.getType()).thenReturn(ExchangeDefaults.TOPIC_EXCHANGE_CLASS);
doReturn(exchange).when(_namedAddressSpace).getAttainedMessageDestination(eq(exchangeName), anyBoolean());
Properties properties = new Properties();
properties.setReplyTo(replyTo);
Message_1_0 message = createTestMessage(properties);
final AMQMessage convertedMessage = _messageConverter.convert(message, _namedAddressSpace);
BasicContentHeaderProperties convertedProperties = convertedMessage.getContentHeaderBody().getProperties();
assertEquals("Unexpected reply-to", "topic://" + exchangeName + "//?routingkey='" + routingKey + "'", convertedProperties.getReplyToAsString());
}
use of org.apache.qpid.server.protocol.v0_8.AMQMessage in project qpid-broker-j by apache.
the class PropertyConverter_1_0_to_0_8Test method testMessageIdBinaryConversion.
@Test
public void testMessageIdBinaryConversion() {
final String messageId = "testMessageId";
Properties properties = new Properties();
properties.setMessageId(new Binary(messageId.getBytes()));
Message_1_0 message = createTestMessage(properties);
final AMQMessage convertedMessage = _messageConverter.convert(message, _namedAddressSpace);
BasicContentHeaderProperties convertedProperties = convertedMessage.getContentHeaderBody().getProperties();
assertEquals("Unexpected messageId", messageId, convertedProperties.getMessageId().toString());
}
use of org.apache.qpid.server.protocol.v0_8.AMQMessage in project qpid-broker-j by apache.
the class PropertyConverter_1_0_to_0_8Test method testUserIdConversionWhenNonUtf8.
@Test
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()));
}
use of org.apache.qpid.server.protocol.v0_8.AMQMessage in project qpid-broker-j by apache.
the class PropertyConverter_1_0_to_0_8Test method testSubjectConversion.
@Test
public void testSubjectConversion() {
final String subject = "testSubject";
Properties properties = new Properties();
properties.setSubject(subject);
Message_1_0 message = createTestMessage(properties);
final AMQMessage convertedMessage = _messageConverter.convert(message, _namedAddressSpace);
BasicContentHeaderProperties convertedProperties = convertedMessage.getContentHeaderBody().getProperties();
final Map<String, Object> headers = convertedProperties.getHeadersAsMap();
assertEquals("Unexpected qpid.subject is missing from headers", subject, headers.get("qpid.subject"));
assertEquals("Unexpected type", subject, convertedProperties.getType().toString());
final MessagePublishInfo messagePublishInfo = convertedMessage.getMessagePublishInfo();
assertEquals("Unexpected routing-key", subject, messagePublishInfo.getRoutingKey().toString());
}
Aggregations