Search in sources :

Example 1 with MessageConversionException

use of org.apache.qpid.server.protocol.converter.MessageConversionException in project qpid-broker-j by apache.

the class MessageConverter_1_0_to_v0_10Test method testAmqpSequenceWithUnsupportedType.

@Test
public void testAmqpSequenceWithUnsupportedType() throws Exception {
    final List<Object> originalList = Collections.singletonList(new Source());
    final AmqpSequence amqpSequence = new AmqpSequence(originalList);
    Message_1_0 sourceMessage = createTestMessage(amqpSequence.createEncodingRetainingSection());
    try {
        _converter.convert(sourceMessage, mock(NamedAddressSpace.class));
        fail("expected exception not thrown.");
    } catch (MessageConversionException e) {
    // pass
    }
}
Also used : MessageConversionException(org.apache.qpid.server.protocol.converter.MessageConversionException) NamedAddressSpace(org.apache.qpid.server.model.NamedAddressSpace) Message_1_0(org.apache.qpid.server.protocol.v1_0.Message_1_0) AmqpSequence(org.apache.qpid.server.protocol.v1_0.type.messaging.AmqpSequence) Source(org.apache.qpid.server.protocol.v1_0.type.messaging.Source) Test(org.junit.Test)

Example 2 with MessageConversionException

use of org.apache.qpid.server.protocol.converter.MessageConversionException in project qpid-broker-j by apache.

the class MessageConverter_1_0_to_v0_10Test method testAmqpValueWithMapContainingNonFieldTableCompliantEntries.

@Test
public void testAmqpValueWithMapContainingNonFieldTableCompliantEntries() throws Exception {
    final AmqpValue amqpValue = new AmqpValue(Collections.<Object, Object>singletonMap(13, 42));
    Message_1_0 sourceMessage = createTestMessage(amqpValue.createEncodingRetainingSection());
    try {
        _converter.convert(sourceMessage, mock(NamedAddressSpace.class));
        fail("expected exception not thrown.");
    } catch (MessageConversionException e) {
    // pass
    }
}
Also used : MessageConversionException(org.apache.qpid.server.protocol.converter.MessageConversionException) NamedAddressSpace(org.apache.qpid.server.model.NamedAddressSpace) Message_1_0(org.apache.qpid.server.protocol.v1_0.Message_1_0) AmqpValue(org.apache.qpid.server.protocol.v1_0.type.messaging.AmqpValue) Test(org.junit.Test)

Example 3 with MessageConversionException

use of org.apache.qpid.server.protocol.converter.MessageConversionException in project qpid-broker-j by apache.

the class PropertyConverter_0_8_to_1_0Test method testHeaderWithFiledTableValueConversionFails.

@Test
public void testHeaderWithFiledTableValueConversionFails() {
    Map<String, Object> headers = Collections.singletonMap("mapHeader", Collections.emptyMap());
    BasicContentHeaderProperties basicContentHeaderProperties = new BasicContentHeaderProperties();
    basicContentHeaderProperties.setHeaders(FieldTable.convertToFieldTable(headers));
    AMQMessage message = createTestMessage(basicContentHeaderProperties);
    try {
        _messageConverter.convert(message, _namedAddressSpace);
        fail("Exception is expected");
    } catch (MessageConversionException e) {
    // pass
    }
}
Also used : MessageConversionException(org.apache.qpid.server.protocol.converter.MessageConversionException) AMQShortString(org.apache.qpid.server.protocol.v0_8.AMQShortString) BasicContentHeaderProperties(org.apache.qpid.server.protocol.v0_8.transport.BasicContentHeaderProperties) AMQMessage(org.apache.qpid.server.protocol.v0_8.AMQMessage) Test(org.junit.Test)

Example 4 with MessageConversionException

use of org.apache.qpid.server.protocol.converter.MessageConversionException in project qpid-broker-j by apache.

the class PropertyConverter_0_10_to_1_0Test method testHeaderWithListValueConversionFails.

@Test
public void testHeaderWithListValueConversionFails() {
    Map<String, Object> headers = Collections.singletonMap("listHeader", Collections.emptyList());
    final MessageProperties messageProperties = new MessageProperties();
    messageProperties.setApplicationHeaders(headers);
    MessageTransferMessage message = createTestMessage(messageProperties);
    try {
        _messageConverter.convert(message, _namedAddressSpace);
        fail("Exception is expected");
    } catch (MessageConversionException e) {
    // pass
    }
}
Also used : MessageConversionException(org.apache.qpid.server.protocol.converter.MessageConversionException) MessageProperties(org.apache.qpid.server.protocol.v0_10.transport.MessageProperties) MessageTransferMessage(org.apache.qpid.server.protocol.v0_10.MessageTransferMessage) Test(org.junit.Test)

Example 5 with MessageConversionException

use of org.apache.qpid.server.protocol.converter.MessageConversionException in project qpid-broker-j by apache.

the class PropertyConverter_0_10_to_0_8Test method testCorrelationIdConversionWhenLengthExceeds255.

@Test
public void testCorrelationIdConversionWhenLengthExceeds255() {
    final String correlationId = generateLongString();
    final MessageProperties messageProperties = new MessageProperties();
    messageProperties.setCorrelationId(correlationId.getBytes());
    MessageTransferMessage message = createTestMessage(messageProperties);
    try {
        _messageConverter.convert(message, _namedAddressSpace);
        fail("expected exception not thrown");
    } catch (MessageConversionException e) {
    // pass
    }
}
Also used : MessageConversionException(org.apache.qpid.server.protocol.converter.MessageConversionException) MessageProperties(org.apache.qpid.server.protocol.v0_10.transport.MessageProperties) MessageTransferMessage(org.apache.qpid.server.protocol.v0_10.MessageTransferMessage) AMQShortString(org.apache.qpid.server.protocol.v0_8.AMQShortString) Test(org.junit.Test)

Aggregations

MessageConversionException (org.apache.qpid.server.protocol.converter.MessageConversionException)59 Test (org.junit.Test)43 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)25 Message_1_0 (org.apache.qpid.server.protocol.v1_0.Message_1_0)22 ApplicationProperties (org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationProperties)17 AMQShortString (org.apache.qpid.server.protocol.v0_8.AMQShortString)16 MessageProperties (org.apache.qpid.server.protocol.v0_10.transport.MessageProperties)15 Properties (org.apache.qpid.server.protocol.v1_0.type.messaging.Properties)15 InternalMessage (org.apache.qpid.server.message.internal.InternalMessage)13 BasicContentHeaderProperties (org.apache.qpid.server.protocol.v0_8.transport.BasicContentHeaderProperties)12 DeliveryProperties (org.apache.qpid.server.protocol.v0_10.transport.DeliveryProperties)9 AMQMessageHeader (org.apache.qpid.server.message.AMQMessageHeader)8 NamedAddressSpace (org.apache.qpid.server.model.NamedAddressSpace)8 MessageTransferMessage (org.apache.qpid.server.protocol.v0_10.MessageTransferMessage)6 AmqpValue (org.apache.qpid.server.protocol.v1_0.type.messaging.AmqpValue)6 Binary (org.apache.qpid.server.protocol.v1_0.type.Binary)5 Date (java.util.Date)4 LinkedHashMap (java.util.LinkedHashMap)4 ServerMessage (org.apache.qpid.server.message.ServerMessage)4 UnsignedInteger (org.apache.qpid.server.protocol.v1_0.type.UnsignedInteger)4