本文整理汇总了Java中org.springframework.test.web.servlet.ResultMatcher.match方法的典型用法代码示例。如果您正苦于以下问题:Java ResultMatcher.match方法的具体用法?Java ResultMatcher.match怎么用?Java ResultMatcher.match使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.test.web.servlet.ResultMatcher
的用法示例。
在下文中一共展示了ResultMatcher.match方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: allOf
import org.springframework.test.web.servlet.ResultMatcher; //导入方法依赖的package包/类
private static ResultMatcher allOf(final ResultMatcher... matchers) throws Exception {
return (result) -> {
for (ResultMatcher m : matchers) {
m.match(result);
}
};
}
示例2: testHttpStatusCodeResultMatchers
import org.springframework.test.web.servlet.ResultMatcher; //导入方法依赖的package包/类
@Test
public void testHttpStatusCodeResultMatchers() throws Exception {
List<AssertionError> failures = new ArrayList<AssertionError>();
for(HttpStatus status : HttpStatus.values()) {
MockHttpServletResponse response = new MockHttpServletResponse();
response.setStatus(status.value());
MvcResult mvcResult = new StubMvcResult(request, null, null, null, null, null, response);
try {
Method method = getMethodForHttpStatus(status);
ResultMatcher matcher = (ResultMatcher) ReflectionUtils.invokeMethod(method, this.matchers);
try {
matcher.match(mvcResult);
}
catch (AssertionError error) {
failures.add(error);
}
}
catch (Exception ex) {
throw new Exception("Failed to obtain ResultMatcher for status " + status, ex);
}
}
if (!failures.isEmpty()) {
fail("Failed status codes: " + failures);
}
}
示例3: match
import org.springframework.test.web.servlet.ResultMatcher; //导入方法依赖的package包/类
@Override
public void match(MvcResult result) throws Exception {
for (ResultMatcher matcher : matchers) {
matcher.match(result);
}
}