From bb51447860113f2c17d5e8d4df22c0ca1817b8f3 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Wed, 22 Jul 2015 16:46:13 +0200 Subject: [PATCH] Fix typos in RequestResultMatchers --- .../servlet/result/RequestResultMatchers.java | 30 +++++++++++-------- 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/spring-test/src/main/java/org/springframework/test/web/servlet/result/RequestResultMatchers.java b/spring-test/src/main/java/org/springframework/test/web/servlet/result/RequestResultMatchers.java index 10456759bb..f40e5209fa 100644 --- a/spring-test/src/main/java/org/springframework/test/web/servlet/result/RequestResultMatchers.java +++ b/spring-test/src/main/java/org/springframework/test/web/servlet/result/RequestResultMatchers.java @@ -36,23 +36,23 @@ import static org.springframework.test.util.AssertionErrors.*; * {@link MockMvcResultMatchers#request}. * * @author Rossen Stoyanchev + * @author Sam Brannen * @since 3.2 */ public class RequestResultMatchers { /** * Protected constructor. - * Use {@link MockMvcResultMatchers#request()}. + *

Use {@link MockMvcResultMatchers#request()}. */ protected RequestResultMatchers() { } /** - * Assert a request attribute value with the given Hamcrest {@link Matcher}. - * Whether asynchronous processing started, usually as a result of a + * Assert whether asynchronous processing started, usually as a result of a * controller method returning {@link Callable} or {@link DeferredResult}. - * The test will await the completion of a {@code Callable} so that + *

The test will await the completion of a {@code Callable} so that * {@link #asyncResult(Matcher)} can be used to assert the resulting value. * Neither a {@code Callable} nor a {@code DeferredResult} will complete * processing all the way since a {@link MockHttpServletRequest} does not @@ -63,13 +63,13 @@ public class RequestResultMatchers { @Override public void match(MvcResult result) { HttpServletRequest request = result.getRequest(); - assertEquals("Async started", true, request.isAsyncStarted()); + assertAsyncStarted(request); } }; } /** - * Assert that asynchronous processing was not start. + * Assert that asynchronous processing was not started. * @see #asyncStarted() */ public ResultMatcher asyncNotStarted() { @@ -84,6 +84,8 @@ public class RequestResultMatchers { /** * Assert the result from asynchronous processing with the given matcher. + *

This method can be used when a controller method returns {@link Callable} + * or {@link WebAsyncTask}. */ public ResultMatcher asyncResult(final Matcher matcher) { return new ResultMatcher() { @@ -91,7 +93,7 @@ public class RequestResultMatchers { @SuppressWarnings("unchecked") public void match(MvcResult result) { HttpServletRequest request = result.getRequest(); - assertEquals("Async started", true, request.isAsyncStarted()); + assertAsyncStarted(request); assertThat("Async result", (T) result.getAsyncResult(), matcher); } }; @@ -99,7 +101,7 @@ public class RequestResultMatchers { /** * Assert the result from asynchronous processing. - * This method can be used when a controller method returns {@link Callable} + *

This method can be used when a controller method returns {@link Callable} * or {@link WebAsyncTask}. The value matched is the value returned from the * {@code Callable} or the exception raised. */ @@ -108,7 +110,7 @@ public class RequestResultMatchers { @Override public void match(MvcResult result) { HttpServletRequest request = result.getRequest(); - assertEquals("Async started", true, request.isAsyncStarted()); + assertAsyncStarted(request); assertEquals("Async result", expectedResult, result.getAsyncResult()); } }; @@ -149,21 +151,25 @@ public class RequestResultMatchers { @SuppressWarnings("unchecked") public void match(MvcResult result) { T value = (T) result.getRequest().getSession().getAttribute(name); - assertThat("Request attribute", value, matcher); + assertThat("Session attribute", value, matcher); } }; } /** - * Assert a session attribute value.. + * Assert a session attribute value. */ public ResultMatcher sessionAttribute(final String name, final Object value) { return new ResultMatcher() { @Override public void match(MvcResult result) { - assertEquals("Request attribute", value, result.getRequest().getSession().getAttribute(name)); + assertEquals("Session attribute", value, result.getRequest().getSession().getAttribute(name)); } }; } + private static void assertAsyncStarted(HttpServletRequest request) { + assertEquals("Async started", true, request.isAsyncStarted()); + } + } -- GitLab