Skip to content

Commit 6d82458

Browse files
committed
Polishing contribution
Fixes gh-35659
1 parent 8a6576e commit 6d82458

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

spring-web/src/test/java/org/springframework/http/HttpStatusTests.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@
2828
import static org.assertj.core.api.Assertions.assertThat;
2929

3030
/**
31+
* Tests for {@link HttpStatus}.
3132
* @author Arjen Poutsma
33+
* @author Brian Clozel
3234
*/
3335
class HttpStatusTests {
3436

@@ -109,12 +111,18 @@ void createStatusCodes() {
109111

110112

111113
@Test
112-
void fromMapToEnum() {
114+
void fromMapToEnum() throws Exception {
113115
for (Map.Entry<Integer, List<String>> entry : statusCodes.entrySet()) {
114116
int value = entry.getKey();
115117
HttpStatus status = HttpStatus.valueOf(value);
116118
assertThat(status.value()).as("Invalid value").isEqualTo(value);
117119
assertThat(entry.getValue()).as("Invalid name for [" + value + "]").contains(status.name());
120+
Deprecated deprecatedAnnotation = HttpStatus.class.getField(status.name()).getAnnotation(Deprecated.class);
121+
if (deprecatedAnnotation != null) {
122+
assertThat(statusCodes.get(entry.getKey()))
123+
.as("Should not resolve deprecated enum value when non-deprecated exists")
124+
.hasSize(1);
125+
}
118126
}
119127
}
120128

0 commit comments

Comments
 (0)