提交 27aaad5a 编写于 作者: J Juergen Hoeller

Add isTooEarly() method to StatusResultMatchers

See gh-23384
上级 4f3b89e9
......@@ -492,6 +492,14 @@ public class StatusResultMatchers {
return matcher(HttpStatus.FAILED_DEPENDENCY);
}
/**
* Assert the response status code is {@code HttpStatus.TOO_EARLY} (425).
* @since 5.2
*/
public ResultMatcher isTooEarly() {
return matcher(HttpStatus.valueOf(425));
}
/**
* Assert the response status code is {@code HttpStatus.UPGRADE_REQUIRED} (426).
*/
......
......@@ -20,7 +20,6 @@ import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
import org.junit.Before;
import org.junit.Test;
import org.springframework.core.Conventions;
......@@ -42,23 +41,14 @@ import static org.assertj.core.api.Assertions.fail;
*/
public class StatusResultMatchersTests {
private StatusResultMatchers matchers;
private final StatusResultMatchers matchers = new StatusResultMatchers();
private MockHttpServletRequest request;
@Before
public void setup() {
this.matchers = new StatusResultMatchers();
this.request = new MockHttpServletRequest();
}
private final MockHttpServletRequest request = new MockHttpServletRequest();
@Test
public void testHttpStatusCodeResultMatchers() throws Exception {
List<AssertionError> failures = new ArrayList<>();
for (HttpStatus status : HttpStatus.values()) {
MockHttpServletResponse response = new MockHttpServletResponse();
response.setStatus(status.value());
......@@ -77,7 +67,6 @@ public class StatusResultMatchersTests {
throw new Exception("Failed to obtain ResultMatcher for status " + status, ex);
}
}
if (!failures.isEmpty()) {
fail("Failed status codes: " + failures);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册