Skip to content

Commit d280358

Browse files
committed
Fix typo in HttpHeadersAssert#doesNotContainHeaders
This commit deprecates the existing doesNotContainsHeaders in favor of a newly introduced method that does not have the typo. Closes gh-34263
1 parent e08a7ec commit d280358

File tree

2 files changed

+34
-3
lines changed

2 files changed

+34
-3
lines changed

spring-test/src/main/java/org/springframework/test/http/HttpHeadersAssert.java

+14-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2024 the original author or authors.
2+
* Copyright 2002-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -78,8 +78,21 @@ public HttpHeadersAssert doesNotContainHeader(String name) {
7878
* Verify that the actual HTTP headers do not contain any of the headers
7979
* with the given {@code names}.
8080
* @param names the names of HTTP headers that should not be present
81+
* @since 6.2.2
8182
* @see #doesNotContainKeys
8283
*/
84+
public HttpHeadersAssert doesNotContainHeaders(String... names) {
85+
return doesNotContainKeys(names);
86+
}
87+
88+
/**
89+
* Verify that the actual HTTP headers do not contain any of the headers
90+
* with the given {@code names}.
91+
* @param names the names of HTTP headers that should not be present
92+
* @see #doesNotContainKeys
93+
* @deprecated in favor of {@link #doesNotContainHeaders(String...)}
94+
*/
95+
@Deprecated(since = "6.2.2", forRemoval = true)
8396
public HttpHeadersAssert doesNotContainsHeaders(String... names) {
8497
return doesNotContainKeys(names);
8598
}

spring-test/src/test/java/org/springframework/test/http/HttpHeadersAssertTests.java

+20-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2024 the original author or authors.
2+
* Copyright 2002-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -78,11 +78,29 @@ void doesNotContainHeaderWithNamePresent() {
7878
@Test
7979
void doesNotContainHeaders() {
8080
assertThat(Map.of("first", "1", "third", "3"))
81-
.doesNotContainsHeaders("second", "fourth");
81+
.doesNotContainHeaders("second", "fourth");
8282
}
8383

8484
@Test
8585
void doesNotContainHeadersWithSeveralNamesPresent() {
86+
Map<String, String> map = Map.of("first", "1", "second", "2", "third", "3");
87+
assertThatExceptionOfType(AssertionError.class)
88+
.isThrownBy(() -> assertThat(map).doesNotContainHeaders("first", "another-wrong-name", "second"))
89+
.withMessageContainingAll("HTTP headers", "first", "second");
90+
}
91+
92+
@Test
93+
@Deprecated(forRemoval = true)
94+
@SuppressWarnings("removal")
95+
void doesNotContainHeadersWithDeprecatedMethod() {
96+
assertThat(Map.of("first", "1", "third", "3"))
97+
.doesNotContainsHeaders("second", "fourth");
98+
}
99+
100+
@Test
101+
@Deprecated(forRemoval = true)
102+
@SuppressWarnings("removal")
103+
void doesNotContainHeadersWithSeveralNamesPresentWithDeprecatedMethod() {
86104
Map<String, String> map = Map.of("first", "1", "second", "2", "third", "3");
87105
assertThatExceptionOfType(AssertionError.class)
88106
.isThrownBy(() -> assertThat(map).doesNotContainsHeaders("first", "another-wrong-name", "second"))

0 commit comments

Comments
 (0)