diff --git a/spring-aspects/src/test/java/org/springframework/aop/aspectj/autoproxy/AutoProxyWithCodeStyleAspectsTests.java b/spring-aspects/src/test/java/org/springframework/aop/aspectj/autoproxy/AutoProxyWithCodeStyleAspectsTests.java index 43947fa29c..fc4b31714d 100644 --- a/spring-aspects/src/test/java/org/springframework/aop/aspectj/autoproxy/AutoProxyWithCodeStyleAspectsTests.java +++ b/spring-aspects/src/test/java/org/springframework/aop/aspectj/autoproxy/AutoProxyWithCodeStyleAspectsTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * 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. @@ -23,11 +23,10 @@ import org.springframework.context.support.ClassPathXmlApplicationContext; /** * @author Adrian Colyer */ -public class AutoProxyWithCodeStyleAspectsTests { +class AutoProxyWithCodeStyleAspectsTests { @Test - @SuppressWarnings("resource") - public void noAutoproxyingOfAjcCompiledAspects() { + void noAutoproxyingOfAjcCompiledAspects() { new ClassPathXmlApplicationContext("org/springframework/aop/aspectj/autoproxy/ajcAutoproxyTests.xml"); } diff --git a/spring-aspects/src/test/java/org/springframework/beans/factory/aspectj/SpringConfiguredWithAutoProxyingTests.java b/spring-aspects/src/test/java/org/springframework/beans/factory/aspectj/SpringConfiguredWithAutoProxyingTests.java index a02bcad679..9be725fa8c 100644 --- a/spring-aspects/src/test/java/org/springframework/beans/factory/aspectj/SpringConfiguredWithAutoProxyingTests.java +++ b/spring-aspects/src/test/java/org/springframework/beans/factory/aspectj/SpringConfiguredWithAutoProxyingTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * 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. @@ -23,8 +23,7 @@ import org.springframework.context.support.ClassPathXmlApplicationContext; public class SpringConfiguredWithAutoProxyingTests { @Test - @SuppressWarnings("resource") - public void springConfiguredAndAutoProxyUsedTogether() { + void springConfiguredAndAutoProxyUsedTogether() { // instantiation is sufficient to trigger failure if this is going to fail... new ClassPathXmlApplicationContext("org/springframework/beans/factory/aspectj/springConfigured.xml"); } diff --git a/spring-aspects/src/test/java/org/springframework/beans/factory/aspectj/XmlBeanConfigurerTests.java b/spring-aspects/src/test/java/org/springframework/beans/factory/aspectj/XmlBeanConfigurerTests.java index 71e98f6829..053417e218 100644 --- a/spring-aspects/src/test/java/org/springframework/beans/factory/aspectj/XmlBeanConfigurerTests.java +++ b/spring-aspects/src/test/java/org/springframework/beans/factory/aspectj/XmlBeanConfigurerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * 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. @@ -25,10 +25,10 @@ import static org.assertj.core.api.Assertions.assertThat; /** * @author Chris Beams */ -public class XmlBeanConfigurerTests { +class XmlBeanConfigurerTests { @Test - public void injection() { + void injection() { try (ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext( "org/springframework/beans/factory/aspectj/beanConfigurerTests.xml")) { diff --git a/spring-aspects/src/test/java/org/springframework/cache/aspectj/AbstractCacheAnnotationTests.java b/spring-aspects/src/test/java/org/springframework/cache/aspectj/AbstractCacheAnnotationTests.java index 53f804d33f..8cec3f65ea 100644 --- a/spring-aspects/src/test/java/org/springframework/cache/aspectj/AbstractCacheAnnotationTests.java +++ b/spring-aspects/src/test/java/org/springframework/cache/aspectj/AbstractCacheAnnotationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * 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. @@ -451,7 +451,7 @@ public abstract class AbstractCacheAnnotationTests { protected void testMultiEvict(CacheableService service) { Object o1 = new Object(); - Object o2 = o1.toString() + "A"; + Object o2 = o1 + "A"; Object r1 = service.multiCache(o1); @@ -556,132 +556,132 @@ public abstract class AbstractCacheAnnotationTests { } @Test - public void testCacheable() { + void testCacheable() { testCacheable(this.cs); } @Test - public void testCacheableNull() { + void testCacheableNull() { testCacheableNull(this.cs); } @Test - public void testCacheableSync() { + void testCacheableSync() { testCacheableSync(this.cs); } @Test - public void testCacheableSyncNull() { + void testCacheableSyncNull() { testCacheableSyncNull(this.cs); } @Test - public void testEvict() { + void testEvict() { testEvict(this.cs, true); } @Test - public void testEvictEarly() { + void testEvictEarly() { testEvictEarly(this.cs); } @Test - public void testEvictWithException() { + void testEvictWithException() { testEvictException(this.cs); } @Test - public void testEvictAll() { + void testEvictAll() { testEvictAll(this.cs, true); } @Test - public void testEvictAllEarly() { + void testEvictAllEarly() { testEvictAllEarly(this.cs); } @Test - public void testEvictWithKey() { + void testEvictWithKey() { testEvictWithKey(this.cs); } @Test - public void testEvictWithKeyEarly() { + void testEvictWithKeyEarly() { testEvictWithKeyEarly(this.cs); } @Test - public void testConditionalExpression() { + void testConditionalExpression() { testConditionalExpression(this.cs); } @Test - public void testConditionalExpressionSync() { + void testConditionalExpressionSync() { testConditionalExpressionSync(this.cs); } @Test - public void testUnlessExpression() { + void testUnlessExpression() { testUnlessExpression(this.cs); } @Test - public void testClassCacheUnlessExpression() { + void testClassCacheUnlessExpression() { testUnlessExpression(this.cs); } @Test - public void testKeyExpression() { + void testKeyExpression() { testKeyExpression(this.cs); } @Test - public void testVarArgsKey() { + void testVarArgsKey() { testVarArgsKey(this.cs); } @Test - public void testClassCacheCacheable() { + void testClassCacheCacheable() { testCacheable(this.ccs); } @Test - public void testClassCacheEvict() { + void testClassCacheEvict() { testEvict(this.ccs, true); } @Test - public void testClassEvictEarly() { + void testClassEvictEarly() { testEvictEarly(this.ccs); } @Test - public void testClassEvictAll() { + void testClassEvictAll() { testEvictAll(this.ccs, true); } @Test - public void testClassEvictWithException() { + void testClassEvictWithException() { testEvictException(this.ccs); } @Test - public void testClassCacheEvictWithWKey() { + void testClassCacheEvictWithWKey() { testEvictWithKey(this.ccs); } @Test - public void testClassEvictWithKeyEarly() { + void testClassEvictWithKeyEarly() { testEvictWithKeyEarly(this.ccs); } @Test - public void testNullValue() { + void testNullValue() { testNullValue(this.cs); } @Test - public void testClassNullValue() { + void testClassNullValue() { Object key = new Object(); assertThat(this.ccs.nullValue(key)).isNull(); int nr = this.ccs.nullInvocations().intValue(); @@ -694,27 +694,27 @@ public abstract class AbstractCacheAnnotationTests { } @Test - public void testMethodName() { + void testMethodName() { testMethodName(this.cs, "name"); } @Test - public void testClassMethodName() { + void testClassMethodName() { testMethodName(this.ccs, "nametestCache"); } @Test - public void testRootVars() { + void testRootVars() { testRootVars(this.cs); } @Test - public void testClassRootVars() { + void testClassRootVars() { testRootVars(this.ccs); } @Test - public void testCustomKeyGenerator() { + void testCustomKeyGenerator() { Object param = new Object(); Object r1 = this.cs.customKeyGenerator(param); assertThat(this.cs.customKeyGenerator(param)).isSameAs(r1); @@ -725,14 +725,14 @@ public abstract class AbstractCacheAnnotationTests { } @Test - public void testUnknownCustomKeyGenerator() { + void testUnknownCustomKeyGenerator() { Object param = new Object(); assertThatExceptionOfType(NoSuchBeanDefinitionException.class).isThrownBy(() -> this.cs.unknownCustomKeyGenerator(param)); } @Test - public void testCustomCacheManager() { + void testCustomCacheManager() { CacheManager customCm = this.ctx.getBean("customCacheManager", CacheManager.class); Object key = new Object(); Object r1 = this.cs.customCacheManager(key); @@ -743,139 +743,139 @@ public abstract class AbstractCacheAnnotationTests { } @Test - public void testUnknownCustomCacheManager() { + void testUnknownCustomCacheManager() { Object param = new Object(); assertThatExceptionOfType(NoSuchBeanDefinitionException.class).isThrownBy(() -> this.cs.unknownCustomCacheManager(param)); } @Test - public void testNullArg() { + void testNullArg() { testNullArg(this.cs); } @Test - public void testClassNullArg() { + void testClassNullArg() { testNullArg(this.ccs); } @Test - public void testCheckedException() { + void testCheckedException() { testCheckedThrowable(this.cs); } @Test - public void testClassCheckedException() { + void testClassCheckedException() { testCheckedThrowable(this.ccs); } @Test - public void testCheckedExceptionSync() { + void testCheckedExceptionSync() { testCheckedThrowableSync(this.cs); } @Test - public void testClassCheckedExceptionSync() { + void testClassCheckedExceptionSync() { testCheckedThrowableSync(this.ccs); } @Test - public void testUncheckedException() { + void testUncheckedException() { testUncheckedThrowable(this.cs); } @Test - public void testClassUncheckedException() { + void testClassUncheckedException() { testUncheckedThrowable(this.ccs); } @Test - public void testUncheckedExceptionSync() { + void testUncheckedExceptionSync() { testUncheckedThrowableSync(this.cs); } @Test - public void testClassUncheckedExceptionSync() { + void testClassUncheckedExceptionSync() { testUncheckedThrowableSync(this.ccs); } @Test - public void testUpdate() { + void testUpdate() { testCacheUpdate(this.cs); } @Test - public void testClassUpdate() { + void testClassUpdate() { testCacheUpdate(this.ccs); } @Test - public void testConditionalUpdate() { + void testConditionalUpdate() { testConditionalCacheUpdate(this.cs); } @Test - public void testClassConditionalUpdate() { + void testClassConditionalUpdate() { testConditionalCacheUpdate(this.ccs); } @Test - public void testMultiCache() { + void testMultiCache() { testMultiCache(this.cs); } @Test - public void testClassMultiCache() { + void testClassMultiCache() { testMultiCache(this.ccs); } @Test - public void testMultiEvict() { + void testMultiEvict() { testMultiEvict(this.cs); } @Test - public void testClassMultiEvict() { + void testClassMultiEvict() { testMultiEvict(this.ccs); } @Test - public void testMultiPut() { + void testMultiPut() { testMultiPut(this.cs); } @Test - public void testClassMultiPut() { + void testClassMultiPut() { testMultiPut(this.ccs); } @Test - public void testPutRefersToResult() { + void testPutRefersToResult() { testPutRefersToResult(this.cs); } @Test - public void testClassPutRefersToResult() { + void testClassPutRefersToResult() { testPutRefersToResult(this.ccs); } @Test - public void testMultiCacheAndEvict() { + void testMultiCacheAndEvict() { testMultiCacheAndEvict(this.cs); } @Test - public void testClassMultiCacheAndEvict() { + void testClassMultiCacheAndEvict() { testMultiCacheAndEvict(this.ccs); } @Test - public void testMultiConditionalCacheAndEvict() { + void testMultiConditionalCacheAndEvict() { testMultiConditionalCacheAndEvict(this.cs); } @Test - public void testClassMultiConditionalCacheAndEvict() { + void testClassMultiConditionalCacheAndEvict() { testMultiConditionalCacheAndEvict(this.ccs); } diff --git a/spring-aspects/src/test/java/org/springframework/cache/aspectj/AspectJCacheAnnotationTests.java b/spring-aspects/src/test/java/org/springframework/cache/aspectj/AspectJCacheAnnotationTests.java index 4601c0ea81..ffeab37c42 100644 --- a/spring-aspects/src/test/java/org/springframework/cache/aspectj/AspectJCacheAnnotationTests.java +++ b/spring-aspects/src/test/java/org/springframework/cache/aspectj/AspectJCacheAnnotationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * 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. @@ -28,7 +28,7 @@ import static org.assertj.core.api.Assertions.assertThat; /** * @author Costin Leau */ -public class AspectJCacheAnnotationTests extends AbstractCacheAnnotationTests { +class AspectJCacheAnnotationTests extends AbstractCacheAnnotationTests { @Override protected ConfigurableApplicationContext getApplicationContext() { @@ -37,7 +37,7 @@ public class AspectJCacheAnnotationTests extends AbstractCacheAnnotationTests { } @Test - public void testKeyStrategy() { + void testKeyStrategy() { AnnotationCacheAspect aspect = ctx.getBean( "org.springframework.cache.config.internalCacheAspect", AnnotationCacheAspect.class); assertThat(aspect.getKeyGenerator()).isSameAs(ctx.getBean("keyGenerator")); diff --git a/spring-aspects/src/test/java/org/springframework/cache/aspectj/AspectJEnableCachingIsolatedTests.java b/spring-aspects/src/test/java/org/springframework/cache/aspectj/AspectJEnableCachingIsolatedTests.java index 7d73e484b4..75647051d4 100644 --- a/spring-aspects/src/test/java/org/springframework/cache/aspectj/AspectJEnableCachingIsolatedTests.java +++ b/spring-aspects/src/test/java/org/springframework/cache/aspectj/AspectJEnableCachingIsolatedTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * 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. @@ -47,7 +47,7 @@ import static org.assertj.core.api.Assertions.assertThat; /** * @author Stephane Nicoll */ -public class AspectJEnableCachingIsolatedTests { +class AspectJEnableCachingIsolatedTests { private ConfigurableApplicationContext ctx; @@ -65,14 +65,14 @@ public class AspectJEnableCachingIsolatedTests { @Test - public void testKeyStrategy() { + void testKeyStrategy() { load(EnableCachingConfig.class); AnnotationCacheAspect aspect = this.ctx.getBean(AnnotationCacheAspect.class); assertThat(aspect.getKeyGenerator()).isSameAs(this.ctx.getBean("keyGenerator", KeyGenerator.class)); } @Test - public void testCacheErrorHandler() { + void testCacheErrorHandler() { load(EnableCachingConfig.class); AnnotationCacheAspect aspect = this.ctx.getBean(AnnotationCacheAspect.class); assertThat(aspect.getErrorHandler()).isSameAs(this.ctx.getBean("errorHandler", CacheErrorHandler.class)); @@ -82,12 +82,12 @@ public class AspectJEnableCachingIsolatedTests { // --- local tests ------- @Test - public void singleCacheManagerBean() { + void singleCacheManagerBean() { load(SingleCacheManagerConfig.class); } @Test - public void multipleCacheManagerBeans() { + void multipleCacheManagerBeans() { try { load(MultiCacheManagerConfig.class); } @@ -97,12 +97,12 @@ public class AspectJEnableCachingIsolatedTests { } @Test - public void multipleCacheManagerBeans_implementsCachingConfigurer() { + void multipleCacheManagerBeans_implementsCachingConfigurer() { load(MultiCacheManagerConfigurer.class); // does not throw } @Test - public void multipleCachingConfigurers() { + void multipleCachingConfigurers() { try { load(MultiCacheManagerConfigurer.class, EnableCachingConfig.class); } @@ -112,7 +112,7 @@ public class AspectJEnableCachingIsolatedTests { } @Test - public void noCacheManagerBeans() { + void noCacheManagerBeans() { try { load(EmptyConfig.class); } @@ -132,7 +132,7 @@ public class AspectJEnableCachingIsolatedTests { } @Test - public void bothSetOnlyResolverIsUsed() { + void bothSetOnlyResolverIsUsed() { load(FullCachingConfig.class); AnnotationCacheAspect aspect = this.ctx.getBean(AnnotationCacheAspect.class); diff --git a/spring-aspects/src/test/java/org/springframework/cache/aspectj/AspectJEnableCachingTests.java b/spring-aspects/src/test/java/org/springframework/cache/aspectj/AspectJEnableCachingTests.java index 4c5f7b414a..8b3b440782 100644 --- a/spring-aspects/src/test/java/org/springframework/cache/aspectj/AspectJEnableCachingTests.java +++ b/spring-aspects/src/test/java/org/springframework/cache/aspectj/AspectJEnableCachingTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * 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. @@ -37,7 +37,7 @@ import org.springframework.context.testfixture.cache.SomeKeyGenerator; /** * @author Stephane Nicoll */ -public class AspectJEnableCachingTests extends AbstractCacheAnnotationTests { +class AspectJEnableCachingTests extends AbstractCacheAnnotationTests { @Override protected ConfigurableApplicationContext getApplicationContext() { diff --git a/spring-aspects/src/test/java/org/springframework/cache/aspectj/JCacheAspectJJavaConfigTests.java b/spring-aspects/src/test/java/org/springframework/cache/aspectj/JCacheAspectJJavaConfigTests.java index dc278365d7..a106633859 100644 --- a/spring-aspects/src/test/java/org/springframework/cache/aspectj/JCacheAspectJJavaConfigTests.java +++ b/spring-aspects/src/test/java/org/springframework/cache/aspectj/JCacheAspectJJavaConfigTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * 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. @@ -34,7 +34,7 @@ import org.springframework.contextsupport.testfixture.jcache.AbstractJCacheAnnot /** * @author Stephane Nicoll */ -public class JCacheAspectJJavaConfigTests extends AbstractJCacheAnnotationTests { +class JCacheAspectJJavaConfigTests extends AbstractJCacheAnnotationTests { @Override protected ApplicationContext getApplicationContext() { diff --git a/spring-aspects/src/test/java/org/springframework/cache/aspectj/JCacheAspectJNamespaceConfigTests.java b/spring-aspects/src/test/java/org/springframework/cache/aspectj/JCacheAspectJNamespaceConfigTests.java index c755d8c3f4..a2879aa576 100644 --- a/spring-aspects/src/test/java/org/springframework/cache/aspectj/JCacheAspectJNamespaceConfigTests.java +++ b/spring-aspects/src/test/java/org/springframework/cache/aspectj/JCacheAspectJNamespaceConfigTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2021 the original author or authors. + * 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. @@ -24,7 +24,7 @@ import org.springframework.contextsupport.testfixture.jcache.AbstractJCacheAnnot * @author Stephane Nicoll * @author Sam Brannen */ -public class JCacheAspectJNamespaceConfigTests extends AbstractJCacheAnnotationTests { +class JCacheAspectJNamespaceConfigTests extends AbstractJCacheAnnotationTests { @Override protected ApplicationContext getApplicationContext() { diff --git a/spring-aspects/src/test/java/org/springframework/context/annotation/aspectj/AnnotationBeanConfigurerTests.java b/spring-aspects/src/test/java/org/springframework/context/annotation/aspectj/AnnotationBeanConfigurerTests.java index c914de1a06..49544d99e0 100644 --- a/spring-aspects/src/test/java/org/springframework/context/annotation/aspectj/AnnotationBeanConfigurerTests.java +++ b/spring-aspects/src/test/java/org/springframework/context/annotation/aspectj/AnnotationBeanConfigurerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * 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. @@ -33,10 +33,10 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Chris Beams * @since 3.1 */ -public class AnnotationBeanConfigurerTests { +class AnnotationBeanConfigurerTests { @Test - public void injection() { + void injection() { try (AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(Config.class)) { ShouldBeConfiguredBySpring myObject = new ShouldBeConfiguredBySpring(); assertThat(myObject.getName()).isEqualTo("Rod"); diff --git a/spring-aspects/src/test/java/org/springframework/scheduling/aspectj/AnnotationAsyncExecutionAspectTests.java b/spring-aspects/src/test/java/org/springframework/scheduling/aspectj/AnnotationAsyncExecutionAspectTests.java index 8d81a07a04..6cf02e31db 100644 --- a/spring-aspects/src/test/java/org/springframework/scheduling/aspectj/AnnotationAsyncExecutionAspectTests.java +++ b/spring-aspects/src/test/java/org/springframework/scheduling/aspectj/AnnotationAsyncExecutionAspectTests.java @@ -64,7 +64,7 @@ public class AnnotationAsyncExecutionAspectTests { @Test - public void asyncMethodGetsRoutedAsynchronously() { + void asyncMethodGetsRoutedAsynchronously() { ClassWithoutAsyncAnnotation obj = new ClassWithoutAsyncAnnotation(); obj.incrementAsync(); executor.waitForCompletion(); @@ -74,7 +74,7 @@ public class AnnotationAsyncExecutionAspectTests { } @Test - public void asyncMethodReturningFutureGetsRoutedAsynchronouslyAndReturnsAFuture() throws InterruptedException, ExecutionException { + void asyncMethodReturningFutureGetsRoutedAsynchronouslyAndReturnsAFuture() throws InterruptedException, ExecutionException { ClassWithoutAsyncAnnotation obj = new ClassWithoutAsyncAnnotation(); Future future = obj.incrementReturningAFuture(); // No need to executor.waitForCompletion() as future.get() will have the same effect @@ -85,7 +85,7 @@ public class AnnotationAsyncExecutionAspectTests { } @Test - public void syncMethodGetsRoutedSynchronously() { + void syncMethodGetsRoutedSynchronously() { ClassWithoutAsyncAnnotation obj = new ClassWithoutAsyncAnnotation(); obj.increment(); assertThat(obj.counter).isEqualTo(1); @@ -94,7 +94,7 @@ public class AnnotationAsyncExecutionAspectTests { } @Test - public void voidMethodInAsyncClassGetsRoutedAsynchronously() { + void voidMethodInAsyncClassGetsRoutedAsynchronously() { ClassWithAsyncAnnotation obj = new ClassWithAsyncAnnotation(); obj.increment(); executor.waitForCompletion(); @@ -104,7 +104,7 @@ public class AnnotationAsyncExecutionAspectTests { } @Test - public void methodReturningFutureInAsyncClassGetsRoutedAsynchronouslyAndReturnsAFuture() throws InterruptedException, ExecutionException { + void methodReturningFutureInAsyncClassGetsRoutedAsynchronouslyAndReturnsAFuture() throws InterruptedException, ExecutionException { ClassWithAsyncAnnotation obj = new ClassWithAsyncAnnotation(); Future future = obj.incrementReturningAFuture(); assertThat(future.get().intValue()).isEqualTo(5); @@ -115,7 +115,7 @@ public class AnnotationAsyncExecutionAspectTests { /* @Test - public void methodReturningNonVoidNonFutureInAsyncClassGetsRoutedSynchronously() { + void methodReturningNonVoidNonFutureInAsyncClassGetsRoutedSynchronously() { ClassWithAsyncAnnotation obj = new ClassWithAsyncAnnotation(); int returnValue = obj.return5(); assertEquals(5, returnValue); @@ -125,7 +125,7 @@ public class AnnotationAsyncExecutionAspectTests { */ @Test - public void qualifiedAsyncMethodsAreRoutedToCorrectExecutor() throws InterruptedException, ExecutionException { + void qualifiedAsyncMethodsAreRoutedToCorrectExecutor() throws InterruptedException, ExecutionException { DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory(); beanFactory.registerBeanDefinition("e1", new RootBeanDefinition(ThreadPoolTaskExecutor.class)); AnnotationAsyncExecutionAspect.aspectOf().setBeanFactory(beanFactory); @@ -144,7 +144,7 @@ public class AnnotationAsyncExecutionAspectTests { } @Test - public void exceptionHandlerCalled() { + void exceptionHandlerCalled() { Method m = ReflectionUtils.findMethod(ClassWithException.class, "failWithVoid"); TestableAsyncUncaughtExceptionHandler exceptionHandler = new TestableAsyncUncaughtExceptionHandler(); AnnotationAsyncExecutionAspect.aspectOf().setExceptionHandler(exceptionHandler); @@ -161,7 +161,7 @@ public class AnnotationAsyncExecutionAspectTests { } @Test - public void exceptionHandlerNeverThrowsUnexpectedException() { + void exceptionHandlerNeverThrowsUnexpectedException() { Method m = ReflectionUtils.findMethod(ClassWithException.class, "failWithVoid"); TestableAsyncUncaughtExceptionHandler exceptionHandler = new TestableAsyncUncaughtExceptionHandler(true); AnnotationAsyncExecutionAspect.aspectOf().setExceptionHandler(exceptionHandler); diff --git a/spring-aspects/src/test/java/org/springframework/scheduling/aspectj/AnnotationDrivenBeanDefinitionParserTests.java b/spring-aspects/src/test/java/org/springframework/scheduling/aspectj/AnnotationDrivenBeanDefinitionParserTests.java index 20c22f4dbb..ee8799a68f 100644 --- a/spring-aspects/src/test/java/org/springframework/scheduling/aspectj/AnnotationDrivenBeanDefinitionParserTests.java +++ b/spring-aspects/src/test/java/org/springframework/scheduling/aspectj/AnnotationDrivenBeanDefinitionParserTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * 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. @@ -32,7 +32,7 @@ import static org.assertj.core.api.Assertions.assertThat; /** * @author Stephane Nicoll */ -public class AnnotationDrivenBeanDefinitionParserTests { +class AnnotationDrivenBeanDefinitionParserTests { private ConfigurableApplicationContext context; @@ -50,7 +50,7 @@ public class AnnotationDrivenBeanDefinitionParserTests { } @Test - public void asyncAspectRegistered() { + void asyncAspectRegistered() { assertThat(context.containsBean(TaskManagementConfigUtils.ASYNC_EXECUTION_ASPECT_BEAN_NAME)).isTrue(); } diff --git a/spring-aspects/src/test/java/org/springframework/scheduling/aspectj/TestableAsyncUncaughtExceptionHandler.java b/spring-aspects/src/test/java/org/springframework/scheduling/aspectj/TestableAsyncUncaughtExceptionHandler.java index 616e429960..86d575febd 100644 --- a/spring-aspects/src/test/java/org/springframework/scheduling/aspectj/TestableAsyncUncaughtExceptionHandler.java +++ b/spring-aspects/src/test/java/org/springframework/scheduling/aspectj/TestableAsyncUncaughtExceptionHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * 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. @@ -74,14 +74,6 @@ class TestableAsyncUncaughtExceptionHandler } } - private static final class UncaughtExceptionDescriptor { - private final Throwable ex; - - private final Method method; - - private UncaughtExceptionDescriptor(Throwable ex, Method method) { - this.ex = ex; - this.method = method; - } + private record UncaughtExceptionDescriptor(Throwable ex, Method method) { } } diff --git a/spring-aspects/src/test/java/org/springframework/transaction/aspectj/JtaTransactionAspectsTests.java b/spring-aspects/src/test/java/org/springframework/transaction/aspectj/JtaTransactionAspectsTests.java index b6ef121a79..0a0280aa8b 100644 --- a/spring-aspects/src/test/java/org/springframework/transaction/aspectj/JtaTransactionAspectsTests.java +++ b/spring-aspects/src/test/java/org/springframework/transaction/aspectj/JtaTransactionAspectsTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * 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. @@ -47,14 +47,14 @@ public class JtaTransactionAspectsTests { } @Test - public void commitOnAnnotatedPublicMethod() throws Throwable { + void commitOnAnnotatedPublicMethod() throws Throwable { assertThat(this.txManager.begun).isEqualTo(0); new JtaAnnotationPublicAnnotatedMember().echo(null); assertThat(this.txManager.commits).isEqualTo(1); } @Test - public void matchingRollbackOnApplied() throws Throwable { + void matchingRollbackOnApplied() { assertThat(this.txManager.begun).isEqualTo(0); InterruptedException test = new InterruptedException(); assertThatExceptionOfType(InterruptedException.class).isThrownBy(() -> @@ -65,7 +65,7 @@ public class JtaTransactionAspectsTests { } @Test - public void nonMatchingRollbackOnApplied() throws Throwable { + void nonMatchingRollbackOnApplied() { assertThat(this.txManager.begun).isEqualTo(0); IOException test = new IOException(); assertThatIOException().isThrownBy(() -> @@ -76,35 +76,35 @@ public class JtaTransactionAspectsTests { } @Test - public void commitOnAnnotatedProtectedMethod() { + void commitOnAnnotatedProtectedMethod() { assertThat(this.txManager.begun).isEqualTo(0); new JtaAnnotationProtectedAnnotatedMember().doInTransaction(); assertThat(this.txManager.commits).isEqualTo(1); } @Test - public void nonAnnotatedMethodCallingProtectedMethod() { + void nonAnnotatedMethodCallingProtectedMethod() { assertThat(this.txManager.begun).isEqualTo(0); new JtaAnnotationProtectedAnnotatedMember().doSomething(); assertThat(this.txManager.commits).isEqualTo(1); } @Test - public void commitOnAnnotatedPrivateMethod() { + void commitOnAnnotatedPrivateMethod() { assertThat(this.txManager.begun).isEqualTo(0); new JtaAnnotationPrivateAnnotatedMember().doInTransaction(); assertThat(this.txManager.commits).isEqualTo(1); } @Test - public void nonAnnotatedMethodCallingPrivateMethod() { + void nonAnnotatedMethodCallingPrivateMethod() { assertThat(this.txManager.begun).isEqualTo(0); new JtaAnnotationPrivateAnnotatedMember().doSomething(); assertThat(this.txManager.commits).isEqualTo(1); } @Test - public void notTransactional() { + void notTransactional() { assertThat(this.txManager.begun).isEqualTo(0); new TransactionAspectTests.NotTransactional().noop(); assertThat(this.txManager.begun).isEqualTo(0); diff --git a/spring-aspects/src/test/java/org/springframework/transaction/aspectj/TransactionAspectTests.java b/spring-aspects/src/test/java/org/springframework/transaction/aspectj/TransactionAspectTests.java index 8c790bf2dc..8724a19738 100644 --- a/spring-aspects/src/test/java/org/springframework/transaction/aspectj/TransactionAspectTests.java +++ b/spring-aspects/src/test/java/org/springframework/transaction/aspectj/TransactionAspectTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * 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. @@ -32,7 +32,7 @@ import static org.assertj.core.api.Assertions.assertThatRuntimeException; * @author Juergen Hoeller * @author Sam Brannen */ -public class TransactionAspectTests { +class TransactionAspectTests { private final CallCountingTransactionManager txManager = new CallCountingTransactionManager(); @@ -56,7 +56,7 @@ public class TransactionAspectTests { @Test - public void testCommitOnAnnotatedClass() throws Throwable { + void testCommitOnAnnotatedClass() throws Throwable { txManager.clear(); assertThat(txManager.begun).isEqualTo(0); annotationOnlyOnClassWithNoInterface.echo(null); @@ -64,7 +64,7 @@ public class TransactionAspectTests { } @Test - public void commitOnAnnotatedProtectedMethod() throws Throwable { + void commitOnAnnotatedProtectedMethod() { txManager.clear(); assertThat(txManager.begun).isEqualTo(0); beanWithAnnotatedProtectedMethod.doInTransaction(); @@ -72,7 +72,7 @@ public class TransactionAspectTests { } @Test - public void commitOnAnnotatedPrivateMethod() throws Throwable { + void commitOnAnnotatedPrivateMethod() { txManager.clear(); assertThat(txManager.begun).isEqualTo(0); beanWithAnnotatedPrivateMethod.doSomething(); @@ -80,7 +80,7 @@ public class TransactionAspectTests { } @Test - public void commitOnNonAnnotatedNonPublicMethodInTransactionalType() throws Throwable { + void commitOnNonAnnotatedNonPublicMethodInTransactionalType() { txManager.clear(); assertThat(txManager.begun).isEqualTo(0); annotationOnlyOnClassWithNoInterface.nonTransactionalMethod(); @@ -88,7 +88,7 @@ public class TransactionAspectTests { } @Test - public void commitOnAnnotatedMethod() throws Throwable { + void commitOnAnnotatedMethod() throws Throwable { txManager.clear(); assertThat(txManager.begun).isEqualTo(0); methodAnnotationOnly.echo(null); @@ -96,7 +96,7 @@ public class TransactionAspectTests { } @Test - public void notTransactional() throws Throwable { + void notTransactional() { txManager.clear(); assertThat(txManager.begun).isEqualTo(0); new NotTransactional().noop(); @@ -104,7 +104,7 @@ public class TransactionAspectTests { } @Test - public void defaultCommitOnAnnotatedClass() throws Throwable { + void defaultCommitOnAnnotatedClass() { Exception ex = new Exception(); assertThatException() .isThrownBy(() -> testRollback(() -> annotationOnlyOnClassWithNoInterface.echo(ex), false)) @@ -112,7 +112,7 @@ public class TransactionAspectTests { } @Test - public void defaultRollbackOnAnnotatedClass() throws Throwable { + void defaultRollbackOnAnnotatedClass() { RuntimeException ex = new RuntimeException(); assertThatRuntimeException() .isThrownBy(() -> testRollback(() -> annotationOnlyOnClassWithNoInterface.echo(ex), true)) @@ -120,7 +120,7 @@ public class TransactionAspectTests { } @Test - public void defaultCommitOnSubclassOfAnnotatedClass() throws Throwable { + void defaultCommitOnSubclassOfAnnotatedClass() { Exception ex = new Exception(); assertThatException() .isThrownBy(() -> testRollback(() -> new SubclassOfClassWithTransactionalAnnotation().echo(ex), false)) @@ -128,7 +128,7 @@ public class TransactionAspectTests { } @Test - public void defaultCommitOnSubclassOfClassWithTransactionalMethodAnnotated() throws Throwable { + void defaultCommitOnSubclassOfClassWithTransactionalMethodAnnotated() { Exception ex = new Exception(); assertThatException() .isThrownBy(() -> testRollback(() -> new SubclassOfClassWithTransactionalMethodAnnotation().echo(ex), false)) @@ -136,13 +136,13 @@ public class TransactionAspectTests { } @Test - public void noCommitOnImplementationOfAnnotatedInterface() throws Throwable { + void noCommitOnImplementationOfAnnotatedInterface() { Exception ex = new Exception(); testNotTransactional(() -> new ImplementsAnnotatedInterface().echo(ex), ex); } @Test - public void noRollbackOnImplementationOfAnnotatedInterface() throws Throwable { + void noRollbackOnImplementationOfAnnotatedInterface() { Exception rollbackProvokingException = new RuntimeException(); testNotTransactional(() -> new ImplementsAnnotatedInterface().echo(rollbackProvokingException), rollbackProvokingException); @@ -164,7 +164,7 @@ public class TransactionAspectTests { } } - protected void testNotTransactional(TransactionOperationCallback toc, Throwable expected) throws Throwable { + protected void testNotTransactional(TransactionOperationCallback toc, Throwable expected) { txManager.clear(); assertThat(txManager.begun).isEqualTo(0); assertThatExceptionOfType(Throwable.class) diff --git a/spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/factory/xml/AbstractBeanFactoryTests.java b/spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/factory/xml/AbstractBeanFactoryTests.java index ff762788fa..6039e7d540 100644 --- a/spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/factory/xml/AbstractBeanFactoryTests.java +++ b/spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/factory/xml/AbstractBeanFactoryTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * 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. @@ -16,9 +16,6 @@ package org.springframework.beans.testfixture.factory.xml; -import java.beans.PropertyEditorSupport; -import java.util.StringTokenizer; - import org.junit.jupiter.api.Test; import org.springframework.beans.BeansException; @@ -53,7 +50,7 @@ public abstract class AbstractBeanFactoryTests { * Roderick bean inherits from rod, overriding name only. */ @Test - public void inheritance() { + protected void inheritance() { assertThat(getBeanFactory().containsBean("rod")).isTrue(); assertThat(getBeanFactory().containsBean("roderick")).isTrue(); TestBean rod = (TestBean) getBeanFactory().getBean("rod"); @@ -66,7 +63,7 @@ public abstract class AbstractBeanFactoryTests { } @Test - public void getBeanWithNullArg() { + protected void getBeanWithNullArg() { assertThatIllegalArgumentException().isThrownBy(() -> getBeanFactory().getBean((String) null)); } @@ -75,7 +72,7 @@ public abstract class AbstractBeanFactoryTests { * Test that InitializingBean objects receive the afterPropertiesSet() callback */ @Test - public void initializingBeanCallback() { + protected void initializingBeanCallback() { MustBeInitialized mbi = (MustBeInitialized) getBeanFactory().getBean("mustBeInitialized"); // The dummy business method will throw an exception if the // afterPropertiesSet() callback wasn't invoked @@ -87,7 +84,7 @@ public abstract class AbstractBeanFactoryTests { * afterPropertiesSet() callback before BeanFactoryAware callbacks */ @Test - public void lifecycleCallbacks() { + protected void lifecycleCallbacks() { LifecycleBean lb = (LifecycleBean) getBeanFactory().getBean("lifecycle"); assertThat(lb.getBeanName()).isEqualTo("lifecycle"); // The dummy business method will throw an exception if the @@ -98,24 +95,22 @@ public abstract class AbstractBeanFactoryTests { } @Test - public void findsValidInstance() { + protected void findsValidInstance() { Object o = getBeanFactory().getBean("rod"); - boolean condition = o instanceof TestBean; - assertThat(condition).as("Rod bean is a TestBean").isTrue(); - TestBean rod = (TestBean) o; - assertThat(rod.getName().equals("Rod")).as("rod.name is Rod").isTrue(); - assertThat(rod.getAge()).as("rod.age is 31").isEqualTo(31); + assertThat(o).isInstanceOfSatisfying(TestBean.class, rod -> { + assertThat(rod.getName().equals("Rod")).as("rod.name is Rod").isTrue(); + assertThat(rod.getAge()).as("rod.age is 31").isEqualTo(31); + }); } @Test - public void getInstanceByMatchingClass() { + protected void getInstanceByMatchingClass() { Object o = getBeanFactory().getBean("rod", TestBean.class); - boolean condition = o instanceof TestBean; - assertThat(condition).as("Rod bean is a TestBean").isTrue(); + assertThat(o).isInstanceOf(TestBean.class); } @Test - public void getInstanceByNonmatchingClass() { + protected void getInstanceByNonmatchingClass() { assertThatExceptionOfType(BeanNotOfRequiredTypeException.class).isThrownBy(() -> getBeanFactory().getBean("rod", BeanFactory.class)) .satisfies(ex -> { @@ -126,21 +121,19 @@ public abstract class AbstractBeanFactoryTests { } @Test - public void getSharedInstanceByMatchingClass() { + protected void getSharedInstanceByMatchingClass() { Object o = getBeanFactory().getBean("rod", TestBean.class); - boolean condition = o instanceof TestBean; - assertThat(condition).as("Rod bean is a TestBean").isTrue(); + assertThat(o).isInstanceOf(TestBean.class); } @Test - public void getSharedInstanceByMatchingClassNoCatch() { + protected void getSharedInstanceByMatchingClassNoCatch() { Object o = getBeanFactory().getBean("rod", TestBean.class); - boolean condition = o instanceof TestBean; - assertThat(condition).as("Rod bean is a TestBean").isTrue(); + assertThat(o).isInstanceOf(TestBean.class); } @Test - public void getSharedInstanceByNonmatchingClass() { + protected void getSharedInstanceByNonmatchingClass() { assertThatExceptionOfType(BeanNotOfRequiredTypeException.class).isThrownBy(() -> getBeanFactory().getBean("rod", BeanFactory.class)) .satisfies(ex -> { @@ -151,18 +144,15 @@ public abstract class AbstractBeanFactoryTests { } @Test - public void sharedInstancesAreEqual() { + protected void sharedInstancesAreEqual() { Object o = getBeanFactory().getBean("rod"); - boolean condition1 = o instanceof TestBean; - assertThat(condition1).as("Rod bean1 is a TestBean").isTrue(); + assertThat(o).isInstanceOf(TestBean.class); Object o1 = getBeanFactory().getBean("rod"); - boolean condition = o1 instanceof TestBean; - assertThat(condition).as("Rod bean2 is a TestBean").isTrue(); - assertThat(o).as("Object equals applies").isSameAs(o1); + assertThat(o1).isInstanceOf(TestBean.class).isSameAs(o); } @Test - public void prototypeInstancesAreIndependent() { + protected void prototypeInstancesAreIndependent() { TestBean tb1 = (TestBean) getBeanFactory().getBean("kathy"); TestBean tb2 = (TestBean) getBeanFactory().getBean("kathy"); assertThat(tb1).as("ref equal DOES NOT apply").isNotSameAs(tb2); @@ -176,36 +166,37 @@ public abstract class AbstractBeanFactoryTests { } @Test - public void notThere() { + protected void notThere() { assertThat(getBeanFactory().containsBean("Mr Squiggle")).isFalse(); assertThatExceptionOfType(BeansException.class).isThrownBy(() -> getBeanFactory().getBean("Mr Squiggle")); } @Test - public void validEmpty() { + protected void validEmpty() { Object o = getBeanFactory().getBean("validEmpty"); - boolean condition = o instanceof TestBean; - assertThat(condition).as("validEmpty bean is a TestBean").isTrue(); - TestBean ve = (TestBean) o; - assertThat(ve.getName() == null && ve.getAge() == 0 && ve.getSpouse() == null).as("Valid empty has defaults").isTrue(); + assertThat(o).isInstanceOfSatisfying(TestBean.class, ve -> { + assertThat(ve.getName()).isNull(); + assertThat(ve.getAge()).isEqualTo(0); + assertThat(ve.getSpouse()).isNull(); + }); } @Test - public void typeMismatch() { + protected void typeMismatch() { assertThatExceptionOfType(BeanCreationException.class) .isThrownBy(() -> getBeanFactory().getBean("typeMismatch")) .withCauseInstanceOf(TypeMismatchException.class); } @Test - public void grandparentDefinitionFoundInBeanFactory() throws Exception { + protected void grandparentDefinitionFoundInBeanFactory() { TestBean dad = (TestBean) getBeanFactory().getBean("father"); assertThat(dad.getName().equals("Albert")).as("Dad has correct name").isTrue(); } @Test - public void factorySingleton() throws Exception { + protected void factorySingleton() { assertThat(getBeanFactory().isSingleton("&singletonFactory")).isTrue(); assertThat(getBeanFactory().isSingleton("singletonFactory")).isTrue(); TestBean tb = (TestBean) getBeanFactory().getBean("singletonFactory"); @@ -217,12 +208,11 @@ public abstract class AbstractBeanFactoryTests { } @Test - public void factoryPrototype() throws Exception { + protected void factoryPrototype() { assertThat(getBeanFactory().isSingleton("&prototypeFactory")).isTrue(); assertThat(getBeanFactory().isSingleton("prototypeFactory")).isFalse(); TestBean tb = (TestBean) getBeanFactory().getBean("prototypeFactory"); - boolean condition = !tb.getName().equals(DummyFactory.SINGLETON_NAME); - assertThat(condition).isTrue(); + assertThat(tb.getName()).isNotEqualTo(DummyFactory.SINGLETON_NAME); TestBean tb2 = (TestBean) getBeanFactory().getBean("prototypeFactory"); assertThat(tb).as("Prototype references !=").isNotSameAs(tb2); } @@ -232,7 +222,7 @@ public abstract class AbstractBeanFactoryTests { * This is only possible if we're dealing with a factory */ @Test - public void getFactoryItself() throws Exception { + protected void getFactoryItself() { assertThat(getBeanFactory().getBean("&singletonFactory")).isNotNull(); } @@ -240,7 +230,7 @@ public abstract class AbstractBeanFactoryTests { * Check that afterPropertiesSet gets called on factory */ @Test - public void factoryIsInitialized() throws Exception { + protected void factoryIsInitialized() { TestBean tb = (TestBean) getBeanFactory().getBean("singletonFactory"); assertThat(tb).isNotNull(); DummyFactory factory = (DummyFactory) getBeanFactory().getBean("&singletonFactory"); @@ -251,7 +241,7 @@ public abstract class AbstractBeanFactoryTests { * It should be illegal to dereference a normal bean as a factory. */ @Test - public void rejectsFactoryGetOnNormalBean() { + protected void rejectsFactoryGetOnNormalBean() { assertThatExceptionOfType(BeanIsNotAFactoryException.class).isThrownBy(() -> getBeanFactory().getBean("&rod")); } @@ -259,7 +249,7 @@ public abstract class AbstractBeanFactoryTests { // TODO: refactor in AbstractBeanFactory (tests for AbstractBeanFactory) // and rename this class @Test - public void aliasing() { + protected void aliasing() { BeanFactory bf = getBeanFactory(); if (!(bf instanceof ConfigurableBeanFactory cbf)) { return; @@ -277,17 +267,4 @@ public abstract class AbstractBeanFactoryTests { assertThat(rod).isSameAs(aliasRod); } - - public static class TestBeanEditor extends PropertyEditorSupport { - - @Override - public void setAsText(String text) { - TestBean tb = new TestBean(); - StringTokenizer st = new StringTokenizer(text, "_"); - tb.setName(st.nextToken()); - tb.setAge(Integer.parseInt(st.nextToken())); - setValue(tb); - } - } - } diff --git a/spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/factory/xml/AbstractListableBeanFactoryTests.java b/spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/factory/xml/AbstractListableBeanFactoryTests.java index c9644f5a6c..21fa185919 100644 --- a/spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/factory/xml/AbstractListableBeanFactoryTests.java +++ b/spring-beans/src/testFixtures/java/org/springframework/beans/testfixture/factory/xml/AbstractListableBeanFactoryTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * 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. @@ -44,7 +44,7 @@ public abstract class AbstractListableBeanFactoryTests extends AbstractBeanFacto * Subclasses can override this. */ @Test - public void count() { + protected void count() { assertCount(13); } @@ -66,7 +66,7 @@ public abstract class AbstractListableBeanFactoryTests extends AbstractBeanFacto } @Test - public void getDefinitionsForNoSuchClass() { + protected void getDefinitionsForNoSuchClass() { String[] defnames = getListableBeanFactory().getBeanNamesForType(String.class); assertThat(defnames.length).as("No string definitions").isEqualTo(0); } @@ -76,7 +76,7 @@ public abstract class AbstractListableBeanFactoryTests extends AbstractBeanFacto * what type factories may return, and it may even change over time.) */ @Test - public void getCountForFactoryClass() { + protected void getCountForFactoryClass() { assertThat(getListableBeanFactory().getBeanNamesForType(FactoryBean.class).length).as("Should have 2 factories, not " + getListableBeanFactory().getBeanNamesForType(FactoryBean.class).length).isEqualTo(2); @@ -85,7 +85,7 @@ public abstract class AbstractListableBeanFactoryTests extends AbstractBeanFacto } @Test - public void containsBeanDefinition() { + protected void containsBeanDefinition() { assertThat(getListableBeanFactory().containsBeanDefinition("rod")).isTrue(); assertThat(getListableBeanFactory().containsBeanDefinition("roderick")).isTrue(); } diff --git a/spring-context-indexer/src/test/java/org/springframework/context/index/processor/CandidateComponentsIndexerTests.java b/spring-context-indexer/src/test/java/org/springframework/context/index/processor/CandidateComponentsIndexerTests.java index f9438ad430..9950814883 100644 --- a/spring-context-indexer/src/test/java/org/springframework/context/index/processor/CandidateComponentsIndexerTests.java +++ b/spring-context-indexer/src/test/java/org/springframework/context/index/processor/CandidateComponentsIndexerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * 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. @@ -199,7 +199,7 @@ class CandidateComponentsIndexerTests { @Test void embeddedCandidatesAreDetected() - throws IOException, ClassNotFoundException { + throws ClassNotFoundException { // Validate nested type structure String nestedType = "org.springframework.context.index.sample.SampleEmbedded.Another$AnotherPublicCandidate"; Class type = ClassUtils.forName(nestedType, getClass().getClassLoader()); @@ -249,8 +249,7 @@ class CandidateComponentsIndexerTests { File metadataFile = new File(outputLocation, MetadataStore.METADATA_PATH); if (metadataFile.isFile()) { try (FileInputStream fileInputStream = new FileInputStream(metadataFile)) { - CandidateComponentsMetadata metadata = PropertiesMarshaller.read(fileInputStream); - return metadata; + return PropertiesMarshaller.read(fileInputStream); } catch (IOException ex) { throw new IllegalStateException("Failed to read metadata from disk", ex); diff --git a/spring-context-indexer/src/test/java/org/springframework/context/index/processor/PropertiesMarshallerTests.java b/spring-context-indexer/src/test/java/org/springframework/context/index/processor/PropertiesMarshallerTests.java index e518841ef3..fcda73406e 100644 --- a/spring-context-indexer/src/test/java/org/springframework/context/index/processor/PropertiesMarshallerTests.java +++ b/spring-context-indexer/src/test/java/org/springframework/context/index/processor/PropertiesMarshallerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * 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. @@ -33,10 +33,10 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Stephane Nicoll * @author Vedran Pavic */ -public class PropertiesMarshallerTests { +class PropertiesMarshallerTests { @Test - public void readWrite() throws IOException { + void readWrite() throws IOException { CandidateComponentsMetadata metadata = new CandidateComponentsMetadata(); metadata.add(createItem("com.foo", "first", "second")); metadata.add(createItem("com.bar", "first")); @@ -51,7 +51,7 @@ public class PropertiesMarshallerTests { } @Test - public void metadataIsWrittenDeterministically() throws IOException { + void metadataIsWrittenDeterministically() throws IOException { CandidateComponentsMetadata metadata = new CandidateComponentsMetadata(); metadata.add(createItem("com.b", "type")); metadata.add(createItem("com.c", "type")); @@ -59,7 +59,7 @@ public class PropertiesMarshallerTests { ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); PropertiesMarshaller.write(metadata, outputStream); - String contents = new String(outputStream.toByteArray(), StandardCharsets.ISO_8859_1); + String contents = outputStream.toString(StandardCharsets.ISO_8859_1); assertThat(contents.split(System.lineSeparator())).containsExactly("com.a=type", "com.b=type", "com.c=type"); } diff --git a/spring-context-support/src/testFixtures/java/org/springframework/contextsupport/testfixture/jcache/AbstractJCacheAnnotationTests.java b/spring-context-support/src/testFixtures/java/org/springframework/contextsupport/testfixture/jcache/AbstractJCacheAnnotationTests.java index b1fc5cda8b..b8892b536c 100644 --- a/spring-context-support/src/testFixtures/java/org/springframework/contextsupport/testfixture/jcache/AbstractJCacheAnnotationTests.java +++ b/spring-context-support/src/testFixtures/java/org/springframework/contextsupport/testfixture/jcache/AbstractJCacheAnnotationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * 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. @@ -54,7 +54,7 @@ public abstract class AbstractJCacheAnnotationTests { protected abstract ApplicationContext getApplicationContext(); @BeforeEach - public void setUp(TestInfo testInfo) { + protected void setUp(TestInfo testInfo) { this.keyItem = testInfo.getTestMethod().get().getName(); this.ctx = getApplicationContext(); this.service = this.ctx.getBean(JCacheableService.class); @@ -62,14 +62,14 @@ public abstract class AbstractJCacheAnnotationTests { } @Test - public void cache() { + protected void cache() { Object first = service.cache(this.keyItem); Object second = service.cache(this.keyItem); assertThat(second).isSameAs(first); } @Test - public void cacheNull() { + protected void cacheNull() { Cache cache = getCache(DEFAULT_CACHE); assertThat(cache.get(this.keyItem)).isNull(); @@ -85,7 +85,7 @@ public abstract class AbstractJCacheAnnotationTests { } @Test - public void cacheException() { + protected void cacheException() { Cache cache = getCache(EXCEPTION_CACHE); Object key = createKey(this.keyItem); @@ -100,7 +100,7 @@ public abstract class AbstractJCacheAnnotationTests { } @Test - public void cacheExceptionVetoed() { + protected void cacheExceptionVetoed() { Cache cache = getCache(EXCEPTION_CACHE); Object key = createKey(this.keyItem); @@ -112,7 +112,7 @@ public abstract class AbstractJCacheAnnotationTests { } @Test - public void cacheCheckedException() { + protected void cacheCheckedException() { Cache cache = getCache(EXCEPTION_CACHE); Object key = createKey(this.keyItem); @@ -128,7 +128,7 @@ public abstract class AbstractJCacheAnnotationTests { @SuppressWarnings("ThrowableResultOfMethodCallIgnored") @Test - public void cacheExceptionRewriteCallStack() { + protected void cacheExceptionRewriteCallStack() { long ref = service.exceptionInvocations(); assertThatExceptionOfType(UnsupportedOperationException.class).isThrownBy(() -> service.cacheWithException(this.keyItem, true)) @@ -151,14 +151,14 @@ public abstract class AbstractJCacheAnnotationTests { } @Test - public void cacheAlwaysInvoke() { + protected void cacheAlwaysInvoke() { Object first = service.cacheAlwaysInvoke(this.keyItem); Object second = service.cacheAlwaysInvoke(this.keyItem); assertThat(second).isNotSameAs(first); } @Test - public void cacheWithPartialKey() { + protected void cacheWithPartialKey() { Object first = service.cacheWithPartialKey(this.keyItem, true); Object second = service.cacheWithPartialKey(this.keyItem, false); // second argument not used, see config @@ -166,7 +166,7 @@ public abstract class AbstractJCacheAnnotationTests { } @Test - public void cacheWithCustomCacheResolver() { + protected void cacheWithCustomCacheResolver() { Cache cache = getCache(DEFAULT_CACHE); Object key = createKey(this.keyItem); @@ -177,7 +177,7 @@ public abstract class AbstractJCacheAnnotationTests { } @Test - public void cacheWithCustomKeyGenerator() { + protected void cacheWithCustomKeyGenerator() { Cache cache = getCache(DEFAULT_CACHE); Object key = createKey(this.keyItem); @@ -187,7 +187,7 @@ public abstract class AbstractJCacheAnnotationTests { } @Test - public void put() { + protected void put() { Cache cache = getCache(DEFAULT_CACHE); Object key = createKey(this.keyItem); @@ -202,7 +202,7 @@ public abstract class AbstractJCacheAnnotationTests { } @Test - public void putWithException() { + protected void putWithException() { Cache cache = getCache(DEFAULT_CACHE); Object key = createKey(this.keyItem); @@ -218,7 +218,7 @@ public abstract class AbstractJCacheAnnotationTests { } @Test - public void putWithExceptionVetoPut() { + protected void putWithExceptionVetoPut() { Cache cache = getCache(DEFAULT_CACHE); Object key = createKey(this.keyItem); @@ -231,7 +231,7 @@ public abstract class AbstractJCacheAnnotationTests { } @Test - public void earlyPut() { + protected void earlyPut() { Cache cache = getCache(DEFAULT_CACHE); Object key = createKey(this.keyItem); @@ -246,7 +246,7 @@ public abstract class AbstractJCacheAnnotationTests { } @Test - public void earlyPutWithException() { + protected void earlyPutWithException() { Cache cache = getCache(DEFAULT_CACHE); Object key = createKey(this.keyItem); @@ -262,7 +262,7 @@ public abstract class AbstractJCacheAnnotationTests { } @Test - public void earlyPutWithExceptionVetoPut() { + protected void earlyPutWithExceptionVetoPut() { Cache cache = getCache(DEFAULT_CACHE); Object key = createKey(this.keyItem); @@ -277,7 +277,7 @@ public abstract class AbstractJCacheAnnotationTests { } @Test - public void remove() { + protected void remove() { Cache cache = getCache(DEFAULT_CACHE); Object key = createKey(this.keyItem); @@ -290,7 +290,7 @@ public abstract class AbstractJCacheAnnotationTests { } @Test - public void removeWithException() { + protected void removeWithException() { Cache cache = getCache(DEFAULT_CACHE); Object key = createKey(this.keyItem); @@ -304,7 +304,7 @@ public abstract class AbstractJCacheAnnotationTests { } @Test - public void removeWithExceptionVetoRemove() { + protected void removeWithExceptionVetoRemove() { Cache cache = getCache(DEFAULT_CACHE); Object key = createKey(this.keyItem); @@ -319,7 +319,7 @@ public abstract class AbstractJCacheAnnotationTests { } @Test - public void earlyRemove() { + protected void earlyRemove() { Cache cache = getCache(DEFAULT_CACHE); Object key = createKey(this.keyItem); @@ -332,7 +332,7 @@ public abstract class AbstractJCacheAnnotationTests { } @Test - public void earlyRemoveWithException() { + protected void earlyRemoveWithException() { Cache cache = getCache(DEFAULT_CACHE); Object key = createKey(this.keyItem); @@ -345,7 +345,7 @@ public abstract class AbstractJCacheAnnotationTests { } @Test - public void earlyRemoveWithExceptionVetoRemove() { + protected void earlyRemoveWithExceptionVetoRemove() { Cache cache = getCache(DEFAULT_CACHE); Object key = createKey(this.keyItem); @@ -359,7 +359,7 @@ public abstract class AbstractJCacheAnnotationTests { } @Test - public void removeAll() { + protected void removeAll() { Cache cache = getCache(DEFAULT_CACHE); Object key = createKey(this.keyItem); @@ -371,7 +371,7 @@ public abstract class AbstractJCacheAnnotationTests { } @Test - public void removeAllWithException() { + protected void removeAllWithException() { Cache cache = getCache(DEFAULT_CACHE); Object key = createKey(this.keyItem); @@ -384,7 +384,7 @@ public abstract class AbstractJCacheAnnotationTests { } @Test - public void removeAllWithExceptionVetoRemove() { + protected void removeAllWithExceptionVetoRemove() { Cache cache = getCache(DEFAULT_CACHE); Object key = createKey(this.keyItem); @@ -396,7 +396,7 @@ public abstract class AbstractJCacheAnnotationTests { } @Test - public void earlyRemoveAll() { + protected void earlyRemoveAll() { Cache cache = getCache(DEFAULT_CACHE); Object key = createKey(this.keyItem); @@ -408,7 +408,7 @@ public abstract class AbstractJCacheAnnotationTests { } @Test - public void earlyRemoveAllWithException() { + protected void earlyRemoveAllWithException() { Cache cache = getCache(DEFAULT_CACHE); Object key = createKey(this.keyItem); @@ -420,7 +420,7 @@ public abstract class AbstractJCacheAnnotationTests { } @Test - public void earlyRemoveAllWithExceptionVetoRemove() { + protected void earlyRemoveAllWithExceptionVetoRemove() { Cache cache = getCache(DEFAULT_CACHE); Object key = createKey(this.keyItem); diff --git a/spring-context/src/testFixtures/java/org/springframework/context/testfixture/AbstractApplicationContextTests.java b/spring-context/src/testFixtures/java/org/springframework/context/testfixture/AbstractApplicationContextTests.java index 033c8e50d9..b119bc4556 100644 --- a/spring-context/src/testFixtures/java/org/springframework/context/testfixture/AbstractApplicationContextTests.java +++ b/spring-context/src/testFixtures/java/org/springframework/context/testfixture/AbstractApplicationContextTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * 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. @@ -47,9 +47,6 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType; */ public abstract class AbstractApplicationContextTests extends AbstractListableBeanFactoryTests { - /** Must be supplied as XML */ - public static final String TEST_NAMESPACE = "testNamespace"; - protected ConfigurableApplicationContext applicationContext; /** Subclass must register this */ @@ -59,17 +56,17 @@ public abstract class AbstractApplicationContextTests extends AbstractListableBe @BeforeEach - public void setup() throws Exception { + protected void setup() throws Exception { this.applicationContext = createContext(); } @Override protected BeanFactory getBeanFactory() { - return applicationContext; + return this.applicationContext; } protected ApplicationContext getApplicationContext() { - return applicationContext; + return this.applicationContext; } /** @@ -82,7 +79,7 @@ public abstract class AbstractApplicationContextTests extends AbstractListableBe @Test - public void contextAwareSingletonWasCalledBack() throws Exception { + protected void contextAwareSingletonWasCalledBack() { ACATester aca = (ACATester) applicationContext.getBean("aca"); assertThat(aca.getApplicationContext()).as("has had context set").isSameAs(applicationContext); Object aca2 = applicationContext.getBean("aca"); @@ -91,7 +88,7 @@ public abstract class AbstractApplicationContextTests extends AbstractListableBe } @Test - public void contextAwarePrototypeWasCalledBack() throws Exception { + protected void contextAwarePrototypeWasCalledBack() { ACATester aca = (ACATester) applicationContext.getBean("aca-prototype"); assertThat(aca.getApplicationContext()).as("has had context set").isSameAs(applicationContext); Object aca2 = applicationContext.getBean("aca-prototype"); @@ -101,35 +98,35 @@ public abstract class AbstractApplicationContextTests extends AbstractListableBe } @Test - public void parentNonNull() { + protected void parentNonNull() { assertThat(applicationContext.getParent()).as("parent isn't null").isNotNull(); } @Test - public void grandparentNull() { + protected void grandparentNull() { assertThat(applicationContext.getParent().getParent()).as("grandparent is null").isNull(); } @Test - public void overrideWorked() throws Exception { + protected void overrideWorked() { TestBean rod = (TestBean) applicationContext.getParent().getBean("rod"); assertThat(rod.getName().equals("Roderick")).as("Parent's name differs").isTrue(); } @Test - public void grandparentDefinitionFound() throws Exception { + protected void grandparentDefinitionFound() { TestBean dad = (TestBean) applicationContext.getBean("father"); assertThat(dad.getName().equals("Albert")).as("Dad has correct name").isTrue(); } @Test - public void grandparentTypedDefinitionFound() throws Exception { + protected void grandparentTypedDefinitionFound() { TestBean dad = applicationContext.getBean("father", TestBean.class); assertThat(dad.getName().equals("Albert")).as("Dad has correct name").isTrue(); } @Test - public void closeTriggersDestroy() { + protected void closeTriggersDestroy() { LifecycleBean lb = (LifecycleBean) applicationContext.getBean("lifecycle"); boolean condition = !lb.isDestroyed(); assertThat(condition).as("Not destroyed").isTrue(); @@ -146,7 +143,7 @@ public abstract class AbstractApplicationContextTests extends AbstractListableBe } @Test - public void messageSource() throws NoSuchMessageException { + protected void messageSource() throws NoSuchMessageException { assertThat(applicationContext.getMessage("code1", null, Locale.getDefault())).isEqualTo("message1"); assertThat(applicationContext.getMessage("code2", null, Locale.getDefault())).isEqualTo("message2"); assertThatExceptionOfType(NoSuchMessageException.class).isThrownBy(() -> @@ -154,12 +151,12 @@ public abstract class AbstractApplicationContextTests extends AbstractListableBe } @Test - public void events() throws Exception { + protected void events() throws Exception { doTestEvents(this.listener, this.parentListener, new MyEvent(this)); } @Test - public void eventsWithNoSource() throws Exception { + protected void eventsWithNoSource() throws Exception { // See SPR-10945 Serialized events result in a null source MyEvent event = new MyEvent(this); ByteArrayOutputStream bos = new ByteArrayOutputStream(); @@ -184,7 +181,7 @@ public abstract class AbstractApplicationContextTests extends AbstractListableBe } @Test - public void beanAutomaticallyHearsEvents() throws Exception { + protected void beanAutomaticallyHearsEvents() { //String[] listenerNames = ((ListableBeanFactory) applicationContext).getBeanDefinitionNames(ApplicationListener.class); //assertTrue("listeners include beanThatListens", Arrays.asList(listenerNames).contains("beanThatListens")); BeanThatListens b = (BeanThatListens) applicationContext.getBean("beanThatListens"); diff --git a/spring-context/src/testFixtures/java/org/springframework/context/testfixture/cache/AbstractCacheAnnotationTests.java b/spring-context/src/testFixtures/java/org/springframework/context/testfixture/cache/AbstractCacheAnnotationTests.java index 589fe7c6a6..5a834ab047 100644 --- a/spring-context/src/testFixtures/java/org/springframework/context/testfixture/cache/AbstractCacheAnnotationTests.java +++ b/spring-context/src/testFixtures/java/org/springframework/context/testfixture/cache/AbstractCacheAnnotationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * 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. @@ -446,7 +446,7 @@ public abstract class AbstractCacheAnnotationTests { protected void testMultiEvict(CacheableService service) { Object o1 = new Object(); - Object o2 = o1.toString() + "A"; + Object o2 = o1 + "A"; Object r1 = service.multiCache(o1); @@ -571,132 +571,132 @@ public abstract class AbstractCacheAnnotationTests { } @Test - public void testCacheable() { + protected void testCacheable() { testCacheable(this.cs); } @Test - public void testCacheableNull() { + protected void testCacheableNull() { testCacheableNull(this.cs); } @Test - public void testCacheableSync() { + protected void testCacheableSync() { testCacheableSync(this.cs); } @Test - public void testCacheableSyncNull() { + protected void testCacheableSyncNull() { testCacheableSyncNull(this.cs); } @Test - public void testEvict() { + protected void testEvict() { testEvict(this.cs, true); } @Test - public void testEvictEarly() { + protected void testEvictEarly() { testEvictEarly(this.cs); } @Test - public void testEvictWithException() { + protected void testEvictWithException() { testEvictException(this.cs); } @Test - public void testEvictAll() { + protected void testEvictAll() { testEvictAll(this.cs, true); } @Test - public void testEvictAllEarly() { + protected void testEvictAllEarly() { testEvictAllEarly(this.cs); } @Test - public void testEvictWithKey() { + protected void testEvictWithKey() { testEvictWithKey(this.cs); } @Test - public void testEvictWithKeyEarly() { + protected void testEvictWithKeyEarly() { testEvictWithKeyEarly(this.cs); } @Test - public void testConditionalExpression() { + protected void testConditionalExpression() { testConditionalExpression(this.cs); } @Test - public void testConditionalExpressionSync() { + protected void testConditionalExpressionSync() { testConditionalExpressionSync(this.cs); } @Test - public void testUnlessExpression() { + protected void testUnlessExpression() { testUnlessExpression(this.cs); } @Test - public void testClassCacheUnlessExpression() { + protected void testClassCacheUnlessExpression() { testUnlessExpression(this.cs); } @Test - public void testKeyExpression() { + protected void testKeyExpression() { testKeyExpression(this.cs); } @Test - public void testVarArgsKey() { + protected void testVarArgsKey() { testVarArgsKey(this.cs); } @Test - public void testClassCacheCacheable() { + protected void testClassCacheCacheable() { testCacheable(this.ccs); } @Test - public void testClassCacheEvict() { + protected void testClassCacheEvict() { testEvict(this.ccs, true); } @Test - public void testClassEvictEarly() { + protected void testClassEvictEarly() { testEvictEarly(this.ccs); } @Test - public void testClassEvictAll() { + protected void testClassEvictAll() { testEvictAll(this.ccs, true); } @Test - public void testClassEvictWithException() { + protected void testClassEvictWithException() { testEvictException(this.ccs); } @Test - public void testClassCacheEvictWithWKey() { + protected void testClassCacheEvictWithWKey() { testEvictWithKey(this.ccs); } @Test - public void testClassEvictWithKeyEarly() { + protected void testClassEvictWithKeyEarly() { testEvictWithKeyEarly(this.ccs); } @Test - public void testNullValue() { + protected void testNullValue() { testNullValue(this.cs); } @Test - public void testClassNullValue() { + protected void testClassNullValue() { Object key = new Object(); assertThat(this.ccs.nullValue(key)).isNull(); int nr = this.ccs.nullInvocations().intValue(); @@ -709,27 +709,27 @@ public abstract class AbstractCacheAnnotationTests { } @Test - public void testMethodName() { + protected void testMethodName() { testMethodName(this.cs, "name"); } @Test - public void testClassMethodName() { + protected void testClassMethodName() { testMethodName(this.ccs, "nametestCache"); } @Test - public void testRootVars() { + protected void testRootVars() { testRootVars(this.cs); } @Test - public void testClassRootVars() { + protected void testClassRootVars() { testRootVars(this.ccs); } @Test - public void testCustomKeyGenerator() { + protected void testCustomKeyGenerator() { Object param = new Object(); Object r1 = this.cs.customKeyGenerator(param); assertThat(this.cs.customKeyGenerator(param)).isSameAs(r1); @@ -740,14 +740,14 @@ public abstract class AbstractCacheAnnotationTests { } @Test - public void testUnknownCustomKeyGenerator() { + protected void testUnknownCustomKeyGenerator() { Object param = new Object(); assertThatExceptionOfType(NoSuchBeanDefinitionException.class).isThrownBy(() -> this.cs.unknownCustomKeyGenerator(param)); } @Test - public void testCustomCacheManager() { + protected void testCustomCacheManager() { CacheManager customCm = this.ctx.getBean("customCacheManager", CacheManager.class); Object key = new Object(); Object r1 = this.cs.customCacheManager(key); @@ -758,159 +758,159 @@ public abstract class AbstractCacheAnnotationTests { } @Test - public void testUnknownCustomCacheManager() { + protected void testUnknownCustomCacheManager() { Object param = new Object(); assertThatExceptionOfType(NoSuchBeanDefinitionException.class).isThrownBy(() -> this.cs.unknownCustomCacheManager(param)); } @Test - public void testNullArg() { + protected void testNullArg() { testNullArg(this.cs); } @Test - public void testClassNullArg() { + protected void testClassNullArg() { testNullArg(this.ccs); } @Test - public void testCheckedException() { + protected void testCheckedException() { testCheckedThrowable(this.cs); } @Test - public void testClassCheckedException() { + protected void testClassCheckedException() { testCheckedThrowable(this.ccs); } @Test - public void testCheckedExceptionSync() { + protected void testCheckedExceptionSync() { testCheckedThrowableSync(this.cs); } @Test - public void testClassCheckedExceptionSync() { + protected void testClassCheckedExceptionSync() { testCheckedThrowableSync(this.ccs); } @Test - public void testUncheckedException() { + protected void testUncheckedException() { testUncheckedThrowable(this.cs); } @Test - public void testClassUncheckedException() { + protected void testClassUncheckedException() { testUncheckedThrowable(this.ccs); } @Test - public void testUncheckedExceptionSync() { + protected void testUncheckedExceptionSync() { testUncheckedThrowableSync(this.cs); } @Test - public void testClassUncheckedExceptionSync() { + protected void testClassUncheckedExceptionSync() { testUncheckedThrowableSync(this.ccs); } @Test - public void testUpdate() { + protected void testUpdate() { testCacheUpdate(this.cs); } @Test - public void testClassUpdate() { + protected void testClassUpdate() { testCacheUpdate(this.ccs); } @Test - public void testConditionalUpdate() { + protected void testConditionalUpdate() { testConditionalCacheUpdate(this.cs); } @Test - public void testClassConditionalUpdate() { + protected void testClassConditionalUpdate() { testConditionalCacheUpdate(this.ccs); } @Test - public void testMultiCache() { + protected void testMultiCache() { testMultiCache(this.cs); } @Test - public void testClassMultiCache() { + protected void testClassMultiCache() { testMultiCache(this.ccs); } @Test - public void testMultiEvict() { + protected void testMultiEvict() { testMultiEvict(this.cs); } @Test - public void testClassMultiEvict() { + protected void testClassMultiEvict() { testMultiEvict(this.ccs); } @Test - public void testMultiPut() { + protected void testMultiPut() { testMultiPut(this.cs); } @Test - public void testClassMultiPut() { + protected void testClassMultiPut() { testMultiPut(this.ccs); } @Test - public void testPutRefersToResult() { + protected void testPutRefersToResult() { testPutRefersToResult(this.cs); } @Test - public void testPutRefersToResultWithUnless() { + protected void testPutRefersToResultWithUnless() { testPutRefersToResultWithUnless(this.cs); } @Test - public void testPutEvaluatesUnlessBeforeKey() { + protected void testPutEvaluatesUnlessBeforeKey() { testPutEvaluatesUnlessBeforeKey(this.cs); } @Test - public void testClassPutRefersToResult() { + protected void testClassPutRefersToResult() { testPutRefersToResult(this.ccs); } @Test - public void testClassPutRefersToResultWithUnless(){ + protected void testClassPutRefersToResultWithUnless(){ testPutRefersToResultWithUnless(this.ccs); } @Test - public void testClassPutEvaluatesUnlessBeforeKey(){ + protected void testClassPutEvaluatesUnlessBeforeKey(){ testPutEvaluatesUnlessBeforeKey(this.ccs); } @Test - public void testMultiCacheAndEvict() { + protected void testMultiCacheAndEvict() { testMultiCacheAndEvict(this.cs); } @Test - public void testClassMultiCacheAndEvict() { + protected void testClassMultiCacheAndEvict() { testMultiCacheAndEvict(this.ccs); } @Test - public void testMultiConditionalCacheAndEvict() { + protected void testMultiConditionalCacheAndEvict() { testMultiConditionalCacheAndEvict(this.cs); } @Test - public void testClassMultiConditionalCacheAndEvict() { + protected void testClassMultiConditionalCacheAndEvict() { testMultiConditionalCacheAndEvict(this.ccs); } diff --git a/spring-context/src/testFixtures/java/org/springframework/context/testfixture/cache/AbstractCacheTests.java b/spring-context/src/testFixtures/java/org/springframework/context/testfixture/cache/AbstractCacheTests.java index 16262f9d35..bb3f43e5d1 100644 --- a/spring-context/src/testFixtures/java/org/springframework/context/testfixture/cache/AbstractCacheTests.java +++ b/spring-context/src/testFixtures/java/org/springframework/context/testfixture/cache/AbstractCacheTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * 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. @@ -41,17 +41,17 @@ public abstract class AbstractCacheTests { @Test - public void testCacheName() throws Exception { + protected void testCacheName() { assertThat(getCache().getName()).isEqualTo(CACHE_NAME); } @Test - public void testNativeCache() throws Exception { + protected void testNativeCache() { assertThat(getCache().getNativeCache()).isSameAs(getNativeCache()); } @Test - public void testCachePut() throws Exception { + protected void testCachePut() { T cache = getCache(); String key = createRandomKey(); @@ -75,7 +75,7 @@ public abstract class AbstractCacheTests { } @Test - public void testCachePutIfAbsent() throws Exception { + protected void testCachePutIfAbsent() { T cache = getCache(); String key = createRandomKey(); @@ -90,7 +90,7 @@ public abstract class AbstractCacheTests { } @Test - public void testCacheRemove() throws Exception { + protected void testCacheRemove() { T cache = getCache(); String key = createRandomKey(); @@ -101,7 +101,7 @@ public abstract class AbstractCacheTests { } @Test - public void testCacheClear() throws Exception { + protected void testCacheClear() { T cache = getCache(); assertThat(cache.get("enescu")).isNull(); @@ -114,12 +114,12 @@ public abstract class AbstractCacheTests { } @Test - public void testCacheGetCallable() { + protected void testCacheGetCallable() { doTestCacheGetCallable("test"); } @Test - public void testCacheGetCallableWithNull() { + protected void testCacheGetCallableWithNull() { doTestCacheGetCallable(null); } @@ -135,12 +135,12 @@ public abstract class AbstractCacheTests { } @Test - public void testCacheGetCallableNotInvokedWithHit() { + protected void testCacheGetCallableNotInvokedWithHit() { doTestCacheGetCallableNotInvokedWithHit("existing"); } @Test - public void testCacheGetCallableNotInvokedWithHitNull() { + protected void testCacheGetCallableNotInvokedWithHitNull() { doTestCacheGetCallableNotInvokedWithHit(null); } @@ -157,7 +157,7 @@ public abstract class AbstractCacheTests { } @Test - public void testCacheGetCallableFail() { + protected void testCacheGetCallableFail() { T cache = getCache(); String key = createRandomKey(); @@ -179,7 +179,7 @@ public abstract class AbstractCacheTests { * invocations. */ @Test - public void testCacheGetSynchronized() throws InterruptedException { + protected void testCacheGetSynchronized() throws InterruptedException { T cache = getCache(); final AtomicInteger counter = new AtomicInteger(); final List results = new CopyOnWriteArrayList<>(); diff --git a/spring-context/src/testFixtures/java/org/springframework/context/testfixture/cache/AbstractValueAdaptingCacheTests.java b/spring-context/src/testFixtures/java/org/springframework/context/testfixture/cache/AbstractValueAdaptingCacheTests.java index 8597c39278..0873914172 100644 --- a/spring-context/src/testFixtures/java/org/springframework/context/testfixture/cache/AbstractValueAdaptingCacheTests.java +++ b/spring-context/src/testFixtures/java/org/springframework/context/testfixture/cache/AbstractValueAdaptingCacheTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * 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. @@ -33,7 +33,7 @@ public abstract class AbstractValueAdaptingCacheTests diff --git a/spring-expression/src/test/java/org/springframework/expression/spel/SpelCompilationCoverageTests.java b/spring-expression/src/test/java/org/springframework/expression/spel/SpelCompilationCoverageTests.java index e9daebca34..3dc3aac474 100644 --- a/spring-expression/src/test/java/org/springframework/expression/spel/SpelCompilationCoverageTests.java +++ b/spring-expression/src/test/java/org/springframework/expression/spel/SpelCompilationCoverageTests.java @@ -377,7 +377,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { @SuppressWarnings("rawtypes") @Test - public void nestedInlineLists() { + void nestedInlineLists() { Object o = null; expression = parser.parseExpression("{{1,2,3},{4,5,6},{7,8,9}}"); diff --git a/spring-jdbc/src/test/java/org/springframework/jdbc/support/CustomSQLExceptionTranslatorRegistrarTests.java b/spring-jdbc/src/test/java/org/springframework/jdbc/support/CustomSQLExceptionTranslatorRegistrarTests.java index 091c19a77f..cd5d3e106f 100644 --- a/spring-jdbc/src/test/java/org/springframework/jdbc/support/CustomSQLExceptionTranslatorRegistrarTests.java +++ b/spring-jdbc/src/test/java/org/springframework/jdbc/support/CustomSQLExceptionTranslatorRegistrarTests.java @@ -35,7 +35,7 @@ import static org.assertj.core.api.Assertions.assertThat; class CustomSQLExceptionTranslatorRegistrarTests { @Test - public void customErrorCodeTranslation() { + void customErrorCodeTranslation() { new ClassPathXmlApplicationContext("test-custom-translators-context.xml", CustomSQLExceptionTranslatorRegistrarTests.class); diff --git a/spring-messaging/src/test/java/org/springframework/messaging/handler/annotation/reactive/HeadersMethodArgumentResolverTests.java b/spring-messaging/src/test/java/org/springframework/messaging/handler/annotation/reactive/HeadersMethodArgumentResolverTests.java index 6c1b8a42b3..2ac98b90d6 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/handler/annotation/reactive/HeadersMethodArgumentResolverTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/handler/annotation/reactive/HeadersMethodArgumentResolverTests.java @@ -42,7 +42,7 @@ class HeadersMethodArgumentResolverTests { private final HeadersMethodArgumentResolver resolver = new HeadersMethodArgumentResolver(); - private Message message = + private final Message message = MessageBuilder.withPayload(new byte[0]).copyHeaders(Collections.singletonMap("foo", "bar")).build(); private final ResolvableMethod resolvable = ResolvableMethod.on(getClass()).named("handleMessage").build(); @@ -62,7 +62,7 @@ class HeadersMethodArgumentResolverTests { } @Test - public void resolveArgumentAnnotated() { + void resolveArgumentAnnotated() { MethodParameter param = this.resolvable.annotPresent(Headers.class).arg(Map.class, String.class, Object.class); Map headers = resolveArgument(param); assertThat(headers.get("foo")).isEqualTo("bar"); diff --git a/spring-messaging/src/test/java/org/springframework/messaging/rsocket/DefaultRSocketRequesterBuilderTests.java b/spring-messaging/src/test/java/org/springframework/messaging/rsocket/DefaultRSocketRequesterBuilderTests.java index 2b8c32dcf6..51e31da25c 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/rsocket/DefaultRSocketRequesterBuilderTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/rsocket/DefaultRSocketRequesterBuilderTests.java @@ -81,7 +81,7 @@ class DefaultRSocketRequesterBuilderTests { @Test - public void rsocketConnectorConfigurer() { + void rsocketConnectorConfigurer() { Consumer strategiesConfigurer = mock(); RSocketRequester.builder() .rsocketConnector(this.connectorConfigurer) diff --git a/spring-tx/src/test/java/org/springframework/dao/annotation/PersistenceExceptionTranslationPostProcessorTests.java b/spring-tx/src/test/java/org/springframework/dao/annotation/PersistenceExceptionTranslationPostProcessorTests.java index 7dfe3679a2..372d32f2c6 100644 --- a/spring-tx/src/test/java/org/springframework/dao/annotation/PersistenceExceptionTranslationPostProcessorTests.java +++ b/spring-tx/src/test/java/org/springframework/dao/annotation/PersistenceExceptionTranslationPostProcessorTests.java @@ -46,7 +46,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType; class PersistenceExceptionTranslationPostProcessorTests { @Test - public void proxiesCorrectly() { + void proxiesCorrectly() { GenericApplicationContext gac = new GenericApplicationContext(); gac.registerBeanDefinition("translator", new RootBeanDefinition(PersistenceExceptionTranslationPostProcessor.class)); diff --git a/spring-tx/src/test/java/org/springframework/transaction/annotation/EnableTransactionManagementTests.java b/spring-tx/src/test/java/org/springframework/transaction/annotation/EnableTransactionManagementTests.java index d70bd1d928..e58cfcf262 100644 --- a/spring-tx/src/test/java/org/springframework/transaction/annotation/EnableTransactionManagementTests.java +++ b/spring-tx/src/test/java/org/springframework/transaction/annotation/EnableTransactionManagementTests.java @@ -222,7 +222,7 @@ class EnableTransactionManagementTests { * get loaded -- or in this case, attempted to be loaded at which point the test fails. */ @Test - public void proxyTypeAspectJCausesRegistrationOfAnnotationTransactionAspect() { + void proxyTypeAspectJCausesRegistrationOfAnnotationTransactionAspect() { // should throw CNFE when trying to load AnnotationTransactionAspect. // Do you actually have org.springframework.aspects on the classpath? assertThatException() diff --git a/spring-tx/src/test/java/org/springframework/transaction/config/AnnotationDrivenTests.java b/spring-tx/src/test/java/org/springframework/transaction/config/AnnotationDrivenTests.java index 7e73b264c6..488e7fcdf5 100644 --- a/spring-tx/src/test/java/org/springframework/transaction/config/AnnotationDrivenTests.java +++ b/spring-tx/src/test/java/org/springframework/transaction/config/AnnotationDrivenTests.java @@ -82,7 +82,7 @@ class AnnotationDrivenTests { } @Test - public void serializableWithPreviousUsage() throws Exception { + void serializableWithPreviousUsage() throws Exception { ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("annotationDrivenProxyTargetClassTests.xml", getClass()); TransactionalService service = context.getBean("service", TransactionalService.class); service.setSomething("someName"); @@ -91,7 +91,7 @@ class AnnotationDrivenTests { } @Test - public void serializableWithoutPreviousUsage() throws Exception { + void serializableWithoutPreviousUsage() throws Exception { ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("annotationDrivenProxyTargetClassTests.xml", getClass()); TransactionalService service = context.getBean("service", TransactionalService.class); service = SerializationTestUtils.serializeAndDeserialize(service); diff --git a/spring-tx/src/test/java/org/springframework/transaction/support/SimpleTransactionScopeTests.java b/spring-tx/src/test/java/org/springframework/transaction/support/SimpleTransactionScopeTests.java index 1ca545b44c..484f0db32e 100644 --- a/spring-tx/src/test/java/org/springframework/transaction/support/SimpleTransactionScopeTests.java +++ b/spring-tx/src/test/java/org/springframework/transaction/support/SimpleTransactionScopeTests.java @@ -37,7 +37,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType; class SimpleTransactionScopeTests { @Test - public void getFromScope() { + void getFromScope() { GenericApplicationContext context = new GenericApplicationContext(); context.getBeanFactory().registerScope("tx", new SimpleTransactionScope()); diff --git a/spring-web/src/test/java/org/springframework/http/converter/json/MappingJackson2HttpMessageConverterTests.java b/spring-web/src/test/java/org/springframework/http/converter/json/MappingJackson2HttpMessageConverterTests.java index 15f0139bc0..a894b4a207 100644 --- a/spring-web/src/test/java/org/springframework/http/converter/json/MappingJackson2HttpMessageConverterTests.java +++ b/spring-web/src/test/java/org/springframework/http/converter/json/MappingJackson2HttpMessageConverterTests.java @@ -108,7 +108,7 @@ class MappingJackson2HttpMessageConverterTests { } @Test // SPR-7905 - public void canReadAndWriteMicroformats() { + void canReadAndWriteMicroformats() { assertThat(converter.canRead(MyBean.class, new MediaType("application", "vnd.test-micro-type+json"))).isTrue(); assertThat(converter.canWrite(MyBean.class, new MediaType("application", "vnd.test-micro-type+json"))).isTrue(); } @@ -151,7 +151,7 @@ class MappingJackson2HttpMessageConverterTests { @Test @SuppressWarnings("unchecked") - public void readUntyped() throws IOException { + void readUntyped() throws IOException { String body = "{" + "\"bytes\":\"AQI=\"," + "\"array\":[\"Foo\",\"Bar\"]," + @@ -247,7 +247,7 @@ class MappingJackson2HttpMessageConverterTests { @Test @SuppressWarnings("unchecked") - public void readAndWriteGenerics() throws Exception { + void readAndWriteGenerics() throws Exception { MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter() { @Override protected JavaType getJavaType(Type type, @Nullable Class contextClass) { @@ -286,7 +286,7 @@ class MappingJackson2HttpMessageConverterTests { @Test @SuppressWarnings("unchecked") - public void readAndWriteParameterizedType() throws Exception { + void readAndWriteParameterizedType() throws Exception { ParameterizedTypeReference> beansList = new ParameterizedTypeReference<>() {}; String body = "[{" + @@ -317,7 +317,7 @@ class MappingJackson2HttpMessageConverterTests { @Test @SuppressWarnings("unchecked") - public void writeParameterizedBaseType() throws Exception { + void writeParameterizedBaseType() throws Exception { ParameterizedTypeReference> beansList = new ParameterizedTypeReference<>() {}; ParameterizedTypeReference> baseList = new ParameterizedTypeReference<>() {}; @@ -460,7 +460,7 @@ class MappingJackson2HttpMessageConverterTests { } @Test // SPR-13318 - public void writeSubType() throws Exception { + void writeSubType() throws Exception { MockHttpOutputMessage outputMessage = new MockHttpOutputMessage(); MyBean bean = new MyBean(); bean.setString("Foo"); @@ -474,7 +474,7 @@ class MappingJackson2HttpMessageConverterTests { } @Test // SPR-13318 - public void writeSubTypeList() throws Exception { + void writeSubTypeList() throws Exception { MockHttpOutputMessage outputMessage = new MockHttpOutputMessage(); List beans = new ArrayList<>(); MyBean foo = new MyBean(); @@ -498,7 +498,7 @@ class MappingJackson2HttpMessageConverterTests { } @Test // gh-27511 - public void readWithNoDefaultConstructor() throws Exception { + void readWithNoDefaultConstructor() throws Exception { String body = "{\"property1\":\"foo\",\"property2\":\"bar\"}"; MockHttpInputMessage inputMessage = new MockHttpInputMessage(body.getBytes(StandardCharsets.UTF_8)); inputMessage.getHeaders().setContentType(MediaType.APPLICATION_JSON); @@ -510,7 +510,7 @@ class MappingJackson2HttpMessageConverterTests { @Test @SuppressWarnings("unchecked") - public void readNonUnicode() throws Exception { + void readNonUnicode() throws Exception { String body = "{\"føø\":\"bår\"}"; Charset charset = StandardCharsets.ISO_8859_1; MockHttpInputMessage inputMessage = new MockHttpInputMessage(body.getBytes(charset)); @@ -522,7 +522,7 @@ class MappingJackson2HttpMessageConverterTests { @Test @SuppressWarnings("unchecked") - public void readAscii() throws Exception { + void readAscii() throws Exception { String body = "{\"foo\":\"bar\"}"; Charset charset = StandardCharsets.US_ASCII; MockHttpInputMessage inputMessage = new MockHttpInputMessage(body.getBytes(charset)); @@ -533,7 +533,7 @@ class MappingJackson2HttpMessageConverterTests { } @Test - public void writeAscii() throws Exception { + void writeAscii() throws Exception { MockHttpOutputMessage outputMessage = new MockHttpOutputMessage(); Map body = new HashMap<>(); body.put("foo", "bar"); diff --git a/spring-web/src/test/java/org/springframework/http/converter/xml/MappingJackson2XmlHttpMessageConverterTests.java b/spring-web/src/test/java/org/springframework/http/converter/xml/MappingJackson2XmlHttpMessageConverterTests.java index 3037311592..4df239ff4c 100644 --- a/spring-web/src/test/java/org/springframework/http/converter/xml/MappingJackson2XmlHttpMessageConverterTests.java +++ b/spring-web/src/test/java/org/springframework/http/converter/xml/MappingJackson2XmlHttpMessageConverterTests.java @@ -193,7 +193,7 @@ class MappingJackson2XmlHttpMessageConverterTests { } @Test - public void readNonUnicode() throws Exception { + void readNonUnicode() throws Exception { String body = "" + "føø bår" + ""; diff --git a/spring-web/src/test/java/org/springframework/web/context/request/RequestAndSessionScopedBeanTests.java b/spring-web/src/test/java/org/springframework/web/context/request/RequestAndSessionScopedBeanTests.java index ab4f434bbc..98bd6a79f1 100644 --- a/spring-web/src/test/java/org/springframework/web/context/request/RequestAndSessionScopedBeanTests.java +++ b/spring-web/src/test/java/org/springframework/web/context/request/RequestAndSessionScopedBeanTests.java @@ -36,7 +36,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType; class RequestAndSessionScopedBeanTests { @Test - public void testPutBeanInRequest() { + void testPutBeanInRequest() { String targetBeanName = "target"; StaticWebApplicationContext wac = new StaticWebApplicationContext(); @@ -70,7 +70,7 @@ class RequestAndSessionScopedBeanTests { } @Test - public void testPutBeanInSession() { + void testPutBeanInSession() { String targetBeanName = "target"; HttpServletRequest request = new MockHttpServletRequest(); RequestContextHolder.setRequestAttributes(new ServletRequestAttributes(request)); diff --git a/spring-web/src/test/java/org/springframework/web/context/support/AnnotationConfigWebApplicationContextTests.java b/spring-web/src/test/java/org/springframework/web/context/support/AnnotationConfigWebApplicationContextTests.java index 39c8286cab..656c784ebb 100644 --- a/spring-web/src/test/java/org/springframework/web/context/support/AnnotationConfigWebApplicationContextTests.java +++ b/spring-web/src/test/java/org/springframework/web/context/support/AnnotationConfigWebApplicationContextTests.java @@ -33,7 +33,7 @@ import static org.assertj.core.api.Assertions.assertThat; class AnnotationConfigWebApplicationContextTests { @Test - public void registerSingleClass() { + void registerSingleClass() { AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext(); ctx.register(Config.class); ctx.refresh(); @@ -43,7 +43,7 @@ class AnnotationConfigWebApplicationContextTests { } @Test - public void configLocationWithSingleClass() { + void configLocationWithSingleClass() { AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext(); ctx.setConfigLocation(Config.class.getName()); ctx.refresh(); @@ -53,7 +53,7 @@ class AnnotationConfigWebApplicationContextTests { } @Test - public void configLocationWithBasePackage() { + void configLocationWithBasePackage() { AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext(); ctx.setConfigLocation("org.springframework.web.context.support"); ctx.refresh(); @@ -63,7 +63,7 @@ class AnnotationConfigWebApplicationContextTests { } @Test - public void withBeanNameGenerator() { + void withBeanNameGenerator() { AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext(); ctx.setBeanNameGenerator(new AnnotationBeanNameGenerator() { @Override diff --git a/spring-web/src/testFixtures/java/org/springframework/web/testfixture/server/handler/AbstractResponseStatusExceptionHandlerTests.java b/spring-web/src/testFixtures/java/org/springframework/web/testfixture/server/handler/AbstractResponseStatusExceptionHandlerTests.java index facc2681dd..c033eeedb6 100644 --- a/spring-web/src/testFixtures/java/org/springframework/web/testfixture/server/handler/AbstractResponseStatusExceptionHandlerTests.java +++ b/spring-web/src/testFixtures/java/org/springframework/web/testfixture/server/handler/AbstractResponseStatusExceptionHandlerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * 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. @@ -51,7 +51,7 @@ public abstract class AbstractResponseStatusExceptionHandlerTests { @BeforeEach - public void setup() { + protected void setup() { this.handler = createResponseStatusExceptionHandler(); } @@ -61,21 +61,21 @@ public abstract class AbstractResponseStatusExceptionHandlerTests { @Test - public void handleResponseStatusException() { + protected void handleResponseStatusException() { Throwable ex = new ResponseStatusException(HttpStatus.BAD_REQUEST, ""); this.handler.handle(this.exchange, ex).block(Duration.ofSeconds(5)); assertThat(this.exchange.getResponse().getStatusCode()).isEqualTo(HttpStatus.BAD_REQUEST); } @Test - public void handleNestedResponseStatusException() { + protected void handleNestedResponseStatusException() { Throwable ex = new Exception(new ResponseStatusException(HttpStatus.BAD_REQUEST, "")); this.handler.handle(this.exchange, ex).block(Duration.ofSeconds(5)); assertThat(this.exchange.getResponse().getStatusCode()).isEqualTo(HttpStatus.BAD_REQUEST); } @Test // gh-23741 - public void handleMethodNotAllowed() { + protected void handleMethodNotAllowed() { Throwable ex = new MethodNotAllowedException(HttpMethod.PATCH, Arrays.asList(HttpMethod.POST, HttpMethod.PUT)); this.handler.handle(this.exchange, ex).block(Duration.ofSeconds(5)); @@ -85,7 +85,7 @@ public abstract class AbstractResponseStatusExceptionHandlerTests { } @Test // gh-23741 - public void handleResponseStatusExceptionWithHeaders() { + protected void handleResponseStatusExceptionWithHeaders() { Throwable ex = new NotAcceptableStatusException(Arrays.asList(MediaType.TEXT_PLAIN, MediaType.TEXT_HTML)); this.handler.handle(this.exchange, ex).block(Duration.ofSeconds(5)); @@ -95,14 +95,14 @@ public abstract class AbstractResponseStatusExceptionHandlerTests { } @Test - public void unresolvedException() { + protected void unresolvedException() { Throwable expected = new IllegalStateException(); Mono mono = this.handler.handle(this.exchange, expected); StepVerifier.create(mono).consumeErrorWith(actual -> assertThat(actual).isSameAs(expected)).verify(); } @Test // SPR-16231 - public void responseCommitted() { + protected void responseCommitted() { Throwable ex = new ResponseStatusException(HttpStatus.INTERNAL_SERVER_ERROR, "Oops"); this.exchange.getResponse().setStatusCode(HttpStatus.CREATED); Mono mono = this.exchange.getResponse().setComplete() diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/RequestMappingInfoHandlerMappingTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/RequestMappingInfoHandlerMappingTests.java index 16970ecf66..0ba5b8ef59 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/RequestMappingInfoHandlerMappingTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/RequestMappingInfoHandlerMappingTests.java @@ -142,7 +142,7 @@ class RequestMappingInfoHandlerMappingTests { } @Test // SPR-9603 - public void getHandlerRequestMethodMatchFalsePositive() { + void getHandlerRequestMethodMatchFalsePositive() { ServerWebExchange exchange = MockServerWebExchange.from(get("/users").accept(MediaType.APPLICATION_XML)); this.handlerMapping.registerHandler(new UserController()); Mono mono = this.handlerMapping.getHandler(exchange); @@ -153,7 +153,7 @@ class RequestMappingInfoHandlerMappingTests { } @Test // SPR-8462 - public void getHandlerMediaTypeNotSupported() { + void getHandlerMediaTypeNotSupported() { testHttpMediaTypeNotSupportedException("/person/1"); testHttpMediaTypeNotSupportedException("/person/1.json"); } @@ -170,12 +170,12 @@ class RequestMappingInfoHandlerMappingTests { } @Test // SPR-8462 - public void getHandlerTestMediaTypeNotAcceptable() { + void getHandlerTestMediaTypeNotAcceptable() { testMediaTypeNotAcceptable("/persons"); } @Test // SPR-12854 - public void getHandlerTestRequestParamMismatch() { + void getHandlerTestRequestParamMismatch() { ServerWebExchange exchange = MockServerWebExchange.from(get("/params")); Mono mono = this.handlerMapping.getHandler(exchange); assertError(mono, UnsatisfiedRequestParameterException.class, ex -> { @@ -215,7 +215,7 @@ class RequestMappingInfoHandlerMappingTests { @Test @SuppressWarnings("unchecked") - public void handleMatchUriTemplateVariables() { + void handleMatchUriTemplateVariables() { ServerWebExchange exchange = MockServerWebExchange.from(get("/1/2")); RequestMappingInfo key = paths("/{path1}/{path2}").build(); @@ -230,7 +230,7 @@ class RequestMappingInfoHandlerMappingTests { } @Test // SPR-9098 - public void handleMatchUriTemplateVariablesDecode() { + void handleMatchUriTemplateVariablesDecode() { RequestMappingInfo key = paths("/{group}/{identifier}").build(); URI url = URI.create("/group/a%2Fb"); ServerWebExchange exchange = MockServerWebExchange.from(method(HttpMethod.GET, url)); @@ -260,7 +260,7 @@ class RequestMappingInfoHandlerMappingTests { } @Test - public void handleMatchBestMatchingPatternAttributeInObservationContext() { + void handleMatchBestMatchingPatternAttributeInObservationContext() { RequestMappingInfo key = paths("/{path1}/2", "/**").build(); ServerWebExchange exchange = MockServerWebExchange.from(get("/1/2")); ServerRequestObservationContext observationContext = new ServerRequestObservationContext(exchange.getRequest(), exchange.getResponse(), exchange.getAttributes()); @@ -271,7 +271,7 @@ class RequestMappingInfoHandlerMappingTests { } @Test // gh-22543 - public void handleMatchBestMatchingPatternAttributeNoPatternsDefined() { + void handleMatchBestMatchingPatternAttributeNoPatternsDefined() { ServerWebExchange exchange = MockServerWebExchange.from(get("")); this.handlerMapping.handleMatch(paths().build(), handlerMethod, exchange); PathPattern pattern = (PathPattern) exchange.getAttributes().get(BEST_MATCHING_PATTERN_ATTRIBUTE); @@ -346,7 +346,7 @@ class RequestMappingInfoHandlerMappingTests { } @Test // gh-29611 - public void handleNoMatchWithoutPartialMatches() throws Exception { + void handleNoMatchWithoutPartialMatches() throws Exception { ServerWebExchange exchange = MockServerWebExchange.from(post("/non-existent")); HandlerMethod handlerMethod = this.handlerMapping.handleNoMatch(new HashSet<>(), exchange); diff --git a/spring-webmvc/src/test/java/org/springframework/web/context/XmlWebApplicationContextTests.java b/spring-webmvc/src/test/java/org/springframework/web/context/XmlWebApplicationContextTests.java index b0a05b045a..e102384516 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/context/XmlWebApplicationContextTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/context/XmlWebApplicationContextTests.java @@ -74,7 +74,7 @@ class XmlWebApplicationContextTests extends AbstractApplicationContextTests { @Test @SuppressWarnings("deprecation") - public void environmentMerge() { + void environmentMerge() { assertThat(this.root.getEnvironment().acceptsProfiles("rootProfile1")).isTrue(); assertThat(this.root.getEnvironment().acceptsProfiles("wacProfile1")).isFalse(); assertThat(this.applicationContext.getEnvironment().acceptsProfiles("rootProfile1")).isTrue(); @@ -82,8 +82,7 @@ class XmlWebApplicationContextTests extends AbstractApplicationContextTests { } /** - * Overridden as we can't trust superclass method - * @see org.springframework.context.testfixture.AbstractApplicationContextTests#testEvents() + * Overridden as we can't trust superclass method. */ @Override protected void doTestEvents(TestApplicationListener listener, TestApplicationListener parentListener, @@ -95,12 +94,12 @@ class XmlWebApplicationContextTests extends AbstractApplicationContextTests { @Test @Override - public void count() { + protected void count() { assertThat(this.applicationContext.getBeanDefinitionCount()).as("should have 14 beans").isEqualTo(14); } @Test - public void withoutMessageSource() { + void withoutMessageSource() { MockServletContext sc = new MockServletContext(""); XmlWebApplicationContext wac = new XmlWebApplicationContext(); wac.setParent(root); diff --git a/spring-webmvc/src/test/java/org/springframework/web/context/support/ServletContextSupportTests.java b/spring-webmvc/src/test/java/org/springframework/web/context/support/ServletContextSupportTests.java index fdb5b2959b..21cbe618c7 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/context/support/ServletContextSupportTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/context/support/ServletContextSupportTests.java @@ -44,7 +44,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType; class ServletContextSupportTests { @Test - public void testServletContextAttributeFactoryBean() { + void testServletContextAttributeFactoryBean() { MockServletContext sc = new MockServletContext(); sc.setAttribute("myAttr", "myValue"); @@ -60,7 +60,7 @@ class ServletContextSupportTests { } @Test - public void testServletContextAttributeFactoryBeanWithAttributeNotFound() { + void testServletContextAttributeFactoryBeanWithAttributeNotFound() { MockServletContext sc = new MockServletContext(); StaticWebApplicationContext wac = new StaticWebApplicationContext(); @@ -76,7 +76,7 @@ class ServletContextSupportTests { } @Test - public void testServletContextParameterFactoryBean() { + void testServletContextParameterFactoryBean() { MockServletContext sc = new MockServletContext(); sc.addInitParameter("myParam", "myValue"); @@ -92,7 +92,7 @@ class ServletContextSupportTests { } @Test - public void testServletContextParameterFactoryBeanWithAttributeNotFound() { + void testServletContextParameterFactoryBeanWithAttributeNotFound() { MockServletContext sc = new MockServletContext(); StaticWebApplicationContext wac = new StaticWebApplicationContext(); diff --git a/spring-webmvc/src/test/java/org/springframework/web/context/support/WebApplicationObjectSupportTests.java b/spring-webmvc/src/test/java/org/springframework/web/context/support/WebApplicationObjectSupportTests.java index a8ecafbfe9..2645e5399d 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/context/support/WebApplicationObjectSupportTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/context/support/WebApplicationObjectSupportTests.java @@ -36,7 +36,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalStateException; class WebApplicationObjectSupportTests { @Test - public void testWebApplicationObjectSupport() { + void testWebApplicationObjectSupport() { StaticWebApplicationContext wac = new StaticWebApplicationContext(); wac.setServletContext(new MockServletContext()); File tempDir = new File(""); @@ -49,7 +49,7 @@ class WebApplicationObjectSupportTests { } @Test - public void testWebApplicationObjectSupportWithWrongContext() { + void testWebApplicationObjectSupportWithWrongContext() { StaticApplicationContext ac = new StaticApplicationContext(); ac.registerBeanDefinition("test", new RootBeanDefinition(TestWebApplicationObject.class)); WebApplicationObjectSupport wao = (WebApplicationObjectSupport) ac.getBean("test"); @@ -58,7 +58,7 @@ class WebApplicationObjectSupportTests { } - public static class TestWebApplicationObject extends WebApplicationObjectSupport { + static class TestWebApplicationObject extends WebApplicationObjectSupport { } } diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/config/MvcNamespaceTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/config/MvcNamespaceTests.java index 17c32edc9d..eb9cba86ba 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/config/MvcNamespaceTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/config/MvcNamespaceTests.java @@ -272,7 +272,7 @@ public class MvcNamespaceTests { } @Test // gh-25290 - public void testDefaultConfigWithBeansInParentContext() { + void testDefaultConfigWithBeansInParentContext() { StaticApplicationContext parent = new StaticApplicationContext(); parent.registerSingleton("localeResolver", CookieLocaleResolver.class); parent.registerSingleton("themeResolver", CookieThemeResolver.class); @@ -376,7 +376,7 @@ public class MvcNamespaceTests { @Test @SuppressWarnings("deprecation") - public void testResources() throws Exception { + void testResources() throws Exception { loadBeanDefinitions("mvc-config-resources.xml"); HttpRequestHandlerAdapter adapter = appContext.getBean(HttpRequestHandlerAdapter.class); @@ -439,7 +439,7 @@ public class MvcNamespaceTests { } @Test - public void testResourcesWithResolversTransformers() { + void testResourcesWithResolversTransformers() { loadBeanDefinitions("mvc-config-resources-chain.xml"); SimpleUrlHandlerMapping mapping = appContext.getBean(SimpleUrlHandlerMapping.class); @@ -484,7 +484,7 @@ public class MvcNamespaceTests { } @Test - public void testResourcesWithResolversTransformersCustom() { + void testResourcesWithResolversTransformersCustom() { loadBeanDefinitions("mvc-config-resources-chain-no-auto.xml"); SimpleUrlHandlerMapping mapping = appContext.getBean(SimpleUrlHandlerMapping.class); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/handler/SimpleUrlHandlerMappingTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/handler/SimpleUrlHandlerMappingTests.java index 57f868e1b6..c5603f2658 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/handler/SimpleUrlHandlerMappingTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/handler/SimpleUrlHandlerMappingTests.java @@ -46,7 +46,7 @@ import static org.springframework.web.servlet.HandlerMapping.PATH_WITHIN_HANDLER class SimpleUrlHandlerMappingTests { @Test - public void handlerBeanNotFound() { + void handlerBeanNotFound() { MockServletContext sc = new MockServletContext(""); XmlWebApplicationContext root = new XmlWebApplicationContext(); root.setServletContext(sc); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/document/XlsViewTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/document/XlsViewTests.java index f92c33e527..3a7eb067a6 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/document/XlsViewTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/document/XlsViewTests.java @@ -50,7 +50,7 @@ class XlsViewTests { @Test - public void testXls() throws Exception { + void testXls() throws Exception { View excelView = new AbstractXlsView() { @Override protected void buildExcelDocument(Map model, Workbook workbook, @@ -73,7 +73,7 @@ class XlsViewTests { } @Test - public void testXlsxView() throws Exception { + void testXlsxView() throws Exception { View excelView = new AbstractXlsxView() { @Override protected void buildExcelDocument(Map model, Workbook workbook, @@ -96,7 +96,7 @@ class XlsViewTests { } @Test - public void testXlsxStreamingView() throws Exception { + void testXlsxStreamingView() throws Exception { View excelView = new AbstractXlsxStreamingView() { @Override protected void buildExcelDocument(Map model, Workbook workbook, diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/groovy/GroovyMarkupConfigurerTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/groovy/GroovyMarkupConfigurerTests.java index eb06af31e5..5e5479e4f9 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/groovy/GroovyMarkupConfigurerTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/groovy/GroovyMarkupConfigurerTests.java @@ -96,7 +96,7 @@ class GroovyMarkupConfigurerTests { } @Test - public void parentLoader() throws Exception { + void parentLoader() throws Exception { this.configurer.setApplicationContext(this.applicationContext);