From 1acf78fb64d94d71265330bebf4652dcd3a49173 Mon Sep 17 00:00:00 2001 From: Sebastien Deleuze Date: Tue, 30 Jul 2019 15:03:54 +0200 Subject: [PATCH 1/4] Add dependency management for Kotlin Coroutines See gh-17701 --- spring-boot-project/spring-boot-dependencies/pom.xml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/spring-boot-project/spring-boot-dependencies/pom.xml b/spring-boot-project/spring-boot-dependencies/pom.xml index 0f7296334a..23af225eb3 100644 --- a/spring-boot-project/spring-boot-dependencies/pom.xml +++ b/spring-boot-project/spring-boot-dependencies/pom.xml @@ -51,6 +51,7 @@ 3.9 1.6 2.7.0 + 1.3.0-RC 2.7.7 2.1.0 10.14.2.0 @@ -2595,6 +2596,13 @@ import pom + + org.jetbrains.kotlinx + kotlinx-coroutines-bom + ${coroutines.version} + import + pom + org.jolokia jolokia-core From 3dfb69841fc1d3ced7b83f39047c9297bbc1ec77 Mon Sep 17 00:00:00 2001 From: Sebastien Deleuze Date: Tue, 30 Jul 2019 15:04:33 +0200 Subject: [PATCH 2/4] Add WebFlux Coroutines smoke test See gh-17701 --- .../spring-boot-smoke-tests/pom.xml | 1 + .../pom.xml | 83 +++++++++++++++++++ .../coroutines/CoroutinesApplication.kt | 10 +++ .../coroutines/CoroutinesController.kt | 24 ++++++ .../coroutines/CoroutinesApplicationTests.kt | 25 ++++++ 5 files changed, 143 insertions(+) create mode 100644 spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-webflux-coroutines/pom.xml create mode 100644 spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-webflux-coroutines/src/main/kotlin/smoketest/coroutines/CoroutinesApplication.kt create mode 100644 spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-webflux-coroutines/src/main/kotlin/smoketest/coroutines/CoroutinesController.kt create mode 100644 spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-webflux-coroutines/src/test/kotlin/smoketest/coroutines/CoroutinesApplicationTests.kt diff --git a/spring-boot-tests/spring-boot-smoke-tests/pom.xml b/spring-boot-tests/spring-boot-smoke-tests/pom.xml index 7d08c31aa7..d6cf48412c 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/pom.xml +++ b/spring-boot-tests/spring-boot-smoke-tests/pom.xml @@ -98,6 +98,7 @@ spring-boot-smoke-test-web-static spring-boot-smoke-test-web-ui spring-boot-smoke-test-webflux + spring-boot-smoke-test-webflux-coroutines spring-boot-smoke-test-websocket-jetty spring-boot-smoke-test-websocket-tomcat spring-boot-smoke-test-websocket-undertow diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-webflux-coroutines/pom.xml b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-webflux-coroutines/pom.xml new file mode 100644 index 0000000000..b7a7ababd6 --- /dev/null +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-webflux-coroutines/pom.xml @@ -0,0 +1,83 @@ + + + 4.0.0 + + + org.springframework.boot + spring-boot-smoke-tests + ${revision} + + spring-boot-smoke-test-webflux-coroutines + Spring Boot WebFlux Coroutines Smoke Test + Spring Boot WebFlux Coroutines Smoke Test + + ${basedir}/../../.. + / + + + + + org.springframework.boot + spring-boot-starter-webflux + + + com.fasterxml.jackson.module + jackson-module-kotlin + + + org.jetbrains.kotlin + kotlin-reflect + + + org.jetbrains.kotlin + kotlin-stdlib-jdk8 + + + org.jetbrains.kotlinx + kotlinx-coroutines-reactor + + + + org.springframework.boot + spring-boot-starter-test + test + + + + ${project.basedir}/src/main/kotlin + ${project.basedir}/src/test/kotlin + + + org.springframework.boot + spring-boot-maven-plugin + + + org.jetbrains.kotlin + kotlin-maven-plugin + + + -Xjsr305=strict + + + spring + + + + + org.jetbrains.kotlin + kotlin-maven-allopen + ${kotlin.version} + + + + + org.apache.maven.plugins + maven-surefire-plugin + + false + + + + + diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-webflux-coroutines/src/main/kotlin/smoketest/coroutines/CoroutinesApplication.kt b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-webflux-coroutines/src/main/kotlin/smoketest/coroutines/CoroutinesApplication.kt new file mode 100644 index 0000000000..f545fa81e0 --- /dev/null +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-webflux-coroutines/src/main/kotlin/smoketest/coroutines/CoroutinesApplication.kt @@ -0,0 +1,10 @@ +package smoketest.coroutines + +import org.springframework.boot.autoconfigure.SpringBootApplication +import org.springframework.boot.runApplication + +@SpringBootApplication +class CoroutinesApplication +fun main(args: Array) { + runApplication(*args) +} diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-webflux-coroutines/src/main/kotlin/smoketest/coroutines/CoroutinesController.kt b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-webflux-coroutines/src/main/kotlin/smoketest/coroutines/CoroutinesController.kt new file mode 100644 index 0000000000..9e902cf2e3 --- /dev/null +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-webflux-coroutines/src/main/kotlin/smoketest/coroutines/CoroutinesController.kt @@ -0,0 +1,24 @@ +package smoketest.coroutines + +import kotlinx.coroutines.delay +import kotlinx.coroutines.flow.flow +import org.springframework.web.bind.annotation.GetMapping +import org.springframework.web.bind.annotation.RestController + +@RestController +class CoroutinesController { + + @GetMapping("/suspending") + suspend fun suspendingFunction(): String { + delay(10) + return "Hello World" + } + + @GetMapping("/flow") + fun flow() = flow { + delay(10) + emit("Hello ") + delay(10) + emit("World") + } +} diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-webflux-coroutines/src/test/kotlin/smoketest/coroutines/CoroutinesApplicationTests.kt b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-webflux-coroutines/src/test/kotlin/smoketest/coroutines/CoroutinesApplicationTests.kt new file mode 100644 index 0000000000..1af3624504 --- /dev/null +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-webflux-coroutines/src/test/kotlin/smoketest/coroutines/CoroutinesApplicationTests.kt @@ -0,0 +1,25 @@ +package smoketest.coroutines + +import org.junit.jupiter.api.Test +import org.springframework.beans.factory.annotation.Autowired +import org.springframework.boot.test.context.SpringBootTest +import org.springframework.boot.test.context.SpringBootTest.* +import org.springframework.http.MediaType +import org.springframework.test.web.reactive.server.WebTestClient +import org.springframework.test.web.reactive.server.expectBody + +@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) +class CoroutinesApplicationTests(@Autowired private val webClient: WebTestClient) { + + @Test + fun testSuspendingFunction() { + webClient.get().uri("/suspending").accept(MediaType.TEXT_PLAIN).exchange() + .expectBody().isEqualTo("Hello World") + } + + @Test + fun testFlow() { + webClient.get().uri("/flow").accept(MediaType.TEXT_PLAIN).exchange() + .expectBody().isEqualTo("Hello World") + } +} From 69f3fe7a9c8c2a6b335bf441c5f52504746365aa Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Wed, 31 Jul 2019 09:50:30 +0200 Subject: [PATCH 3/4] Polish "Add dependency management for Kotlin Coroutines" See gh-17701 --- spring-boot-project/spring-boot-dependencies/pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spring-boot-project/spring-boot-dependencies/pom.xml b/spring-boot-project/spring-boot-dependencies/pom.xml index 23af225eb3..bfbb85a388 100644 --- a/spring-boot-project/spring-boot-dependencies/pom.xml +++ b/spring-boot-project/spring-boot-dependencies/pom.xml @@ -51,7 +51,6 @@ 3.9 1.6 2.7.0 - 1.3.0-RC 2.7.7 2.1.0 10.14.2.0 @@ -140,6 +139,7 @@ 5.5.1 2.3.0 1.3.41 + 1.3.0-RC 5.1.8.RELEASE 3.7.0 2.12.0 @@ -2599,7 +2599,7 @@ org.jetbrains.kotlinx kotlinx-coroutines-bom - ${coroutines.version} + ${kotlin-coroutines.version} import pom From 78d2578c78fe89adb76e04c57babafd05a78fa4b Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Wed, 31 Jul 2019 09:59:48 +0200 Subject: [PATCH 4/4] Polish "Add WebFlux Coroutines smoke test" See gh-17701 --- .../pom.xml | 17 ++++++----------- .../coroutines/CoroutinesController.kt | 1 + ...cation.kt => SampleCoroutinesApplication.kt} | 5 +++-- ...ionTests.kt => CoroutinesControllerTests.kt} | 3 ++- 4 files changed, 12 insertions(+), 14 deletions(-) rename spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-webflux-coroutines/src/main/kotlin/smoketest/coroutines/{CoroutinesApplication.kt => SampleCoroutinesApplication.kt} (70%) rename spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-webflux-coroutines/src/test/kotlin/smoketest/coroutines/{CoroutinesApplicationTests.kt => CoroutinesControllerTests.kt} (90%) diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-webflux-coroutines/pom.xml b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-webflux-coroutines/pom.xml index b7a7ababd6..e852ff180d 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-webflux-coroutines/pom.xml +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-webflux-coroutines/pom.xml @@ -21,10 +21,7 @@ org.springframework.boot spring-boot-starter-webflux - - com.fasterxml.jackson.module - jackson-module-kotlin - + org.jetbrains.kotlin kotlin-reflect @@ -37,6 +34,11 @@ org.jetbrains.kotlinx kotlinx-coroutines-reactor + + + com.fasterxml.jackson.module + jackson-module-kotlin + org.springframework.boot @@ -71,13 +73,6 @@ - - org.apache.maven.plugins - maven-surefire-plugin - - false - - diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-webflux-coroutines/src/main/kotlin/smoketest/coroutines/CoroutinesController.kt b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-webflux-coroutines/src/main/kotlin/smoketest/coroutines/CoroutinesController.kt index 9e902cf2e3..2137a0bdb4 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-webflux-coroutines/src/main/kotlin/smoketest/coroutines/CoroutinesController.kt +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-webflux-coroutines/src/main/kotlin/smoketest/coroutines/CoroutinesController.kt @@ -21,4 +21,5 @@ class CoroutinesController { delay(10) emit("World") } + } diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-webflux-coroutines/src/main/kotlin/smoketest/coroutines/CoroutinesApplication.kt b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-webflux-coroutines/src/main/kotlin/smoketest/coroutines/SampleCoroutinesApplication.kt similarity index 70% rename from spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-webflux-coroutines/src/main/kotlin/smoketest/coroutines/CoroutinesApplication.kt rename to spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-webflux-coroutines/src/main/kotlin/smoketest/coroutines/SampleCoroutinesApplication.kt index f545fa81e0..cf22d38e40 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-webflux-coroutines/src/main/kotlin/smoketest/coroutines/CoroutinesApplication.kt +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-webflux-coroutines/src/main/kotlin/smoketest/coroutines/SampleCoroutinesApplication.kt @@ -4,7 +4,8 @@ import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication @SpringBootApplication -class CoroutinesApplication +class SampleCoroutinesApplication fun main(args: Array) { - runApplication(*args) + runApplication(*args) + } diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-webflux-coroutines/src/test/kotlin/smoketest/coroutines/CoroutinesApplicationTests.kt b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-webflux-coroutines/src/test/kotlin/smoketest/coroutines/CoroutinesControllerTests.kt similarity index 90% rename from spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-webflux-coroutines/src/test/kotlin/smoketest/coroutines/CoroutinesApplicationTests.kt rename to spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-webflux-coroutines/src/test/kotlin/smoketest/coroutines/CoroutinesControllerTests.kt index 1af3624504..440cea3a43 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-webflux-coroutines/src/test/kotlin/smoketest/coroutines/CoroutinesApplicationTests.kt +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-webflux-coroutines/src/test/kotlin/smoketest/coroutines/CoroutinesControllerTests.kt @@ -9,7 +9,7 @@ import org.springframework.test.web.reactive.server.WebTestClient import org.springframework.test.web.reactive.server.expectBody @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) -class CoroutinesApplicationTests(@Autowired private val webClient: WebTestClient) { +class CoroutinesControllerTests(@Autowired private val webClient: WebTestClient) { @Test fun testSuspendingFunction() { @@ -22,4 +22,5 @@ class CoroutinesApplicationTests(@Autowired private val webClient: WebTestClient webClient.get().uri("/flow").accept(MediaType.TEXT_PLAIN).exchange() .expectBody().isEqualTo("Hello World") } + }