Skip to content

Commit 79b5710

Browse files
MichalStehlikCzjhoeller
authored andcommitted
StatusAssertion value methods fail when used with custom status code
1 parent b2bcb0f commit 79b5710

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

spring-test/src/main/java/org/springframework/test/web/reactive/server/StatusAssertions.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ public WebTestClient.ResponseSpec is5xxServerError() {
205205
* @since 5.1
206206
*/
207207
public WebTestClient.ResponseSpec value(Matcher<? super Integer> matcher) {
208-
int value = this.exchangeResult.getStatus().value();
208+
int value = this.exchangeResult.getRawStatusCode();
209209
this.exchangeResult.assertWithDiagnostics(() -> MatcherAssert.assertThat("Response status", value, matcher));
210210
return this.responseSpec;
211211
}
@@ -216,7 +216,7 @@ public WebTestClient.ResponseSpec value(Matcher<? super Integer> matcher) {
216216
* @since 5.1
217217
*/
218218
public WebTestClient.ResponseSpec value(Consumer<Integer> consumer) {
219-
int value = this.exchangeResult.getStatus().value();
219+
int value = this.exchangeResult.getRawStatusCode();
220220
this.exchangeResult.assertWithDiagnostics(() -> consumer.accept(value));
221221
return this.responseSpec;
222222
}

spring-test/src/test/java/org/springframework/test/web/reactive/server/StatusAssertionTests.java

+4
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,10 @@ void matches() {
147147
assertions.value(equalTo(200)));
148148
}
149149

150+
@Test
151+
void matchesWithCustomStatus() {
152+
statusAssertions(600).value(equalTo(600));
153+
}
150154

151155
private StatusAssertions statusAssertions(HttpStatus status) {
152156
return statusAssertions(status.value());

0 commit comments

Comments
 (0)