use of org.springframework.cloud.stream.binder.test.OutputDestination in project spring-cloud-stream by spring-cloud.
the class ContentTypeTckTests method stringToPojoInboundContentTypeHeader.
@Test
public void stringToPojoInboundContentTypeHeader() {
ApplicationContext context = new SpringApplicationBuilder(StringToPojoStreamListener.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(), new MessageHeaders(Collections.singletonMap(MessageHeaders.CONTENT_TYPE, MimeTypeUtils.TEXT_PLAIN))));
Message<byte[]> outputMessage = target.receive();
assertEquals(MimeTypeUtils.APPLICATION_JSON, outputMessage.getHeaders().get(MessageHeaders.CONTENT_TYPE));
assertEquals(jsonPayload, new String(outputMessage.getPayload(), StandardCharsets.UTF_8));
}
use of org.springframework.cloud.stream.binder.test.OutputDestination in project spring-cloud-stream by spring-cloud.
the class ContentTypeTckTests method pojoToStringOutboundContentTypeBinding.
@Test
public void pojoToStringOutboundContentTypeBinding() {
ApplicationContext context = new SpringApplicationBuilder(PojoToStringStreamListener.class).web(WebApplicationType.NONE).run("--spring.cloud.stream.bindings.output.contentType=text/plain", "--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.TEXT_PLAIN, outputMessage.getHeaders().get(MessageHeaders.CONTENT_TYPE));
assertEquals("oleg", new String(outputMessage.getPayload(), StandardCharsets.UTF_8));
}
use of org.springframework.cloud.stream.binder.test.OutputDestination in project spring-cloud-stream by spring-cloud.
the class ContentTypeTckTests method pojoToByteArray.
@Test
public void pojoToByteArray() {
ApplicationContext context = new SpringApplicationBuilder(PojoToByteArrayStreamListener.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));
}
use of org.springframework.cloud.stream.binder.test.OutputDestination in project spring-cloud-stream by spring-cloud.
the class ContentTypeTckTests method customMessageConverter_defaultContentTypeBinding.
@Test
public void customMessageConverter_defaultContentTypeBinding() {
ApplicationContext context = new SpringApplicationBuilder(StringToStringStreamListener.class, CustomConverters.class).web(WebApplicationType.NONE).run("--spring.cloud.stream.default.contentType=foo/bar", "--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();
assertNotNull(outputMessage);
assertEquals("FooBarMessageConverter", new String(outputMessage.getPayload(), StandardCharsets.UTF_8));
assertEquals(MimeType.valueOf("foo/bar"), outputMessage.getHeaders().get(MessageHeaders.CONTENT_TYPE));
}
use of org.springframework.cloud.stream.binder.test.OutputDestination in project spring-cloud-stream by spring-cloud.
the class ContentTypeTckTests method byteArrayToByteArray.
@Test
public void byteArrayToByteArray() {
ApplicationContext context = new SpringApplicationBuilder(ByteArrayToByteArrayStreamListener.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(jsonPayload, new String(outputMessage.getPayload(), StandardCharsets.UTF_8));
}
Aggregations