From 1732844137ec890e2b3c00421484288c4582e9ea Mon Sep 17 00:00:00 2001 From: Sam Brannen <104798+sbrannen@users.noreply.github.com> Date: Wed, 20 Mar 2024 12:55:35 +0100 Subject: [PATCH] Polishing --- .../support/CommonCacheTestExecutionListener.java | 12 +++++++----- .../CommonCacheTestExecutionListenerTests.java | 4 ++-- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/spring-test/src/main/java/org/springframework/test/context/support/CommonCacheTestExecutionListener.java b/spring-test/src/main/java/org/springframework/test/context/support/CommonCacheTestExecutionListener.java index c61cadb68c14..5a47d225b72a 100644 --- a/spring-test/src/main/java/org/springframework/test/context/support/CommonCacheTestExecutionListener.java +++ b/spring-test/src/main/java/org/springframework/test/context/support/CommonCacheTestExecutionListener.java @@ -22,11 +22,13 @@ /** * {@code TestExecutionListener} which makes sure that caches are cleared once - * they are no longer required. Clears the resource cache of the - * {@link ApplicationContext} as it is only required during the beans - * initialization phase. Runs after {@link DirtiesContextTestExecutionListener} - * as dirtying the context will remove it from the cache and make this - * unnecessary. + * they are no longer required. + * + *

Clears the resource caches of the {@link ApplicationContext} since they are + * only required during the bean initialization phase. Runs after + * {@link DirtiesContextTestExecutionListener} since dirtying the context will + * close it and remove it from the context cache, making it unnecessary to clear + * the associated resource caches. * * @author Stephane Nicoll * @since 6.2 diff --git a/spring-test/src/test/java/org/springframework/test/context/support/CommonCacheTestExecutionListenerTests.java b/spring-test/src/test/java/org/springframework/test/context/support/CommonCacheTestExecutionListenerTests.java index 1209df579c54..c4b109f806e7 100644 --- a/spring-test/src/test/java/org/springframework/test/context/support/CommonCacheTestExecutionListenerTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/support/CommonCacheTestExecutionListenerTests.java @@ -37,7 +37,7 @@ class CommonCacheTestExecutionListenerTests { @Test void afterTestClassWhenContextIsAvailable() throws Exception { - AbstractApplicationContext applicationContext = mock(AbstractApplicationContext.class); + AbstractApplicationContext applicationContext = mock(); TestContext testContext = mock(TestContext.class); given(testContext.hasApplicationContext()).willReturn(true); given(testContext.getApplicationContext()).willReturn(applicationContext); @@ -47,7 +47,7 @@ void afterTestClassWhenContextIsAvailable() throws Exception { @Test void afterTestClassCWhenContextIsNotAvailable() throws Exception { - TestContext testContext = mock(TestContext.class); + TestContext testContext = mock(); given(testContext.hasApplicationContext()).willReturn(false); listener.afterTestClass(testContext); verify(testContext).hasApplicationContext();