diff --git a/bom/application/pom.xml b/bom/application/pom.xml index 3f0d5c9832569..2b29cf76dee1d 100644 --- a/bom/application/pom.xml +++ b/bom/application/pom.xml @@ -1957,6 +1957,16 @@ quarkus-vertx-http-dev-ui-resources ${project.version} + + io.quarkus + quarkus-vertx-kotlin + ${project.version} + + + io.quarkus + quarkus-vertx-kotlin-deployment + ${project.version} + io.quarkus diff --git a/devtools/bom-descriptor-json/pom.xml b/devtools/bom-descriptor-json/pom.xml index ffc75fd522023..c9b4761dbcffe 100644 --- a/devtools/bom-descriptor-json/pom.xml +++ b/devtools/bom-descriptor-json/pom.xml @@ -2930,6 +2930,19 @@ + + io.quarkus + quarkus-vertx-kotlin + ${project.version} + pom + test + + + * + * + + + io.quarkus quarkus-virtual-threads diff --git a/docs/pom.xml b/docs/pom.xml index 622f79f6cb4c0..5438527e5fec1 100644 --- a/docs/pom.xml +++ b/docs/pom.xml @@ -2946,6 +2946,19 @@ + + io.quarkus + quarkus-vertx-kotlin-deployment + ${project.version} + pom + test + + + * + * + + + io.quarkus quarkus-virtual-threads-deployment diff --git a/extensions/kotlin/deployment/pom.xml b/extensions/kotlin/deployment/pom.xml index 46070fe8c2877..9515f8f899c83 100644 --- a/extensions/kotlin/deployment/pom.xml +++ b/extensions/kotlin/deployment/pom.xml @@ -18,14 +18,6 @@ io.quarkus quarkus-kotlin - - io.quarkus - quarkus-arc-deployment - - - io.quarkus - quarkus-vertx-deployment-spi - io.quarkus quarkus-jackson-spi @@ -36,6 +28,11 @@ kotlin-compiler + + io.quarkus + quarkus-vertx-kotlin-deployment + true + diff --git a/extensions/kotlin/deployment/src/main/java/io/quarkus/kotlin/deployment/KotlinProcessor.java b/extensions/kotlin/deployment/src/main/java/io/quarkus/kotlin/deployment/KotlinProcessor.java index 4f67df86a5b3e..340f4de9888ac 100644 --- a/extensions/kotlin/deployment/src/main/java/io/quarkus/kotlin/deployment/KotlinProcessor.java +++ b/extensions/kotlin/deployment/src/main/java/io/quarkus/kotlin/deployment/KotlinProcessor.java @@ -2,13 +2,6 @@ import static io.quarkus.deployment.builditem.nativeimage.NativeImageResourcePatternsBuildItem.builder; -import java.util.function.BiConsumer; - -import org.jboss.jandex.MethodInfo; - -import io.quarkus.arc.deployment.AdditionalBeanBuildItem; -import io.quarkus.arc.processor.InvokerBuilder; -import io.quarkus.arc.processor.KotlinUtils; import io.quarkus.bootstrap.classloading.QuarkusClassLoader; import io.quarkus.deployment.Feature; import io.quarkus.deployment.annotations.BuildProducer; @@ -18,14 +11,10 @@ import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem; import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassFinalFieldsWritablePredicateBuildItem; import io.quarkus.jackson.spi.ClassPathJacksonModuleBuildItem; -import io.quarkus.kotlin.runtime.ApplicationCoroutineScope; -import io.quarkus.kotlin.runtime.CoroutineInvoker; -import io.quarkus.vertx.deployment.spi.EventConsumerInvokerCustomizerBuildItem; public class KotlinProcessor { private static final String KOTLIN_JACKSON_MODULE = "com.fasterxml.jackson.module.kotlin.KotlinModule"; - private static final String KOTLIN_COROUTINE_SCOPE = "kotlinx.coroutines.CoroutineScope"; @BuildStep FeatureBuildItem feature() { @@ -79,34 +68,4 @@ void registerKotlinReflection(final BuildProducer refl ".*.kotlin_builtins") .build()); } - - @BuildStep - void produceCoroutineScope(BuildProducer additionalBean) { - if (!QuarkusClassLoader.isClassPresentAtRuntime(KOTLIN_COROUTINE_SCOPE)) { - return; - } - - additionalBean.produce(AdditionalBeanBuildItem.builder() - .addBeanClass(ApplicationCoroutineScope.class) - .setUnremovable() - .build()); - } - - @BuildStep - void produceInvokerCustomizerForSuspendConsumeEventMethods( - BuildProducer customizers) { - if (!QuarkusClassLoader.isClassPresentAtRuntime(KOTLIN_COROUTINE_SCOPE)) { - return; - } - - customizers.produce(new EventConsumerInvokerCustomizerBuildItem(new BiConsumer() { - @Override - public void accept(MethodInfo method, InvokerBuilder invokerBuilder) { - if (KotlinUtils.isKotlinSuspendMethod(method)) { - invokerBuilder.withInvocationWrapper(CoroutineInvoker.class, "inNewCoroutine"); - } - } - })); - } - } diff --git a/extensions/kotlin/runtime/pom.xml b/extensions/kotlin/runtime/pom.xml index b5820188b1515..7af7abdf3c66c 100644 --- a/extensions/kotlin/runtime/pom.xml +++ b/extensions/kotlin/runtime/pom.xml @@ -13,16 +13,30 @@ quarkus-kotlin Quarkus - Kotlin - Runtime Write your services in Kotlin - + + + + io.quarkus + quarkus-extension-maven-plugin + + + + org.jetbrains.kotlin:kotlin-compiler + + + io.quarkus.kotlin + + + + + io.quarkus quarkus-core - - io.quarkus - quarkus-arc - org.jetbrains annotations @@ -45,10 +59,6 @@ org.jetbrains.kotlin kotlin-reflect - - io.vertx - vertx-core - io.smallrye.reactive @@ -68,97 +78,11 @@ org.jetbrains.kotlinx kotlinx-coroutines-jdk8 - - - - ${project.basedir}/src/main/kotlin - ${project.basedir}/src/test/kotlin - - - io.quarkus - quarkus-extension-maven-plugin - - - - org.jetbrains.kotlin:kotlin-compiler - - - io.quarkus.kotlin - - - - - - org.jetbrains.kotlin - kotlin-maven-plugin - ${kotlin.version} - - - compile - - compile - - - - test-compile - - test-compile - - - - - ${maven.compiler.target} - - - - org.apache.maven.plugins - maven-compiler-plugin - - - - io.quarkus - quarkus-extension-processor - ${project.version} - - - - - - - default-compile - none - - - - default-testCompile - none - - - java-compile - compile - - compile - - - - java-test-compile - test-compile - - testCompile - - - - - - org.apache.maven.plugins - maven-javadoc-plugin - - false - - - - + + io.quarkus + quarkus-vertx-kotlin + true + + diff --git a/extensions/vertx/kotlin/deployment/pom.xml b/extensions/vertx/kotlin/deployment/pom.xml new file mode 100644 index 0000000000000..45cb0e8d86ae9 --- /dev/null +++ b/extensions/vertx/kotlin/deployment/pom.xml @@ -0,0 +1,52 @@ + + + + quarkus-vertx-kotlin-parent + io.quarkus + 999-SNAPSHOT + + 4.0.0 + + quarkus-vertx-kotlin-deployment + Quarkus - Vert.x - Kotlin - Deployment + + + + io.quarkus + quarkus-vertx-kotlin + + + + io.quarkus + quarkus-arc-deployment + + + io.quarkus + quarkus-vertx-deployment-spi + + + + + + + maven-compiler-plugin + + + + io.quarkus + quarkus-extension-processor + ${project.version} + + + + + + de.thetaphi + forbiddenapis + + + + + diff --git a/extensions/vertx/kotlin/deployment/src/main/java/io/quarkus/vertx/kotlin/deployment/VertxKotlinProcessor.java b/extensions/vertx/kotlin/deployment/src/main/java/io/quarkus/vertx/kotlin/deployment/VertxKotlinProcessor.java new file mode 100644 index 0000000000000..8c7dbbb22c778 --- /dev/null +++ b/extensions/vertx/kotlin/deployment/src/main/java/io/quarkus/vertx/kotlin/deployment/VertxKotlinProcessor.java @@ -0,0 +1,48 @@ +package io.quarkus.vertx.kotlin.deployment; + +import java.util.function.BiConsumer; + +import org.jboss.jandex.MethodInfo; + +import io.quarkus.arc.deployment.AdditionalBeanBuildItem; +import io.quarkus.arc.processor.InvokerBuilder; +import io.quarkus.arc.processor.KotlinUtils; +import io.quarkus.bootstrap.classloading.QuarkusClassLoader; +import io.quarkus.deployment.annotations.BuildProducer; +import io.quarkus.deployment.annotations.BuildStep; +import io.quarkus.vertx.deployment.spi.EventConsumerInvokerCustomizerBuildItem; +import io.quarkus.vertx.kotlin.runtime.ApplicationCoroutineScope; +import io.quarkus.vertx.kotlin.runtime.CoroutineInvoker; + +public class VertxKotlinProcessor { + private static final String KOTLIN_COROUTINE_SCOPE = "kotlinx.coroutines.CoroutineScope"; + + @BuildStep + void produceCoroutineScope(BuildProducer additionalBean) { + if (!QuarkusClassLoader.isClassPresentAtRuntime(KOTLIN_COROUTINE_SCOPE)) { + return; + } + + additionalBean.produce(AdditionalBeanBuildItem.builder() + .addBeanClass(ApplicationCoroutineScope.class) + .setUnremovable() + .build()); + } + + @BuildStep + void produceInvokerCustomizerForSuspendConsumeEventMethods( + BuildProducer customizers) { + if (!QuarkusClassLoader.isClassPresentAtRuntime(KOTLIN_COROUTINE_SCOPE)) { + return; + } + + customizers.produce(new EventConsumerInvokerCustomizerBuildItem(new BiConsumer() { + @Override + public void accept(MethodInfo method, InvokerBuilder invokerBuilder) { + if (KotlinUtils.isKotlinSuspendMethod(method)) { + invokerBuilder.withInvocationWrapper(CoroutineInvoker.class, "inNewCoroutine"); + } + } + })); + } +} diff --git a/extensions/vertx/kotlin/pom.xml b/extensions/vertx/kotlin/pom.xml new file mode 100644 index 0000000000000..92dfa833c09bc --- /dev/null +++ b/extensions/vertx/kotlin/pom.xml @@ -0,0 +1,19 @@ + + + + quarkus-vertx-parent + io.quarkus + 999-SNAPSHOT + + 4.0.0 + + quarkus-vertx-kotlin-parent + Quarkus - Vert.x - Kotlin + pom + + deployment + runtime + + diff --git a/extensions/vertx/kotlin/runtime/pom.xml b/extensions/vertx/kotlin/runtime/pom.xml new file mode 100644 index 0000000000000..ec1e2e7f975b3 --- /dev/null +++ b/extensions/vertx/kotlin/runtime/pom.xml @@ -0,0 +1,121 @@ + + + + quarkus-vertx-kotlin-parent + io.quarkus + 999-SNAPSHOT + + 4.0.0 + + quarkus-vertx-kotlin + Quarkus - Vert.x - Kotlin - Runtime + + + + io.quarkus + quarkus-arc + + + io.vertx + vertx-core + + + org.jetbrains.kotlin + kotlin-stdlib + true + + + org.jetbrains.kotlinx + kotlinx-coroutines-core + true + + + + + ${project.basedir}/src/main/kotlin + ${project.basedir}/src/test/kotlin + + + + io.quarkus + quarkus-extension-maven-plugin + + + io.quarkus:quarkus-vertx + + + + + + org.jetbrains.kotlin + kotlin-maven-plugin + ${kotlin.version} + + + compile + + compile + + + + test-compile + + test-compile + + + + + ${maven.compiler.target} + + + + org.apache.maven.plugins + maven-compiler-plugin + + + + io.quarkus + quarkus-extension-processor + ${project.version} + + + + + + + default-compile + none + + + + default-testCompile + none + + + java-compile + compile + + compile + + + + java-test-compile + test-compile + + testCompile + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + + false + + + + + diff --git a/extensions/kotlin/runtime/src/main/kotlin/io/quarkus/kotlin/runtime/ApplicationCoroutineScope.kt b/extensions/vertx/kotlin/runtime/src/main/kotlin/io/quarkus/vertx/kotlin/runtime/ApplicationCoroutineScope.kt similarity index 92% rename from extensions/kotlin/runtime/src/main/kotlin/io/quarkus/kotlin/runtime/ApplicationCoroutineScope.kt rename to extensions/vertx/kotlin/runtime/src/main/kotlin/io/quarkus/vertx/kotlin/runtime/ApplicationCoroutineScope.kt index 4429a5d671fd7..7a9719fdbeb86 100644 --- a/extensions/kotlin/runtime/src/main/kotlin/io/quarkus/kotlin/runtime/ApplicationCoroutineScope.kt +++ b/extensions/vertx/kotlin/runtime/src/main/kotlin/io/quarkus/vertx/kotlin/runtime/ApplicationCoroutineScope.kt @@ -1,4 +1,4 @@ -package io.quarkus.kotlin.runtime +package io.quarkus.vertx.kotlin.runtime import jakarta.annotation.PreDestroy import jakarta.inject.Singleton diff --git a/extensions/kotlin/runtime/src/main/kotlin/io/quarkus/kotlin/runtime/CoroutineInvoker.kt b/extensions/vertx/kotlin/runtime/src/main/kotlin/io/quarkus/vertx/kotlin/runtime/CoroutineInvoker.kt similarity index 96% rename from extensions/kotlin/runtime/src/main/kotlin/io/quarkus/kotlin/runtime/CoroutineInvoker.kt rename to extensions/vertx/kotlin/runtime/src/main/kotlin/io/quarkus/vertx/kotlin/runtime/CoroutineInvoker.kt index a777db5903533..48e5a26f084f0 100644 --- a/extensions/kotlin/runtime/src/main/kotlin/io/quarkus/kotlin/runtime/CoroutineInvoker.kt +++ b/extensions/vertx/kotlin/runtime/src/main/kotlin/io/quarkus/vertx/kotlin/runtime/CoroutineInvoker.kt @@ -1,4 +1,4 @@ -package io.quarkus.kotlin.runtime +package io.quarkus.vertx.kotlin.runtime import io.quarkus.arc.Arc import io.vertx.core.Vertx diff --git a/extensions/kotlin/runtime/src/main/kotlin/io/quarkus/kotlin/runtime/VertxDispatcher.kt b/extensions/vertx/kotlin/runtime/src/main/kotlin/io/quarkus/vertx/kotlin/runtime/VertxDispatcher.kt similarity index 94% rename from extensions/kotlin/runtime/src/main/kotlin/io/quarkus/kotlin/runtime/VertxDispatcher.kt rename to extensions/vertx/kotlin/runtime/src/main/kotlin/io/quarkus/vertx/kotlin/runtime/VertxDispatcher.kt index 51b56f460557a..67cee1bfab8b8 100644 --- a/extensions/kotlin/runtime/src/main/kotlin/io/quarkus/kotlin/runtime/VertxDispatcher.kt +++ b/extensions/vertx/kotlin/runtime/src/main/kotlin/io/quarkus/vertx/kotlin/runtime/VertxDispatcher.kt @@ -1,4 +1,4 @@ -package io.quarkus.kotlin.runtime +package io.quarkus.vertx.kotlin.runtime import io.quarkus.arc.Arc import io.vertx.core.Context diff --git a/extensions/vertx/kotlin/runtime/src/main/resources/META-INF/quarkus-extension.yaml b/extensions/vertx/kotlin/runtime/src/main/resources/META-INF/quarkus-extension.yaml new file mode 100644 index 0000000000000..42269a5f6e853 --- /dev/null +++ b/extensions/vertx/kotlin/runtime/src/main/resources/META-INF/quarkus-extension.yaml @@ -0,0 +1,5 @@ +--- +artifact: ${project.groupId}:${project.artifactId}:${project.version} +name: "Vert.x Kotlin integration" +metadata: + unlisted: true diff --git a/extensions/vertx/pom.xml b/extensions/vertx/pom.xml index d6ae6c6bf9d23..6c19b787b8145 100644 --- a/extensions/vertx/pom.xml +++ b/extensions/vertx/pom.xml @@ -16,6 +16,7 @@ deployment deployment-spi + kotlin latebound-mdc-provider runtime diff --git a/integration-tests/kotlin-vertx/src/test/kotlin/io/quarkus/it/kotlin/vertx/KotlinConsumeEventTest.kt b/integration-tests/kotlin-vertx/src/test/kotlin/io/quarkus/it/kotlin/vertx/KotlinConsumeEventTest.kt deleted file mode 100644 index f578f658d3696..0000000000000 --- a/integration-tests/kotlin-vertx/src/test/kotlin/io/quarkus/it/kotlin/vertx/KotlinConsumeEventTest.kt +++ /dev/null @@ -1,122 +0,0 @@ -package io.quarkus.it.kotlin.vertx - -import io.quarkus.test.QuarkusUnitTest -import io.quarkus.vertx.ConsumeEvent -import io.vertx.core.eventbus.DeliveryOptions -import io.vertx.core.eventbus.EventBus -import jakarta.inject.Inject -import jakarta.inject.Singleton -import org.junit.jupiter.api.Assertions.assertEquals -import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.RegisterExtension -import java.util.concurrent.CountDownLatch -import java.util.concurrent.TimeUnit -import kotlin.concurrent.Volatile - -class KotlinConsumeEventTest { - companion object { - @RegisterExtension - val config = QuarkusUnitTest() - .withApplicationRoot { jar -> - jar.addClass(MessageConsumers::class.java) - } - } - - @Inject - lateinit var bean: MessageConsumers - - @Inject - lateinit var bus: EventBus - - @Test - fun message() { - MessageConsumers.latch = CountDownLatch(1) - - bus.send("message", "message") - - MessageConsumers.latch.await(2, TimeUnit.SECONDS) - assertEquals("message", MessageConsumers.message) - } - - @Test - fun mutinyMessage() { - MessageConsumers.latch = CountDownLatch(1) - - bus.send("mutiny-message", "mutiny message") - - MessageConsumers.latch.await(2, TimeUnit.SECONDS) - assertEquals("mutiny message", MessageConsumers.message) - } - - @Test - fun payload() { - MessageConsumers.latch = CountDownLatch(1) - - bus.send("payload", "just payload") - - MessageConsumers.latch.await(2, TimeUnit.SECONDS) - assertEquals("just payload", MessageConsumers.message) - } - - @Test - fun headersPayload() { - MessageConsumers.latch = CountDownLatch(1) - - val options = DeliveryOptions().addHeader("header", "test header") - bus.send("headers-payload", "payload", options) - - MessageConsumers.latch.await(2, TimeUnit.SECONDS) - assertEquals("test header - payload", MessageConsumers.message) - } - - @Test - fun mutinyHeadersPayload() { - MessageConsumers.latch = CountDownLatch(1) - - val options = DeliveryOptions().addHeader("header", "test mutiny header") - bus.send("mutiny-headers-payload", "payload", options) - - MessageConsumers.latch.await(2, TimeUnit.SECONDS) - assertEquals("test mutiny header - payload", MessageConsumers.message) - } - - @Singleton - class MessageConsumers { - companion object { - @Volatile - var latch: CountDownLatch = CountDownLatch(1) - - var message: String? = null - } - - @ConsumeEvent("message") - fun message(msg: io.vertx.core.eventbus.Message) { - message = msg.body() - latch.countDown() - } - - @ConsumeEvent("mutiny-message") - fun mutinyMessage(msg: io.vertx.mutiny.core.eventbus.Message) { - message = msg.body() - latch.countDown() - } - - @ConsumeEvent("payload") - fun payload(msg: String) { - message = msg - latch.countDown() - } - - @ConsumeEvent("headers-payload") - fun headersPayload(headers: io.vertx.core.MultiMap, msg: String) { - message = "${headers["header"]} - $msg" - latch.countDown() - } - - @ConsumeEvent("mutiny-headers-payload") - fun mutinyHeadersPayload(headers: io.vertx.mutiny.core.MultiMap, msg: String) { - message = "${headers["header"]} - $msg" - latch.countDown() - } - } -} diff --git a/integration-tests/kotlin-vertx/src/test/kotlin/io/quarkus/it/kotlin/vertx/KotlinSuspendConsumeEventTest.kt b/integration-tests/kotlin-vertx/src/test/kotlin/io/quarkus/it/kotlin/vertx/KotlinSuspendConsumeEventTest.kt deleted file mode 100644 index cc49aab6e0d3f..0000000000000 --- a/integration-tests/kotlin-vertx/src/test/kotlin/io/quarkus/it/kotlin/vertx/KotlinSuspendConsumeEventTest.kt +++ /dev/null @@ -1,131 +0,0 @@ -package io.quarkus.it.kotlin.vertx - -import io.quarkus.test.QuarkusUnitTest -import io.quarkus.vertx.ConsumeEvent -import io.vertx.core.eventbus.DeliveryOptions -import io.vertx.core.eventbus.EventBus -import jakarta.inject.Inject -import jakarta.inject.Singleton -import kotlinx.coroutines.delay -import org.jboss.logging.Logger -import org.junit.jupiter.api.Assertions.assertEquals -import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.RegisterExtension -import java.util.concurrent.CountDownLatch -import java.util.concurrent.TimeUnit -import kotlin.concurrent.Volatile - -class KotlinSuspendConsumeEventTest { - companion object { - @RegisterExtension - val config = QuarkusUnitTest() - .withApplicationRoot { jar -> - jar.addClass(MessageConsumers::class.java) - } - } - - @Inject - lateinit var bean: MessageConsumers - - @Inject - lateinit var bus: EventBus - - @Test - fun message() { - MessageConsumers.latch = CountDownLatch(1) - - bus.send("message", "message") - - MessageConsumers.latch.await(2, TimeUnit.SECONDS) - assertEquals("message", MessageConsumers.message) - } - - @Test - fun mutinyMessage() { - MessageConsumers.latch = CountDownLatch(1) - - bus.send("mutiny-message", "mutiny message") - - MessageConsumers.latch.await(2, TimeUnit.SECONDS) - assertEquals("mutiny message", MessageConsumers.message) - } - - @Test - fun payload() { - MessageConsumers.latch = CountDownLatch(1) - - bus.send("payload", "just payload") - - MessageConsumers.latch.await(2, TimeUnit.SECONDS) - assertEquals("just payload", MessageConsumers.message) - } - - @Test - fun headersPayload() { - MessageConsumers.latch = CountDownLatch(1) - - val options = DeliveryOptions().addHeader("header", "test header") - bus.send("headers-payload", "payload", options) - - MessageConsumers.latch.await(2, TimeUnit.SECONDS) - assertEquals("test header - payload", MessageConsumers.message) - } - - @Test - fun mutinyHeadersPayload() { - MessageConsumers.latch = CountDownLatch(1) - - val options = DeliveryOptions().addHeader("header", "test mutiny header") - bus.send("mutiny-headers-payload", "payload", options) - - MessageConsumers.latch.await(2, TimeUnit.SECONDS) - assertEquals("test mutiny header - payload", MessageConsumers.message) - } - - @Singleton - class MessageConsumers { - companion object { - @Volatile - var latch: CountDownLatch = CountDownLatch(1) - - var message: String? = null - - var log = Logger.getLogger(MessageConsumers::class.java) - } - - @ConsumeEvent("message") - suspend fun message(msg: io.vertx.core.eventbus.Message) { - delay(100) - message = msg.body() - latch.countDown() - } - - @ConsumeEvent("mutiny-message") - suspend fun mutinyMessage(msg: io.vertx.mutiny.core.eventbus.Message) { - delay(100) - message = msg.body() - latch.countDown() - } - - @ConsumeEvent("payload") - suspend fun payload(msg: String) { - delay(100) - message = msg - latch.countDown() - } - - @ConsumeEvent("headers-payload") - suspend fun headersPayload(headers: io.vertx.core.MultiMap, msg: String) { - delay(100) - message = "${headers["header"]} - $msg" - latch.countDown() - } - - @ConsumeEvent("mutiny-headers-payload") - suspend fun mutinyHeadersPayload(headers: io.vertx.mutiny.core.MultiMap, msg: String) { - delay(100) - message = "${headers["header"]} - $msg" - latch.countDown() - } - } -} diff --git a/integration-tests/pom.xml b/integration-tests/pom.xml index f6904b211d7d9..e95d7bec29e52 100644 --- a/integration-tests/pom.xml +++ b/integration-tests/pom.xml @@ -229,6 +229,7 @@ vertx-web vertx-web-jackson vertx + vertx-kotlin websockets spring-di spring-web @@ -296,7 +297,6 @@ scala kotlin kotlin-serialization - kotlin-vertx mongodb-panache mongodb-panache-kotlin mongodb-rest-data-panache diff --git a/integration-tests/kotlin-vertx/pom.xml b/integration-tests/vertx-kotlin/pom.xml similarity index 71% rename from integration-tests/kotlin-vertx/pom.xml rename to integration-tests/vertx-kotlin/pom.xml index d614c4f1e00bb..14a08e162a825 100644 --- a/integration-tests/kotlin-vertx/pom.xml +++ b/integration-tests/vertx-kotlin/pom.xml @@ -10,39 +10,55 @@ 999-SNAPSHOT - quarkus-integration-test-kotlin-vertx - Quarkus - Integration Tests - Kotlin Vert.x + quarkus-integration-test-vertx-kotlin + Quarkus - Integration Tests - Vert.x Kotlin io.quarkus - quarkus-arc-deployment + quarkus-kotlin io.quarkus - quarkus-kotlin-deployment + quarkus-vertx io.quarkus - quarkus-vertx-deployment - - - org.jetbrains.kotlin - kotlin-stdlib + quarkus-junit5 + test - org.jetbrains.kotlinx - kotlinx-coroutines-core + org.assertj + assertj-core + test + + io.quarkus - quarkus-junit5-internal + quarkus-kotlin-deployment + ${project.version} + pom test + + + * + * + + - org.assertj - assertj-core + io.quarkus + quarkus-vertx-deployment + ${project.version} + pom test + + + * + * + + diff --git a/integration-tests/vertx-kotlin/src/main/kotlin/io/quarkus/it/vertx/kotlin/MessageConsumers.kt b/integration-tests/vertx-kotlin/src/main/kotlin/io/quarkus/it/vertx/kotlin/MessageConsumers.kt new file mode 100644 index 0000000000000..d6ec06eedc5e4 --- /dev/null +++ b/integration-tests/vertx-kotlin/src/main/kotlin/io/quarkus/it/vertx/kotlin/MessageConsumers.kt @@ -0,0 +1,49 @@ +package io.quarkus.it.vertx.kotlin + +import io.quarkus.vertx.ConsumeEvent +import jakarta.inject.Singleton +import java.util.concurrent.CountDownLatch + +@Singleton +class MessageConsumers { + companion object { + @Volatile var latch: CountDownLatch = CountDownLatch(1) + + var message: String? = null + + fun reset() { + latch = CountDownLatch(1) + message = null + } + } + + @ConsumeEvent("message") + fun message(msg: io.vertx.core.eventbus.Message) { + message = msg.body() + latch.countDown() + } + + @ConsumeEvent("mutiny-message") + fun mutinyMessage(msg: io.vertx.mutiny.core.eventbus.Message) { + message = msg.body() + latch.countDown() + } + + @ConsumeEvent("payload") + fun payload(msg: String) { + message = msg + latch.countDown() + } + + @ConsumeEvent("headers-payload") + fun headersPayload(headers: io.vertx.core.MultiMap, msg: String) { + message = "${headers["header"]} - $msg" + latch.countDown() + } + + @ConsumeEvent("mutiny-headers-payload") + fun mutinyHeadersPayload(headers: io.vertx.mutiny.core.MultiMap, msg: String) { + message = "${headers["header"]} - $msg" + latch.countDown() + } +} diff --git a/integration-tests/vertx-kotlin/src/main/kotlin/io/quarkus/it/vertx/kotlin/SuspendMessageConsumers.kt b/integration-tests/vertx-kotlin/src/main/kotlin/io/quarkus/it/vertx/kotlin/SuspendMessageConsumers.kt new file mode 100644 index 0000000000000..58e5b76788e96 --- /dev/null +++ b/integration-tests/vertx-kotlin/src/main/kotlin/io/quarkus/it/vertx/kotlin/SuspendMessageConsumers.kt @@ -0,0 +1,55 @@ +package io.quarkus.it.vertx.kotlin + +import io.quarkus.vertx.ConsumeEvent +import jakarta.inject.Singleton +import java.util.concurrent.CountDownLatch +import kotlinx.coroutines.delay + +@Singleton +class SuspendMessageConsumers { + companion object { + @Volatile var latch: CountDownLatch = CountDownLatch(1) + + var message: String? = null + + fun reset() { + latch = CountDownLatch(1) + message = null + } + } + + @ConsumeEvent("suspend-message") + suspend fun message(msg: io.vertx.core.eventbus.Message) { + delay(100) + message = msg.body() + latch.countDown() + } + + @ConsumeEvent("suspend-mutiny-message") + suspend fun mutinyMessage(msg: io.vertx.mutiny.core.eventbus.Message) { + delay(100) + message = msg.body() + latch.countDown() + } + + @ConsumeEvent("suspend-payload") + suspend fun payload(msg: String) { + delay(100) + message = msg + latch.countDown() + } + + @ConsumeEvent("suspend-headers-payload") + suspend fun headersPayload(headers: io.vertx.core.MultiMap, msg: String) { + delay(100) + message = "${headers["header"]} - $msg" + latch.countDown() + } + + @ConsumeEvent("suspend-mutiny-headers-payload") + suspend fun mutinyHeadersPayload(headers: io.vertx.mutiny.core.MultiMap, msg: String) { + delay(100) + message = "${headers["header"]} - $msg" + latch.countDown() + } +} diff --git a/integration-tests/vertx-kotlin/src/test/kotlin/io/quarkus/it/vertx/kotlin/KotlinConsumeEventTest.kt b/integration-tests/vertx-kotlin/src/test/kotlin/io/quarkus/it/vertx/kotlin/KotlinConsumeEventTest.kt new file mode 100644 index 0000000000000..5b5034bd4f918 --- /dev/null +++ b/integration-tests/vertx-kotlin/src/test/kotlin/io/quarkus/it/vertx/kotlin/KotlinConsumeEventTest.kt @@ -0,0 +1,62 @@ +package io.quarkus.it.vertx.kotlin + +import io.quarkus.test.junit.QuarkusTest +import io.vertx.core.eventbus.DeliveryOptions +import io.vertx.core.eventbus.EventBus +import jakarta.inject.Inject +import java.util.concurrent.TimeUnit +import org.junit.jupiter.api.Assertions.assertEquals +import org.junit.jupiter.api.BeforeEach +import org.junit.jupiter.api.Test + +@QuarkusTest +class KotlinConsumeEventTest { + @Inject lateinit var bus: EventBus + + @BeforeEach + fun setup() { + MessageConsumers.reset() + } + + @Test + fun message() { + bus.send("message", "message") + + MessageConsumers.latch.await(2, TimeUnit.SECONDS) + assertEquals("message", MessageConsumers.message) + } + + @Test + fun mutinyMessage() { + bus.send("mutiny-message", "mutiny message") + + MessageConsumers.latch.await(2, TimeUnit.SECONDS) + assertEquals("mutiny message", MessageConsumers.message) + } + + @Test + fun payload() { + bus.send("payload", "just payload") + + MessageConsumers.latch.await(2, TimeUnit.SECONDS) + assertEquals("just payload", MessageConsumers.message) + } + + @Test + fun headersPayload() { + val options = DeliveryOptions().addHeader("header", "test header") + bus.send("headers-payload", "payload", options) + + MessageConsumers.latch.await(2, TimeUnit.SECONDS) + assertEquals("test header - payload", MessageConsumers.message) + } + + @Test + fun mutinyHeadersPayload() { + val options = DeliveryOptions().addHeader("header", "test mutiny header") + bus.send("mutiny-headers-payload", "payload", options) + + MessageConsumers.latch.await(2, TimeUnit.SECONDS) + assertEquals("test mutiny header - payload", MessageConsumers.message) + } +} diff --git a/integration-tests/vertx-kotlin/src/test/kotlin/io/quarkus/it/vertx/kotlin/KotlinSuspendConsumeEventTest.kt b/integration-tests/vertx-kotlin/src/test/kotlin/io/quarkus/it/vertx/kotlin/KotlinSuspendConsumeEventTest.kt new file mode 100644 index 0000000000000..975c80e428426 --- /dev/null +++ b/integration-tests/vertx-kotlin/src/test/kotlin/io/quarkus/it/vertx/kotlin/KotlinSuspendConsumeEventTest.kt @@ -0,0 +1,62 @@ +package io.quarkus.it.vertx.kotlin + +import io.quarkus.test.junit.QuarkusTest +import io.vertx.core.eventbus.DeliveryOptions +import io.vertx.core.eventbus.EventBus +import jakarta.inject.Inject +import java.util.concurrent.TimeUnit +import org.junit.jupiter.api.Assertions.assertEquals +import org.junit.jupiter.api.BeforeEach +import org.junit.jupiter.api.Test + +@QuarkusTest +class KotlinSuspendConsumeEventTest { + @Inject lateinit var bus: EventBus + + @BeforeEach + fun setup() { + SuspendMessageConsumers.reset() + } + + @Test + fun message() { + bus.send("suspend-message", "message") + + SuspendMessageConsumers.latch.await(2, TimeUnit.SECONDS) + assertEquals("message", SuspendMessageConsumers.message) + } + + @Test + fun mutinyMessage() { + bus.send("suspend-mutiny-message", "mutiny message") + + SuspendMessageConsumers.latch.await(2, TimeUnit.SECONDS) + assertEquals("mutiny message", SuspendMessageConsumers.message) + } + + @Test + fun payload() { + bus.send("suspend-payload", "just payload") + + SuspendMessageConsumers.latch.await(2, TimeUnit.SECONDS) + assertEquals("just payload", SuspendMessageConsumers.message) + } + + @Test + fun headersPayload() { + val options = DeliveryOptions().addHeader("header", "test header") + bus.send("suspend-headers-payload", "payload", options) + + SuspendMessageConsumers.latch.await(2, TimeUnit.SECONDS) + assertEquals("test header - payload", SuspendMessageConsumers.message) + } + + @Test + fun mutinyHeadersPayload() { + val options = DeliveryOptions().addHeader("header", "test mutiny header") + bus.send("suspend-mutiny-headers-payload", "payload", options) + + SuspendMessageConsumers.latch.await(2, TimeUnit.SECONDS) + assertEquals("test mutiny header - payload", SuspendMessageConsumers.message) + } +}