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 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