Search in sources :

Example 26 with InputDestination

use of org.springframework.cloud.stream.binder.test.InputDestination in project spring-cloud-stream by spring-cloud.

the class ContentTypeTckTests method pojoToString.

@Test
public void pojoToString() {
    ApplicationContext context = new SpringApplicationBuilder(PojoToStringStreamListener.class).web(WebApplicationType.NONE).run("--spring.jmx.enabled=false");
    InputDestination source = context.getBean(InputDestination.class);
    OutputDestination target = context.getBean(OutputDestination.class);
    String jsonPayload = "{\"name\":\"oleg\"}";
    source.send(new GenericMessage<>(jsonPayload.getBytes()));
    Message<byte[]> outputMessage = target.receive();
    assertEquals(MimeTypeUtils.APPLICATION_JSON, outputMessage.getHeaders().get(MessageHeaders.CONTENT_TYPE));
    assertEquals("oleg", new String(outputMessage.getPayload(), StandardCharsets.UTF_8));
}
Also used : ApplicationContext(org.springframework.context.ApplicationContext) OutputDestination(org.springframework.cloud.stream.binder.test.OutputDestination) SpringApplicationBuilder(org.springframework.boot.builder.SpringApplicationBuilder) InputDestination(org.springframework.cloud.stream.binder.test.InputDestination) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)26 SpringApplicationBuilder (org.springframework.boot.builder.SpringApplicationBuilder)26 InputDestination (org.springframework.cloud.stream.binder.test.InputDestination)26 ApplicationContext (org.springframework.context.ApplicationContext)26 OutputDestination (org.springframework.cloud.stream.binder.test.OutputDestination)24 MessageHeaders (org.springframework.messaging.MessageHeaders)4 TestChannelBinder (org.springframework.cloud.stream.binder.test.TestChannelBinder)2 KryoMessageConverter (org.springframework.cloud.stream.converter.KryoMessageConverter)2 Message (org.springframework.messaging.Message)2 MessageConversionException (org.springframework.messaging.converter.MessageConversionException)2 GenericMessage (org.springframework.messaging.support.GenericMessage)2 MimeType (org.springframework.util.MimeType)2