diff --git a/spring-boot-project/spring-boot-dependencies/pom.xml b/spring-boot-project/spring-boot-dependencies/pom.xml index 0f7296334a..bfbb85a388 100644 --- a/spring-boot-project/spring-boot-dependencies/pom.xml +++ b/spring-boot-project/spring-boot-dependencies/pom.xml @@ -139,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 @@ -2595,6 +2596,13 @@ import pom + + org.jetbrains.kotlinx + kotlinx-coroutines-bom + ${kotlin-coroutines.version} + import + pom + org.jolokia jolokia-core 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..e852ff180d --- /dev/null +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-webflux-coroutines/pom.xml @@ -0,0 +1,78 @@ + + + 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 + + + + org.jetbrains.kotlin + kotlin-reflect + + + org.jetbrains.kotlin + kotlin-stdlib-jdk8 + + + org.jetbrains.kotlinx + kotlinx-coroutines-reactor + + + + com.fasterxml.jackson.module + jackson-module-kotlin + + + + 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} + + + + + + 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..2137a0bdb4 --- /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,25 @@ +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/main/kotlin/smoketest/coroutines/SampleCoroutinesApplication.kt b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-webflux-coroutines/src/main/kotlin/smoketest/coroutines/SampleCoroutinesApplication.kt new file mode 100644 index 0000000000..cf22d38e40 --- /dev/null +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-webflux-coroutines/src/main/kotlin/smoketest/coroutines/SampleCoroutinesApplication.kt @@ -0,0 +1,11 @@ +package smoketest.coroutines + +import org.springframework.boot.autoconfigure.SpringBootApplication +import org.springframework.boot.runApplication + +@SpringBootApplication +class SampleCoroutinesApplication +fun main(args: Array) { + runApplication(*args) + +} diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-webflux-coroutines/src/test/kotlin/smoketest/coroutines/CoroutinesControllerTests.kt b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-webflux-coroutines/src/test/kotlin/smoketest/coroutines/CoroutinesControllerTests.kt new file mode 100644 index 0000000000..440cea3a43 --- /dev/null +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-webflux-coroutines/src/test/kotlin/smoketest/coroutines/CoroutinesControllerTests.kt @@ -0,0 +1,26 @@ +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 CoroutinesControllerTests(@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") + } + +}