use of org.springframework.cloud.stream.binder.test.InputDestination in project spring-cloud-stream by spring-cloud.
the class ContentTypeTckTests method byteArrayToPojoInboundContentTypeHeader.
@Test
public void byteArrayToPojoInboundContentTypeHeader() {
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.InputDestination in project spring-cloud-stream by spring-cloud.
the class ContentTypeTckTests method stringToPojoInboundContentTypeBinding.
@Test
public void stringToPojoInboundContentTypeBinding() {
ApplicationContext context = new SpringApplicationBuilder(StringToPojoStreamListener.class).web(WebApplicationType.NONE).run("--spring.cloud.stream.bindings.input.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.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.InputDestination in project spring-cloud-stream by spring-cloud.
the class ContentTypeTckTests method pojoToByteArrayOutboundContentTypeBinding.
@Test
public void pojoToByteArrayOutboundContentTypeBinding() {
ApplicationContext context = new SpringApplicationBuilder(PojoToByteArrayStreamListener.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.InputDestination in project spring-cloud-stream by spring-cloud.
the class ContentTypeTckTests method stringToMapMessageStreamListenerOriginalContentType.
@Test
public // emulates 1.3 behavior
void stringToMapMessageStreamListenerOriginalContentType() {
ApplicationContext context = new SpringApplicationBuilder(StringToMapMessageStreamListener.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\"}";
Message<byte[]> message = MessageBuilder.withPayload(jsonPayload.getBytes()).setHeader(MessageHeaders.CONTENT_TYPE, "text/plain").setHeader("originalContentType", "application/json;charset=UTF-8").build();
source.send(message);
Message<byte[]> outputMessage = target.receive();
assertEquals("oleg", new String(outputMessage.getPayload()));
}
use of org.springframework.cloud.stream.binder.test.InputDestination in project spring-cloud-stream by spring-cloud.
the class ContentTypeTckTests method stringToMapStreamListener.
@Test
public void stringToMapStreamListener() {
ApplicationContext context = new SpringApplicationBuilder(StringToMapStreamListener.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("oleg", new String(outputMessage.getPayload()));
}
Aggregations