diff --git a/spring-test/src/main/java/org/springframework/test/web/reactive/server/DefaultWebTestClient.java b/spring-test/src/main/java/org/springframework/test/web/reactive/server/DefaultWebTestClient.java index 236cf882806..20e1587921c 100644 --- a/spring-test/src/main/java/org/springframework/test/web/reactive/server/DefaultWebTestClient.java +++ b/spring-test/src/main/java/org/springframework/test/web/reactive/server/DefaultWebTestClient.java @@ -47,13 +47,13 @@ import org.springframework.web.reactive.function.client.WebClient; import org.springframework.web.server.ServerWebExchange; import org.springframework.web.util.UriBuilder; -import static java.util.stream.Collectors.toList; import static org.springframework.test.util.AssertionErrors.assertEquals; import static org.springframework.test.util.AssertionErrors.assertTrue; import static org.springframework.web.reactive.function.BodyExtractors.toDataBuffers; import static org.springframework.web.reactive.function.BodyExtractors.toFlux; import static org.springframework.web.reactive.function.BodyExtractors.toMono; + /** * Default implementation of {@link WebTestClient}. * @@ -290,63 +290,57 @@ class DefaultWebTestClient implements WebTestClient { private DefaultResponseSpec toResponseSpec(Mono mono) { ClientResponse clientResponse = mono.block(getTimeout()); ExchangeResult exchangeResult = wiretapConnector.claimRequest(this.requestId); - return new DefaultResponseSpec(exchangeResult, clientResponse); + return new DefaultResponseSpec(exchangeResult, clientResponse, getTimeout()); } } - /** - * The {@code ExchangeResult} with live, undecoded {@link ClientResponse}. - */ - private class UndecodedExchangeResult extends ExchangeResult { + + private static class UndecodedExchangeResult extends ExchangeResult { private final ClientResponse response; + private final Duration timeout; - public UndecodedExchangeResult(ExchangeResult result, ClientResponse response) { + + UndecodedExchangeResult(ExchangeResult result, ClientResponse response, Duration timeout) { super(result); this.response = response; + this.timeout = timeout; } - public EntityExchangeResult consumeSingle(ResolvableType elementType) { - Object body = this.response.body(toMono(elementType)).block(getTimeout()); - return new EntityExchangeResult<>(this, body); - } - - public EntityExchangeResult> consumeList(ResolvableType elementType, int count) { - Flux flux = this.response.body(toFlux(elementType)); - if (count >= 0) { - flux = flux.take(count); - } - List body = flux.collectList().block(getTimeout()); - return new EntityExchangeResult<>(this, body); - } - - public FluxExchangeResult decodeBody(ResolvableType elementType) { - Flux body = this.response.body(toFlux(elementType)); - return new FluxExchangeResult<>(this, body, getTimeout()); - } - @SuppressWarnings("unchecked") - public EntityExchangeResult> consumeMap(ResolvableType keyType, ResolvableType valueType) { - ResolvableType mapType = ResolvableType.forClassWithGenerics(Map.class, keyType, valueType); - return (EntityExchangeResult>) consumeSingle(mapType); + public EntityExchangeResult decode(ResolvableType bodyType) { + T body = (T) this.response.body(toMono(bodyType)).block(this.timeout); + return new EntityExchangeResult<>(this, body); } - public EntityExchangeResult consumeEmpty() { - DataBuffer buffer = this.response.body(toDataBuffers()).blockFirst(getTimeout()); + public EntityExchangeResult> decodeToList(ResolvableType elementType) { + Flux flux = this.response.body(toFlux(elementType)); + List body = flux.collectList().block(this.timeout); + return new EntityExchangeResult<>(this, body); + } + + public FluxExchangeResult decodeToFlux(ResolvableType elementType) { + Flux body = this.response.body(toFlux(elementType)); + return new FluxExchangeResult<>(this, body, this.timeout); + } + + public EntityExchangeResult decodeToEmpty() { + DataBuffer buffer = this.response.body(toDataBuffers()).blockFirst(this.timeout); assertWithDiagnostics(() -> assertTrue("Expected empty body", buffer == null)); return new EntityExchangeResult<>(this, null); } } - private class DefaultResponseSpec implements ResponseSpec { + + private static class DefaultResponseSpec implements ResponseSpec { private final UndecodedExchangeResult result; - public DefaultResponseSpec(ExchangeResult result, ClientResponse response) { - this.result = new UndecodedExchangeResult(result, response); + DefaultResponseSpec(ExchangeResult result, ClientResponse response, Duration timeout) { + this.result = new UndecodedExchangeResult(result, response, timeout); } @Override @@ -360,210 +354,133 @@ class DefaultWebTestClient implements WebTestClient { } @Override - public TypeBodySpec expectBody(Class elementType) { - return expectBody(ResolvableType.forClass(elementType)); + public BodySpec expectBody(Class bodyType) { + return expectBody(ResolvableType.forClass(bodyType)); } @Override - public TypeBodySpec expectBody(ResolvableType elementType) { - return new DefaultTypeBodySpec(this.result, elementType); + public BodySpec expectBody(ResolvableType bodyType) { + return new DefaultBodySpec<>(this.result.decode(bodyType)); } @Override - public BodySpec expectBody() { - return new DefaultBodySpec(this.result); + public ListBodySpec expectBodyList(Class elementType) { + return expectBodyList(ResolvableType.forClass(elementType)); + } + + @Override + public ListBodySpec expectBodyList(ResolvableType elementType) { + return new DefaultListBodySpec<>(this.result.decodeToList(elementType)); + } + + @Override + public BodyContentSpec expectBody() { + return new DefaultBodyContentSpec(this.result); + } + + @Override + public FluxExchangeResult returnResult(Class elementType) { + return returnResult(ResolvableType.forClass(elementType)); + } + + @Override + public FluxExchangeResult returnResult(ResolvableType elementType) { + return this.result.decodeToFlux(elementType); } } - private class DefaultTypeBodySpec implements TypeBodySpec { + + private static class DefaultBodySpec> implements BodySpec { + + private final EntityExchangeResult result; + + + DefaultBodySpec(EntityExchangeResult result) { + this.result = result; + } + + + protected EntityExchangeResult getResult() { + return this.result; + } + + @Override + public T isEqualTo(B expected) { + Object actual = this.result.getResponseBody(); + this.result.assertWithDiagnostics(() -> assertEquals("Response body", expected, actual)); + return self(); + } + + @SuppressWarnings("unchecked") + private T self() { + return (T) this; + } + + @Override + public EntityExchangeResult returnResult() { + return this.result; + } + } + + + private static class DefaultListBodySpec extends DefaultBodySpec, ListBodySpec> + implements ListBodySpec { + + + DefaultListBodySpec(EntityExchangeResult> result) { + super(result); + } + + + @Override + public ListBodySpec hasSize(int size) { + List actual = getResult().getResponseBody(); + String message = "Response body does not contain " + size + " elements"; + getResult().assertWithDiagnostics(() -> assertEquals(message, size, actual.size())); + return this; + } + + @Override + @SuppressWarnings("unchecked") + public ListBodySpec contains(E... elements) { + List expected = Arrays.asList(elements); + List actual = getResult().getResponseBody(); + String message = "Response body does not contain " + expected; + getResult().assertWithDiagnostics(() -> assertTrue(message, actual.containsAll(expected))); + return this; + } + + @Override + @SuppressWarnings("unchecked") + public ListBodySpec doesNotContain(E... elements) { + List expected = Arrays.asList(elements); + List actual = getResult().getResponseBody(); + String message = "Response body should have contained " + expected; + getResult().assertWithDiagnostics(() -> assertTrue(message, !actual.containsAll(expected))); + return this; + } + + @Override + @SuppressWarnings("unchecked") + public EntityExchangeResult> returnResult() { + return getResult(); + } + } + + + private static class DefaultBodyContentSpec implements BodyContentSpec { private final UndecodedExchangeResult result; - private final ResolvableType elementType; - - public DefaultTypeBodySpec(UndecodedExchangeResult result, ResolvableType elementType) { + DefaultBodyContentSpec(UndecodedExchangeResult result) { this.result = result; - this.elementType = elementType; - } - - - @Override - public SingleValueBodySpec value() { - return new DefaultSingleValueBodySpec(this.result.consumeSingle(this.elementType)); - } - - @Override - public ListBodySpec list() { - return list(-1); - } - - @Override - public ListBodySpec list(int count) { - return new DefaultListBodySpec(this.result.consumeList(this.elementType, count)); - } - - @Override - public FluxExchangeResult returnResult() { - return this.result.decodeBody(this.elementType); - } - } - - private class DefaultSingleValueBodySpec implements SingleValueBodySpec { - - private final EntityExchangeResult result; - - - public DefaultSingleValueBodySpec(EntityExchangeResult result) { - this.result = result; - } - - - @Override - public EntityExchangeResult isEqualTo(T expected) { - Object actual = this.result.getResponseBody(); - this.result.assertWithDiagnostics(() -> assertEquals("Response body", expected, actual)); - return returnResult(); - } - - @SuppressWarnings("unchecked") - @Override - public EntityExchangeResult returnResult() { - return new EntityExchangeResult<>(this.result, (T) this.result.getResponseBody()); - } - } - - private class DefaultListBodySpec implements ListBodySpec { - - private final EntityExchangeResult> result; - - - public DefaultListBodySpec(EntityExchangeResult> result) { - this.result = result; - } - - - @Override - public EntityExchangeResult> isEqualTo(List expected) { - List actual = this.result.getResponseBody(); - this.result.assertWithDiagnostics(() -> assertEquals("Response body", expected, actual)); - return returnResult(); - } - - @Override - public ListBodySpec hasSize(int size) { - List actual = this.result.getResponseBody(); - String message = "Response body does not contain " + size + " elements"; - this.result.assertWithDiagnostics(() -> assertEquals(message, size, actual.size())); - return this; - } - - @Override - public ListBodySpec contains(Object... elements) { - List expected = Arrays.asList(elements); - List actual = this.result.getResponseBody(); - String message = "Response body does not contain " + expected; - this.result.assertWithDiagnostics(() -> assertTrue(message, actual.containsAll(expected))); - return this; - } - - @Override - public ListBodySpec doesNotContain(Object... elements) { - List expected = Arrays.asList(elements); - List actual = this.result.getResponseBody(); - String message = "Response body should have contained " + expected; - this.result.assertWithDiagnostics(() -> assertTrue(message, !actual.containsAll(expected))); - return this; - } - - @Override - @SuppressWarnings("unchecked") - public EntityExchangeResult> returnResult() { - return new EntityExchangeResult<>(this.result, (List) this.result.getResponseBody()); - } - } - - private class DefaultBodySpec implements BodySpec { - - private final UndecodedExchangeResult exchangeResult; - - - public DefaultBodySpec(UndecodedExchangeResult result) { - this.exchangeResult = result; } @Override public EntityExchangeResult isEmpty() { - return this.exchangeResult.consumeEmpty(); - } - - @Override - public MapBodySpec map(Class keyType, Class valueType) { - return map(ResolvableType.forClass(keyType), ResolvableType.forClass(valueType)); - } - - @Override - public MapBodySpec map(ResolvableType keyType, ResolvableType valueType) { - return new DefaultMapBodySpec(this.exchangeResult.consumeMap(keyType, valueType)); - } - } - - private class DefaultMapBodySpec implements MapBodySpec { - - private final EntityExchangeResult> result; - - - public DefaultMapBodySpec(EntityExchangeResult> result) { - this.result = result; - } - - - private Map getBody() { - return this.result.getResponseBody(); - } - - @Override - public EntityExchangeResult> isEqualTo(Map expected) { - String message = "Response body map"; - this.result.assertWithDiagnostics(() -> assertEquals(message, expected, getBody())); - return returnResult(); - } - - @Override - public MapBodySpec hasSize(int size) { - String message = "Response body map size"; - this.result.assertWithDiagnostics(() -> assertEquals(message, size, getBody().size())); - return this; - } - - @Override - public MapBodySpec contains(Object key, Object value) { - String message = "Response body map value for key " + key; - this.result.assertWithDiagnostics(() -> assertEquals(message, value, getBody().get(key))); - return this; - } - - @Override - public MapBodySpec containsKeys(Object... keys) { - List missing = Arrays.stream(keys).filter(k -> !getBody().containsKey(k)).collect(toList()); - String message = "Response body map does not contain keys " + missing; - this.result.assertWithDiagnostics(() -> assertTrue(message, missing.isEmpty())); - return this; - } - - @Override - public MapBodySpec containsValues(Object... values) { - List missing = Arrays.stream(values).filter(v -> !getBody().containsValue(v)).collect(toList()); - String message = "Response body map does not contain values " + missing; - this.result.assertWithDiagnostics(() -> assertTrue(message, missing.isEmpty())); - return this; - } - - @Override - @SuppressWarnings("unchecked") - public EntityExchangeResult> returnResult() { - return new EntityExchangeResult<>(this.result, (Map) getBody()); + return this.result.decodeToEmpty(); } } diff --git a/spring-test/src/main/java/org/springframework/test/web/reactive/server/WebTestClient.java b/spring-test/src/main/java/org/springframework/test/web/reactive/server/WebTestClient.java index eb8e0c74d27..aa4ac7d46a4 100644 --- a/spring-test/src/main/java/org/springframework/test/web/reactive/server/WebTestClient.java +++ b/spring-test/src/main/java/org/springframework/test/web/reactive/server/WebTestClient.java @@ -491,177 +491,110 @@ public interface WebTestClient { interface ResponseSpec { /** - * Assertions on the response status. + * Declare expectations on the response status. */ StatusAssertions expectStatus(); /** - * Assertions on the headers of the response. + * Declared expectations on the headers of the response. */ HeaderAssertions expectHeader(); /** - * Assertions on the body of the response extracted to one or more - * representations of the given type. + * Declare expectations on the response body decoded to {@code }. + * @param bodyType the expected body type */ - TypeBodySpec expectBody(Class elementType); + BodySpec expectBody(Class bodyType); /** - * Variant of {@link #expectBody(Class)} for use with generic types. + * Variant of {@link #expectBody(Class)} for a body type with generics. */ - TypeBodySpec expectBody(ResolvableType elementType); + BodySpec expectBody(ResolvableType bodyType); /** - * Other assertions on the response body -- isEmpty, map, etc. + * Declare expectations on the response body decoded to {@code List}. + * @param elementType the expected List element type */ - BodySpec expectBody(); + ListBodySpec expectBodyList(Class elementType); + /** + * Variant of {@link #expectBodyList(Class)} for element types with generics. + */ + ListBodySpec expectBodyList(ResolvableType elementType); + + /** + * Declare expectations on the response body content. + */ + BodyContentSpec expectBody(); + + /** + * Return the exchange result with the body decoded to {@code Flux}. + * Use this option for infinite streams and consume the stream with + * the {@code StepVerifier} from the Reactor Add-Ons. + * + * @see + * https://github.com/reactor/reactor-addons + */ + FluxExchangeResult returnResult(Class elementType); + + /** + * Variant of {@link #returnResult(Class)} for element types with generics. + */ + FluxExchangeResult returnResult(ResolvableType elementType); } /** - * Specification for extracting entities from the response body. + * Specification for asserting a response body decoded to a single Object. */ - interface TypeBodySpec { - - /** - * Extract a single representations from the response. - */ - SingleValueBodySpec value(); - - /** - * Extract a list of representations from the response. - */ - ListBodySpec list(); - - /** - * Extract a list of representations consuming the first N elements. - */ - ListBodySpec list(int elementCount); - - /** - * Return request and response details for the exchange incluidng the - * response body decoded as {@code Flux} where {@code } is the - * expected element type. The returned {@code Flux} may for example be - * verified with the Reactor {@code StepVerifier}. - */ - FluxExchangeResult returnResult(); - } - - /** - * Specification to assert a single value extracted from the response body. - */ - interface SingleValueBodySpec { + interface BodySpec> { /** * Assert the extracted body is equal to the given value. */ - EntityExchangeResult isEqualTo(T expected); + T isEqualTo(B expected); /** - * Return request and response details for the exchange including the - * extracted response body. + * Return the exchange result with the decoded body. */ - EntityExchangeResult returnResult(); + EntityExchangeResult returnResult(); + } /** - * Specification to assert a list of values extracted from the response. + * Specification for asserting a response body decoded to a List. */ - interface ListBodySpec { - - /** - * Assert the extracted body is equal to the given list. - */ - EntityExchangeResult> isEqualTo(List expected); + interface ListBodySpec extends BodySpec, ListBodySpec> { /** * Assert the extracted list of values is of the given size. * @param size the expected size */ - ListBodySpec hasSize(int size); + ListBodySpec hasSize(int size); /** * Assert the extracted list of values contains the given elements. * @param elements the elements to check */ - ListBodySpec contains(Object... elements); + @SuppressWarnings("unchecked") + ListBodySpec contains(E... elements); /** * Assert the extracted list of values doesn't contain the given elements. * @param elements the elements to check */ - ListBodySpec doesNotContain(Object... elements); + @SuppressWarnings("unchecked") + ListBodySpec doesNotContain(E... elements); - /** - * Return request and response details for the exchange including the - * extracted response body. - */ - EntityExchangeResult> returnResult(); } - /** - * Specification to apply additional assertions on the response body. - */ - interface BodySpec { + interface BodyContentSpec { /** * Consume the body and verify it is empty. - * @return request and response details from the exchange + * @return the exchange result */ EntityExchangeResult isEmpty(); - /** - * Extract the response body as a Map with the given key and value type. - */ - MapBodySpec map(Class keyType, Class valueType); - - /** - * Variant of {@link #map(Class, Class)} for use with generic types. - */ - MapBodySpec map(ResolvableType keyType, ResolvableType valueType); - - } - - /** - * Specification to assert response the body extracted as a map. - */ - interface MapBodySpec { - - /** - * Assert the extracted map is equal to the given list of elements. - */ - EntityExchangeResult> isEqualTo(Map expected); - - /** - * Assert the extracted map has the given size. - * @param size the expected size - */ - MapBodySpec hasSize(int size); - - /** - * Assert the extracted map contains the given key value pair. - * @param key the key to check - * @param value the value to check - */ - MapBodySpec contains(Object key, Object value); - - /** - * Assert the extracted map contains the given keys. - * @param keys the keys to check - */ - MapBodySpec containsKeys(Object... keys); - - /** - * Assert the extracted map contains the given values. - * @param values the keys to check - */ - MapBodySpec containsValues(Object... values); - - /** - * Return request and response details for the exchange including the - * extracted response body. - */ - EntityExchangeResult> returnResult(); } } diff --git a/spring-test/src/test/java/org/springframework/test/web/reactive/server/DefaultControllerSpecTests.java b/spring-test/src/test/java/org/springframework/test/web/reactive/server/DefaultControllerSpecTests.java index d267367f03b..e0ea8701497 100644 --- a/spring-test/src/test/java/org/springframework/test/web/reactive/server/DefaultControllerSpecTests.java +++ b/spring-test/src/test/java/org/springframework/test/web/reactive/server/DefaultControllerSpecTests.java @@ -38,7 +38,7 @@ public class DefaultControllerSpecTests { .get().uri("/") .exchange() .expectStatus().isOk() - .expectBody(String.class).value().isEqualTo("Success"); + .expectBody(String.class).isEqualTo("Success"); } @Test @@ -49,7 +49,7 @@ public class DefaultControllerSpecTests { .get().uri("/exception") .exchange() .expectStatus().isBadRequest() - .expectBody(String.class).value().isEqualTo("Handled exception"); + .expectBody(String.class).isEqualTo("Handled exception"); } diff --git a/spring-test/src/test/java/org/springframework/test/web/reactive/server/samples/ResponseEntityTests.java b/spring-test/src/test/java/org/springframework/test/web/reactive/server/samples/ResponseEntityTests.java index 01b754aae85..ad8a857374c 100644 --- a/spring-test/src/test/java/org/springframework/test/web/reactive/server/samples/ResponseEntityTests.java +++ b/spring-test/src/test/java/org/springframework/test/web/reactive/server/samples/ResponseEntityTests.java @@ -40,9 +40,10 @@ import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -import static java.time.Duration.*; +import static java.time.Duration.ofMillis; import static org.hamcrest.CoreMatchers.endsWith; -import static org.junit.Assert.*; +import static org.junit.Assert.assertThat; +import static org.springframework.core.ResolvableType.forClassWithGenerics; import static org.springframework.http.MediaType.TEXT_EVENT_STREAM; /** @@ -62,7 +63,7 @@ public class ResponseEntityTests { .exchange() .expectStatus().isOk() .expectHeader().contentType(MediaType.APPLICATION_JSON_UTF8) - .expectBody(Person.class).value().isEqualTo(new Person("John")); + .expectBody(Person.class).isEqualTo(new Person("John")); } @Test @@ -75,7 +76,7 @@ public class ResponseEntityTests { .exchange() .expectStatus().isOk() .expectHeader().contentType(MediaType.APPLICATION_JSON_UTF8) - .expectBody(Person.class).list().isEqualTo(expected); + .expectBodyList(Person.class).isEqualTo(expected); } @Test @@ -89,8 +90,7 @@ public class ResponseEntityTests { this.client.get().uri("/persons?map=true") .exchange() .expectStatus().isOk() - .expectBody() - .map(String.class, Person.class).isEqualTo(map); + .expectBody(forClassWithGenerics(Map.class, String.class, Person.class)).isEqualTo(map); } @Test @@ -102,8 +102,7 @@ public class ResponseEntityTests { .exchange() .expectStatus().isOk() .expectHeader().contentType(TEXT_EVENT_STREAM) - .expectBody(Person.class) - .returnResult(); + .returnResult(Person.class); StepVerifier.create(result.getResponseBody()) .expectNext(new Person("N0"), new Person("N1"), new Person("N2")) @@ -126,6 +125,7 @@ public class ResponseEntityTests { @RestController @RequestMapping("/persons") + @SuppressWarnings("unused") static class PersonController { @GetMapping("/{name}") diff --git a/spring-test/src/test/java/org/springframework/test/web/reactive/server/samples/bind/ApplicationContextTests.java b/spring-test/src/test/java/org/springframework/test/web/reactive/server/samples/bind/ApplicationContextTests.java index fca4e4406c6..7891cd4084b 100644 --- a/spring-test/src/test/java/org/springframework/test/web/reactive/server/samples/bind/ApplicationContextTests.java +++ b/spring-test/src/test/java/org/springframework/test/web/reactive/server/samples/bind/ApplicationContextTests.java @@ -63,7 +63,7 @@ public class ApplicationContextTests { this.client.get().uri("/principal") .exchange() .expectStatus().isOk() - .expectBody(String.class).value().isEqualTo("Hello Mr. Pablo!"); + .expectBody(String.class).isEqualTo("Hello Mr. Pablo!"); } @Test @@ -72,7 +72,7 @@ public class ApplicationContextTests { .get().uri("/principal") .exchange() .expectStatus().isOk() - .expectBody(String.class).value().isEqualTo("Hello Mr. Giovanni!"); + .expectBody(String.class).isEqualTo("Hello Mr. Giovanni!"); } @Test @@ -83,7 +83,7 @@ public class ApplicationContextTests { .get().uri("/attributes") .exchange() .expectStatus().isOk() - .expectBody(String.class).value().isEqualTo("foo+bar"); + .expectBody(String.class).isEqualTo("foo+bar"); } diff --git a/spring-test/src/test/java/org/springframework/test/web/reactive/server/samples/bind/ControllerTests.java b/spring-test/src/test/java/org/springframework/test/web/reactive/server/samples/bind/ControllerTests.java index 6e6ab8dea87..e775d5bc0f2 100644 --- a/spring-test/src/test/java/org/springframework/test/web/reactive/server/samples/bind/ControllerTests.java +++ b/spring-test/src/test/java/org/springframework/test/web/reactive/server/samples/bind/ControllerTests.java @@ -48,7 +48,7 @@ public class ControllerTests { this.client.get().uri("/principal") .exchange() .expectStatus().isOk() - .expectBody(String.class).value().isEqualTo("Hello Mr. Pablo!"); + .expectBody(String.class).isEqualTo("Hello Mr. Pablo!"); } @Test @@ -57,7 +57,7 @@ public class ControllerTests { .get().uri("/principal") .exchange() .expectStatus().isOk() - .expectBody(String.class).value().isEqualTo("Hello Mr. Giovanni!"); + .expectBody(String.class).isEqualTo("Hello Mr. Giovanni!"); } @Test @@ -68,7 +68,7 @@ public class ControllerTests { .get().uri("/attributes") .exchange() .expectStatus().isOk() - .expectBody(String.class).value().isEqualTo("foo+bar"); + .expectBody(String.class).isEqualTo("foo+bar"); } diff --git a/spring-test/src/test/java/org/springframework/test/web/reactive/server/samples/bind/HttpServerTests.java b/spring-test/src/test/java/org/springframework/test/web/reactive/server/samples/bind/HttpServerTests.java index 376b6ebf24a..f8599fc37d5 100644 --- a/spring-test/src/test/java/org/springframework/test/web/reactive/server/samples/bind/HttpServerTests.java +++ b/spring-test/src/test/java/org/springframework/test/web/reactive/server/samples/bind/HttpServerTests.java @@ -71,7 +71,7 @@ public class HttpServerTests { this.client.get().uri("/test") .exchange() .expectStatus().isOk() - .expectBody(String.class).value().isEqualTo("It works!"); + .expectBody(String.class).isEqualTo("It works!"); } } diff --git a/spring-test/src/test/java/org/springframework/test/web/reactive/server/samples/bind/RouterFunctionTests.java b/spring-test/src/test/java/org/springframework/test/web/reactive/server/samples/bind/RouterFunctionTests.java index c5884034ae2..e2d727e04dc 100644 --- a/spring-test/src/test/java/org/springframework/test/web/reactive/server/samples/bind/RouterFunctionTests.java +++ b/spring-test/src/test/java/org/springframework/test/web/reactive/server/samples/bind/RouterFunctionTests.java @@ -52,7 +52,7 @@ public class RouterFunctionTests { this.testClient.get().uri("/test") .exchange() .expectStatus().isOk() - .expectBody(String.class).value().isEqualTo("It works!"); + .expectBody(String.class).isEqualTo("It works!"); } }