"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "spring-webflux/src/test/kotlin/org/springframework/web/reactive/result/KotlinInvocableHandlerMethodTests.kt" between
spring-framework-5.3.23.tar.gz and spring-framework-5.3.24.tar.gz

About: Spring Framework is an application framework for the Java platform and .NET Framework. Community edition.

KotlinInvocableHandlerMethodTests.kt  (spring-framework-5.3.23):KotlinInvocableHandlerMethodTests.kt  (spring-framework-5.3.24)
skipping to change at line 37 skipping to change at line 37
import org.springframework.web.testfixture.server.MockServerWebExchange import org.springframework.web.testfixture.server.MockServerWebExchange
import org.springframework.web.bind.annotation.ResponseStatus import org.springframework.web.bind.annotation.ResponseStatus
import org.springframework.web.reactive.BindingContext import org.springframework.web.reactive.BindingContext
import org.springframework.web.reactive.HandlerResult import org.springframework.web.reactive.HandlerResult
import org.springframework.web.reactive.result.method.HandlerMethodArgumentResol ver import org.springframework.web.reactive.result.method.HandlerMethodArgumentResol ver
import org.springframework.web.reactive.result.method.InvocableHandlerMethod import org.springframework.web.reactive.result.method.InvocableHandlerMethod
import org.springframework.web.reactive.result.method.annotation.ContinuationHan dlerMethodArgumentResolver import org.springframework.web.reactive.result.method.annotation.ContinuationHan dlerMethodArgumentResolver
import reactor.core.publisher.Mono import reactor.core.publisher.Mono
import reactor.test.StepVerifier import reactor.test.StepVerifier
import java.lang.reflect.Method import java.lang.reflect.Method
import java.time.Duration
import kotlin.reflect.jvm.javaMethod import kotlin.reflect.jvm.javaMethod
class KotlinInvocableHandlerMethodTests { class KotlinInvocableHandlerMethodTests {
private val exchange = MockServerWebExchange.from(get("http://localhost:8 080/path")) private val exchange = MockServerWebExchange.from(get("http://localhost:8 080/path"))
private val resolvers = mutableListOf<HandlerMethodArgumentResolver>(Cont inuationHandlerMethodArgumentResolver()) private val resolvers = mutableListOf<HandlerMethodArgumentResolver>(Cont inuationHandlerMethodArgumentResolver())
@Test @Test
fun resolveNoArg() { fun resolveNoArg() {
skipping to change at line 92 skipping to change at line 93
assertHandlerResultValue(result, "created") assertHandlerResultValue(result, "created")
assertThat(this.exchange.response.statusCode).isSameAs(HttpStatus .CREATED) assertThat(this.exchange.response.statusCode).isSameAs(HttpStatus .CREATED)
} }
@Test @Test
fun voidMethodWithResponseArg() { fun voidMethodWithResponseArg() {
val response = this.exchange.response val response = this.exchange.response
this.resolvers.add(stubResolver(response)) this.resolvers.add(stubResolver(response))
val method = CoroutinesController::response.javaMethod!! val method = CoroutinesController::response.javaMethod!!
val result = invoke(CoroutinesController(), method) val result = invokeForResult(CoroutinesController(), method, resp onse)
StepVerifier.create(result) assertThat(result).`as`("Expected no result (i.e. fully handled)"
.consumeNextWith { StepVerifier.create(it.returnV ).isNull()
alue as Mono<*>).verifyComplete() }
.verifyComplete()
assertThat(this.exchange.response.headers.getFirst("foo")).isEqua lTo("bar") assertThat(this.exchange.response.headers.getFirst("foo")).isEqua lTo("bar")
} }
@Test @Test
fun privateController() { fun privateController() {
this.resolvers.add(stubResolver("foo")) this.resolvers.add(stubResolver("foo"))
val method = PrivateCoroutinesController::singleArg.javaMethod!! val method = PrivateCoroutinesController::singleArg.javaMethod!!
val result = invoke(PrivateCoroutinesController(), method,"foo") val result = invoke(PrivateCoroutinesController(), method,"foo")
assertHandlerResultValue(result, "success:foo") assertHandlerResultValue(result, "success:foo")
} }
private fun invokeForResult(handler: Any, method: Method, vararg provided
Args: Any): HandlerResult? {
return invoke(handler, method, *providedArgs).block(Duration.ofSe
conds(5))
}
private fun invoke(handler: Any, method: Method, vararg providedArgs: Any ?): Mono<HandlerResult> { private fun invoke(handler: Any, method: Method, vararg providedArgs: Any ?): Mono<HandlerResult> {
val invocable = InvocableHandlerMethod(handler, method) val invocable = InvocableHandlerMethod(handler, method)
invocable.setArgumentResolvers(this.resolvers) invocable.setArgumentResolvers(this.resolvers)
return invocable.invoke(this.exchange, BindingContext(), *provide dArgs) return invocable.invoke(this.exchange, BindingContext(), *provide dArgs)
} }
private fun stubResolver(stubValue: Any?): HandlerMethodArgumentResolver { private fun stubResolver(stubValue: Any?): HandlerMethodArgumentResolver {
return stubResolver(Mono.justOrEmpty(stubValue)) return stubResolver(Mono.justOrEmpty(stubValue))
} }
 End of changes. 4 change blocks. 
5 lines changed or deleted 10 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)