Merge pull request #17701 from sdeleuze
* pr/17701: Polish "Add WebFlux Coroutines smoke test" Polish "Add dependency management for Kotlin Coroutines" Add WebFlux Coroutines smoke test Add dependency management for Kotlin Coroutines Closes gh-17701
This commit is contained in:
@@ -139,6 +139,7 @@
|
||||
<junit-jupiter.version>5.5.1</junit-jupiter.version>
|
||||
<kafka.version>2.3.0</kafka.version>
|
||||
<kotlin.version>1.3.41</kotlin.version>
|
||||
<kotlin-coroutines.version>1.3.0-RC</kotlin-coroutines.version>
|
||||
<lettuce.version>5.1.8.RELEASE</lettuce.version>
|
||||
<liquibase.version>3.7.0</liquibase.version>
|
||||
<log4j2.version>2.12.0</log4j2.version>
|
||||
@@ -2595,6 +2596,13 @@
|
||||
<scope>import</scope>
|
||||
<type>pom</type>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlinx</groupId>
|
||||
<artifactId>kotlinx-coroutines-bom</artifactId>
|
||||
<version>${kotlin-coroutines.version}</version>
|
||||
<scope>import</scope>
|
||||
<type>pom</type>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jolokia</groupId>
|
||||
<artifactId>jolokia-core</artifactId>
|
||||
|
||||
@@ -98,6 +98,7 @@
|
||||
<module>spring-boot-smoke-test-web-static</module>
|
||||
<module>spring-boot-smoke-test-web-ui</module>
|
||||
<module>spring-boot-smoke-test-webflux</module>
|
||||
<module>spring-boot-smoke-test-webflux-coroutines</module>
|
||||
<module>spring-boot-smoke-test-websocket-jetty</module>
|
||||
<module>spring-boot-smoke-test-websocket-tomcat</module>
|
||||
<module>spring-boot-smoke-test-websocket-undertow</module>
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<!-- Your own application should inherit from spring-boot-starter-parent -->
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-smoke-tests</artifactId>
|
||||
<version>${revision}</version>
|
||||
</parent>
|
||||
<artifactId>spring-boot-smoke-test-webflux-coroutines</artifactId>
|
||||
<name>Spring Boot WebFlux Coroutines Smoke Test</name>
|
||||
<description>Spring Boot WebFlux Coroutines Smoke Test</description>
|
||||
<properties>
|
||||
<main.basedir>${basedir}/../../..</main.basedir>
|
||||
<m2eclipse.wtp.contextRoot>/</m2eclipse.wtp.contextRoot>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<!-- Compile -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-webflux</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-reflect</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-stdlib-jdk8</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlinx</groupId>
|
||||
<artifactId>kotlinx-coroutines-reactor</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.module</groupId>
|
||||
<artifactId>jackson-module-kotlin</artifactId>
|
||||
</dependency>
|
||||
<!-- Test -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<sourceDirectory>${project.basedir}/src/main/kotlin</sourceDirectory>
|
||||
<testSourceDirectory>${project.basedir}/src/test/kotlin</testSourceDirectory>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
<args>
|
||||
<arg>-Xjsr305=strict</arg>
|
||||
</args>
|
||||
<compilerPlugins>
|
||||
<plugin>spring</plugin>
|
||||
</compilerPlugins>
|
||||
</configuration>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-maven-allopen</artifactId>
|
||||
<version>${kotlin.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
@@ -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")
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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<String>) {
|
||||
runApplication<SampleCoroutinesApplication>(*args)
|
||||
|
||||
}
|
||||
@@ -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<String>().isEqualTo("Hello World")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testFlow() {
|
||||
webClient.get().uri("/flow").accept(MediaType.TEXT_PLAIN).exchange()
|
||||
.expectBody<String>().isEqualTo("Hello World")
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user