From 4c66ed77c9596ca51dc0329fc883b6a484e53dea Mon Sep 17 00:00:00 2001 From: Oleg Zhurakousky Date: Thu, 30 Nov 2023 19:01:00 +0100 Subject: [PATCH] Add test for empty JSON --- .../stream/function/StreamBridgeTests.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/core/spring-cloud-stream-integration-tests/src/test/java/org/springframework/cloud/stream/function/StreamBridgeTests.java b/core/spring-cloud-stream-integration-tests/src/test/java/org/springframework/cloud/stream/function/StreamBridgeTests.java index 226745dc6..9e75b1433 100644 --- a/core/spring-cloud-stream-integration-tests/src/test/java/org/springframework/cloud/stream/function/StreamBridgeTests.java +++ b/core/spring-cloud-stream-integration-tests/src/test/java/org/springframework/cloud/stream/function/StreamBridgeTests.java @@ -86,6 +86,22 @@ public class StreamBridgeTests { System.clearProperty("spring.cloud.function.definition"); } + @Test // + void ensureEmptyPojoIsAllowed() { + try (ConfigurableApplicationContext context = new SpringApplicationBuilder( + TestChannelBinderConfiguration.getCompleteConfiguration(EmptyConfiguration.class)) + .web(WebApplicationType.NONE).run("--spring.jmx.enabled=false")) { + + StreamBridge streamBridge = context.getBean(StreamBridge.class); + OutputDestination outputDestination = context.getBean(OutputDestination.class); + Message message = CloudEventMessageBuilder.withData(new EmptyPojo()).build(); + streamBridge.send("fooDestination", message); + + Message messageReceived = outputDestination.receive(1000, "fooDestination"); + assertThat(new String(messageReceived.getPayload())).isEqualTo("{}"); + } + } + @Test // see SCF-985 void ensurePassThruFunctionIsNotPrePostProcessed() { try (ConfigurableApplicationContext context = new SpringApplicationBuilder( @@ -937,4 +953,8 @@ public class StreamBridgeTests { } } + public static class EmptyPojo { + + } + }