From 19335341ad94b04e0b735f77d651320c4ffc7f81 Mon Sep 17 00:00:00 2001 From: Soby Chacko Date: Wed, 30 Oct 2019 20:53:33 -0400 Subject: [PATCH] Refactor test-embedded-kafka --- testing-samples/test-embedded-kafka/pom.xml | 97 ++++++++++++++++++- .../java/demo/EmbeddedKafkaApplication.java | 15 ++- .../src/main/resources/application.properties | 6 +- 3 files changed, 102 insertions(+), 16 deletions(-) diff --git a/testing-samples/test-embedded-kafka/pom.xml b/testing-samples/test-embedded-kafka/pom.xml index b645c04..4034617 100644 --- a/testing-samples/test-embedded-kafka/pom.xml +++ b/testing-samples/test-embedded-kafka/pom.xml @@ -10,12 +10,28 @@ Spring Cloud Stream Sample for Testing with Embedded Kafka - io.spring.cloud.stream.sample - spring-cloud-stream-samples-parent - 0.0.1-SNAPSHOT - ../.. + org.springframework.boot + spring-boot-starter-parent + 2.2.0.RELEASE + + + Hoxton.BUILD-SNAPSHOT + + + + + + org.springframework.cloud + spring-cloud-dependencies + ${spring-cloud.version} + pom + import + + + + org.springframework.cloud @@ -31,5 +47,78 @@ spring-kafka-test test + + org.springframework.boot + spring-boot-starter-actuator + + + org.springframework.boot + spring-boot-starter + + + org.springframework.boot + spring-boot-starter-web + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + + + + spring-snapshots + Spring Snapshots + https://repo.spring.io/libs-snapshot-local + + true + + + false + + + + spring-milestones + Spring Milestones + https://repo.spring.io/libs-milestone-local + + false + + + + + + spring-snapshots + Spring Snapshots + https://repo.spring.io/libs-snapshot-local + + true + + + false + + + + spring-milestones + Spring Milestones + https://repo.spring.io/libs-milestone-local + + false + + + + spring-releases + Spring Releases + https://repo.spring.io/libs-release-local + + false + + + + diff --git a/testing-samples/test-embedded-kafka/src/main/java/demo/EmbeddedKafkaApplication.java b/testing-samples/test-embedded-kafka/src/main/java/demo/EmbeddedKafkaApplication.java index 39fe36f..b4603f3 100644 --- a/testing-samples/test-embedded-kafka/src/main/java/demo/EmbeddedKafkaApplication.java +++ b/testing-samples/test-embedded-kafka/src/main/java/demo/EmbeddedKafkaApplication.java @@ -16,29 +16,26 @@ package demo; +import java.util.function.Function; + import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.cloud.stream.annotation.EnableBinding; -import org.springframework.cloud.stream.annotation.StreamListener; -import org.springframework.cloud.stream.messaging.Processor; -import org.springframework.messaging.handler.annotation.SendTo; +import org.springframework.context.annotation.Bean; /** * @author Gary Russell * */ @SpringBootApplication -@EnableBinding(Processor.class) public class EmbeddedKafkaApplication { public static void main(String[] args) { SpringApplication.run(EmbeddedKafkaApplication.class, args); } - @StreamListener(Processor.INPUT) - @SendTo(Processor.OUTPUT) - public byte[] handle(byte[] in){ - return new String(in).toUpperCase().getBytes(); + @Bean + public Function handle(){ + return in -> new String(in).toUpperCase().getBytes(); } } diff --git a/testing-samples/test-embedded-kafka/src/main/resources/application.properties b/testing-samples/test-embedded-kafka/src/main/resources/application.properties index 193fc6c..0366f9e 100644 --- a/testing-samples/test-embedded-kafka/src/main/resources/application.properties +++ b/testing-samples/test-embedded-kafka/src/main/resources/application.properties @@ -1,4 +1,4 @@ # Binding properties -spring.cloud.stream.bindings.output.destination=testEmbeddedOut -spring.cloud.stream.bindings.input.destination=testEmbeddedIn -spring.cloud.stream.bindings.input.group=embeddedKafkaApplication +spring.cloud.stream.bindings.handle-out-0.destination=testEmbeddedOut +spring.cloud.stream.bindings.handle-in-0.destination=testEmbeddedIn +spring.cloud.stream.bindings.handle-in-0.group=embeddedKafkaApplication