Browse Source

Cleanup kotlin sources

1. remove unused import
2. remove redundant semicolon
3. remove redundant empty constructor and SAM-constructor
4. remove unnecessary type argument
5. adjust indent

See gh-31913
pull/31917/head
Yanming Zhou 2 years ago committed by Stéphane Nicoll
parent
commit
7474af4f09
  1. 4
      integration-tests/src/test/kotlin/org/springframework/aop/framework/autoproxy/AspectJAutoProxyInterceptorKotlinIntegrationTests.kt
  2. 2
      spring-aop/src/test/kotlin/org/springframework/aop/support/AopUtilsKotlinTests.kt
  3. 24
      spring-beans/src/jmh/kotlin/org/springframework/beans/KotlinBeanUtilsBenchmark.kt
  4. 6
      spring-jdbc/src/main/kotlin/org/springframework/jdbc/core/JdbcOperationsExtensions.kt
  5. 48
      spring-webflux/src/main/kotlin/org/springframework/web/reactive/function/server/RouterFunctionDsl.kt
  6. 4
      spring-webflux/src/test/kotlin/org/springframework/web/reactive/function/server/CoRouterFunctionDslTests.kt
  7. 5
      spring-webflux/src/test/kotlin/org/springframework/web/reactive/function/server/RouterFunctionDslTests.kt
  8. 2
      spring-webflux/src/test/kotlin/org/springframework/web/reactive/result/InvocableHandlerMethodKotlinTests.kt
  9. 20
      spring-webflux/src/test/kotlin/org/springframework/web/reactive/result/method/annotation/CoroutinesIntegrationTests.kt
  10. 1
      spring-webflux/src/test/kotlin/org/springframework/web/reactive/result/method/annotation/MessageWriterResultHandlerKotlinTests.kt

4
integration-tests/src/test/kotlin/org/springframework/aop/framework/autoproxy/AspectJAutoProxyInterceptorKotlinIntegrationTests.kt

@ -94,12 +94,12 @@ class AspectJAutoProxyInterceptorKotlinIntegrationTests( @@ -94,12 +94,12 @@ class AspectJAutoProxyInterceptorKotlinIntegrationTests(
open class Echo {
open fun echo(value: String): String {
return value;
return value
}
open suspend fun suspendingEcho(value: String): String {
delay(1)
return value;
return value
}
}

2
spring-aop/src/test/kotlin/org/springframework/aop/support/AopUtilsKotlinTests.kt

@ -46,7 +46,7 @@ class AopUtilsKotlinTests { @@ -46,7 +46,7 @@ class AopUtilsKotlinTests {
@Suppress("unused")
suspend fun suspendingFunction(value: String): String {
delay(1)
return value;
return value
}
}

24
spring-beans/src/jmh/kotlin/org/springframework/beans/KotlinBeanUtilsBenchmark.kt

@ -16,7 +16,7 @@ @@ -16,7 +16,7 @@
package org.springframework.beans
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeUnit
import org.openjdk.jmh.annotations.Benchmark
import org.openjdk.jmh.annotations.BenchmarkMode
@ -30,22 +30,22 @@ import org.openjdk.jmh.annotations.State @@ -30,22 +30,22 @@ import org.openjdk.jmh.annotations.State
@OutputTimeUnit(TimeUnit.NANOSECONDS)
open class KotlinBeanUtilsBenchmark {
private val noArgConstructor = TestClass1::class.java.getDeclaredConstructor()
private val constructor = TestClass2::class.java.getDeclaredConstructor(Int::class.java, String::class.java)
private val noArgConstructor = TestClass1::class.java.getDeclaredConstructor()
private val constructor = TestClass2::class.java.getDeclaredConstructor(Int::class.java, String::class.java)
@Benchmark
fun emptyConstructor(): Any {
@Benchmark
fun emptyConstructor(): Any {
return BeanUtils.instantiateClass(noArgConstructor)
}
}
@Benchmark
fun nonEmptyConstructor(): Any {
@Benchmark
fun nonEmptyConstructor(): Any {
return BeanUtils.instantiateClass(constructor, 1, "str")
}
}
class TestClass1()
class TestClass1
@Suppress("UNUSED_PARAMETER")
class TestClass2(int: Int, string: String)
@Suppress("UNUSED_PARAMETER")
class TestClass2(int: Int, string: String)
}

6
spring-jdbc/src/main/kotlin/org/springframework/jdbc/core/JdbcOperationsExtensions.kt

@ -35,7 +35,7 @@ inline fun <reified T> JdbcOperations.queryForObject(sql: String): T = @@ -35,7 +35,7 @@ inline fun <reified T> JdbcOperations.queryForObject(sql: String): T =
* @since 5.0
*/
inline fun <reified T> JdbcOperations.queryForObject(sql: String, vararg args: Any, crossinline function: (ResultSet, Int) -> T): T =
queryForObject(sql, RowMapper { resultSet, i -> function(resultSet, i) }, *args) as T
queryForObject(sql, { resultSet, i -> function(resultSet, i) }, *args) as T
/**
* Extension for [JdbcOperations.queryForObject] providing a
@ -113,7 +113,7 @@ inline fun <reified T> JdbcOperations.query(sql: String, vararg args: Any, @@ -113,7 +113,7 @@ inline fun <reified T> JdbcOperations.query(sql: String, vararg args: Any,
* @since 5.0
*/
fun JdbcOperations.query(sql: String, vararg args: Any, function: (ResultSet) -> Unit): Unit =
query(sql, RowCallbackHandler { function(it) }, *args)
query(sql, { function(it) }, *args)
/**
* Extensions for [JdbcOperations.query] providing a RowMapper-like function variant:
@ -123,4 +123,4 @@ fun JdbcOperations.query(sql: String, vararg args: Any, function: (ResultSet) -> @@ -123,4 +123,4 @@ fun JdbcOperations.query(sql: String, vararg args: Any, function: (ResultSet) ->
* @since 5.0
*/
fun <T> JdbcOperations.query(sql: String, vararg args: Any, function: (ResultSet, Int) -> T): List<T> =
query(sql, RowMapper { rs, i -> function(rs, i) }, *args)
query(sql, { rs, i -> function(rs, i) }, *args)

48
spring-webflux/src/main/kotlin/org/springframework/web/reactive/function/server/RouterFunctionDsl.kt

@ -174,7 +174,7 @@ class RouterFunctionDsl internal constructor (private val init: RouterFunctionDs @@ -174,7 +174,7 @@ class RouterFunctionDsl internal constructor (private val init: RouterFunctionDs
* @since 5.3
*/
fun GET(predicate: RequestPredicate, f: (ServerRequest) -> Mono<out ServerResponse>) {
builder.GET(predicate, HandlerFunction<ServerResponse> { f(it).cast(ServerResponse::class.java) })
builder.GET(predicate, { f(it).cast(ServerResponse::class.java) })
}
/**
@ -185,7 +185,7 @@ class RouterFunctionDsl internal constructor (private val init: RouterFunctionDs @@ -185,7 +185,7 @@ class RouterFunctionDsl internal constructor (private val init: RouterFunctionDs
* @since 5.2
*/
fun GET(pattern: String, predicate: RequestPredicate, f: (ServerRequest) -> Mono<out ServerResponse>) {
builder.GET(pattern, predicate, HandlerFunction<ServerResponse> { f(it).cast(ServerResponse::class.java) })
builder.GET(pattern, predicate, HandlerFunction { f(it).cast(ServerResponse::class.java) })
}
/**
@ -219,7 +219,7 @@ class RouterFunctionDsl internal constructor (private val init: RouterFunctionDs @@ -219,7 +219,7 @@ class RouterFunctionDsl internal constructor (private val init: RouterFunctionDs
* @since 5.3
*/
fun HEAD(predicate: RequestPredicate, f: (ServerRequest) -> Mono<out ServerResponse>) {
builder.HEAD(predicate, HandlerFunction<ServerResponse> { f(it).cast(ServerResponse::class.java) })
builder.HEAD(predicate, HandlerFunction { f(it).cast(ServerResponse::class.java) })
}
/**
@ -230,7 +230,7 @@ class RouterFunctionDsl internal constructor (private val init: RouterFunctionDs @@ -230,7 +230,7 @@ class RouterFunctionDsl internal constructor (private val init: RouterFunctionDs
* @since 5.2
*/
fun HEAD(pattern: String, predicate: RequestPredicate, f: (ServerRequest) -> Mono<out ServerResponse>) {
builder.HEAD(pattern, predicate, HandlerFunction<ServerResponse> { f(it).cast(ServerResponse::class.java) })
builder.HEAD(pattern, predicate, HandlerFunction { f(it).cast(ServerResponse::class.java) })
}
/**
@ -264,7 +264,7 @@ class RouterFunctionDsl internal constructor (private val init: RouterFunctionDs @@ -264,7 +264,7 @@ class RouterFunctionDsl internal constructor (private val init: RouterFunctionDs
* @since 5.3
*/
fun POST(predicate: RequestPredicate, f: (ServerRequest) -> Mono<out ServerResponse>) {
builder.POST(predicate, HandlerFunction<ServerResponse> { f(it).cast(ServerResponse::class.java) })
builder.POST(predicate, HandlerFunction { f(it).cast(ServerResponse::class.java) })
}
/**
@ -275,7 +275,7 @@ class RouterFunctionDsl internal constructor (private val init: RouterFunctionDs @@ -275,7 +275,7 @@ class RouterFunctionDsl internal constructor (private val init: RouterFunctionDs
* @since 5.2
*/
fun POST(pattern: String, predicate: RequestPredicate, f: (ServerRequest) -> Mono<out ServerResponse>) {
builder.POST(pattern, predicate, HandlerFunction<ServerResponse> { f(it).cast(ServerResponse::class.java) })
builder.POST(pattern, predicate, HandlerFunction { f(it).cast(ServerResponse::class.java) })
}
/**
@ -309,7 +309,7 @@ class RouterFunctionDsl internal constructor (private val init: RouterFunctionDs @@ -309,7 +309,7 @@ class RouterFunctionDsl internal constructor (private val init: RouterFunctionDs
* @since 5.3
*/
fun PUT(predicate: RequestPredicate, f: (ServerRequest) -> Mono<out ServerResponse>) {
builder.PUT(predicate, HandlerFunction<ServerResponse> { f(it).cast(ServerResponse::class.java) })
builder.PUT(predicate, HandlerFunction { f(it).cast(ServerResponse::class.java) })
}
/**
@ -320,7 +320,7 @@ class RouterFunctionDsl internal constructor (private val init: RouterFunctionDs @@ -320,7 +320,7 @@ class RouterFunctionDsl internal constructor (private val init: RouterFunctionDs
* @since 5.2
*/
fun PUT(pattern: String, predicate: RequestPredicate, f: (ServerRequest) -> Mono<out ServerResponse>) {
builder.PUT(pattern, predicate, HandlerFunction<ServerResponse> { f(it).cast(ServerResponse::class.java) })
builder.PUT(pattern, predicate, HandlerFunction { f(it).cast(ServerResponse::class.java) })
}
/**
@ -354,7 +354,7 @@ class RouterFunctionDsl internal constructor (private val init: RouterFunctionDs @@ -354,7 +354,7 @@ class RouterFunctionDsl internal constructor (private val init: RouterFunctionDs
* @since 5.3
*/
fun PATCH(predicate: RequestPredicate, f: (ServerRequest) -> Mono<out ServerResponse>) {
builder.PATCH(predicate, HandlerFunction<ServerResponse> { f(it).cast(ServerResponse::class.java) })
builder.PATCH(predicate, HandlerFunction { f(it).cast(ServerResponse::class.java) })
}
/**
@ -365,7 +365,7 @@ class RouterFunctionDsl internal constructor (private val init: RouterFunctionDs @@ -365,7 +365,7 @@ class RouterFunctionDsl internal constructor (private val init: RouterFunctionDs
* @since 5.2
*/
fun PATCH(pattern: String, predicate: RequestPredicate, f: (ServerRequest) -> Mono<out ServerResponse>) {
builder.PATCH(pattern, predicate, HandlerFunction<ServerResponse> { f(it).cast(ServerResponse::class.java) })
builder.PATCH(pattern, predicate, HandlerFunction { f(it).cast(ServerResponse::class.java) })
}
/**
@ -401,7 +401,7 @@ class RouterFunctionDsl internal constructor (private val init: RouterFunctionDs @@ -401,7 +401,7 @@ class RouterFunctionDsl internal constructor (private val init: RouterFunctionDs
* @since 5.3
*/
fun DELETE(predicate: RequestPredicate, f: (ServerRequest) -> Mono<out ServerResponse>) {
builder.DELETE(predicate, HandlerFunction<ServerResponse> { f(it).cast(ServerResponse::class.java) })
builder.DELETE(predicate, HandlerFunction { f(it).cast(ServerResponse::class.java) })
}
/**
@ -412,7 +412,7 @@ class RouterFunctionDsl internal constructor (private val init: RouterFunctionDs @@ -412,7 +412,7 @@ class RouterFunctionDsl internal constructor (private val init: RouterFunctionDs
* @since 5.2
*/
fun DELETE(pattern: String, predicate: RequestPredicate, f: (ServerRequest) -> Mono<out ServerResponse>) {
builder.DELETE(pattern, predicate, HandlerFunction<ServerResponse> { f(it).cast(ServerResponse::class.java) })
builder.DELETE(pattern, predicate, HandlerFunction { f(it).cast(ServerResponse::class.java) })
}
/**
@ -448,7 +448,7 @@ class RouterFunctionDsl internal constructor (private val init: RouterFunctionDs @@ -448,7 +448,7 @@ class RouterFunctionDsl internal constructor (private val init: RouterFunctionDs
* @since 5.3
*/
fun OPTIONS(predicate: RequestPredicate, f: (ServerRequest) -> Mono<out ServerResponse>) {
builder.OPTIONS(predicate, HandlerFunction<ServerResponse> { f(it).cast(ServerResponse::class.java) })
builder.OPTIONS(predicate, HandlerFunction { f(it).cast(ServerResponse::class.java) })
}
/**
@ -459,7 +459,7 @@ class RouterFunctionDsl internal constructor (private val init: RouterFunctionDs @@ -459,7 +459,7 @@ class RouterFunctionDsl internal constructor (private val init: RouterFunctionDs
* @since 5.2
*/
fun OPTIONS(pattern: String, predicate: RequestPredicate, f: (ServerRequest) -> Mono<out ServerResponse>) {
builder.OPTIONS(pattern, predicate, HandlerFunction<ServerResponse> { f(it).cast(ServerResponse::class.java) })
builder.OPTIONS(pattern, predicate, HandlerFunction { f(it).cast(ServerResponse::class.java) })
}
/**
@ -476,7 +476,7 @@ class RouterFunctionDsl internal constructor (private val init: RouterFunctionDs @@ -476,7 +476,7 @@ class RouterFunctionDsl internal constructor (private val init: RouterFunctionDs
* @see RouterFunctions.route
*/
fun accept(mediaType: MediaType, f: (ServerRequest) -> Mono<out ServerResponse>) {
builder.add(RouterFunctions.route(RequestPredicates.accept(mediaType), HandlerFunction<ServerResponse> { f(it).cast(ServerResponse::class.java) }))
builder.add(RouterFunctions.route(RequestPredicates.accept(mediaType), HandlerFunction { f(it).cast(ServerResponse::class.java) }))
}
/**
@ -493,7 +493,7 @@ class RouterFunctionDsl internal constructor (private val init: RouterFunctionDs @@ -493,7 +493,7 @@ class RouterFunctionDsl internal constructor (private val init: RouterFunctionDs
* @see RouterFunctions.route
*/
fun contentType(mediaTypes: MediaType, f: (ServerRequest) -> Mono<out ServerResponse>) {
builder.add(RouterFunctions.route(RequestPredicates.contentType(mediaTypes), HandlerFunction<ServerResponse> { f(it).cast(ServerResponse::class.java) }))
builder.add(RouterFunctions.route(RequestPredicates.contentType(mediaTypes), HandlerFunction { f(it).cast(ServerResponse::class.java) }))
}
/**
@ -510,7 +510,7 @@ class RouterFunctionDsl internal constructor (private val init: RouterFunctionDs @@ -510,7 +510,7 @@ class RouterFunctionDsl internal constructor (private val init: RouterFunctionDs
* @see RouterFunctions.route
*/
fun headers(headersPredicate: (ServerRequest.Headers) -> Boolean, f: (ServerRequest) -> Mono<out ServerResponse>) {
builder.add(RouterFunctions.route(RequestPredicates.headers(headersPredicate), HandlerFunction<ServerResponse> { f(it).cast(ServerResponse::class.java) }))
builder.add(RouterFunctions.route(RequestPredicates.headers(headersPredicate), HandlerFunction { f(it).cast(ServerResponse::class.java) }))
}
/**
@ -526,7 +526,7 @@ class RouterFunctionDsl internal constructor (private val init: RouterFunctionDs @@ -526,7 +526,7 @@ class RouterFunctionDsl internal constructor (private val init: RouterFunctionDs
* @see RouterFunctions.route
*/
fun method(httpMethod: HttpMethod, f: (ServerRequest) -> Mono<out ServerResponse>) {
builder.add(RouterFunctions.route(RequestPredicates.method(httpMethod), HandlerFunction<ServerResponse> { f(it).cast(ServerResponse::class.java) }))
builder.add(RouterFunctions.route(RequestPredicates.method(httpMethod), HandlerFunction { f(it).cast(ServerResponse::class.java) }))
}
/**
@ -541,7 +541,7 @@ class RouterFunctionDsl internal constructor (private val init: RouterFunctionDs @@ -541,7 +541,7 @@ class RouterFunctionDsl internal constructor (private val init: RouterFunctionDs
* @see RouterFunctions.route
*/
fun path(pattern: String, f: (ServerRequest) -> Mono<out ServerResponse>) {
builder.add(RouterFunctions.route(RequestPredicates.path(pattern), HandlerFunction<ServerResponse> { f(it).cast(ServerResponse::class.java) }))
builder.add(RouterFunctions.route(RequestPredicates.path(pattern), HandlerFunction { f(it).cast(ServerResponse::class.java) }))
}
/**
@ -555,7 +555,7 @@ class RouterFunctionDsl internal constructor (private val init: RouterFunctionDs @@ -555,7 +555,7 @@ class RouterFunctionDsl internal constructor (private val init: RouterFunctionDs
* @see RouterFunctions.route
*/
fun pathExtension(extension: String, f: (ServerRequest) -> Mono<out ServerResponse>) {
builder.add(RouterFunctions.route(RequestPredicates.pathExtension(extension), HandlerFunction<ServerResponse> { f(it).cast(ServerResponse::class.java) }))
builder.add(RouterFunctions.route(RequestPredicates.pathExtension(extension), HandlerFunction { f(it).cast(ServerResponse::class.java) }))
}
/**
@ -570,7 +570,7 @@ class RouterFunctionDsl internal constructor (private val init: RouterFunctionDs @@ -570,7 +570,7 @@ class RouterFunctionDsl internal constructor (private val init: RouterFunctionDs
* @see RouterFunctions.route
*/
fun pathExtension(predicate: (String) -> Boolean, f: (ServerRequest) -> Mono<out ServerResponse>) {
builder.add(RouterFunctions.route(RequestPredicates.pathExtension(predicate), HandlerFunction<ServerResponse> { f(it).cast(ServerResponse::class.java) }))
builder.add(RouterFunctions.route(RequestPredicates.pathExtension(predicate), HandlerFunction { f(it).cast(ServerResponse::class.java) }))
}
/**
@ -586,7 +586,7 @@ class RouterFunctionDsl internal constructor (private val init: RouterFunctionDs @@ -586,7 +586,7 @@ class RouterFunctionDsl internal constructor (private val init: RouterFunctionDs
* @see RouterFunctions.route
*/
fun queryParam(name: String, predicate: (String) -> Boolean, f: (ServerRequest) -> Mono<out ServerResponse>) {
builder.add(RouterFunctions.route(RequestPredicates.queryParam(name, predicate), HandlerFunction<ServerResponse> { f(it).cast(ServerResponse::class.java) }))
builder.add(RouterFunctions.route(RequestPredicates.queryParam(name, predicate), HandlerFunction { f(it).cast(ServerResponse::class.java) }))
}
/**
@ -605,7 +605,7 @@ class RouterFunctionDsl internal constructor (private val init: RouterFunctionDs @@ -605,7 +605,7 @@ class RouterFunctionDsl internal constructor (private val init: RouterFunctionDs
* @see RouterFunctions.route
*/
operator fun RequestPredicate.invoke(f: (ServerRequest) -> Mono<out ServerResponse>) {
builder.add(RouterFunctions.route(this, HandlerFunction<ServerResponse> { f(it).cast(ServerResponse::class.java) }))
builder.add(RouterFunctions.route(this, HandlerFunction { f(it).cast(ServerResponse::class.java) }))
}
/**
@ -614,7 +614,7 @@ class RouterFunctionDsl internal constructor (private val init: RouterFunctionDs @@ -614,7 +614,7 @@ class RouterFunctionDsl internal constructor (private val init: RouterFunctionDs
* @see RouterFunctions.route
*/
operator fun String.invoke(f: (ServerRequest) -> Mono<out ServerResponse>) {
builder.add(RouterFunctions.route(RequestPredicates.path(this), HandlerFunction<ServerResponse> { f(it).cast(ServerResponse::class.java) }))
builder.add(RouterFunctions.route(RequestPredicates.path(this), HandlerFunction { f(it).cast(ServerResponse::class.java) }))
}
/**

4
spring-webflux/src/test/kotlin/org/springframework/web/reactive/function/server/CoRouterFunctionDslTests.kt

@ -281,8 +281,8 @@ class CoRouterFunctionDslTests { @@ -281,8 +281,8 @@ class CoRouterFunctionDslTests {
listOf(mapOf("foo" to "bar"), mapOf("foo" to "n1")),
listOf(mapOf("baz" to "qux"), mapOf("foo" to "n1")),
listOf(mapOf("foo" to "n3"), mapOf("foo" to "n2"), mapOf("foo" to "n1"))
);
assertThat(visitor.visitCount()).isEqualTo(7);
)
assertThat(visitor.visitCount()).isEqualTo(7)
}
private fun sampleRouter() = coRouter {

5
spring-webflux/src/test/kotlin/org/springframework/web/reactive/function/server/RouterFunctionDslTests.kt

@ -27,7 +27,6 @@ import org.springframework.http.MediaType.* @@ -27,7 +27,6 @@ import org.springframework.http.MediaType.*
import org.springframework.web.reactive.function.server.support.ServerRequestWrapper
import org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest.*
import org.springframework.web.testfixture.server.MockServerWebExchange
import org.springframework.web.reactive.function.server.AttributesTestVisitor
import reactor.core.publisher.Mono
import reactor.test.StepVerifier
import java.security.Principal
@ -167,8 +166,8 @@ class RouterFunctionDslTests { @@ -167,8 +166,8 @@ class RouterFunctionDslTests {
listOf(mapOf("foo" to "bar"), mapOf("foo" to "n1")),
listOf(mapOf("baz" to "qux"), mapOf("foo" to "n1")),
listOf(mapOf("foo" to "n3"), mapOf("foo" to "n2"), mapOf("foo" to "n1"))
);
assertThat(visitor.visitCount()).isEqualTo(7);
)
assertThat(visitor.visitCount()).isEqualTo(7)
}
@Test

2
spring-webflux/src/test/kotlin/org/springframework/web/reactive/result/InvocableHandlerMethodKotlinTests.kt

@ -52,7 +52,7 @@ class InvocableHandlerMethodKotlinTests { @@ -52,7 +52,7 @@ class InvocableHandlerMethodKotlinTests {
private var exchange = MockServerWebExchange.from(get("http://localhost:8080/path"))
private val resolvers = mutableListOf<HandlerMethodArgumentResolver>(ContinuationHandlerMethodArgumentResolver(),
private val resolvers = mutableListOf(ContinuationHandlerMethodArgumentResolver(),
RequestParamMethodArgumentResolver(null, ReactiveAdapterRegistry.getSharedInstance(), false))
@Test

20
spring-webflux/src/test/kotlin/org/springframework/web/reactive/result/method/annotation/CoroutinesIntegrationTests.kt

@ -55,7 +55,7 @@ class CoroutinesIntegrationTests : AbstractRequestMappingIntegrationTests() { @@ -55,7 +55,7 @@ class CoroutinesIntegrationTests : AbstractRequestMappingIntegrationTests() {
fun `Suspending handler method`(httpServer: HttpServer) {
startServer(httpServer)
val entity = performGet<String>("/suspend", HttpHeaders.EMPTY, String::class.java)
val entity = performGet("/suspend", HttpHeaders.EMPTY, String::class.java)
assertThat(entity.statusCode).isEqualTo(HttpStatus.OK)
assertThat(entity.body).isEqualTo("foo")
}
@ -64,7 +64,7 @@ class CoroutinesIntegrationTests : AbstractRequestMappingIntegrationTests() { @@ -64,7 +64,7 @@ class CoroutinesIntegrationTests : AbstractRequestMappingIntegrationTests() {
fun `Handler method returning Deferred`(httpServer: HttpServer) {
startServer(httpServer)
val entity = performGet<String>("/deferred", HttpHeaders.EMPTY, String::class.java)
val entity = performGet("/deferred", HttpHeaders.EMPTY, String::class.java)
assertThat(entity.statusCode).isEqualTo(HttpStatus.OK)
assertThat(entity.body).isEqualTo("foo")
}
@ -73,7 +73,7 @@ class CoroutinesIntegrationTests : AbstractRequestMappingIntegrationTests() { @@ -73,7 +73,7 @@ class CoroutinesIntegrationTests : AbstractRequestMappingIntegrationTests() {
fun `Suspending ResponseEntity handler method`(httpServer: HttpServer) {
startServer(httpServer)
val entity = performGet<String>("/suspend-response-entity", HttpHeaders.EMPTY, String::class.java)
val entity = performGet("/suspend-response-entity", HttpHeaders.EMPTY, String::class.java)
assertThat(entity.statusCode).isEqualTo(HttpStatus.OK)
assertThat(entity.body).isEqualTo("{\"value\":\"foo\"}")
}
@ -82,7 +82,7 @@ class CoroutinesIntegrationTests : AbstractRequestMappingIntegrationTests() { @@ -82,7 +82,7 @@ class CoroutinesIntegrationTests : AbstractRequestMappingIntegrationTests() {
fun `Handler method returning Flow`(httpServer: HttpServer) {
startServer(httpServer)
val entity = performGet<String>("/flow", HttpHeaders.EMPTY, String::class.java)
val entity = performGet("/flow", HttpHeaders.EMPTY, String::class.java)
assertThat(entity.statusCode).isEqualTo(HttpStatus.OK)
assertThat(entity.body).isEqualTo("foobar")
}
@ -91,7 +91,7 @@ class CoroutinesIntegrationTests : AbstractRequestMappingIntegrationTests() { @@ -91,7 +91,7 @@ class CoroutinesIntegrationTests : AbstractRequestMappingIntegrationTests() {
fun `Suspending handler method returning Flow`(httpServer: HttpServer) {
startServer(httpServer)
val entity = performGet<String>("/suspending-flow", HttpHeaders.EMPTY, String::class.java)
val entity = performGet("/suspending-flow", HttpHeaders.EMPTY, String::class.java)
assertThat(entity.statusCode).isEqualTo(HttpStatus.OK)
assertThat(entity.body).isEqualTo("foobar")
}
@ -101,7 +101,7 @@ class CoroutinesIntegrationTests : AbstractRequestMappingIntegrationTests() { @@ -101,7 +101,7 @@ class CoroutinesIntegrationTests : AbstractRequestMappingIntegrationTests() {
startServer(httpServer)
assertThatExceptionOfType(HttpServerErrorException.InternalServerError::class.java).isThrownBy {
performGet<String>("/error", HttpHeaders.EMPTY, String::class.java)
performGet("/error", HttpHeaders.EMPTY, String::class.java)
}
}
@ -110,7 +110,7 @@ class CoroutinesIntegrationTests : AbstractRequestMappingIntegrationTests() { @@ -110,7 +110,7 @@ class CoroutinesIntegrationTests : AbstractRequestMappingIntegrationTests() {
startServer(httpServer)
assertThatExceptionOfType(HttpServerErrorException.InternalServerError::class.java).isThrownBy {
performGet<String>("/flow-error", HttpHeaders.EMPTY, String::class.java)
performGet("/flow-error", HttpHeaders.EMPTY, String::class.java)
}
}
@ -120,7 +120,7 @@ class CoroutinesIntegrationTests : AbstractRequestMappingIntegrationTests() { @@ -120,7 +120,7 @@ class CoroutinesIntegrationTests : AbstractRequestMappingIntegrationTests() {
startServer(httpServer)
val entity = performGet<String>("/entity-flux", HttpHeaders.EMPTY, String::class.java)
val entity = performGet("/entity-flux", HttpHeaders.EMPTY, String::class.java)
assertThat(entity.statusCode).isEqualTo(HttpStatus.OK)
assertThat(entity.body).isEqualTo("foobar")
}
@ -129,7 +129,7 @@ class CoroutinesIntegrationTests : AbstractRequestMappingIntegrationTests() { @@ -129,7 +129,7 @@ class CoroutinesIntegrationTests : AbstractRequestMappingIntegrationTests() {
fun `Suspending handler method returning ResponseEntity of Flow`(httpServer: HttpServer) {
startServer(httpServer)
val entity = performGet<String>("/entity-flow", HttpHeaders.EMPTY, String::class.java)
val entity = performGet("/entity-flow", HttpHeaders.EMPTY, String::class.java)
assertThat(entity.statusCode).isEqualTo(HttpStatus.OK)
assertThat(entity.body).isEqualTo("foobar")
}
@ -195,7 +195,7 @@ class CoroutinesIntegrationTests : AbstractRequestMappingIntegrationTests() { @@ -195,7 +195,7 @@ class CoroutinesIntegrationTests : AbstractRequestMappingIntegrationTests() {
@GetMapping("/entity-flux")
suspend fun entityFlux() : ResponseEntity<Flux<String>> {
val strings = Flux.just("foo", "bar");
val strings = Flux.just("foo", "bar")
delay(1)
return ResponseEntity.ok().body(strings)
}

1
spring-webflux/src/test/kotlin/org/springframework/web/reactive/result/method/annotation/MessageWriterResultHandlerKotlinTests.kt

@ -37,7 +37,6 @@ import org.springframework.web.testfixture.server.MockServerWebExchange @@ -37,7 +37,6 @@ import org.springframework.web.testfixture.server.MockServerWebExchange
import reactor.test.StepVerifier
import java.nio.charset.StandardCharsets
import java.time.Duration
import java.util.*
/**
* Kotlin unit tests for [AbstractMessageWriterResultHandler].

Loading…
Cancel
Save