diff --git a/devtools/project-core-extension-codestarts/src/main/resources/codestarts/quarkus/extension-codestarts/reactive-messaging-codestart/base/README.tpl.qute.md b/devtools/project-core-extension-codestarts/src/main/resources/codestarts/quarkus/extension-codestarts/reactive-messaging-codestart/base/README.tpl.qute.md index 087035a8a1b22e..4b89133ba542eb 100644 --- a/devtools/project-core-extension-codestarts/src/main/resources/codestarts/quarkus/extension-codestarts/reactive-messaging-codestart/base/README.tpl.qute.md +++ b/devtools/project-core-extension-codestarts/src/main/resources/codestarts/quarkus/extension-codestarts/reactive-messaging-codestart/base/README.tpl.qute.md @@ -1,12 +1,12 @@ {#include readme-header /} -{#each input.selected-extensions-ga} - {#if it.equals("io.quarkus:quarkus-smallrye-reactive-messaging-kafka")} -// TODO : which one to choose ? -[Related Apache Kafka guide section...](https://quarkus.io/guides/kafka) +{#each input.selected-extensions-ga} +{#switch it} +{#case 'io.quarkus:quarkus-smallrye-reactive-messaging-kafka'} [Related Apache Kafka guide section...](https://quarkus.io/guides/kafka-reactive-getting-started) - {/if} - {#if it.equals("io.quarkus:quarkus-smallrye-reactive-messaging-amqp")} + +{#case 'io.quarkus:quarkus-smallrye-reactive-messaging-amqp'} [Related Apache AMQP 1.0 guide section...](https://quarkus.io/guides/amqp) - {/if} + +{/switch} {/each} \ No newline at end of file diff --git a/devtools/project-core-extension-codestarts/src/main/resources/codestarts/quarkus/extension-codestarts/reactive-messaging-codestart/base/src/main/resources/application.tpl.qute.yml b/devtools/project-core-extension-codestarts/src/main/resources/codestarts/quarkus/extension-codestarts/reactive-messaging-codestart/base/src/main/resources/application.tpl.qute.yml index d1ec25a5b62e97..65162fb33deb7a 100644 --- a/devtools/project-core-extension-codestarts/src/main/resources/codestarts/quarkus/extension-codestarts/reactive-messaging-codestart/base/src/main/resources/application.tpl.qute.yml +++ b/devtools/project-core-extension-codestarts/src/main/resources/codestarts/quarkus/extension-codestarts/reactive-messaging-codestart/base/src/main/resources/application.tpl.qute.yml @@ -1,7 +1,6 @@ {#each input.selected-extensions-ga} - {#if it.equals("io.quarkus:quarkus-smallrye-reactive-messaging-kafka")} - {#if count == 1 } - +{#switch it} +{#case 'io.quarkus:quarkus-smallrye-reactive-messaging-kafka'} mp: messaging: outgoing: @@ -18,29 +17,8 @@ mp: uppercase-in: connector: smallrye-kafka topic: uppercase-word - {#else} - -#mp: -# messaging: -# outgoing: -# source-out: -# connector: smallrye-kafka -# topic: word -# uppercase-out: -# connector: smallrye-kafka -# topic: uppercase-word -# incoming: -# source-in: -# connector: smallrye-kafka -# topic: word -# uppercase-in: -# connector: smallrye-kafka -# topic: uppercase-word - {/if} - {/if} - {#if it.equals("io.quarkus:quarkus-smallrye-reactive-messaging-mqtt")} - {#if count == 1 } +{#case 'io.quarkus:quarkus-smallrye-reactive-messaging-mqtt'} mp: messaging: outgoing: @@ -65,37 +43,8 @@ mp: host: localhost port: '1883' topic: uppercase-word - {#else} - -#mp: -# messaging: -# outgoing: -# source-out: -# connector: smallrye-mqtt -# host: localhost -# port: '1883' -# topic: word -# uppercase-out: -# connector: smallrye-mqtt -# host: localhost -# port: '1883' -# topic: uppercase-word -# incoming: -# source-in: -# connector: smallrye-mqtt -# host: localhost -# port: '1883' -# topic: word -# uppercase-in: -# connector: smallrye-mqtt -# host: localhost -# port: '1883' -# topic: uppercase-word - {/if} - {/if} - {#if it.equals("io.quarkus:quarkus-smallrye-reactive-messaging-amqp")} - {#if count == 1 } +{#case 'io.quarkus:quarkus-smallrye-reactive-messaging-amqp'} mp: messaging: outgoing: @@ -112,24 +61,6 @@ mp: uppercase-in: address: uppercase-word connector: smallrye-amqp - {#else} -#mp: -# messaging: -# outgoing: -# source-out: -# address: word -# connector: smallrye-amqp -# uppercase-out: -# connector: smallrye-amqp -# address: uppercase-word -# incoming: -# source-in: -# connector: smallrye-amqp -# address: word -# uppercase-in: -# address: uppercase-word -# connector: smallrye-amqp - {/if} - {/if} +{/switch} {/each} \ No newline at end of file diff --git a/devtools/project-core-extension-codestarts/src/main/resources/codestarts/quarkus/extension-codestarts/reactive-messaging-codestart/java/src/test/java/org/acme/MyReactiveMessagingApplicationTest.java b/devtools/project-core-extension-codestarts/src/main/resources/codestarts/quarkus/extension-codestarts/reactive-messaging-codestart/java/src/test/java/org/acme/MyReactiveMessagingApplicationTest.java index ac0b73426e5e0f..e712418a249d0e 100644 --- a/devtools/project-core-extension-codestarts/src/main/resources/codestarts/quarkus/extension-codestarts/reactive-messaging-codestart/java/src/test/java/org/acme/MyReactiveMessagingApplicationTest.java +++ b/devtools/project-core-extension-codestarts/src/main/resources/codestarts/quarkus/extension-codestarts/reactive-messaging-codestart/java/src/test/java/org/acme/MyReactiveMessagingApplicationTest.java @@ -1,6 +1,7 @@ package org.acme; import io.quarkus.test.common.QuarkusTestResource; +import io.quarkus.test.common.QuarkusTestResourceLifecycleManager; import io.quarkus.test.junit.QuarkusTest; import io.smallrye.reactive.messaging.connectors.InMemoryConnector; import io.smallrye.reactive.messaging.connectors.InMemorySink; diff --git a/independent-projects/tools/devtools-testing/src/main/java/io/quarkus/devtools/testing/codestarts/QuarkusCodestartTest.java b/independent-projects/tools/devtools-testing/src/main/java/io/quarkus/devtools/testing/codestarts/QuarkusCodestartTest.java index 4b72d772ab051d..f741564f59aa59 100644 --- a/independent-projects/tools/devtools-testing/src/main/java/io/quarkus/devtools/testing/codestarts/QuarkusCodestartTest.java +++ b/independent-projects/tools/devtools-testing/src/main/java/io/quarkus/devtools/testing/codestarts/QuarkusCodestartTest.java @@ -22,6 +22,7 @@ import java.io.IOException; import java.nio.file.Path; import java.nio.file.Paths; +import java.time.Instant; import java.util.Collection; import java.util.Collections; import java.util.HashSet; @@ -280,7 +281,8 @@ private AbstractPathAssert checkGeneratedSource(String sourceDir, Language la private String getTestId() { String tool = buildTool != null ? buildTool.getKey() + "-" : ""; - return tool + String.join("-", codestarts); + String suffix = codestarts.isEmpty() ? String.valueOf(Instant.now().toEpochMilli()) : String.join("-", codestarts); + return tool + suffix; } private void generateRealDataProjectIfNeeded(Path path, Language language) throws IOException { diff --git a/integration-tests/devtools/src/test/java/io/quarkus/devtools/codestarts/quarkus/ReactiveMessagingCodestartIT.java b/integration-tests/devtools/src/test/java/io/quarkus/devtools/codestarts/quarkus/ReactiveMessagingCodestartIT.java index c5952e8d9e5b96..48fd4c1c610f69 100644 --- a/integration-tests/devtools/src/test/java/io/quarkus/devtools/codestarts/quarkus/ReactiveMessagingCodestartIT.java +++ b/integration-tests/devtools/src/test/java/io/quarkus/devtools/codestarts/quarkus/ReactiveMessagingCodestartIT.java @@ -11,25 +11,44 @@ public class ReactiveMessagingCodestartIT { @RegisterExtension - public static QuarkusCodestartTest codestartTest = QuarkusCodestartTest.builder() - .codestarts("reactive-messaging") + public static QuarkusCodestartTest kafkaCodestartTest = QuarkusCodestartTest.builder() .extension(ArtifactKey.fromString("io.quarkus:quarkus-smallrye-reactive-messaging-kafka")) - .extension(ArtifactKey.fromString("io.quarkus:quarkus-smallrye-reactive-messaging-amqp")) - .extension(ArtifactKey.fromString("io.quarkus:quarkus-smallrye-reactive-messaging-mqtt")) .languages(JAVA) .build(); + @RegisterExtension + public static QuarkusCodestartTest amqpCodestartTest = QuarkusCodestartTest.builder() + .extension(ArtifactKey.fromString("io.quarkus:quarkus-smallrye-reactive-messaging-amqp")) + .languages(JAVA) + .build(); + + @RegisterExtension + public static QuarkusCodestartTest mqttCodestartTest = QuarkusCodestartTest.builder() + .extension(ArtifactKey.fromString("io.quarkus:quarkus-smallrye-reactive-messaging-mqtt")) + .languages(JAVA) + .build(); + + @Test + void testKafkaContent() throws Throwable { + kafkaCodestartTest.checkGeneratedSource("org.acme.MyReactiveMessagingApplication"); + kafkaCodestartTest.assertThatGeneratedFileMatchSnapshot(JAVA, "src/main/resources/application.properties"); + kafkaCodestartTest.checkGeneratedTestSource("org.acme.MyReactiveMessagingApplicationTest"); + } + + @Test + void testMQTTContent() throws Throwable { + mqttCodestartTest.assertThatGeneratedFileMatchSnapshot(JAVA, "src/main/resources/application.properties"); + } + @Test - void testContent() throws Throwable { - codestartTest.checkGeneratedSource("org.acme.MyReactiveMessagingApplication"); - // TODO : the generated application.properties is empty - codestartTest.assertThatGeneratedFileMatchSnapshot(JAVA, "src/main/resources/application.properties"); - // TODO : the test class doesn't work using the inner class InMemoryChannelTestResource - codestartTest.checkGeneratedTestSource("org.acme.MyReactiveMessagingApplicationTest"); + void testAMQPContent() throws Throwable { + amqpCodestartTest.assertThatGeneratedFileMatchSnapshot(JAVA, "src/main/resources/application.properties"); } @Test void buildAll() throws Throwable { - codestartTest.buildAllProjects(); + kafkaCodestartTest.buildAllProjects(); + mqttCodestartTest.buildAllProjects(); + amqpCodestartTest.buildAllProjects(); } } diff --git a/integration-tests/devtools/src/test/resources/__snapshots__/ReactiveMessagingCodestartIT/testAMQPContent/src_main_resources_application.properties b/integration-tests/devtools/src/test/resources/__snapshots__/ReactiveMessagingCodestartIT/testAMQPContent/src_main_resources_application.properties new file mode 100644 index 00000000000000..c5fbcd65a5680a --- /dev/null +++ b/integration-tests/devtools/src/test/resources/__snapshots__/ReactiveMessagingCodestartIT/testAMQPContent/src_main_resources_application.properties @@ -0,0 +1,8 @@ +mp.messaging.outgoing.uppercase-out.connector=smallrye-amqp +mp.messaging.outgoing.uppercase-out.address=uppercase-word +mp.messaging.incoming.source-in.connector=smallrye-amqp +mp.messaging.incoming.uppercase-in.address=uppercase-word +mp.messaging.outgoing.source-out.address=word +mp.messaging.incoming.source-in.address=word +mp.messaging.outgoing.source-out.connector=smallrye-amqp +mp.messaging.incoming.uppercase-in.connector=smallrye-amqp diff --git a/integration-tests/devtools/src/test/resources/__snapshots__/ReactiveMessagingCodestartIT/testContent/src_main_resources_application.properties b/integration-tests/devtools/src/test/resources/__snapshots__/ReactiveMessagingCodestartIT/testContent/src_main_resources_application.properties deleted file mode 100644 index e69de29bb2d1d6..00000000000000 diff --git a/integration-tests/devtools/src/test/resources/__snapshots__/ReactiveMessagingCodestartIT/testContent/src_main_java_ilove_quark_us_MyReactiveMessagingApplication.java b/integration-tests/devtools/src/test/resources/__snapshots__/ReactiveMessagingCodestartIT/testKafkaContent/src_main_java_ilove_quark_us_MyReactiveMessagingApplication.java similarity index 100% rename from integration-tests/devtools/src/test/resources/__snapshots__/ReactiveMessagingCodestartIT/testContent/src_main_java_ilove_quark_us_MyReactiveMessagingApplication.java rename to integration-tests/devtools/src/test/resources/__snapshots__/ReactiveMessagingCodestartIT/testKafkaContent/src_main_java_ilove_quark_us_MyReactiveMessagingApplication.java diff --git a/integration-tests/devtools/src/test/resources/__snapshots__/ReactiveMessagingCodestartIT/testKafkaContent/src_main_resources_application.properties b/integration-tests/devtools/src/test/resources/__snapshots__/ReactiveMessagingCodestartIT/testKafkaContent/src_main_resources_application.properties new file mode 100644 index 00000000000000..0b6dfe2325a36f --- /dev/null +++ b/integration-tests/devtools/src/test/resources/__snapshots__/ReactiveMessagingCodestartIT/testKafkaContent/src_main_resources_application.properties @@ -0,0 +1,8 @@ +mp.messaging.outgoing.uppercase-out.connector=smallrye-kafka +mp.messaging.incoming.source-in.connector=smallrye-kafka +mp.messaging.outgoing.source-out.topic=word +mp.messaging.incoming.source-in.topic=word +mp.messaging.incoming.uppercase-in.topic=uppercase-word +mp.messaging.outgoing.source-out.connector=smallrye-kafka +mp.messaging.outgoing.uppercase-out.topic=uppercase-word +mp.messaging.incoming.uppercase-in.connector=smallrye-kafka diff --git a/integration-tests/devtools/src/test/resources/__snapshots__/ReactiveMessagingCodestartIT/testContent/src_test_java_ilove_quark_us_MyReactiveMessagingApplicationTest.java b/integration-tests/devtools/src/test/resources/__snapshots__/ReactiveMessagingCodestartIT/testKafkaContent/src_test_java_ilove_quark_us_MyReactiveMessagingApplicationTest.java similarity index 66% rename from integration-tests/devtools/src/test/resources/__snapshots__/ReactiveMessagingCodestartIT/testContent/src_test_java_ilove_quark_us_MyReactiveMessagingApplicationTest.java rename to integration-tests/devtools/src/test/resources/__snapshots__/ReactiveMessagingCodestartIT/testKafkaContent/src_test_java_ilove_quark_us_MyReactiveMessagingApplicationTest.java index f3818af8a9fbef..aa937365cdb110 100644 --- a/integration-tests/devtools/src/test/resources/__snapshots__/ReactiveMessagingCodestartIT/testContent/src_test_java_ilove_quark_us_MyReactiveMessagingApplicationTest.java +++ b/integration-tests/devtools/src/test/resources/__snapshots__/ReactiveMessagingCodestartIT/testKafkaContent/src_test_java_ilove_quark_us_MyReactiveMessagingApplicationTest.java @@ -1,6 +1,7 @@ package ilove.quark.us; import io.quarkus.test.common.QuarkusTestResource; +import io.quarkus.test.common.QuarkusTestResourceLifecycleManager; import io.quarkus.test.junit.QuarkusTest; import io.smallrye.reactive.messaging.connectors.InMemoryConnector; import io.smallrye.reactive.messaging.connectors.InMemorySink; @@ -17,6 +18,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue; @QuarkusTest +@QuarkusTestResource(MyReactiveMessagingApplicationTest.InMemoryChannelTestResource.class) class MyReactiveMessagingApplicationTest { @Inject @@ -38,4 +40,20 @@ void test() { assertTrue(uppercase.received().stream().anyMatch(message -> message.getPayload().equals("CONNECTORS"))); } + + public static class InMemoryChannelTestResource implements QuarkusTestResourceLifecycleManager { + + @Override + public Map start() { + Map env = new HashMap<>(); + env.putAll(InMemoryConnector.switchIncomingChannelsToInMemory("source-in")); + env.putAll(InMemoryConnector.switchOutgoingChannelsToInMemory("uppercase-out")); + return env; + } + + @Override + public void stop() { + InMemoryConnector.clear(); + } + } } \ No newline at end of file diff --git a/integration-tests/devtools/src/test/resources/__snapshots__/ReactiveMessagingCodestartIT/testMQTTContent/src_main_resources_application.properties b/integration-tests/devtools/src/test/resources/__snapshots__/ReactiveMessagingCodestartIT/testMQTTContent/src_main_resources_application.properties new file mode 100644 index 00000000000000..5fb0fc20f3ffd5 --- /dev/null +++ b/integration-tests/devtools/src/test/resources/__snapshots__/ReactiveMessagingCodestartIT/testMQTTContent/src_main_resources_application.properties @@ -0,0 +1,16 @@ +mp.messaging.outgoing.source-out.host=localhost +mp.messaging.outgoing.uppercase-out.connector=smallrye-mqtt +mp.messaging.outgoing.source-out.topic=word +mp.messaging.incoming.uppercase-in.host=localhost +mp.messaging.incoming.source-in.topic=word +mp.messaging.incoming.uppercase-in.topic=uppercase-word +mp.messaging.outgoing.uppercase-out.port=1883 +mp.messaging.outgoing.uppercase-out.topic=uppercase-word +mp.messaging.incoming.source-in.port=1883 +mp.messaging.incoming.uppercase-in.connector=smallrye-mqtt +mp.messaging.incoming.source-in.connector=smallrye-mqtt +mp.messaging.incoming.source-in.host=localhost +mp.messaging.outgoing.uppercase-out.host=localhost +mp.messaging.incoming.uppercase-in.port=1883 +mp.messaging.outgoing.source-out.port=1883 +mp.messaging.outgoing.source-out.connector=smallrye-mqtt