From e5b58effa3b74569ca6d3b091fa44f47bdc6ccea Mon Sep 17 00:00:00 2001 From: Sam Brannen <104798+sbrannen@users.noreply.github.com> Date: Thu, 4 Sep 2025 14:26:56 +0200 Subject: [PATCH] Deprecate put(MergedContextConfiguration, ApplicationContext) in ContextCache Closes gh-35415 --- .../org/springframework/test/context/cache/ContextCache.java | 3 +++ .../test/context/cache/DefaultContextCache.java | 1 + .../test/context/cache/LruContextCacheTests.java | 1 + 3 files changed, 5 insertions(+) diff --git a/spring-test/src/main/java/org/springframework/test/context/cache/ContextCache.java b/spring-test/src/main/java/org/springframework/test/context/cache/ContextCache.java index 66528de3ead..260e8b60b17 100644 --- a/spring-test/src/main/java/org/springframework/test/context/cache/ContextCache.java +++ b/spring-test/src/main/java/org/springframework/test/context/cache/ContextCache.java @@ -116,7 +116,10 @@ public interface ContextCache { * @param context the {@code ApplicationContext}; never {@code null} * @see #get(MergedContextConfiguration) * @see #put(MergedContextConfiguration, LoadFunction) + * @deprecated since Spring Framework 7.0 in favor of + * {@link #put(MergedContextConfiguration, LoadFunction)} */ + @Deprecated(since = "7.0") void put(MergedContextConfiguration key, ApplicationContext context); /** diff --git a/spring-test/src/main/java/org/springframework/test/context/cache/DefaultContextCache.java b/spring-test/src/main/java/org/springframework/test/context/cache/DefaultContextCache.java index b00c261393b..3b102fa4e3d 100644 --- a/spring-test/src/main/java/org/springframework/test/context/cache/DefaultContextCache.java +++ b/spring-test/src/main/java/org/springframework/test/context/cache/DefaultContextCache.java @@ -154,6 +154,7 @@ public class DefaultContextCache implements ContextCache { } @Override + @Deprecated(since = "7.0") public void put(MergedContextConfiguration key, ApplicationContext context) { Assert.notNull(key, "Key must not be null"); Assert.notNull(context, "ApplicationContext must not be null"); diff --git a/spring-test/src/test/java/org/springframework/test/context/cache/LruContextCacheTests.java b/spring-test/src/test/java/org/springframework/test/context/cache/LruContextCacheTests.java index 8067565fb25..186addab6b5 100644 --- a/spring-test/src/test/java/org/springframework/test/context/cache/LruContextCacheTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/cache/LruContextCacheTests.java @@ -83,6 +83,7 @@ class LruContextCacheTests { @Nested + @SuppressWarnings("deprecation") class PutUnitTests { @Test