Merge branch '7.0.x'

This commit is contained in:
Sam Brannen
2026-03-18 18:39:17 +01:00
249 changed files with 424 additions and 361 deletions
@@ -0,0 +1,36 @@
/*
* Copyright 2002-present 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.core.env;
/**
* Constants used both locally and in scan* sub-packages
*/
public class Constants {
public static final String XML_PATH = "org/springframework/core/env/EnvironmentSystemIntegrationTests-context.xml";
public static final String ENVIRONMENT_AWARE_BEAN_NAME = "envAwareBean";
public static final String PROD_BEAN_NAME = "prodBean";
public static final String DEV_BEAN_NAME = "devBean";
public static final String DERIVED_DEV_BEAN_NAME = "derivedDevBean";
public static final String TRANSITIVE_BEAN_NAME = "transitiveBean";
public static final String PROD_ENV_NAME = "prod";
public static final String DEV_ENV_NAME = "dev";
public static final String DERIVED_DEV_ENV_NAME = "derivedDev";
}
@@ -58,15 +58,15 @@ import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import static org.springframework.beans.factory.support.BeanDefinitionBuilder.rootBeanDefinition;
import static org.springframework.context.ConfigurableApplicationContext.ENVIRONMENT_BEAN_NAME;
import static org.springframework.core.env.EnvironmentSystemIntegrationTests.Constants.DERIVED_DEV_BEAN_NAME;
import static org.springframework.core.env.EnvironmentSystemIntegrationTests.Constants.DERIVED_DEV_ENV_NAME;
import static org.springframework.core.env.EnvironmentSystemIntegrationTests.Constants.DEV_BEAN_NAME;
import static org.springframework.core.env.EnvironmentSystemIntegrationTests.Constants.DEV_ENV_NAME;
import static org.springframework.core.env.EnvironmentSystemIntegrationTests.Constants.ENVIRONMENT_AWARE_BEAN_NAME;
import static org.springframework.core.env.EnvironmentSystemIntegrationTests.Constants.PROD_BEAN_NAME;
import static org.springframework.core.env.EnvironmentSystemIntegrationTests.Constants.PROD_ENV_NAME;
import static org.springframework.core.env.EnvironmentSystemIntegrationTests.Constants.TRANSITIVE_BEAN_NAME;
import static org.springframework.core.env.EnvironmentSystemIntegrationTests.Constants.XML_PATH;
import static org.springframework.core.env.Constants.DERIVED_DEV_BEAN_NAME;
import static org.springframework.core.env.Constants.DERIVED_DEV_ENV_NAME;
import static org.springframework.core.env.Constants.DEV_BEAN_NAME;
import static org.springframework.core.env.Constants.DEV_ENV_NAME;
import static org.springframework.core.env.Constants.ENVIRONMENT_AWARE_BEAN_NAME;
import static org.springframework.core.env.Constants.PROD_BEAN_NAME;
import static org.springframework.core.env.Constants.PROD_ENV_NAME;
import static org.springframework.core.env.Constants.TRANSITIVE_BEAN_NAME;
import static org.springframework.core.env.Constants.XML_PATH;
/**
* System integration tests for container support of the {@link Environment} API.
@@ -87,7 +87,7 @@ import static org.springframework.core.env.EnvironmentSystemIntegrationTests.Con
* @author Sam Brannen
* @see org.springframework.context.support.EnvironmentIntegrationTests
*/
public class EnvironmentSystemIntegrationTests {
class EnvironmentSystemIntegrationTests {
private final ConfigurableEnvironment prodEnv = new StandardEnvironment();
@@ -648,7 +648,7 @@ public class EnvironmentSystemIntegrationTests {
}
}
@Profile(DERIVED_DEV_ENV_NAME)
@Profile(Constants.DERIVED_DEV_ENV_NAME)
@Configuration
static class DerivedDevConfig extends DevConfig {
@Bean
@@ -666,24 +666,4 @@ public class EnvironmentSystemIntegrationTests {
}
}
/**
* Constants used both locally and in scan* sub-packages
*/
public static class Constants {
public static final String XML_PATH = "org/springframework/core/env/EnvironmentSystemIntegrationTests-context.xml";
public static final String ENVIRONMENT_AWARE_BEAN_NAME = "envAwareBean";
public static final String PROD_BEAN_NAME = "prodBean";
public static final String DEV_BEAN_NAME = "devBean";
public static final String DERIVED_DEV_BEAN_NAME = "derivedDevBean";
public static final String TRANSITIVE_BEAN_NAME = "transitiveBean";
public static final String PROD_ENV_NAME = "prod";
public static final String DEV_ENV_NAME = "dev";
public static final String DERIVED_DEV_ENV_NAME = "derivedDev";
}
}
@@ -20,7 +20,7 @@ import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
@Profile(org.springframework.core.env.EnvironmentSystemIntegrationTests.Constants.DEV_ENV_NAME)
@Profile(org.springframework.core.env.Constants.DEV_ENV_NAME)
@Configuration
class DevConfig {
@@ -20,7 +20,7 @@ import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
@Profile(org.springframework.core.env.EnvironmentSystemIntegrationTests.Constants.PROD_ENV_NAME)
@Profile(org.springframework.core.env.Constants.PROD_ENV_NAME)
@Configuration
class ProdConfig {
@@ -19,7 +19,7 @@ package org.springframework.core.env.scan2;
import org.springframework.context.annotation.Profile;
import org.springframework.stereotype.Component;
@Profile(org.springframework.core.env.EnvironmentSystemIntegrationTests.Constants.DEV_ENV_NAME)
@Component(org.springframework.core.env.EnvironmentSystemIntegrationTests.Constants.DEV_BEAN_NAME)
@Profile(org.springframework.core.env.Constants.DEV_ENV_NAME)
@Component(org.springframework.core.env.Constants.DEV_BEAN_NAME)
class DevBean {
}
@@ -19,8 +19,8 @@ package org.springframework.core.env.scan2;
import org.springframework.context.annotation.Profile;
import org.springframework.stereotype.Component;
@Profile(org.springframework.core.env.EnvironmentSystemIntegrationTests.Constants.PROD_ENV_NAME)
@Component(org.springframework.core.env.EnvironmentSystemIntegrationTests.Constants.PROD_BEAN_NAME)
@Profile(org.springframework.core.env.Constants.PROD_ENV_NAME)
@Component(org.springframework.core.env.Constants.PROD_BEAN_NAME)
class ProdBean {
}
@@ -49,12 +49,12 @@ import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
class MethodInvocationProceedingJoinPointTests {
@Test
void testingBindingWithJoinPoint() {
void bindingWithJoinPoint() {
assertThatIllegalStateException().isThrownBy(AbstractAspectJAdvice::currentJoinPoint);
}
@Test
void testingBindingWithProceedingJoinPoint() {
void bindingWithProceedingJoinPoint() {
assertThatIllegalStateException().isThrownBy(AbstractAspectJAdvice::currentJoinPoint);
}
@@ -47,7 +47,7 @@ class AspectJNamespaceHandlerTests {
@BeforeEach
public void setUp() {
void setUp() {
SourceExtractor sourceExtractor = new PassThroughSourceExtractor();
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(this.registry);
XmlReaderContext readerContext =
@@ -33,6 +33,7 @@ import org.springframework.aop.aspectj.AspectJExpressionPointcut;
import org.springframework.aop.aspectj.AspectJMethodBeforeAdvice;
import org.springframework.aop.aspectj.AspectJPointcutAdvisor;
import org.springframework.aop.support.DefaultPointcutAdvisor;
import org.springframework.util.ClassUtils;
import static org.assertj.core.api.Assertions.assertThat;
@@ -48,18 +49,15 @@ class AspectJPrecedenceComparatorTests {
private static final int LATE_ADVICE_DECLARATION_ORDER = 10;
private AspectJPrecedenceComparator comparator;
private final AspectJPrecedenceComparator comparator = new AspectJPrecedenceComparator();
private Method anyOldMethod;
private final Method anyOldMethod = ClassUtils.getMethod(MessageService.class, "getMessage");
private AspectJExpressionPointcut anyOldPointcut;
private final AspectJExpressionPointcut anyOldPointcut = new AspectJExpressionPointcut();
@BeforeEach
public void setUp() {
this.comparator = new AspectJPrecedenceComparator();
this.anyOldMethod = getClass().getMethods()[0];
this.anyOldPointcut = new AspectJExpressionPointcut();
void setUp() {
this.anyOldPointcut.setExpression("execution(* *(..))");
}
@@ -209,4 +207,11 @@ class AspectJPrecedenceComparatorTests {
return advisor;
}
static class MessageService {
public String getMessage() {
return "test";
}
}
}
@@ -48,7 +48,7 @@ class HotSwappableTargetSourceTests {
@BeforeEach
public void setup() {
void setup() {
this.beanFactory = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(this.beanFactory).loadBeanDefinitions(
qualifiedResource(HotSwappableTargetSourceTests.class, "context.xml"));
@@ -58,7 +58,7 @@ class HotSwappableTargetSourceTests {
* We must simulate container shutdown, which should clear threads.
*/
@AfterEach
public void close() {
void close() {
// Will call pool.close()
this.beanFactory.destroySingletons();
}
@@ -39,7 +39,7 @@ class PrototypeTargetSourceTests {
@BeforeEach
public void setup() {
void setup() {
this.beanFactory = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(this.beanFactory).loadBeanDefinitions(
qualifiedResource(PrototypeTargetSourceTests.class, "context.xml"));
@@ -40,7 +40,7 @@ class ThreadLocalTargetSourceTests {
@BeforeEach
public void setup() {
void setup() {
this.beanFactory = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(this.beanFactory).loadBeanDefinitions(
qualifiedResource(ThreadLocalTargetSourceTests.class, "context.xml"));
@@ -46,7 +46,7 @@ import static org.springframework.core.testfixture.TestGroup.LONG_RUNNING;
* @author Stephane Nicoll
*/
@EnabledForTestGroups(LONG_RUNNING)
public class AnnotationAsyncExecutionAspectTests {
class AnnotationAsyncExecutionAspectTests {
private static final long WAIT_TIME = 1000; //milliseconds
@@ -56,7 +56,7 @@ public class AnnotationAsyncExecutionAspectTests {
@BeforeEach
public void setUp() {
void setUp() {
executor = new CountingExecutor();
AnnotationAsyncExecutionAspect.aspectOf().setExecutor(executor);
}
@@ -37,13 +37,13 @@ class AnnotationDrivenBeanDefinitionParserTests {
private ConfigurableApplicationContext context;
@BeforeEach
public void setup() {
void setup() {
this.context = new ClassPathXmlApplicationContext(
"annotationDrivenContext.xml", AnnotationDrivenBeanDefinitionParserTests.class);
}
@AfterEach
public void after() {
void after() {
if (this.context != null) {
this.context.close();
}
@@ -36,13 +36,13 @@ import static org.assertj.core.api.Assertions.assertThatIOException;
* @author Stephane Nicoll
*/
@SpringJUnitConfig(JtaTransactionAspectsTests.Config.class)
public class JtaTransactionAspectsTests {
class JtaTransactionAspectsTests {
@Autowired
private CallCountingTransactionManager txManager;
@BeforeEach
public void setUp() {
void setUp() {
this.txManager.clear();
}
@@ -30,7 +30,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
* @author Juergen Hoeller
* @since 6.2
*/
public class CustomObjectProviderTests {
class CustomObjectProviderTests {
@Test
void getObject() {
@@ -34,7 +34,7 @@ import static org.assertj.core.api.Assertions.assertThat;
*
* @author Sebastien Deleuze
*/
public class BeanRegistryAdapterTests {
class BeanRegistryAdapterTests {
private final DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
@@ -37,7 +37,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Juergen Hoeller
*/
@SuppressWarnings("resource")
public class BeanMethodPolymorphismTests {
class BeanMethodPolymorphismTests {
@Test
void beanMethodDetectedOnSuperClass() {
@@ -28,7 +28,7 @@ import org.springframework.context.annotation.componentscan.simple.SimpleCompone
* @author Chris Beams
* @since 3.1
*/
public class ComponentScanAndImportAnnotationInteractionTests {
class ComponentScanAndImportAnnotationInteractionTests {
@Test
void componentScanOverlapsWithImport() {
@@ -101,10 +101,4 @@ public class ComponentScanAndImportAnnotationInteractionTests {
static final class Config3 {
}
@ComponentScan("org.springframework.context.annotation.componentscan.simple")
@ComponentScan("org.springframework.context.annotation.componentscan.importing")
public static final class ImportedConfig {
}
}
@@ -83,7 +83,7 @@ import static org.assertj.core.api.Assertions.entry;
* @author Sam Brannen
* @author Sebastien Deleuze
*/
public class ConfigurationClassPostProcessorAotContributionTests {
class ConfigurationClassPostProcessorAotContributionTests {
private final TestGenerationContext generationContext = new TestGenerationContext();
@@ -466,7 +466,7 @@ public class ConfigurationClassPostProcessorAotContributionTests {
}
@Nested
public class BeanRegistrarTests {
class BeanRegistrarTests {
@Test
void applyToWhenHasDefaultConstructor() throws NoSuchMethodException {
@@ -40,7 +40,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Juergen Hoeller
*/
@SuppressWarnings("resource")
public class ConfigurationClassWithConditionTests {
class ConfigurationClassWithConditionTests {
@Test
void conditionalOnMissingBeanMatch() {
@@ -31,7 +31,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
*
* @author Stephane Nicoll
*/
public class Gh23206Tests {
class Gh23206Tests {
@Test
void componentScanShouldFailWithRegisterBeanCondition() {
@@ -33,7 +33,7 @@ import static org.assertj.core.api.Assertions.assertThat;
*
* @author Stephane Nicoll
*/
public class Gh32489Tests {
class Gh32489Tests {
@Test
void resolveFactoryBeansWithWildcard() {
@@ -64,7 +64,7 @@ import static org.mockito.Mockito.spy;
* @author Stephane Nicoll
*/
@SuppressWarnings("resource")
public class ImportSelectorTests {
class ImportSelectorTests {
static Map<Class<?>, String> importFrom = new HashMap<>();
@@ -0,0 +1,22 @@
/*
* Copyright 2002-present 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.context.annotation;
@ComponentScan("org.springframework.context.annotation.componentscan.simple")
@ComponentScan("org.springframework.context.annotation.componentscan.importing")
public final class ImportedConfig {
}
@@ -41,7 +41,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Oliver Gierke
*/
@SuppressWarnings("resource")
public class Spr8954Tests {
class Spr8954Tests {
@Test
void repro() {
@@ -44,7 +44,7 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy;
*
* @author Sebastien Deleuze
*/
public class BeanRegistrarConfigurationTests {
class BeanRegistrarConfigurationTests {
@Test
void beanRegistrar() {
@@ -16,11 +16,11 @@
package org.springframework.context.annotation.componentscan.importing;
import org.springframework.context.annotation.ComponentScanAndImportAnnotationInteractionTests;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.context.annotation.ImportedConfig;
@Configuration
@Import(ComponentScanAndImportAnnotationInteractionTests.ImportedConfig.class)
@Import(ImportedConfig.class)
public class ImportingConfig {
}
@@ -0,0 +1,20 @@
/*
* Copyright 2002-present 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.context.annotation.configuration;
public class Bar {
}
@@ -41,7 +41,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @since 3.1
*/
@SuppressWarnings("resource")
public class ImportAnnotationDetectionTests {
class ImportAnnotationDetectionTests {
@Test
void multipleMetaImportsAreProcessed() {
@@ -30,7 +30,7 @@ import static org.assertj.core.api.Assertions.assertThat;
*
* @author Chris Beams
*/
public class PackagePrivateBeanMethodInheritanceTests {
class PackagePrivateBeanMethodInheritanceTests {
@Test
void repro() {
@@ -64,9 +64,6 @@ public class PackagePrivateBeanMethodInheritanceTests {
}
}
public static class Bar {
}
@Configuration
public static class ReproConfig extends org.springframework.context.annotation.configuration.a.BaseConfig {
@Bean
@@ -17,7 +17,7 @@
package org.springframework.context.annotation.configuration.a;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.configuration.PackagePrivateBeanMethodInheritanceTests.Bar;
import org.springframework.context.annotation.configuration.Bar;
public abstract class BaseConfig {
@@ -0,0 +1,25 @@
/*
* Copyright 2002-present 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.context.annotation.configuration.spr9031;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@Retention(RetentionPolicy.RUNTIME)
public @interface MarkerAnnotation {
}
@@ -16,9 +16,6 @@
package org.springframework.context.annotation.configuration.spr9031;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
@@ -37,7 +34,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Chris Beams
* @since 3.1.1
*/
public class Spr9031Tests {
class Spr9031Tests {
/**
* Use of @Import to register LowLevelConfig results in ASM-based annotation
@@ -76,7 +73,4 @@ public class Spr9031Tests {
@Autowired Spr9031Component scanned;
}
@Retention(RetentionPolicy.RUNTIME)
public @interface MarkerAnnotation {}
}
@@ -16,7 +16,7 @@
package org.springframework.context.annotation.configuration.spr9031.scanpackage;
import org.springframework.context.annotation.configuration.spr9031.Spr9031Tests.MarkerAnnotation;
import org.springframework.context.annotation.configuration.spr9031.MarkerAnnotation;
@MarkerAnnotation
public class Spr9031Component {
@@ -61,7 +61,7 @@ public abstract class AbstractMBeanServerTests {
@BeforeEach
public final void setUp() throws Exception {
protected final void setUp() throws Exception {
this.server = MBeanServerFactory.createMBeanServer();
try {
onSetUp();
@@ -39,7 +39,7 @@ import static org.assertj.core.api.InstanceOfAssertFactories.type;
* @author Chris Beams
*/
@SuppressWarnings("unchecked")
public class ScheduledTasksBeanDefinitionParserTests {
class ScheduledTasksBeanDefinitionParserTests {
private ApplicationContext context;
@@ -33,7 +33,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Dave Syer
*/
@SuppressWarnings("resource")
public class ScriptingDefaultsTests {
class ScriptingDefaultsTests {
private static final String CONFIG =
"org/springframework/scripting/config/scriptingDefaultsTests.xml";
@@ -63,7 +63,7 @@ import static org.mockito.Mockito.mock;
* @author Chris Beams
*/
@SuppressWarnings("resource")
public class GroovyScriptFactoryTests {
class GroovyScriptFactoryTests {
@Test
void staticScript() {
@@ -19,7 +19,7 @@ package org.springframework.context.testfixture.cache;
import java.util.Collection;
import java.util.UUID;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.AutoClose;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -46,6 +46,7 @@ import static org.assertj.core.api.Assertions.assertThatIOException;
*/
public abstract class AbstractCacheAnnotationTests {
@AutoClose
protected ConfigurableApplicationContext ctx;
protected CacheableService<?> cs;
@@ -62,7 +63,7 @@ public abstract class AbstractCacheAnnotationTests {
@BeforeEach
public void setup() {
void setup() {
this.ctx = getApplicationContext();
this.cs = ctx.getBean("service", CacheableService.class);
this.ccs = ctx.getBean("classService", CacheableService.class);
@@ -72,13 +73,6 @@ public abstract class AbstractCacheAnnotationTests {
assertThat(cn).containsOnly("testCache", "secondary", "primary");
}
@AfterEach
public void close() {
if (this.ctx != null) {
this.ctx.close();
}
}
protected void testCacheable(CacheableService<?> service) {
Object o1 = new Object();
@@ -109,7 +109,7 @@ class InstrumentedMethodTests {
.onInstance(String.class).returnValue(String.class.getDeclaredConstructors()).build();
@BeforeEach
public void setup() throws Exception {
void setup() throws Exception {
this.stringGetConstructor = RecordedInvocation.of(InstrumentedMethod.CLASS_GETCONSTRUCTOR)
.onInstance(String.class).withArgument(new Class[0]).returnValue(String.class.getConstructor()).build();
this.stringGetDeclaredConstructor = RecordedInvocation.of(InstrumentedMethod.CLASS_GETDECLAREDCONSTRUCTOR)
@@ -31,7 +31,7 @@ import org.springframework.core.testfixture.nullness.marked.unmarked.PackageUnma
*
* @author Sebastien Deleuze
*/
public class NullnessTests {
class NullnessTests {
// JSpecify without @NullMarked and @NullUnmarked
@@ -32,7 +32,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
* @author Arjen Poutsma
* @author Brian Clozel
*/
public class JettyDataBufferTests {
class JettyDataBufferTests {
private final JettyDataBufferFactory dataBufferFactory = new JettyDataBufferFactory();
@@ -660,9 +660,8 @@ class ClassUtilsTests {
}
@Test
// This method is intentionally public.
public void publicMethodInNonPublicClass(TestInfo testInfo) {
Method originalMethod = testInfo.getTestMethod().get();
void publicMethodInNonPublicClass() throws Exception {
Method originalMethod = getClass().getMethod("publicMethod");
// Prerequisites for this use case:
assertPublic(originalMethod);
@@ -673,6 +672,9 @@ class ClassUtilsTests {
assertNotPubliclyAccessible(publiclyAccessibleMethod);
}
public void publicMethod() {
}
@Test
void publicMethodInNonPublicInterface() throws Exception {
Class<?> originalType = PrivateInterface.class;
@@ -162,7 +162,7 @@ public abstract class AbstractDataBufferAllocatingTests {
@BeforeAll
@SuppressWarnings("deprecation") // PooledByteBufAllocator no longer supports tinyCacheSize.
public static void createAllocators() {
static void createAllocators() {
netty4OnHeapUnpooled = new UnpooledByteBufAllocator(false);
netty4OffHeapUnpooled = new UnpooledByteBufAllocator(true);
netty4OnHeapPooled = new PooledByteBufAllocator(false, 1, 1, 4096, 4, 0, 0, 0, true);
@@ -35,7 +35,7 @@ import static org.assertj.core.api.Assertions.fail;
* @since 4.1
*/
@Disabled
public class SpelCompilationPerformanceTests extends AbstractExpressionTests {
class SpelCompilationPerformanceTests extends AbstractExpressionTests {
int count = 50000; // number of evaluations that are timed in one run
@@ -829,7 +829,7 @@ class JdbcTemplateTests {
}));
}
void test3BatchesOf2ItemsFailing(Consumer<Exception> exception) throws Exception {
private void test3BatchesOf2ItemsFailing(Consumer<Exception> exception) throws Exception {
String sql = "INSERT INTO NOSUCHTABLE values (?)";
List<Integer> ids = Arrays.asList(1, 2, 3, 2, 4, 5);
int[] rowsAffected = new int[] {1, 1};
@@ -53,7 +53,7 @@ class HeaderMethodArgumentResolverTests {
@BeforeEach
public void setup() {
void setup() {
GenericApplicationContext context = new GenericApplicationContext();
context.refresh();
this.resolver = new HeaderMethodArgumentResolver(new DefaultConversionService(), context.getBeanFactory());
@@ -59,7 +59,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Rossen Stoyanchev
*/
@SuppressWarnings("ALL")
public class MessageMappingMessageHandlerTests {
class MessageMappingMessageHandlerTests {
private TestEncoderMethodReturnValueHandler returnValueHandler;
@@ -54,7 +54,7 @@ class HeaderMethodArgumentResolverTests {
@BeforeEach
public void setup() {
void setup() {
GenericApplicationContext context = new GenericApplicationContext();
context.refresh();
this.resolver = new HeaderMethodArgumentResolver(new DefaultConversionService(), context.getBeanFactory());
@@ -74,7 +74,7 @@ class RSocketClientToServerIntegrationTests {
@BeforeAll
@SuppressWarnings("ConstantConditions")
public static void setupOnce() {
static void setupOnce() {
MimeType metadataMimeType = MimeTypeUtils.parseMimeType(
WellKnownMimeType.MESSAGE_RSOCKET_COMPOSITE_METADATA.getString());
@@ -71,7 +71,7 @@ import static org.mockito.Mockito.verify;
* @author Stephane Nicoll
*/
@ExtendWith(MockitoExtension.class)
public class SendToMethodReturnValueHandlerTests {
class SendToMethodReturnValueHandlerTests {
private static final MimeType MIME_TYPE = new MimeType("text", "plain", StandardCharsets.UTF_8);
@@ -79,7 +79,7 @@ import static org.mockito.Mockito.verify;
* @author Sebastien Deleuze
*/
@ExtendWith(MockitoExtension.class)
public class SimpAnnotationMethodMessageHandlerTests {
class SimpAnnotationMethodMessageHandlerTests {
private static final String TEST_INVALID_VALUE = "invalidValue";
@@ -60,7 +60,7 @@ import static org.mockito.Mockito.verifyNoMoreInteractions;
*/
@ExtendWith(MockitoExtension.class)
@SuppressWarnings("unchecked")
public class SimpleBrokerMessageHandlerTests {
class SimpleBrokerMessageHandlerTests {
private SimpleBrokerMessageHandler messageHandler;
@@ -66,7 +66,7 @@ import static org.mockito.Mockito.verifyNoMoreInteractions;
* @author Rossen Stoyanchev
*/
@MockitoSettings(strictness = Strictness.LENIENT)
public class DefaultStompSessionTests {
class DefaultStompSessionTests {
private DefaultStompSession session;
@@ -32,11 +32,11 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy;
* @author Injae Kim
* @author Rossen Stoyanchev
*/
public class SplittingStompEncoderTests {
class SplittingStompEncoderTests {
private static final StompEncoder ENCODER = new StompEncoder();
public static final byte[] EMPTY_PAYLOAD = new byte[0];
private static final byte[] EMPTY_PAYLOAD = new byte[0];
@Test
@@ -47,7 +47,7 @@ import static org.mockito.Mockito.verifyNoMoreInteractions;
* @author Phillip Webb
*/
@ExtendWith(MockitoExtension.class)
public class ExecutorSubscribableChannelTests {
class ExecutorSubscribableChannelTests {
private ExecutorSubscribableChannel channel = new ExecutorSubscribableChannel();
@@ -57,7 +57,7 @@ public abstract class AbstractMarshallerTests<M extends Marshaller> {
protected Object flights;
@BeforeEach
public final void setUp() throws Exception {
final void setUp() throws Exception {
marshaller = createMarshaller();
flights = createFlights();
}
@@ -59,7 +59,7 @@ public abstract class AbstractUnmarshallerTests<U extends Unmarshaller> {
"<tns:flight><tns:number>42</tns:number></tns:flight></tns:flights>";
@BeforeEach
public final void setUp() throws Exception {
final void setUp() throws Exception {
unmarshaller = createUnmarshaller();
}
@@ -216,7 +216,7 @@ class ScriptUtilsTests {
~/* double " quotes */\n insert into colors(color_num) values(42);~ | ; | true
~/* double \\" quotes */\n insert into colors(color_num) values(42);~ | ; | true
""")
public void containsStatementSeparator(String script, String delimiter, boolean expected) {
void containsStatementSeparator(String script, String delimiter, boolean expected) {
boolean contains = ScriptUtils.containsStatementSeparator(null, script, delimiter,
DEFAULT_COMMENT_PREFIXES, DEFAULT_BLOCK_COMMENT_START_DELIMITER, DEFAULT_BLOCK_COMMENT_END_DELIMITER);
@@ -37,7 +37,7 @@ import static org.mockito.Mockito.when;
* @author Mark Paluch
*/
@ExtendWith(MockitoExtension.class)
public class BeanFactoryConnectionFactoryLookupTests {
class BeanFactoryConnectionFactoryLookupTests {
private static final String CONNECTION_FACTORY_BEAN_NAME = "connectionFactory";
@@ -47,7 +47,7 @@ abstract class AbstractDatabaseClientIntegrationTests {
@BeforeEach
public void before() {
protected void before() {
connectionFactory = createConnectionFactory();
Mono.from(connectionFactory.create())
@@ -19,7 +19,7 @@ package org.springframework.r2dbc.core;
import io.r2dbc.spi.ConnectionFactory;
import io.r2dbc.spi.Result;
import org.assertj.core.api.Condition;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.AutoClose;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import reactor.core.publisher.Flux;
@@ -48,6 +48,7 @@ abstract class AbstractTransactionalDatabaseClientIntegrationTests {
private ConnectionFactory connectionFactory;
@AutoClose
AnnotationConfigApplicationContext context;
DatabaseClient databaseClient;
@@ -58,7 +59,7 @@ abstract class AbstractTransactionalDatabaseClientIntegrationTests {
@BeforeEach
public void before() {
void before() {
connectionFactory = createConnectionFactory();
context = new AnnotationConfigApplicationContext();
@@ -78,11 +79,6 @@ abstract class AbstractTransactionalDatabaseClientIntegrationTests {
rxtx = TransactionalOperator.create(transactionManager);
}
@AfterEach
public void tearDown() {
context.close();
}
/**
* Create a {@link ConnectionFactory} to be used in this test.
@@ -45,7 +45,7 @@ class H2DatabaseClientContextIntegrationTests extends H2DatabaseClientIntegratio
}
@AfterEach
public void tearDown() {
void tearDown() {
context.close();
assertThatExceptionOfType(R2dbcNonTransientResourceException.class).isThrownBy(
() -> connectionFactory.create().block());
@@ -52,5 +52,5 @@ import org.junit.platform.suite.api.Suite;
key = ClassOrderer.DEFAULT_ORDER_PROPERTY_NAME,
value = "org.junit.jupiter.api.ClassOrderer$ClassName"
)
public class ContextCacheTestSuite {
class ContextCacheTestSuite {
}
@@ -50,5 +50,5 @@ import org.junit.platform.suite.api.Suite;
key = ClassOrderer.DEFAULT_ORDER_PROPERTY_NAME,
value = "org.junit.jupiter.api.ClassOrderer$ClassName"
)
public class ContextConfigTestSuite {
class ContextConfigTestSuite {
}
@@ -45,13 +45,13 @@ import static org.springframework.test.context.TestExecutionListeners.MergeMode.
*/
@ExtendWith(SpringExtension.class)
@TestExecutionListeners(listeners = CustomEventPublishingTestExecutionListener.class, mergeMode = MERGE_WITH_DEFAULTS)
public class CustomTestEventTests {
class CustomTestEventTests {
private static final List<CustomEvent> events = new ArrayList<>();
@BeforeEach
public void clearEvents() {
void clearEvents() {
events.clear();
}
@@ -66,7 +66,7 @@ import static org.mockito.Mockito.verify;
* @author Sam Brannen
* @since 5.2
*/
public class EventPublishingTestExecutionListenerIntegrationTests {
class EventPublishingTestExecutionListenerIntegrationTests {
private static final String THREAD_NAME_PREFIX = "Test-";
@@ -88,7 +88,7 @@ public class EventPublishingTestExecutionListenerIntegrationTests {
@AfterEach
public void closeApplicationContext() {
void closeApplicationContext() {
this.testContext.markApplicationContextDirty(null);
}
@@ -35,7 +35,7 @@ import static org.assertj.core.api.Assertions.assertThat;
*/
@ContextHierarchy(@ContextConfiguration)
@DisabledInAotMode("@ContextHierarchy is not supported in AOT")
public class DispatcherWacRootWacEarTests extends RootWacEarTests {
class DispatcherWacRootWacEarTests extends RootWacEarTests {
@Autowired
private WebApplicationContext wac;
@@ -58,5 +58,5 @@ import org.springframework.context.ApplicationContextInitializer;
key = ClassOrderer.DEFAULT_ORDER_PROPERTY_NAME,
value = "org.junit.jupiter.api.ClassOrderer$ClassName"
)
public class AciTestSuite {
class AciTestSuite {
}
@@ -53,7 +53,7 @@ import static org.assertj.core.api.Assertions.assertThat;
*/
@ExtendWith(SpringExtension.class)
@ComposedContextConfiguration(BarConfig.class)
public class InitializerConfiguredViaMetaAnnotationTests {
class InitializerConfiguredViaMetaAnnotationTests {
@Autowired
String foo;
@@ -36,7 +36,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @since 3.2
*/
@SpringJUnitConfig(initializers = EntireAppInitializer.class)
public class InitializerWithoutConfigFilesOrClassesTests {
class InitializerWithoutConfigFilesOrClassesTests {
@Autowired
private String foo;
@@ -33,7 +33,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @since 3.2
*/
@SpringJUnitConfig(initializers = DevProfileInitializer.class)
public class MergedInitializersAnnotationConfigTests extends SingleInitializerAnnotationConfigTests {
class MergedInitializersAnnotationConfigTests extends SingleInitializerAnnotationConfigTests {
@Override
@Test
@@ -36,7 +36,7 @@ import static org.assertj.core.api.Assertions.assertThat;
*/
@SpringJUnitConfig(classes = { GlobalConfig.class, DevProfileConfig.class }, initializers = {
FooBarAliasInitializer.class, DevProfileInitializer.class })
public class MultipleInitializersAnnotationConfigTests {
class MultipleInitializersAnnotationConfigTests {
@Autowired
private String foo, bar, baz;
@@ -50,7 +50,7 @@ import static org.assertj.core.api.Assertions.assertThat;
// Note: the ordering of the initializers is intentionally: two, one.
@SpringJUnitConfig(classes = { GlobalConfig.class, ConfigTwo.class, ConfigOne.class }, initializers = {
OrderedTwoInitializer.class, OrderedOneInitializer.class })
public class OrderedInitializersAnnotationConfigTests {
class OrderedInitializersAnnotationConfigTests {
private static final String PROFILE_GLOBAL = "global";
private static final String PROFILE_ONE = "one";
@@ -33,7 +33,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @since 3.2
*/
@SpringJUnitConfig(initializers = DevProfileInitializer.class, inheritInitializers = false)
public class OverriddenInitializersAnnotationConfigTests extends SingleInitializerAnnotationConfigTests {
class OverriddenInitializersAnnotationConfigTests extends SingleInitializerAnnotationConfigTests {
@Test
@Override
@@ -38,7 +38,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @since 4.1
*/
@SpringJUnitConfig(initializers = PropertySourcesInitializerTests.PropertySourceInitializer.class)
public class PropertySourcesInitializerTests {
class PropertySourcesInitializerTests {
@Configuration
static class Config {
@@ -35,7 +35,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @since 3.2
*/
@SpringJUnitConfig(classes = { GlobalConfig.class, DevProfileConfig.class }, initializers = FooBarAliasInitializer.class)
public class SingleInitializerAnnotationConfigTests {
class SingleInitializerAnnotationConfigTests {
@Autowired
protected String foo;
@@ -35,7 +35,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @since 3.2
*/
@SpringJUnitConfig(initializers = { FooBarAliasInitializer.class, DevProfileInitializer.class })
public class MultipleInitializersXmlConfigTests {
class MultipleInitializersXmlConfigTests {
@Autowired
private String foo, bar, baz;
@@ -46,5 +46,5 @@ import org.junit.platform.suite.api.Suite;
@SelectPackages("org.springframework.test.context.junit.jupiter")
@IncludeClassNamePatterns(".*Tests$")
@ExcludeTags("failing-test-case")
public class SpringJUnitJupiterTestSuite {
class SpringJUnitJupiterTestSuite {
}
@@ -24,11 +24,12 @@ import org.springframework.test.context.ActiveProfilesResolver;
* @since 4.0
*/
@ActiveProfiles(resolver = DevProfileResolverAnnotationConfigTests.class, inheritProfiles = false)
public class DevProfileResolverAnnotationConfigTests extends DevProfileAnnotationConfigTests implements
class DevProfileResolverAnnotationConfigTests extends DevProfileAnnotationConfigTests implements
ActiveProfilesResolver {
@Override
public String[] resolve(Class<?> testClass) {
return new String[] { "dev" };
}
}
@@ -30,7 +30,7 @@ import static org.assertj.core.api.Assertions.assertThatNoException;
* @author Sam Brannen
* @since 5.3.10
*/
public class ExceptionCollectorTests {
class ExceptionCollectorTests {
private static final char EOL = '\n';
@@ -37,7 +37,7 @@ import static org.hamcrest.Matchers.hasXPath;
*
* @author Rossen Stoyanchev
*/
public class ContentRequestMatchersTests {
class ContentRequestMatchersTests {
private final MockClientHttpRequest request = new MockClientHttpRequest();
@@ -32,7 +32,7 @@ import static org.hamcrest.Matchers.equalTo;
* @author Rossen Stoyanchev
* @author Sam Brannen
*/
public class JsonPathRequestMatchersTests {
class JsonPathRequestMatchersTests {
private static final String REQUEST_CONTENT = "{" + //
"'str': 'foo', " + //
@@ -44,7 +44,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
* @author Valentin Spac
* @author Rossen Stoyanchev
*/
public class MultipartRequestMatchersTests {
class MultipartRequestMatchersTests {
private final MockClientHttpRequest request = new MockClientHttpRequest();
@@ -54,7 +54,7 @@ public class MultipartRequestMatchersTests {
@BeforeEach
public void setup() {
void setup() {
this.request.getHeaders().setContentType(MediaType.MULTIPART_FORM_DATA);
}
@@ -31,7 +31,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
*
* @author Rossen Stoyanchev
*/
public class XpathRequestMatchersTests {
class XpathRequestMatchersTests {
private static final String RESPONSE_CONTENT = "<foo><bar>111</bar><bar>true</bar></foo>";
@@ -39,7 +39,7 @@ public class XpathRequestMatchersTests {
@BeforeEach
public void setUp() throws IOException {
void setUp() throws IOException {
this.request = new MockClientHttpRequest();
this.request.getBody().write(RESPONSE_CONTENT.getBytes());
}
@@ -53,7 +53,7 @@ import static org.springframework.test.web.client.response.MockRestResponseCreat
* @see ContentRequestMatchersIntegrationTests
* @see XmlContentRequestMatchersIntegrationTests
*/
public class XpathRequestMatchersIntegrationTests {
class XpathRequestMatchersIntegrationTests {
private static final Map<String, String> NS =
Collections.singletonMap("ns", "https://example.org/music/people");
@@ -67,7 +67,7 @@ public class XpathRequestMatchersIntegrationTests {
@BeforeEach
public void setup() {
void setup() {
List<Person> composers = Arrays.asList(
new Person("Johann Sebastian Bach").setSomeDouble(21),
new Person("Johannes Brahms").setSomeDouble(.0025),
@@ -34,8 +34,7 @@ import org.springframework.web.server.session.WebSessionManager;
* Unit tests with {@link ApplicationContextSpec}.
* @author Rossen Stoyanchev
*/
public class ApplicationContextSpecTests {
class ApplicationContextSpecTests {
@Test // SPR-17094
void sessionManagerBean() {
@@ -41,7 +41,7 @@ import static org.assertj.core.api.Assertions.assertThat;
*
* @author Rossen Stoyanchev
*/
public class DefaultControllerSpecTests {
class DefaultControllerSpecTests {
@Test
void controller() {
@@ -30,7 +30,7 @@ import org.springframework.web.reactive.function.server.ServerResponse;
*
* @author Rossen Stoyanchev
*/
public class DefaultRouterFunctionSpecTests {
class DefaultRouterFunctionSpecTests {
@Test
void webFilter() {
@@ -48,7 +48,7 @@ import static org.assertj.core.api.Assertions.assertThat;
*
* @author Rossen Stoyanchev
*/
public class HttpHandlerConnectorTests {
class HttpHandlerConnectorTests {
@Test
void adaptRequest() {
@@ -37,7 +37,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* Tests for {@link AbstractMockServerSpec}.
* @author Rossen Stoyanchev
*/
public class MockServerSpecTests {
class MockServerSpecTests {
private final TestMockServerSpec serverSpec = new TestMockServerSpec();
@@ -37,8 +37,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* Test scenarios involving a mock server.
* @author Rossen Stoyanchev
*/
public class MockServerTests {
class MockServerTests {
@Test // SPR-15674 (in comments)
void mutateDoesNotCreateNewSession() {
@@ -50,7 +50,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Rossen Stoyanchev
* @since 5.0
*/
public class WiretapConnectorTests {
class WiretapConnectorTests {
private final LeakAwareDataBufferFactory bufferFactory =
new LeakAwareDataBufferFactory(new NettyDataBufferFactory(PooledByteBufAllocator.DEFAULT));
@@ -37,7 +37,7 @@ import static org.assertj.core.api.Assertions.assertThat;
*
* @author Rossen Stoyanchev
*/
public class WebTestClientResponseTests {
class WebTestClientResponseTests {
private final WebTestClient client = WebTestClient.bindToController(HelloController.class).build();
@@ -36,7 +36,7 @@ import static org.assertj.core.api.Assertions.assertThat;
*
* @author Rossen Stoyanchev
*/
public class ApiVersionTests {
class ApiVersionTests {
@Test
void header() {
@@ -35,7 +35,7 @@ import static org.assertj.core.api.Assertions.assertThat;
*
* @author Rossen Stoyanchev
*/
public class GlobalEntityResultConsumerTests {
class GlobalEntityResultConsumerTests {
private final StringBuilder output = new StringBuilder();
@@ -29,13 +29,13 @@ import org.springframework.web.bind.annotation.RestController;
*
* @author Rossen Stoyanchev
*/
public class ControllerTests {
class ControllerTests {
private WebTestClient client;
@BeforeEach
public void setUp() throws Exception {
void setUp() throws Exception {
this.client = WebTestClient.bindToController(new TestController()).build();
}
@@ -35,7 +35,7 @@ import static org.springframework.web.reactive.function.server.RouterFunctions.r
* @author Rossen Stoyanchev
* @since 5.0
*/
public class HttpServerTests {
class HttpServerTests {
private ReactorHttpServer server;
@@ -43,7 +43,7 @@ public class HttpServerTests {
@BeforeEach
public void start() throws Exception {
void start() throws Exception {
HttpHandler httpHandler = RouterFunctions.toHttpHandler(
route(GET("/test"), request -> ServerResponse.ok().bodyValue("It works!")));
@@ -58,7 +58,7 @@ public class HttpServerTests {
}
@AfterEach
public void stop() {
void stop() {
this.server.stop();
}
@@ -32,13 +32,13 @@ import static org.springframework.web.reactive.function.server.RouterFunctions.r
* @author Rossen Stoyanchev
* @since 5.0
*/
public class RouterFunctionTests {
class RouterFunctionTests {
private WebTestClient testClient;
@BeforeEach
public void setUp() throws Exception {
void setUp() throws Exception {
RouterFunction<?> route = route(GET("/test"), request ->
ServerResponse.ok().bodyValue("It works!"));

Some files were not shown because too many files have changed in this diff Show More