Search in sources :

Example 71 with Binary

use of org.apache.qpid.server.protocol.v1_0.type.Binary in project qpid-broker-j by apache.

the class MessageConverter_1_0_to_v0_10Test method testDataWithContentTypeAmqpList.

public void testDataWithContentTypeAmqpList() throws Exception {
    List<Object> originalMap = Collections.singletonList("testValue");
    byte[] bytes = new ListToAmqpListConverter().toMimeContent(originalMap);
    final Data value = new Data(new Binary(bytes));
    Properties properties = new Properties();
    properties.setContentType(Symbol.valueOf("amqp/list"));
    Message_1_0 sourceMessage = createTestMessage(properties, value.createEncodingRetainingSection());
    final MessageTransferMessage convertedMessage = _converter.convert(sourceMessage, mock(NamedAddressSpace.class));
    assertEquals("Unexpected mime type", "amqp/list", convertedMessage.getMessageHeader().getMimeType());
    final QpidByteBuffer content = convertedMessage.getContent(0, (int) convertedMessage.getSize());
    assertArrayEquals("Unexpected content", bytes, getBytes(content));
}
Also used : MessageTransferMessage(org.apache.qpid.server.protocol.v0_10.MessageTransferMessage) ListToAmqpListConverter(org.apache.qpid.server.protocol.v0_10.transport.mimecontentconverter.ListToAmqpListConverter) NamedAddressSpace(org.apache.qpid.server.model.NamedAddressSpace) Message_1_0(org.apache.qpid.server.protocol.v1_0.Message_1_0) Data(org.apache.qpid.server.protocol.v1_0.type.messaging.Data) QpidByteBuffer(org.apache.qpid.server.bytebuffer.QpidByteBuffer) Binary(org.apache.qpid.server.protocol.v1_0.type.Binary) ApplicationProperties(org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationProperties) Properties(org.apache.qpid.server.protocol.v1_0.type.messaging.Properties)

Example 72 with Binary

use of org.apache.qpid.server.protocol.v1_0.type.Binary in project qpid-broker-j by apache.

the class PropertyConverter_0_10_to_1_0Test method testBinaryCorrelationIdConversion.

public void testBinaryCorrelationIdConversion() {
    final byte[] correlationId = new byte[] { 0x00, (byte) 0xff, (byte) 0xc3 };
    final MessageProperties messageProperties = new MessageProperties();
    messageProperties.setCorrelationId(correlationId);
    MessageTransferMessage message = createTestMessage(messageProperties);
    final Message_1_0 convertedMessage = _messageConverter.convert(message, _namedAddressSpace);
    Properties properties = convertedMessage.getPropertiesSection().getValue();
    assertTrue(String.format("Unexpected correlationId type. expected 'Binary' actual '%s'", properties.getCorrelationId().getClass().getSimpleName()), properties.getCorrelationId() instanceof Binary);
    assertArrayEquals("Unexpected correlationId", correlationId, ((Binary) properties.getCorrelationId()).getArray());
}
Also used : MessageProperties(org.apache.qpid.server.protocol.v0_10.transport.MessageProperties) MessageTransferMessage(org.apache.qpid.server.protocol.v0_10.MessageTransferMessage) Message_1_0(org.apache.qpid.server.protocol.v1_0.Message_1_0) Binary(org.apache.qpid.server.protocol.v1_0.type.Binary) MessageProperties(org.apache.qpid.server.protocol.v0_10.transport.MessageProperties) Properties(org.apache.qpid.server.protocol.v1_0.type.messaging.Properties) DeliveryProperties(org.apache.qpid.server.protocol.v0_10.transport.DeliveryProperties)

Example 73 with Binary

use of org.apache.qpid.server.protocol.v1_0.type.Binary in project qpid-broker-j by apache.

the class PropertyConverter_1_0_to_0_10Test method testUserIdConversionWhenLengthExceeds16Bit.

public void testUserIdConversionWhenLengthExceeds16Bit() {
    final String userId = generateLongLongString();
    Properties properties = new Properties();
    properties.setUserId(new Binary(userId.getBytes()));
    Message_1_0 message = createTestMessage(properties);
    final MessageTransferMessage convertedMessage = _messageConverter.convert(message, _namedAddressSpace);
    final MessageProperties messageProperties = convertedMessage.getStoredMessage().getMetaData().getMessageProperties();
    assertNull("Unexpected user-id", messageProperties.getUserId());
}
Also used : MessageTransferMessage(org.apache.qpid.server.protocol.v0_10.MessageTransferMessage) MessageProperties(org.apache.qpid.server.protocol.v0_10.transport.MessageProperties) Message_1_0(org.apache.qpid.server.protocol.v1_0.Message_1_0) Matchers.anyString(org.mockito.Matchers.anyString) Binary(org.apache.qpid.server.protocol.v1_0.type.Binary) ApplicationProperties(org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationProperties) Properties(org.apache.qpid.server.protocol.v1_0.type.messaging.Properties) DeliveryProperties(org.apache.qpid.server.protocol.v0_10.transport.DeliveryProperties) MessageProperties(org.apache.qpid.server.protocol.v0_10.transport.MessageProperties)

Example 74 with Binary

use of org.apache.qpid.server.protocol.v1_0.type.Binary in project qpid-broker-j by apache.

the class PropertyConverter_1_0_to_0_10Test method testUserIdConversion.

public void testUserIdConversion() {
    final String userId = "test-userId";
    Properties properties = new Properties();
    properties.setUserId(new Binary(userId.getBytes()));
    Message_1_0 message = createTestMessage(properties);
    final MessageTransferMessage convertedMessage = _messageConverter.convert(message, _namedAddressSpace);
    final MessageProperties messageProperties = convertedMessage.getStoredMessage().getMetaData().getMessageProperties();
    assertTrue("Unexpected user-id", Arrays.equals(userId.getBytes(UTF_8), messageProperties.getUserId()));
}
Also used : MessageTransferMessage(org.apache.qpid.server.protocol.v0_10.MessageTransferMessage) MessageProperties(org.apache.qpid.server.protocol.v0_10.transport.MessageProperties) Message_1_0(org.apache.qpid.server.protocol.v1_0.Message_1_0) Matchers.anyString(org.mockito.Matchers.anyString) Binary(org.apache.qpid.server.protocol.v1_0.type.Binary) ApplicationProperties(org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationProperties) Properties(org.apache.qpid.server.protocol.v1_0.type.messaging.Properties) DeliveryProperties(org.apache.qpid.server.protocol.v0_10.transport.DeliveryProperties) MessageProperties(org.apache.qpid.server.protocol.v0_10.transport.MessageProperties)

Example 75 with Binary

use of org.apache.qpid.server.protocol.v1_0.type.Binary in project qpid-broker-j by apache.

the class PropertyConverter_1_0_to_0_10Test method testMessageIdBinaryConversionWhenNonUtf8.

public void testMessageIdBinaryConversionWhenNonUtf8() {
    final byte[] messageId = new byte[] { (byte) 0xc3, 0x28 };
    Properties properties = new Properties();
    properties.setMessageId(new Binary(messageId));
    Message_1_0 message = createTestMessage(properties);
    final MessageTransferMessage convertedMessage = _messageConverter.convert(message, _namedAddressSpace);
    final MessageProperties messageProperties = convertedMessage.getStoredMessage().getMetaData().getMessageProperties();
    assertEquals("Unexpected messageId", UUID.nameUUIDFromBytes(messageId), messageProperties.getMessageId());
}
Also used : MessageTransferMessage(org.apache.qpid.server.protocol.v0_10.MessageTransferMessage) MessageProperties(org.apache.qpid.server.protocol.v0_10.transport.MessageProperties) Message_1_0(org.apache.qpid.server.protocol.v1_0.Message_1_0) Binary(org.apache.qpid.server.protocol.v1_0.type.Binary) ApplicationProperties(org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationProperties) Properties(org.apache.qpid.server.protocol.v1_0.type.messaging.Properties) DeliveryProperties(org.apache.qpid.server.protocol.v0_10.transport.DeliveryProperties) MessageProperties(org.apache.qpid.server.protocol.v0_10.transport.MessageProperties)

Aggregations

Binary (org.apache.qpid.server.protocol.v1_0.type.Binary)104 Message_1_0 (org.apache.qpid.server.protocol.v1_0.Message_1_0)50 QpidByteBuffer (org.apache.qpid.server.bytebuffer.QpidByteBuffer)47 Properties (org.apache.qpid.server.protocol.v1_0.type.messaging.Properties)45 ApplicationProperties (org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationProperties)43 NamedAddressSpace (org.apache.qpid.server.model.NamedAddressSpace)42 Data (org.apache.qpid.server.protocol.v1_0.type.messaging.Data)32 SpecificationTest (org.apache.qpid.tests.protocol.SpecificationTest)32 FrameTransport (org.apache.qpid.tests.protocol.v1_0.FrameTransport)32 Test (org.junit.Test)32 Interaction (org.apache.qpid.tests.protocol.v1_0.Interaction)31 AMQMessage (org.apache.qpid.server.protocol.v0_8.AMQMessage)25 MessageTransferMessage (org.apache.qpid.server.protocol.v0_10.MessageTransferMessage)24 Attach (org.apache.qpid.server.protocol.v1_0.type.transport.Attach)23 UnsignedInteger (org.apache.qpid.server.protocol.v1_0.type.UnsignedInteger)22 Disposition (org.apache.qpid.server.protocol.v1_0.type.transport.Disposition)17 Error (org.apache.qpid.server.protocol.v1_0.type.transport.Error)16 Flow (org.apache.qpid.server.protocol.v1_0.type.transport.Flow)14 HashMap (java.util.HashMap)13 DeliveryState (org.apache.qpid.server.protocol.v1_0.type.DeliveryState)13