diff --git a/spring-test/src/test/java/org/springframework/test/context/aot/AotIntegrationTests.java b/spring-test/src/test/java/org/springframework/test/context/aot/AotIntegrationTests.java index 9961702eba..aa9eae8800 100644 --- a/spring-test/src/test/java/org/springframework/test/context/aot/AotIntegrationTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/aot/AotIntegrationTests.java @@ -167,7 +167,6 @@ class AotIntegrationTests extends AbstractAotTests { void endToEndTestsForSelectedTestClasses() { List> testClasses = List.of( org.springframework.test.context.bean.override.easymock.EasyMockBeanIntegrationTests.class, - org.springframework.test.context.junit4.SpringJUnit4ClassRunnerAppCtxTests.class, org.springframework.test.context.junit4.ParameterizedDependencyInjectionTests.class ); diff --git a/spring-test/src/test/java/org/springframework/test/context/cache/SpringExtensionContextCacheTests.java b/spring-test/src/test/java/org/springframework/test/context/cache/SpringExtensionContextCacheTests.java index f32aea8948..2c0861c8a2 100644 --- a/spring-test/src/test/java/org/springframework/test/context/cache/SpringExtensionContextCacheTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/cache/SpringExtensionContextCacheTests.java @@ -47,7 +47,7 @@ import static org.springframework.test.context.cache.ContextCacheTestUtils.reset * @see ContextCacheTests * @see LruContextCacheTests */ -@SpringJUnitConfig(locations = "../junit4/SpringJUnit4ClassRunnerAppCtxTests-context.xml") +@SpringJUnitConfig(locations = "../config/CoreContextConfigurationAppCtxTests-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, DirtiesContextTestExecutionListener.class }) @TestMethodOrder(MethodOrderer.OrderAnnotation.class) class SpringExtensionContextCacheTests { diff --git a/spring-test/src/test/java/org/springframework/test/context/junit4/AbsolutePathSpringJUnit4ClassRunnerAppCtxTests.java b/spring-test/src/test/java/org/springframework/test/context/config/AbsolutePathContextConfigurationAppCtxTests.java similarity index 62% rename from spring-test/src/test/java/org/springframework/test/context/junit4/AbsolutePathSpringJUnit4ClassRunnerAppCtxTests.java rename to spring-test/src/test/java/org/springframework/test/context/config/AbsolutePathContextConfigurationAppCtxTests.java index 56caa8c903..4cc1559eaf 100644 --- a/spring-test/src/test/java/org/springframework/test/context/junit4/AbsolutePathSpringJUnit4ClassRunnerAppCtxTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/config/AbsolutePathContextConfigurationAppCtxTests.java @@ -14,22 +14,22 @@ * limitations under the License. */ -package org.springframework.test.context.junit4; +package org.springframework.test.context.config; import org.springframework.test.context.ContextConfiguration; /** - * Extension of {@link SpringJUnit4ClassRunnerAppCtxTests}, which verifies that + * Extension of {@link CoreContextConfigurationAppCtxTests}, which verifies that * we can specify an explicit, absolute path location for our * application context. * * @author Sam Brannen * @since 2.5 - * @see SpringJUnit4ClassRunnerAppCtxTests - * @see ClassPathResourceSpringJUnit4ClassRunnerAppCtxTests - * @see RelativePathSpringJUnit4ClassRunnerAppCtxTests + * @see CoreContextConfigurationAppCtxTests + * @see ClassPathResourceContextConfigurationAppCtxTests + * @see RelativePathContextConfigurationAppCtxTests */ -@ContextConfiguration(locations = { SpringJUnit4ClassRunnerAppCtxTests.DEFAULT_CONTEXT_RESOURCE_PATH }, inheritLocations = false) -public class AbsolutePathSpringJUnit4ClassRunnerAppCtxTests extends SpringJUnit4ClassRunnerAppCtxTests { +@ContextConfiguration(locations = CoreContextConfigurationAppCtxTests.DEFAULT_CONTEXT_RESOURCE_PATH, inheritLocations = false) +class AbsolutePathContextConfigurationAppCtxTests extends CoreContextConfigurationAppCtxTests { /* all tests are in the parent class. */ } diff --git a/spring-test/src/test/java/org/springframework/test/context/junit4/AnnotationConfigSpringJUnit4ClassRunnerAppCtxTests.java b/spring-test/src/test/java/org/springframework/test/context/config/AnnotationConfigContextConfigurationAppCtxTests.java similarity index 76% rename from spring-test/src/test/java/org/springframework/test/context/junit4/AnnotationConfigSpringJUnit4ClassRunnerAppCtxTests.java rename to spring-test/src/test/java/org/springframework/test/context/config/AnnotationConfigContextConfigurationAppCtxTests.java index d87ca44a61..e55e6840ef 100644 --- a/spring-test/src/test/java/org/springframework/test/context/junit4/AnnotationConfigSpringJUnit4ClassRunnerAppCtxTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/config/AnnotationConfigContextConfigurationAppCtxTests.java @@ -14,19 +14,18 @@ * limitations under the License. */ -package org.springframework.test.context.junit4; +package org.springframework.test.context.config; import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.annotation.PojoAndStringConfig; /** * Integration tests that verify support for configuration classes in * the Spring TestContext Framework. * - *

Furthermore, by extending {@code SpringJUnit4ClassRunnerAppCtxTests}, + *

Furthermore, by extending {@link CoreContextConfigurationAppCtxTests}, * this class also verifies support for several basic features of the * Spring TestContext Framework. See JavaDoc in - * {@link SpringJUnit4ClassRunnerAppCtxTests} for details. + * {@link CoreContextConfigurationAppCtxTests} for details. * *

Configuration will be loaded from {@link PojoAndStringConfig}. * @@ -34,6 +33,6 @@ import org.springframework.test.context.annotation.PojoAndStringConfig; * @since 3.1 */ @ContextConfiguration(classes = PojoAndStringConfig.class, inheritLocations = false) -public class AnnotationConfigSpringJUnit4ClassRunnerAppCtxTests extends SpringJUnit4ClassRunnerAppCtxTests { +class AnnotationConfigContextConfigurationAppCtxTests extends CoreContextConfigurationAppCtxTests { /* all tests are in the parent class. */ } diff --git a/spring-test/src/test/java/org/springframework/test/context/AutowiredQualifierTests.java b/spring-test/src/test/java/org/springframework/test/context/config/AutowiredQualifierTests.java similarity index 67% rename from spring-test/src/test/java/org/springframework/test/context/AutowiredQualifierTests.java rename to spring-test/src/test/java/org/springframework/test/context/config/AutowiredQualifierTests.java index 5101960d4e..d46cda1c46 100644 --- a/spring-test/src/test/java/org/springframework/test/context/AutowiredQualifierTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/config/AutowiredQualifierTests.java @@ -14,13 +14,17 @@ * limitations under the License. */ -package org.springframework.test.context; +package org.springframework.test.context.config; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit.jupiter.SpringExtension; import static org.assertj.core.api.Assertions.assertThat; @@ -32,15 +36,16 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Chris Beams * @since 3.0 */ -@SpringJUnitConfig +@ExtendWith(SpringExtension.class) +@ContextConfiguration class AutowiredQualifierTests { @Autowired - private String foo; + String foo; @Autowired @Qualifier("customFoo") - private String customFoo; + String customFoo; @Test @@ -49,4 +54,19 @@ class AutowiredQualifierTests { assertThat(customFoo).isEqualTo("custom"); } + + @Configuration(proxyBeanMethods = false) + static class Config { + + @Bean + String foo() { + return "normal"; + } + + @Bean + String customFoo() { + return "custom"; + } + } + } diff --git a/spring-test/src/test/java/org/springframework/test/context/annotation/BeanOverridingDefaultConfigClassesInheritedTests.java b/spring-test/src/test/java/org/springframework/test/context/config/BeanOverridingDefaultConfigClassesInheritedTests.java similarity index 97% rename from spring-test/src/test/java/org/springframework/test/context/annotation/BeanOverridingDefaultConfigClassesInheritedTests.java rename to spring-test/src/test/java/org/springframework/test/context/config/BeanOverridingDefaultConfigClassesInheritedTests.java index f518595c59..f9b1b3db0c 100644 --- a/spring-test/src/test/java/org/springframework/test/context/annotation/BeanOverridingDefaultConfigClassesInheritedTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/config/BeanOverridingDefaultConfigClassesInheritedTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.test.context.annotation; +package org.springframework.test.context.config; import org.junit.jupiter.api.Test; diff --git a/spring-test/src/test/java/org/springframework/test/context/annotation/BeanOverridingExplicitConfigClassesInheritedTests.java b/spring-test/src/test/java/org/springframework/test/context/config/BeanOverridingExplicitConfigClassesInheritedTests.java similarity index 96% rename from spring-test/src/test/java/org/springframework/test/context/annotation/BeanOverridingExplicitConfigClassesInheritedTests.java rename to spring-test/src/test/java/org/springframework/test/context/config/BeanOverridingExplicitConfigClassesInheritedTests.java index 85224b4a42..c2170704e9 100644 --- a/spring-test/src/test/java/org/springframework/test/context/annotation/BeanOverridingExplicitConfigClassesInheritedTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/config/BeanOverridingExplicitConfigClassesInheritedTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.test.context.annotation; +package org.springframework.test.context.config; import org.junit.jupiter.api.Test; diff --git a/spring-test/src/test/java/org/springframework/test/context/junit4/ClassPathResourceSpringJUnit4ClassRunnerAppCtxTests.java b/spring-test/src/test/java/org/springframework/test/context/config/ClassPathResourceContextConfigurationAppCtxTests.java similarity index 55% rename from spring-test/src/test/java/org/springframework/test/context/junit4/ClassPathResourceSpringJUnit4ClassRunnerAppCtxTests.java rename to spring-test/src/test/java/org/springframework/test/context/config/ClassPathResourceContextConfigurationAppCtxTests.java index cbdc15cf9c..df4c3f7aae 100644 --- a/spring-test/src/test/java/org/springframework/test/context/junit4/ClassPathResourceSpringJUnit4ClassRunnerAppCtxTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/config/ClassPathResourceContextConfigurationAppCtxTests.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. @@ -14,36 +14,35 @@ * limitations under the License. */ -package org.springframework.test.context.junit4; +package org.springframework.test.context.config; import org.springframework.test.context.ContextConfiguration; import org.springframework.util.ResourceUtils; /** - * Extension of {@link SpringJUnit4ClassRunnerAppCtxTests}, which verifies that + * Extension of {@link CoreContextConfigurationAppCtxTests}, which verifies that * we can specify an explicit, classpath location for our application * context. * * @author Sam Brannen * @since 2.5 - * @see SpringJUnit4ClassRunnerAppCtxTests + * @see CoreContextConfigurationAppCtxTests * @see #CLASSPATH_CONTEXT_RESOURCE_PATH - * @see AbsolutePathSpringJUnit4ClassRunnerAppCtxTests - * @see RelativePathSpringJUnit4ClassRunnerAppCtxTests + * @see AbsolutePathContextConfigurationAppCtxTests + * @see RelativePathContextConfigurationAppCtxTests */ -@ContextConfiguration(locations = { ClassPathResourceSpringJUnit4ClassRunnerAppCtxTests.CLASSPATH_CONTEXT_RESOURCE_PATH }, inheritLocations = false) -public class ClassPathResourceSpringJUnit4ClassRunnerAppCtxTests extends SpringJUnit4ClassRunnerAppCtxTests { +@ContextConfiguration(locations = { ClassPathResourceContextConfigurationAppCtxTests.CLASSPATH_CONTEXT_RESOURCE_PATH }, inheritLocations = false) +class ClassPathResourceContextConfigurationAppCtxTests extends CoreContextConfigurationAppCtxTests { /** * Classpath-based resource path for the application context configuration - * for {@link SpringJUnit4ClassRunnerAppCtxTests}: - * {@code "classpath:/org/springframework/test/context/junit4/SpringJUnit4ClassRunnerAppCtxTests-context.xml"} + * for {@link CoreContextConfigurationAppCtxTests}: {@value} * - * @see SpringJUnit4ClassRunnerAppCtxTests#DEFAULT_CONTEXT_RESOURCE_PATH + * @see CoreContextConfigurationAppCtxTests#DEFAULT_CONTEXT_RESOURCE_PATH * @see ResourceUtils#CLASSPATH_URL_PREFIX */ public static final String CLASSPATH_CONTEXT_RESOURCE_PATH = ResourceUtils.CLASSPATH_URL_PREFIX + - SpringJUnit4ClassRunnerAppCtxTests.DEFAULT_CONTEXT_RESOURCE_PATH; + CoreContextConfigurationAppCtxTests.DEFAULT_CONTEXT_RESOURCE_PATH; /* all tests are in the parent class. */ diff --git a/spring-test/src/test/java/org/springframework/test/context/annotation/AnnotationConfigTestSuite.java b/spring-test/src/test/java/org/springframework/test/context/config/ContextConfigTestSuite.java similarity index 91% rename from spring-test/src/test/java/org/springframework/test/context/annotation/AnnotationConfigTestSuite.java rename to spring-test/src/test/java/org/springframework/test/context/config/ContextConfigTestSuite.java index 8331b926dd..485e128b6b 100644 --- a/spring-test/src/test/java/org/springframework/test/context/annotation/AnnotationConfigTestSuite.java +++ b/spring-test/src/test/java/org/springframework/test/context/config/ContextConfigTestSuite.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.test.context.annotation; +package org.springframework.test.context.config; import org.junit.jupiter.api.ClassOrderer; import org.junit.platform.suite.api.ConfigurationParameter; @@ -44,11 +44,11 @@ import org.junit.platform.suite.api.Suite; */ @Suite @IncludeEngines("junit-jupiter") -@SelectPackages("org.springframework.test.context.annotation") +@SelectPackages("org.springframework.test.context.config") @IncludeClassNamePatterns(".*Tests$") @ConfigurationParameter( key = ClassOrderer.DEFAULT_ORDER_PROPERTY_NAME, value = "org.junit.jupiter.api.ClassOrderer$ClassName" ) -public class AnnotationConfigTestSuite { +public class ContextConfigTestSuite { } diff --git a/spring-test/src/test/java/org/springframework/test/context/junit4/SpringJUnit4ClassRunnerAppCtxTests.java b/spring-test/src/test/java/org/springframework/test/context/config/CoreContextConfigurationAppCtxTests.java similarity index 79% rename from spring-test/src/test/java/org/springframework/test/context/junit4/SpringJUnit4ClassRunnerAppCtxTests.java rename to spring-test/src/test/java/org/springframework/test/context/config/CoreContextConfigurationAppCtxTests.java index 4bbc906dd0..4d00fba6a6 100644 --- a/spring-test/src/test/java/org/springframework/test/context/junit4/SpringJUnit4ClassRunnerAppCtxTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/config/CoreContextConfigurationAppCtxTests.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. @@ -14,13 +14,13 @@ * limitations under the License. */ -package org.springframework.test.context.junit4; +package org.springframework.test.context.config; import jakarta.annotation.Resource; import jakarta.inject.Inject; import jakarta.inject.Named; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.BeanNameAware; import org.springframework.beans.factory.InitializingBean; @@ -33,18 +33,18 @@ import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContextAware; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.test.context.support.GenericXmlContextLoader; import static org.assertj.core.api.Assertions.assertThat; /** - * SpringJUnit4ClassRunnerAppCtxTests serves as a proof of concept - * JUnit 4 based test class, which verifies the expected functionality of - * {@link SpringRunner} in conjunction with the following: + * {@code CoreContextConfigurationAppCtxTests} serves as a core test class, which + * verifies the expected functionality of {@link ContextConfiguration @ContextConfiguration} + * in conjunction with the following: * *