use of org.springframework.test.web.servlet.MvcResult in project spring-framework by spring-projects.
the class RequestResultMatchers method asyncNotStarted.
/**
* Assert that asynchronous processing was not started.
* @see #asyncStarted()
*/
public ResultMatcher asyncNotStarted() {
return new ResultMatcher() {
@Override
public void match(MvcResult result) {
HttpServletRequest request = result.getRequest();
assertEquals("Async started", false, request.isAsyncStarted());
}
};
}
use of org.springframework.test.web.servlet.MvcResult in project spring-framework by spring-projects.
the class RequestResultMatchers method asyncResult.
/**
* Assert the result from asynchronous processing with the given matcher.
* <p>This method can be used when a controller method returns {@link Callable}
* or {@link WebAsyncTask}.
*/
public <T> ResultMatcher asyncResult(final Matcher<T> matcher) {
return new ResultMatcher() {
@Override
@SuppressWarnings("unchecked")
public void match(MvcResult result) {
HttpServletRequest request = result.getRequest();
assertAsyncStarted(request);
assertThat("Async result", (T) result.getAsyncResult(), matcher);
}
};
}
use of org.springframework.test.web.servlet.MvcResult in project spring-framework by spring-projects.
the class ViewResultMatchers method name.
/**
* Assert the selected view name.
*/
public ResultMatcher name(final String expectedViewName) {
return new ResultMatcher() {
@Override
public void match(MvcResult result) throws Exception {
ModelAndView mav = result.getModelAndView();
assertTrue("No ModelAndView found", mav != null);
assertEquals("View name", expectedViewName, mav.getViewName());
}
};
}
use of org.springframework.test.web.servlet.MvcResult in project spring-framework by spring-projects.
the class XpathResultMatchers method number.
/**
* Evaluate the XPath and assert the {@link Double} value found with the
* given Hamcrest {@link Matcher}.
*/
public ResultMatcher number(final Matcher<? super Double> matcher) {
return new ResultMatcher() {
@Override
public void match(MvcResult result) throws Exception {
MockHttpServletResponse response = result.getResponse();
xpathHelper.assertNumber(response.getContentAsByteArray(), getDefinedEncoding(response), matcher);
}
};
}
use of org.springframework.test.web.servlet.MvcResult in project spring-framework by spring-projects.
the class XpathResultMatchers method doesNotExist.
/**
* Evaluate the XPath and assert that content doesn't exist.
*/
public ResultMatcher doesNotExist() {
return new ResultMatcher() {
@Override
public void match(MvcResult result) throws Exception {
MockHttpServletResponse response = result.getResponse();
xpathHelper.doesNotExist(response.getContentAsByteArray(), getDefinedEncoding(response));
}
};
}
Aggregations