Skip to content

Commit

Permalink
Fixing failing tests
Browse files Browse the repository at this point in the history
Mostly related to this commit in spring-cloud-funtion:
spring-cloud/spring-cloud-function@85a4fff
  • Loading branch information
sobychacko committed Sep 10, 2024
1 parent f456405 commit 4df2e76
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
* @author Gary Russell
* @author Byungjun You
* @author Kotaro Matsumoto
*
* @author Soby Chacko
*/
class ContentTypeTckTests {

Expand Down Expand Up @@ -111,15 +111,15 @@ void pojoToString() {
void pojoToStringOutboundContentTypeBinding() {
ApplicationContext context = new SpringApplicationBuilder(
PojoToStringConfiguration.class).web(WebApplicationType.NONE).run(
"--spring.cloud.stream.bindings.echo-out-0.contentType=text/plain",
"--spring.cloud.stream.bindings.echo-in-0.contentType=application/json",
"--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();
assertThat(outputMessage.getHeaders().get(MessageHeaders.CONTENT_TYPE))
.isEqualTo(MimeTypeUtils.TEXT_PLAIN_VALUE);
.isEqualTo(MimeTypeUtils.APPLICATION_JSON_VALUE);
assertThat(new String(outputMessage.getPayload(), StandardCharsets.UTF_8))
.isEqualTo("oleg");
}
Expand Down Expand Up @@ -173,7 +173,7 @@ void stringToPojoInboundContentTypeBinding() {
void typelessToPojoInboundContentTypeBinding() {
ApplicationContext context = new SpringApplicationBuilder(
TypelessToPojoConfiguration.class).web(WebApplicationType.NONE).run(
"--spring.cloud.stream.bindings.echo-in-0.contentType=text/plain",
"--spring.cloud.stream.bindings.echo-in-0.contentType=application/json",
"--spring.jmx.enabled=false");
InputDestination source = context.getBean(InputDestination.class);
OutputDestination target = context.getBean(OutputDestination.class);
Expand Down Expand Up @@ -207,7 +207,7 @@ void typelessToPojoInboundContentTypeBindingJson() {
void typelessMessageToPojoInboundContentTypeBinding() {
ApplicationContext context = new SpringApplicationBuilder(
TypelessMessageToPojoConfiguration.class).web(WebApplicationType.NONE)
.run("--spring.cloud.stream.bindings.echo-in-0.contentType=text/plain",
.run("--spring.cloud.stream.bindings.echo-in-0.contentType=application/json",
"--spring.jmx.enabled=false");
InputDestination source = context.getBean(InputDestination.class);
OutputDestination target = context.getBean(OutputDestination.class);
Expand Down Expand Up @@ -246,7 +246,7 @@ void typelessToPojoWithTextHeaderContentTypeBinding() {
OutputDestination target = context.getBean(OutputDestination.class);
String jsonPayload = "{\"name\":\"oleg\"}";
source.send(MessageBuilder.withPayload(jsonPayload.getBytes())
.setHeader(MessageHeaders.CONTENT_TYPE, MimeType.valueOf("text/plain"))
.setHeader(MessageHeaders.CONTENT_TYPE, MimeType.valueOf("application/json"))
.build());
Message<byte[]> outputMessage = target.receive();
assertThat(outputMessage.getHeaders().get(MessageHeaders.CONTENT_TYPE))
Expand Down Expand Up @@ -303,7 +303,7 @@ void stringToPojoInboundContentTypeHeader() {
String jsonPayload = "{\"name\":\"oleg\"}";
source.send(new GenericMessage<>(jsonPayload.getBytes(),
new MessageHeaders(Collections.singletonMap(MessageHeaders.CONTENT_TYPE,
MimeTypeUtils.TEXT_PLAIN))));
MimeTypeUtils.APPLICATION_JSON_VALUE))));
Message<byte[]> outputMessage = target.receive();
assertThat(outputMessage.getHeaders().get(MessageHeaders.CONTENT_TYPE))
.isEqualTo(MimeTypeUtils.APPLICATION_JSON_VALUE);
Expand All @@ -315,7 +315,7 @@ void stringToPojoInboundContentTypeHeader() {
void byteArrayToPojoInboundContentTypeBinding() {
ApplicationContext context = new SpringApplicationBuilder(
ByteArrayToPojoConfiguration.class).web(WebApplicationType.NONE).run(
"--spring.cloud.stream.bindings.echo-in-0.contentType=text/plain",
"--spring.cloud.stream.bindings.echo-in-0.contentType=application/json",
"--spring.jmx.enabled=false");
InputDestination source = context.getBean(InputDestination.class);
OutputDestination target = context.getBean(OutputDestination.class);
Expand All @@ -338,7 +338,7 @@ void byteArrayToPojoInboundContentTypeHeader() {
String jsonPayload = "{\"name\":\"oleg\"}";
source.send(new GenericMessage<>(jsonPayload.getBytes(),
new MessageHeaders(Collections.singletonMap(MessageHeaders.CONTENT_TYPE,
MimeTypeUtils.TEXT_PLAIN))));
MimeTypeUtils.APPLICATION_JSON))));
Message<byte[]> outputMessage = target.receive();
assertThat(outputMessage.getHeaders().get(MessageHeaders.CONTENT_TYPE))
.isEqualTo(MimeTypeUtils.APPLICATION_JSON_VALUE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package org.springframework.cloud.stream.function;

import java.io.Serializable;
import java.nio.charset.StandardCharsets;
import java.time.Duration;
import java.util.ArrayList;
import java.util.Arrays;
Expand Down Expand Up @@ -929,7 +928,8 @@ void contentTypeAsByteArrayTest() {
OutputDestination outputDestination = context.getBean(OutputDestination.class);

Message<byte[]> inputMessage = MessageBuilder.withPayload("{\"name\":\"Jim Lahey\",\"id\":420}".getBytes())
.setHeader(MessageHeaders.CONTENT_TYPE, "application/json".getBytes(StandardCharsets.UTF_8))
// .setHeader(MessageHeaders.CONTENT_TYPE, "application/json".getBytes(StandardCharsets.UTF_8))
.setHeader(MessageHeaders.CONTENT_TYPE, "application/json")
.build();

inputDestination.send(inputMessage, "echoPerson-in-0");
Expand Down

0 comments on commit 4df2e76

Please sign in to comment.