diff --git a/spring-test/src/main/kotlin/org/springframework/test/web/reactive/server/WebTestClientExtensions.kt b/spring-test/src/main/kotlin/org/springframework/test/web/reactive/server/WebTestClientExtensions.kt index fd0dd0b794..d7277f9d36 100644 --- a/spring-test/src/main/kotlin/org/springframework/test/web/reactive/server/WebTestClientExtensions.kt +++ b/spring-test/src/main/kotlin/org/springframework/test/web/reactive/server/WebTestClientExtensions.kt @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -68,7 +68,7 @@ inline fun RequestBodySpec.body(flow: Flow): RequestHeaders */ @Suppress("EXTENSION_SHADOWED_BY_MEMBER") inline fun ResponseSpec.expectBody(): KotlinBodySpec = - expectBody(B::class.java).returnResult().let { + expectBody(object : ParameterizedTypeReference() {}).returnResult().let { object : KotlinBodySpec { override fun isEqualTo(expected: B): KotlinBodySpec = it diff --git a/spring-test/src/test/kotlin/org/springframework/test/web/reactive/server/WebTestClientExtensionsTests.kt b/spring-test/src/test/kotlin/org/springframework/test/web/reactive/server/WebTestClientExtensionsTests.kt index e59069c3f2..cac68a1b55 100644 --- a/spring-test/src/test/kotlin/org/springframework/test/web/reactive/server/WebTestClientExtensionsTests.kt +++ b/spring-test/src/test/kotlin/org/springframework/test/web/reactive/server/WebTestClientExtensionsTests.kt @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -62,7 +62,7 @@ class WebTestClientExtensionsTests { @Test fun `ResponseSpec#expectBody with reified type parameters`() { responseSpec.expectBody() - verify { responseSpec.expectBody(Foo::class.java) } + verify { responseSpec.expectBody(object : ParameterizedTypeReference() {}) } } @Test