From a906fe2909e2bf541a9e109ff62079fc0d2de9bf Mon Sep 17 00:00:00 2001 From: Ozan Gunalp Date: Thu, 8 Jul 2021 11:31:30 +0100 Subject: [PATCH] Kafka serde autodetection : reproduce #18495 in tests Multiple annotations for the same channel causes duplicate default configs --- .../deployment/DefaultSerdeConfigTest.java | 60 ++++++++++++++++++- 1 file changed, 59 insertions(+), 1 deletion(-) diff --git a/extensions/smallrye-reactive-messaging-kafka/deployment/src/test/java/io/quarkus/smallrye/reactivemessaging/kafka/deployment/DefaultSerdeConfigTest.java b/extensions/smallrye-reactive-messaging-kafka/deployment/src/test/java/io/quarkus/smallrye/reactivemessaging/kafka/deployment/DefaultSerdeConfigTest.java index b4c3dcfe3c3af..69a35ba4c7326 100644 --- a/extensions/smallrye-reactive-messaging-kafka/deployment/src/test/java/io/quarkus/smallrye/reactivemessaging/kafka/deployment/DefaultSerdeConfigTest.java +++ b/extensions/smallrye-reactive-messaging-kafka/deployment/src/test/java/io/quarkus/smallrye/reactivemessaging/kafka/deployment/DefaultSerdeConfigTest.java @@ -55,7 +55,7 @@ boolean isKafkaConnector(boolean incoming, String channelName) { assertThat(configs) .extracting(RunTimeConfigurationDefaultBuildItem::getKey, RunTimeConfigurationDefaultBuildItem::getValue) - .containsOnly(expectations); + .containsExactlyInAnyOrder(expectations); } private static IndexView index(Class... classes) { @@ -1977,4 +1977,62 @@ private static class FloatJsonArrayInShortByteArrayOut { @Channel("channel25") Multi> consumer25; } + + @Test + void produceDefaultConfigOnce() { + // @formatter:off + Tuple[] expectations = { + tuple("mp.messaging.outgoing.channel1.value.serializer", "io.quarkus.smallrye.reactivemessaging.kafka.deployment.DefaultSerdeConfigTest$JsonbDtoSerializer"), + tuple("mp.messaging.incoming.channel2.value.deserializer", "io.quarkus.smallrye.reactivemessaging.kafka.deployment.DefaultSerdeConfigTest$JacksonDtoDeserializer"), + tuple("mp.messaging.incoming.channel3.key.deserializer", "org.apache.kafka.common.serialization.IntegerDeserializer"), + tuple("mp.messaging.incoming.channel3.value.deserializer", "io.quarkus.smallrye.reactivemessaging.kafka.deployment.DefaultSerdeConfigTest$JacksonDtoDeserializer"), + tuple("mp.messaging.outgoing.channel4.key.serializer", "org.apache.kafka.common.serialization.StringSerializer"), + tuple("mp.messaging.outgoing.channel4.value.serializer", "org.apache.kafka.common.serialization.IntegerSerializer"), + }; + // @formatter:on + + doTest(expectations, JsonbDto.class, JsonbDtoSerializer.class, JacksonDto.class, JacksonDtoDeserializer.class, + MultipleChannels.class); + } + + private static class MultipleChannels { + + @Channel("channel1") + Emitter emitter1; + + @Outgoing("channel1") + Publisher> method1() { + return null; + } + + @Outgoing("channel1") + Publisher method1Duplicate() { + return null; + } + + @Channel("channel2") + Multi channel2; + + @Incoming("channel2") + void channel2Duplicate(JacksonDto jacksonDto) { + + } + + @Channel("channel3") + Multi> channel3; + + @Incoming("channel3") + void channel3Duplicate(Record jacksonDto) { + + } + + @Channel("channel4") + Emitter> emitterChannel4; + + @Outgoing("channel4") + ProducerRecord method4() { + return null; + }; + + } }