Search in sources :

Example 76 with DeliveryProperties

use of org.apache.qpid.server.protocol.v0_10.transport.DeliveryProperties in project qpid-broker-j by apache.

the class PropertyConverter_Internal_to_v0_10Test method testToConversionWhenExchangeIsSpecified.

public void testToConversionWhenExchangeIsSpecified() throws IOException {
    final String testExchange = "testExchange";
    InternalMessage message = createTestMessage(testExchange);
    final Exchange<?> exchange = mock(Exchange.class);
    when(exchange.getName()).thenReturn(testExchange);
    when(_addressSpace.getAttainedMessageDestination(testExchange)).thenReturn(exchange);
    final MessageTransferMessage convertedMessage = _messageConverter.convert(message, _addressSpace);
    final DeliveryProperties deliveryProperties = convertedMessage.getStoredMessage().getMetaData().getDeliveryProperties();
    assertEquals("Unexpected exchange", testExchange, deliveryProperties.getExchange());
    assertEquals("Unexpected routing key", "", deliveryProperties.getRoutingKey());
}
Also used : InternalMessage(org.apache.qpid.server.message.internal.InternalMessage) Matchers.anyString(org.mockito.Matchers.anyString) AMQShortString(org.apache.qpid.server.protocol.v0_8.AMQShortString) DeliveryProperties(org.apache.qpid.server.protocol.v0_10.transport.DeliveryProperties)

Example 77 with DeliveryProperties

use of org.apache.qpid.server.protocol.v0_10.transport.DeliveryProperties in project qpid-broker-j by apache.

the class PropertyConverter_Internal_to_v0_10Test method testToConversionWhenExchangeAndRoutingKeyIsSpecified.

public void testToConversionWhenExchangeAndRoutingKeyIsSpecified() throws IOException {
    final String testExchange = "testExchange";
    final String testRoutingKey = "testRoutingKey";
    String to = testExchange + "/" + testRoutingKey;
    InternalMessage message = createTestMessage(to);
    final Exchange<?> exchange = mock(Exchange.class);
    when(exchange.getName()).thenReturn(testExchange);
    when(_addressSpace.getAttainedMessageDestination(testExchange)).thenReturn(exchange);
    final MessageTransferMessage convertedMessage = _messageConverter.convert(message, _addressSpace);
    final DeliveryProperties deliveryProperties = convertedMessage.getStoredMessage().getMetaData().getDeliveryProperties();
    assertEquals("Unexpected exchange", testExchange, deliveryProperties.getExchange());
    assertEquals("Unexpected routing key", testRoutingKey, deliveryProperties.getRoutingKey());
}
Also used : InternalMessage(org.apache.qpid.server.message.internal.InternalMessage) Matchers.anyString(org.mockito.Matchers.anyString) AMQShortString(org.apache.qpid.server.protocol.v0_8.AMQShortString) DeliveryProperties(org.apache.qpid.server.protocol.v0_10.transport.DeliveryProperties)

Example 78 with DeliveryProperties

use of org.apache.qpid.server.protocol.v0_10.transport.DeliveryProperties in project qpid-broker-j by apache.

the class PropertyConverter_Internal_to_v0_10Test method testToConversionWhenGlobalAddressIsUnknown.

public void testToConversionWhenGlobalAddressIsUnknown() throws IOException {
    final String queueName = "testQueue";
    final String prefix = "/testPrefix";
    final String globalAddress = prefix + "/" + queueName;
    InternalMessage message = createTestMessage(globalAddress);
    final Queue<?> queue = mock(Queue.class);
    when(queue.getName()).thenReturn(queueName);
    when(_addressSpace.getAttainedMessageDestination(queueName)).thenReturn(queue);
    final MessageTransferMessage convertedMessage = _messageConverter.convert(message, _addressSpace);
    final DeliveryProperties deliveryProperties = convertedMessage.getStoredMessage().getMetaData().getDeliveryProperties();
    assertEquals("Unexpected exchange", "", deliveryProperties.getExchange());
    assertEquals("Unexpected routing key", globalAddress, deliveryProperties.getRoutingKey());
}
Also used : InternalMessage(org.apache.qpid.server.message.internal.InternalMessage) Matchers.anyString(org.mockito.Matchers.anyString) AMQShortString(org.apache.qpid.server.protocol.v0_8.AMQShortString) DeliveryProperties(org.apache.qpid.server.protocol.v0_10.transport.DeliveryProperties)

Example 79 with DeliveryProperties

use of org.apache.qpid.server.protocol.v0_10.transport.DeliveryProperties in project qpid-broker-j by apache.

the class PropertyConverter_Internal_to_v0_10Test method testToConversionWhenQueueIsSpecified.

public void testToConversionWhenQueueIsSpecified() throws IOException {
    final String testQueue = "testQueue";
    InternalMessage message = createTestMessage(testQueue);
    final Queue<?> queue = mock(Queue.class);
    when(queue.getName()).thenReturn(testQueue);
    when(_addressSpace.getAttainedMessageDestination(testQueue)).thenReturn(queue);
    final MessageTransferMessage convertedMessage = _messageConverter.convert(message, _addressSpace);
    final DeliveryProperties deliveryProperties = convertedMessage.getStoredMessage().getMetaData().getDeliveryProperties();
    assertEquals("Unexpected exchange", "", deliveryProperties.getExchange());
    assertEquals("Unexpected routing key", testQueue, deliveryProperties.getRoutingKey());
}
Also used : InternalMessage(org.apache.qpid.server.message.internal.InternalMessage) Matchers.anyString(org.mockito.Matchers.anyString) AMQShortString(org.apache.qpid.server.protocol.v0_8.AMQShortString) DeliveryProperties(org.apache.qpid.server.protocol.v0_10.transport.DeliveryProperties)

Example 80 with DeliveryProperties

use of org.apache.qpid.server.protocol.v0_10.transport.DeliveryProperties in project qpid-broker-j by apache.

the class MessageConverter_v0_10 method convertMetaData.

private MessageMetaData_0_10 convertMetaData(ServerMessage serverMsg) {
    DeliveryProperties deliveryProps = new DeliveryProperties();
    MessageProperties messageProps = new MessageProperties();
    int size = (int) serverMsg.getSize();
    deliveryProps.setExpiration(serverMsg.getExpiration());
    deliveryProps.setPriority(MessageDeliveryPriority.get(serverMsg.getMessageHeader().getPriority()));
    deliveryProps.setRoutingKey(serverMsg.getInitialRoutingAddress());
    deliveryProps.setTimestamp(serverMsg.getMessageHeader().getTimestamp());
    messageProps.setContentEncoding(serverMsg.getMessageHeader().getEncoding());
    messageProps.setContentLength(size);
    messageProps.setContentType(serverMsg.getMessageHeader().getMimeType());
    if (serverMsg.getMessageHeader().getCorrelationId() != null) {
        messageProps.setCorrelationId(serverMsg.getMessageHeader().getCorrelationId().getBytes(UTF_8));
    }
    Header header = new Header(deliveryProps, messageProps, null);
    return new MessageMetaData_0_10(header, size, serverMsg.getArrivalTime());
}
Also used : Header(org.apache.qpid.server.protocol.v0_10.transport.Header) MessageProperties(org.apache.qpid.server.protocol.v0_10.transport.MessageProperties) DeliveryProperties(org.apache.qpid.server.protocol.v0_10.transport.DeliveryProperties)

Aggregations

DeliveryProperties (org.apache.qpid.server.protocol.v0_10.transport.DeliveryProperties)81 MessageTransferMessage (org.apache.qpid.server.protocol.v0_10.MessageTransferMessage)54 MessageProperties (org.apache.qpid.server.protocol.v0_10.transport.MessageProperties)39 Message_1_0 (org.apache.qpid.server.protocol.v1_0.Message_1_0)27 AMQMessage (org.apache.qpid.server.protocol.v0_8.AMQMessage)25 BasicContentHeaderProperties (org.apache.qpid.server.protocol.v0_8.transport.BasicContentHeaderProperties)21 Properties (org.apache.qpid.server.protocol.v1_0.type.messaging.Properties)20 InternalMessage (org.apache.qpid.server.message.internal.InternalMessage)17 Header (org.apache.qpid.server.protocol.v1_0.type.messaging.Header)16 Matchers.anyString (org.mockito.Matchers.anyString)16 AMQShortString (org.apache.qpid.server.protocol.v0_8.AMQShortString)14 ApplicationProperties (org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationProperties)14 Header (org.apache.qpid.server.protocol.v0_10.transport.Header)10 MessagePublishInfo (org.apache.qpid.server.protocol.v0_8.transport.MessagePublishInfo)7 Date (java.util.Date)5 MessageAnnotations (org.apache.qpid.server.protocol.v1_0.type.messaging.MessageAnnotations)5 MessageMetaData_0_10 (org.apache.qpid.server.protocol.v0_10.MessageMetaData_0_10)4 MessageDeliveryMode (org.apache.qpid.server.protocol.v0_10.transport.MessageDeliveryMode)4 DeliveryAnnotations (org.apache.qpid.server.protocol.v1_0.type.messaging.DeliveryAnnotations)4 Method (org.apache.qpid.server.protocol.v0_10.transport.Method)3