Rename listener to CommonCachesTestExecutionListener

See gh-30954
This commit is contained in:
Sam Brannen 2024-03-20 16:37:22 +01:00
parent 7d197972e0
commit 5698191ba0
7 changed files with 43 additions and 16 deletions

View File

@ -16,7 +16,7 @@ by default, exactly in the following order:
Micrometer's `ObservationRegistry`.
* `DirtiesContextTestExecutionListener`: Handles the `@DirtiesContext` annotation for
"`after`" modes.
* `CommonCacheTestExecutionListener`: Clears resource caches in the test's
* `CommonCachesTestExecutionListener`: Clears resource caches in the test's
`ApplicationContext` if necessary.
* `TransactionalTestExecutionListener`: Provides transactional test execution with
default rollback semantics.

View File

@ -21,8 +21,8 @@ import org.springframework.context.support.AbstractApplicationContext;
import org.springframework.test.context.TestContext;
/**
* {@code TestExecutionListener} which makes sure that caches are cleared once
* they are no longer required.
* {@code TestExecutionListener} which makes sure that common caches are cleared
* once they are no longer required.
*
* <p>Clears the resource caches of the {@link ApplicationContext} since they are
* only required during the bean initialization phase. Runs after
@ -33,7 +33,7 @@ import org.springframework.test.context.TestContext;
* @author Stephane Nicoll
* @since 6.2
*/
public class CommonCacheTestExecutionListener extends AbstractTestExecutionListener {
public class CommonCachesTestExecutionListener extends AbstractTestExecutionListener {
/**
* Returns {@code 3005}.

View File

@ -8,7 +8,7 @@ org.springframework.test.context.TestExecutionListener = \
org.springframework.test.context.support.DependencyInjectionTestExecutionListener,\
org.springframework.test.context.observation.MicrometerObservationRegistryTestExecutionListener,\
org.springframework.test.context.support.DirtiesContextTestExecutionListener,\
org.springframework.test.context.support.CommonCacheTestExecutionListener,\
org.springframework.test.context.support.CommonCachesTestExecutionListener,\
org.springframework.test.context.transaction.TransactionalTestExecutionListener,\
org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener,\
org.springframework.test.context.event.EventPublishingTestExecutionListener,\

View File

@ -32,7 +32,7 @@ import org.springframework.test.context.event.ApplicationEventsTestExecutionList
import org.springframework.test.context.event.EventPublishingTestExecutionListener;
import org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener;
import org.springframework.test.context.support.AbstractTestExecutionListener;
import org.springframework.test.context.support.CommonCacheTestExecutionListener;
import org.springframework.test.context.support.CommonCachesTestExecutionListener;
import org.springframework.test.context.support.DependencyInjectionTestExecutionListener;
import org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener;
import org.springframework.test.context.support.DirtiesContextTestExecutionListener;
@ -73,7 +73,7 @@ class TestExecutionListenersTests {
DependencyInjectionTestExecutionListener.class,//
micrometerListenerClass,//
DirtiesContextTestExecutionListener.class,//
CommonCacheTestExecutionListener.class, //
CommonCachesTestExecutionListener.class, //
TransactionalTestExecutionListener.class,//
SqlScriptsTestExecutionListener.class,//
EventPublishingTestExecutionListener.class,//
@ -96,7 +96,7 @@ class TestExecutionListenersTests {
DependencyInjectionTestExecutionListener.class,//
micrometerListenerClass,//
DirtiesContextTestExecutionListener.class,//
CommonCacheTestExecutionListener.class, //
CommonCachesTestExecutionListener.class, //
TransactionalTestExecutionListener.class,//
SqlScriptsTestExecutionListener.class,//
EventPublishingTestExecutionListener.class,//
@ -118,7 +118,7 @@ class TestExecutionListenersTests {
DependencyInjectionTestExecutionListener.class,//
micrometerListenerClass,//
DirtiesContextTestExecutionListener.class,//
CommonCacheTestExecutionListener.class, //
CommonCachesTestExecutionListener.class, //
TransactionalTestExecutionListener.class,
SqlScriptsTestExecutionListener.class,//
EventPublishingTestExecutionListener.class,//
@ -142,7 +142,7 @@ class TestExecutionListenersTests {
BarTestExecutionListener.class,//
micrometerListenerClass,//
DirtiesContextTestExecutionListener.class,//
CommonCacheTestExecutionListener.class, //
CommonCachesTestExecutionListener.class, //
TransactionalTestExecutionListener.class,//
SqlScriptsTestExecutionListener.class,//
EventPublishingTestExecutionListener.class,//

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.test.context.cache;
package org.springframework.test.context.support;
import org.junit.jupiter.api.ClassOrderer;
import org.junit.jupiter.api.Nested;
@ -31,6 +31,7 @@ import org.springframework.context.support.AbstractApplicationContext;
import org.springframework.core.io.ResourceLoader;
import org.springframework.core.type.classreading.MetadataReader;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import org.springframework.test.context.support.samples.SampleComponent;
import static org.assertj.core.api.Assertions.assertThat;
@ -44,7 +45,7 @@ import static org.assertj.core.api.Assertions.assertThat;
*/
@SpringJUnitConfig
@TestClassOrder(ClassOrderer.OrderAnnotation.class)
class SpringExtensionCommonCacheTests {
class CommonCachesTestExecutionListenerIntegrationTests {
@Autowired
AbstractApplicationContext applicationContext;
@ -81,7 +82,7 @@ class SpringExtensionCommonCacheTests {
String dummyBean(ResourceLoader resourceLoader) {
ClassPathScanningCandidateComponentProvider scanner = new ClassPathScanningCandidateComponentProvider(true);
scanner.setResourceLoader(resourceLoader);
scanner.findCandidateComponents(TestConfiguration.class.getPackageName());
scanner.findCandidateComponents(SampleComponent.class.getPackageName());
return "Dummy";
}
}

View File

@ -27,13 +27,13 @@ import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
/**
* Tests for {@link CommonCacheTestExecutionListener}.
* Tests for {@link CommonCachesTestExecutionListener}.
*
* @author Stephane Nicoll
*/
class CommonCacheTestExecutionListenerTests {
class CommonCachesTestExecutionListenerTests {
private final CommonCacheTestExecutionListener listener = new CommonCacheTestExecutionListener();
private final CommonCachesTestExecutionListener listener = new CommonCachesTestExecutionListener();
@Test
void afterTestClassWhenContextIsAvailable() throws Exception {

View File

@ -0,0 +1,26 @@
/*
* Copyright 2002-2024 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.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.test.context.support.samples;
import org.springframework.stereotype.Component;
/**
* Intended to be picked up by component scanning in tests in the support package.
*/
@Component
public class SampleComponent {
}