From d280358e98aebe5cabf6d1a15ab20aee0ef337af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Nicoll?= Date: Wed, 15 Jan 2025 11:17:33 +0100 Subject: [PATCH] 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 --- .../test/http/HttpHeadersAssert.java | 15 ++++++++++++- .../test/http/HttpHeadersAssertTests.java | 22 +++++++++++++++++-- 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/spring-test/src/main/java/org/springframework/test/http/HttpHeadersAssert.java b/spring-test/src/main/java/org/springframework/test/http/HttpHeadersAssert.java index a03bda4bc2b..7e43b42f191 100644 --- a/spring-test/src/main/java/org/springframework/test/http/HttpHeadersAssert.java +++ b/spring-test/src/main/java/org/springframework/test/http/HttpHeadersAssert.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -78,8 +78,21 @@ public class HttpHeadersAssert extends AbstractMapAssert map = Map.of("first", "1", "second", "2", "third", "3"); + assertThatExceptionOfType(AssertionError.class) + .isThrownBy(() -> assertThat(map).doesNotContainHeaders("first", "another-wrong-name", "second")) + .withMessageContainingAll("HTTP headers", "first", "second"); + } + + @Test + @Deprecated(forRemoval = true) + @SuppressWarnings("removal") + void doesNotContainHeadersWithDeprecatedMethod() { + assertThat(Map.of("first", "1", "third", "3")) + .doesNotContainsHeaders("second", "fourth"); + } + + @Test + @Deprecated(forRemoval = true) + @SuppressWarnings("removal") + void doesNotContainHeadersWithSeveralNamesPresentWithDeprecatedMethod() { Map map = Map.of("first", "1", "second", "2", "third", "3"); assertThatExceptionOfType(AssertionError.class) .isThrownBy(() -> assertThat(map).doesNotContainsHeaders("first", "another-wrong-name", "second"))