Example usage for org.springframework.amqp.support.converter DefaultClassMapper setDefaultType

List of usage examples for org.springframework.amqp.support.converter DefaultClassMapper setDefaultType

Introduction

In this page you can find the example usage for org.springframework.amqp.support.converter DefaultClassMapper setDefaultType.

Prototype

public void setDefaultType(Class<?> defaultType) 

Source Link

Document

The type returned by #toClass(MessageProperties) if no type information is found in the message properties.

Usage

From source file:org.springframework.amqp.support.converter.Jackson2JsonMessageConverterTests.java

@Test
public void testDefaultType() {
    byte[] bytes = "{\"name\" : \"foo\" }".getBytes();
    MessageProperties messageProperties = new MessageProperties();
    messageProperties.setContentType("application/json");
    Message message = new Message(bytes, messageProperties);
    JsonMessageConverter converter = new JsonMessageConverter();
    DefaultClassMapper classMapper = new DefaultClassMapper();
    classMapper.setDefaultType(Foo.class);
    converter.setClassMapper(classMapper);
    Object foo = converter.fromMessage(message);
    assertTrue(foo instanceof Foo);
}