diff --git a/spring-context-support/src/test/java/org/springframework/cache/caffeine/CaffeineCacheManagerTests.java b/spring-context-support/src/test/java/org/springframework/cache/caffeine/CaffeineCacheManagerTests.java index 4e81fdb33cf..c88b3c8d2b2 100644 --- a/spring-context-support/src/test/java/org/springframework/cache/caffeine/CaffeineCacheManagerTests.java +++ b/spring-context-support/src/test/java/org/springframework/cache/caffeine/CaffeineCacheManagerTests.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. @@ -265,7 +265,6 @@ class CaffeineCacheManagerTests { CaffeineCacheManager cm = new CaffeineCacheManager("c1"); Cache cache1 = cm.getCache("c1"); - @SuppressWarnings("unchecked") CacheLoader loader = mock(); cm.setCacheLoader(loader); diff --git a/spring-context-support/src/test/java/org/springframework/cache/caffeine/CaffeineReactiveCachingTests.java b/spring-context-support/src/test/java/org/springframework/cache/caffeine/CaffeineReactiveCachingTests.java index 50917d2f7d1..24ac179c47d 100644 --- a/spring-context-support/src/test/java/org/springframework/cache/caffeine/CaffeineReactiveCachingTests.java +++ b/spring-context-support/src/test/java/org/springframework/cache/caffeine/CaffeineReactiveCachingTests.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,7 +41,7 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Juergen Hoeller * @since 6.1 */ -public class CaffeineReactiveCachingTests { +class CaffeineReactiveCachingTests { @ParameterizedTest @ValueSource(classes = {AsyncCacheModeConfig.class, AsyncCacheModeConfig.class}) diff --git a/spring-context-support/src/test/java/org/springframework/cache/jcache/JCacheCacheManagerTests.java b/spring-context-support/src/test/java/org/springframework/cache/jcache/JCacheCacheManagerTests.java index 502b17f6dcd..481bd9b912f 100644 --- a/spring-context-support/src/test/java/org/springframework/cache/jcache/JCacheCacheManagerTests.java +++ b/spring-context-support/src/test/java/org/springframework/cache/jcache/JCacheCacheManagerTests.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.mockito.Mockito.mock; /** * @author Stephane Nicoll */ -public class JCacheCacheManagerTests extends AbstractTransactionSupportingCacheManagerTests { +class JCacheCacheManagerTests extends AbstractTransactionSupportingCacheManagerTests { private CacheManagerMock cacheManagerMock; @@ -42,7 +42,7 @@ public class JCacheCacheManagerTests extends AbstractTransactionSupportingCacheM @BeforeEach - public void setupOnce() { + void setupOnce() { cacheManagerMock = new CacheManagerMock(); cacheManagerMock.addCache(CACHE_NAME); diff --git a/spring-context-support/src/test/java/org/springframework/cache/jcache/JCacheEhCacheAnnotationTests.java b/spring-context-support/src/test/java/org/springframework/cache/jcache/JCacheEhCacheAnnotationTests.java index e77e948c802..61f2020d711 100644 --- a/spring-context-support/src/test/java/org/springframework/cache/jcache/JCacheEhCacheAnnotationTests.java +++ b/spring-context-support/src/test/java/org/springframework/cache/jcache/JCacheEhCacheAnnotationTests.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. @@ -46,7 +46,7 @@ import org.springframework.transaction.testfixture.CallCountingTransactionManage * @author Stephane Nicoll * @author Juergen Hoeller */ -public class JCacheEhCacheAnnotationTests extends AbstractCacheAnnotationTests { +class JCacheEhCacheAnnotationTests extends AbstractCacheAnnotationTests { private final TransactionTemplate txTemplate = new TransactionTemplate(new CallCountingTransactionManager()); @@ -68,7 +68,7 @@ public class JCacheEhCacheAnnotationTests extends AbstractCacheAnnotationTests { } @AfterEach - public void shutdown() { + void shutdown() { if (jCacheManager != null) { jCacheManager.close(); } @@ -82,22 +82,22 @@ public class JCacheEhCacheAnnotationTests extends AbstractCacheAnnotationTests { } @Test - public void testEvictWithTransaction() { + void testEvictWithTransaction() { txTemplate.executeWithoutResult(s -> testEvict(this.cs, false)); } @Test - public void testEvictEarlyWithTransaction() { + void testEvictEarlyWithTransaction() { txTemplate.executeWithoutResult(s -> testEvictEarly(this.cs)); } @Test - public void testEvictAllWithTransaction() { + void testEvictAllWithTransaction() { txTemplate.executeWithoutResult(s -> testEvictAll(this.cs, false)); } @Test - public void testEvictAllEarlyWithTransaction() { + void testEvictAllEarlyWithTransaction() { txTemplate.executeWithoutResult(s -> testEvictAllEarly(this.cs)); } diff --git a/spring-context-support/src/test/java/org/springframework/cache/jcache/JCacheEhCacheApiTests.java b/spring-context-support/src/test/java/org/springframework/cache/jcache/JCacheEhCacheApiTests.java index 289bb82008a..1adea115c39 100644 --- a/spring-context-support/src/test/java/org/springframework/cache/jcache/JCacheEhCacheApiTests.java +++ b/spring-context-support/src/test/java/org/springframework/cache/jcache/JCacheEhCacheApiTests.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 @@ import static org.assertj.core.api.Assertions.assertThat; /** * @author Stephane Nicoll */ -public class JCacheEhCacheApiTests extends AbstractValueAdaptingCacheTests { +class JCacheEhCacheApiTests extends AbstractValueAdaptingCacheTests { private CacheManager cacheManager; @@ -45,7 +45,7 @@ public class JCacheEhCacheApiTests extends AbstractValueAdaptingCacheTests()); this.cacheManager.createCache(CACHE_NAME_NO_NULL, new MutableConfiguration<>()); @@ -61,7 +61,7 @@ public class JCacheEhCacheApiTests extends AbstractValueAdaptingCacheTests interceptors = ctx.getBeansOfType(JCacheInterceptor.class); assertThat(interceptors).as("Only one interceptor should be defined").hasSize(1); JCacheInterceptor interceptor = interceptors.values().iterator().next(); @@ -78,14 +78,14 @@ public class JCacheCustomInterceptorTests { } @Test - public void customInterceptorAppliesWithRuntimeException() { + void customInterceptorAppliesWithRuntimeException() { Object o = cs.cacheWithException("id", true); // See TestCacheInterceptor assertThat(o).isEqualTo(55L); } @Test - public void customInterceptorAppliesWithCheckedException() { + void customInterceptorAppliesWithCheckedException() { assertThatRuntimeException() .isThrownBy(() -> cs.cacheWithCheckedException("id", true)) .withCauseExactlyInstanceOf(IOException.class); diff --git a/spring-context-support/src/test/java/org/springframework/cache/jcache/config/JCacheJavaConfigTests.java b/spring-context-support/src/test/java/org/springframework/cache/jcache/config/JCacheJavaConfigTests.java index 1dcc12540d1..4cdfa12cec6 100644 --- a/spring-context-support/src/test/java/org/springframework/cache/jcache/config/JCacheJavaConfigTests.java +++ b/spring-context-support/src/test/java/org/springframework/cache/jcache/config/JCacheJavaConfigTests.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. @@ -52,7 +52,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalStateException; /** * @author Stephane Nicoll */ -public class JCacheJavaConfigTests extends AbstractJCacheAnnotationTests { +class JCacheJavaConfigTests extends AbstractJCacheAnnotationTests { @Override protected ApplicationContext getApplicationContext() { @@ -61,7 +61,7 @@ public class JCacheJavaConfigTests extends AbstractJCacheAnnotationTests { @Test - public void fullCachingConfig() throws Exception { + void fullCachingConfig() { AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(FullCachingConfig.class); @@ -75,7 +75,7 @@ public class JCacheJavaConfigTests extends AbstractJCacheAnnotationTests { } @Test - public void emptyConfigSupport() { + void emptyConfigSupport() { ConfigurableApplicationContext context = new AnnotationConfigApplicationContext(EmptyConfigSupportConfig.class); @@ -88,7 +88,7 @@ public class JCacheJavaConfigTests extends AbstractJCacheAnnotationTests { } @Test - public void bothSetOnlyResolverIsUsed() { + void bothSetOnlyResolverIsUsed() { ConfigurableApplicationContext context = new AnnotationConfigApplicationContext(FullCachingConfigSupport.class); @@ -100,7 +100,7 @@ public class JCacheJavaConfigTests extends AbstractJCacheAnnotationTests { } @Test - public void exceptionCacheResolverLazilyRequired() { + void exceptionCacheResolverLazilyRequired() { try (ConfigurableApplicationContext context = new AnnotationConfigApplicationContext(NoExceptionCacheResolverConfig.class)) { DefaultJCacheOperationSource cos = context.getBean(DefaultJCacheOperationSource.class); assertThat(cos.getCacheResolver()).isSameAs(context.getBean("cacheResolver")); diff --git a/spring-context-support/src/test/java/org/springframework/cache/jcache/config/JCacheNamespaceDrivenTests.java b/spring-context-support/src/test/java/org/springframework/cache/jcache/config/JCacheNamespaceDrivenTests.java index 262689f83ad..2e4800fac7b 100644 --- a/spring-context-support/src/test/java/org/springframework/cache/jcache/config/JCacheNamespaceDrivenTests.java +++ b/spring-context-support/src/test/java/org/springframework/cache/jcache/config/JCacheNamespaceDrivenTests.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. @@ -31,7 +31,7 @@ import static org.assertj.core.api.Assertions.assertThat; /** * @author Stephane Nicoll */ -public class JCacheNamespaceDrivenTests extends AbstractJCacheAnnotationTests { +class JCacheNamespaceDrivenTests extends AbstractJCacheAnnotationTests { @Override protected ApplicationContext getApplicationContext() { @@ -40,7 +40,7 @@ public class JCacheNamespaceDrivenTests extends AbstractJCacheAnnotationTests { } @Test - public void cacheResolver() { + void cacheResolver() { ConfigurableApplicationContext context = new GenericXmlApplicationContext( "/org/springframework/cache/jcache/config/jCacheNamespaceDriven-resolver.xml"); @@ -50,7 +50,7 @@ public class JCacheNamespaceDrivenTests extends AbstractJCacheAnnotationTests { } @Test - public void testCacheErrorHandler() { + void testCacheErrorHandler() { JCacheInterceptor ci = ctx.getBean(JCacheInterceptor.class); assertThat(ci.getErrorHandler()).isSameAs(ctx.getBean("errorHandler", CacheErrorHandler.class)); } diff --git a/spring-context-support/src/test/java/org/springframework/cache/jcache/config/JCacheStandaloneConfigTests.java b/spring-context-support/src/test/java/org/springframework/cache/jcache/config/JCacheStandaloneConfigTests.java index f07e5214850..615498040a4 100644 --- a/spring-context-support/src/test/java/org/springframework/cache/jcache/config/JCacheStandaloneConfigTests.java +++ b/spring-context-support/src/test/java/org/springframework/cache/jcache/config/JCacheStandaloneConfigTests.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. @@ -23,7 +23,7 @@ import org.springframework.contextsupport.testfixture.jcache.AbstractJCacheAnnot /** * @author Stephane Nicoll */ -public class JCacheStandaloneConfigTests extends AbstractJCacheAnnotationTests { +class JCacheStandaloneConfigTests extends AbstractJCacheAnnotationTests { @Override protected ApplicationContext getApplicationContext() { diff --git a/spring-context-support/src/test/java/org/springframework/cache/jcache/interceptor/AbstractCacheOperationTests.java b/spring-context-support/src/test/java/org/springframework/cache/jcache/interceptor/AbstractCacheOperationTests.java index 7b28de03be4..337454ed2b2 100644 --- a/spring-context-support/src/test/java/org/springframework/cache/jcache/interceptor/AbstractCacheOperationTests.java +++ b/spring-context-support/src/test/java/org/springframework/cache/jcache/interceptor/AbstractCacheOperationTests.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. @@ -42,7 +42,7 @@ public abstract class AbstractCacheOperationTests> @Test - public void simple() { + void simple() { O operation = createSimpleOperation(); assertThat(operation.getCacheName()).as("Wrong cache name").isEqualTo("simpleCache"); assertThat(operation.getAnnotations()).as("Unexpected number of annotation on " + operation.getMethod()) diff --git a/spring-context-support/src/test/java/org/springframework/cache/jcache/interceptor/AnnotationCacheOperationSourceTests.java b/spring-context-support/src/test/java/org/springframework/cache/jcache/interceptor/AnnotationCacheOperationSourceTests.java index e85c2750786..4ced7de3d6a 100644 --- a/spring-context-support/src/test/java/org/springframework/cache/jcache/interceptor/AnnotationCacheOperationSourceTests.java +++ b/spring-context-support/src/test/java/org/springframework/cache/jcache/interceptor/AnnotationCacheOperationSourceTests.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. @@ -46,7 +46,7 @@ import static org.mockito.Mockito.mock; /** * @author Stephane Nicoll */ -public class AnnotationCacheOperationSourceTests extends AbstractJCacheTests { +class AnnotationCacheOperationSourceTests extends AbstractJCacheTests { private final DefaultJCacheOperationSource source = new DefaultJCacheOperationSource(); @@ -54,7 +54,7 @@ public class AnnotationCacheOperationSourceTests extends AbstractJCacheTests { @BeforeEach - public void setup() { + void setup() { source.setCacheResolver(defaultCacheResolver); source.setExceptionCacheResolver(defaultExceptionCacheResolver); source.setKeyGenerator(defaultKeyGenerator); @@ -63,14 +63,14 @@ public class AnnotationCacheOperationSourceTests extends AbstractJCacheTests { @Test - public void cache() { + void cache() { CacheResultOperation op = getDefaultCacheOperation(CacheResultOperation.class, String.class); assertDefaults(op); assertThat(op.getExceptionCacheResolver()).as("Exception caching not enabled so resolver should not be set").isNull(); } @Test - public void cacheWithException() { + void cacheWithException() { CacheResultOperation op = getDefaultCacheOperation(CacheResultOperation.class, String.class, boolean.class); assertDefaults(op); assertThat(op.getExceptionCacheResolver()).isEqualTo(defaultExceptionCacheResolver); @@ -78,41 +78,41 @@ public class AnnotationCacheOperationSourceTests extends AbstractJCacheTests { } @Test - public void put() { + void put() { CachePutOperation op = getDefaultCacheOperation(CachePutOperation.class, String.class, Object.class); assertDefaults(op); } @Test - public void remove() { + void remove() { CacheRemoveOperation op = getDefaultCacheOperation(CacheRemoveOperation.class, String.class); assertDefaults(op); } @Test - public void removeAll() { + void removeAll() { CacheRemoveAllOperation op = getDefaultCacheOperation(CacheRemoveAllOperation.class); assertThat(op.getCacheResolver()).isEqualTo(defaultCacheResolver); } @Test - public void noAnnotation() { + void noAnnotation() { assertThat(getCacheOperation(AnnotatedJCacheableService.class, this.cacheName)).isNull(); } @Test - public void multiAnnotations() { + void multiAnnotations() { assertThatIllegalStateException().isThrownBy(() -> getCacheOperation(InvalidCases.class, this.cacheName)); } @Test - public void defaultCacheNameWithCandidate() { + void defaultCacheNameWithCandidate() { Method method = ReflectionUtils.findMethod(Object.class, "toString"); assertThat(source.determineCacheName(method, null, "foo")).isEqualTo("foo"); } @Test - public void defaultCacheNameWithDefaults() { + void defaultCacheNameWithDefaults() { Method method = ReflectionUtils.findMethod(Object.class, "toString"); CacheDefaults mock = mock(); given(mock.cacheName()).willReturn(""); @@ -120,19 +120,19 @@ public class AnnotationCacheOperationSourceTests extends AbstractJCacheTests { } @Test - public void defaultCacheNameNoDefaults() { + void defaultCacheNameNoDefaults() { Method method = ReflectionUtils.findMethod(Object.class, "toString"); assertThat(source.determineCacheName(method, null, "")).isEqualTo("java.lang.Object.toString()"); } @Test - public void defaultCacheNameWithParameters() { + void defaultCacheNameWithParameters() { Method method = ReflectionUtils.findMethod(Comparator.class, "compare", Object.class, Object.class); assertThat(source.determineCacheName(method, null, "")).isEqualTo("java.util.Comparator.compare(java.lang.Object,java.lang.Object)"); } @Test - public void customCacheResolver() { + void customCacheResolver() { CacheResultOperation operation = getCacheOperation(CacheResultOperation.class, CustomService.class, this.cacheName, Long.class); assertJCacheResolver(operation.getCacheResolver(), TestableCacheResolver.class); @@ -142,7 +142,7 @@ public class AnnotationCacheOperationSourceTests extends AbstractJCacheTests { } @Test - public void customKeyGenerator() { + void customKeyGenerator() { CacheResultOperation operation = getCacheOperation(CacheResultOperation.class, CustomService.class, this.cacheName, Long.class); assertThat(operation.getCacheResolver()).isEqualTo(defaultCacheResolver); @@ -151,7 +151,7 @@ public class AnnotationCacheOperationSourceTests extends AbstractJCacheTests { } @Test - public void customKeyGeneratorSpringBean() { + void customKeyGeneratorSpringBean() { TestableCacheKeyGenerator bean = new TestableCacheKeyGenerator(); beanFactory.registerSingleton("fooBar", bean); CacheResultOperation operation = @@ -164,7 +164,7 @@ public class AnnotationCacheOperationSourceTests extends AbstractJCacheTests { } @Test - public void customKeyGeneratorAndCacheResolver() { + void customKeyGeneratorAndCacheResolver() { CacheResultOperation operation = getCacheOperation(CacheResultOperation.class, CustomServiceWithDefaults.class, this.cacheName, Long.class); assertJCacheResolver(operation.getCacheResolver(), TestableCacheResolver.class); @@ -173,7 +173,7 @@ public class AnnotationCacheOperationSourceTests extends AbstractJCacheTests { } @Test - public void customKeyGeneratorAndCacheResolverWithExceptionName() { + void customKeyGeneratorAndCacheResolverWithExceptionName() { CacheResultOperation operation = getCacheOperation(CacheResultOperation.class, CustomServiceWithDefaults.class, this.cacheName, Long.class); assertJCacheResolver(operation.getCacheResolver(), TestableCacheResolver.class); diff --git a/spring-context-support/src/test/java/org/springframework/cache/jcache/interceptor/CachePutOperationTests.java b/spring-context-support/src/test/java/org/springframework/cache/jcache/interceptor/CachePutOperationTests.java index dee2f07ba3d..ce3437751a1 100644 --- a/spring-context-support/src/test/java/org/springframework/cache/jcache/interceptor/CachePutOperationTests.java +++ b/spring-context-support/src/test/java/org/springframework/cache/jcache/interceptor/CachePutOperationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 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. @@ -31,7 +31,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalStateException; /** * @author Stephane Nicoll */ -public class CachePutOperationTests extends AbstractCacheOperationTests { +class CachePutOperationTests extends AbstractCacheOperationTests { @Override protected CachePutOperation createSimpleOperation() { @@ -41,7 +41,7 @@ public class CachePutOperationTests extends AbstractCacheOperationTests methodDetails = create(CachePut.class, SampleObject.class, "noCacheValue", Long.class); @@ -64,7 +64,7 @@ public class CachePutOperationTests extends AbstractCacheOperationTests methodDetails = create(CachePut.class, SampleObject.class, "multiCacheValues", Long.class, SampleObject.class, SampleObject.class); @@ -73,7 +73,7 @@ public class CachePutOperationTests extends AbstractCacheOperationTests @@ -81,7 +81,7 @@ public class CachePutOperationTests extends AbstractCacheOperationTests methodDetails = create(CachePut.class, SampleObject.class, "fullPutConfig", Long.class, SampleObject.class); CachePutOperation operation = createDefaultOperation(methodDetails); diff --git a/spring-context-support/src/test/java/org/springframework/cache/jcache/interceptor/CacheRemoveAllOperationTests.java b/spring-context-support/src/test/java/org/springframework/cache/jcache/interceptor/CacheRemoveAllOperationTests.java index 083ae9048b1..e614b970e9d 100644 --- a/spring-context-support/src/test/java/org/springframework/cache/jcache/interceptor/CacheRemoveAllOperationTests.java +++ b/spring-context-support/src/test/java/org/springframework/cache/jcache/interceptor/CacheRemoveAllOperationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 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. @@ -27,7 +27,7 @@ import static org.assertj.core.api.Assertions.assertThat; /** * @author Stephane Nicoll */ -public class CacheRemoveAllOperationTests extends AbstractCacheOperationTests { +class CacheRemoveAllOperationTests extends AbstractCacheOperationTests { @Override protected CacheRemoveAllOperation createSimpleOperation() { @@ -38,7 +38,7 @@ public class CacheRemoveAllOperationTests extends AbstractCacheOperationTests { +class CacheRemoveOperationTests extends AbstractCacheOperationTests { @Override protected CacheRemoveOperation createSimpleOperation() { @@ -38,7 +38,7 @@ public class CacheRemoveOperationTests extends AbstractCacheOperationTests dummyContext = createDummyContext(); CacheResolverAdapter adapter = new CacheResolverAdapter(getCacheResolver(dummyContext, "testCache")); Collection caches = adapter.resolveCaches(dummyContext); @@ -51,7 +51,7 @@ public class CacheResolverAdapterTests extends AbstractJCacheTests { } @Test - public void resolveUnknownCache() throws Exception { + void resolveUnknownCache() throws Exception { DefaultCacheInvocationContext dummyContext = createDummyContext(); CacheResolverAdapter adapter = new CacheResolverAdapter(getCacheResolver(dummyContext, null)); diff --git a/spring-context-support/src/test/java/org/springframework/cache/jcache/interceptor/CacheResultOperationTests.java b/spring-context-support/src/test/java/org/springframework/cache/jcache/interceptor/CacheResultOperationTests.java index 0764e1788e4..34477dfe9b3 100644 --- a/spring-context-support/src/test/java/org/springframework/cache/jcache/interceptor/CacheResultOperationTests.java +++ b/spring-context-support/src/test/java/org/springframework/cache/jcache/interceptor/CacheResultOperationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 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. @@ -35,7 +35,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalStateException; /** * @author Stephane Nicoll */ -public class CacheResultOperationTests extends AbstractCacheOperationTests { +class CacheResultOperationTests extends AbstractCacheOperationTests { @Override protected CacheResultOperation createSimpleOperation() { @@ -47,7 +47,7 @@ public class CacheResultOperationTests extends AbstractCacheOperationTests methodDetails = create(CacheResult.class, SampleObject.class, "multiKeysGet", Long.class, Boolean.class, String.class); CacheResultOperation operation = createDefaultOperation(methodDetails); @@ -78,7 +78,7 @@ public class CacheResultOperationTests extends AbstractCacheOperationTests methodDetails = create(CacheResult.class, SampleObject.class, "anotherSimpleGet", String.class, Long.class); CacheResultOperation operation = createDefaultOperation(methodDetails); @@ -89,7 +89,7 @@ public class CacheResultOperationTests extends AbstractCacheOperationTests methodDetails = create(CacheResult.class, SampleObject.class, "anotherSimpleGet", String.class, Long.class); CacheResultOperation operation = createDefaultOperation(methodDetails); @@ -100,7 +100,7 @@ public class CacheResultOperationTests extends AbstractCacheOperationTests methodDetails = create(CacheResult.class, SampleObject.class, "annotatedGet", Long.class, String.class); CacheResultOperation operation = createDefaultOperation(methodDetails); @@ -116,7 +116,7 @@ public class CacheResultOperationTests extends AbstractCacheOperationTests methodDetails = create(CacheResult.class, SampleObject.class, "fullGetConfig", Long.class); CacheResultOperation operation = createDefaultOperation(methodDetails); diff --git a/spring-context-support/src/test/java/org/springframework/cache/jcache/interceptor/JCacheErrorHandlerTests.java b/spring-context-support/src/test/java/org/springframework/cache/jcache/interceptor/JCacheErrorHandlerTests.java index 3626d9f90f2..b26719570c0 100644 --- a/spring-context-support/src/test/java/org/springframework/cache/jcache/interceptor/JCacheErrorHandlerTests.java +++ b/spring-context-support/src/test/java/org/springframework/cache/jcache/interceptor/JCacheErrorHandlerTests.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. @@ -49,7 +49,7 @@ import static org.mockito.Mockito.verify; /** * @author Stephane Nicoll */ -public class JCacheErrorHandlerTests { +class JCacheErrorHandlerTests { private Cache cache; @@ -61,7 +61,7 @@ public class JCacheErrorHandlerTests { @BeforeEach - public void setup() { + void setup() { AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(Config.class); this.cache = context.getBean("mockCache", Cache.class); this.errorCache = context.getBean("mockErrorCache", Cache.class); @@ -72,7 +72,7 @@ public class JCacheErrorHandlerTests { @Test - public void getFail() { + void getFail() { UnsupportedOperationException exception = new UnsupportedOperationException("Test exception on get"); Object key = SimpleKeyGenerator.generateKey(0L); willThrow(exception).given(this.cache).get(key); @@ -82,7 +82,7 @@ public class JCacheErrorHandlerTests { } @Test - public void getPutNewElementFail() { + void getPutNewElementFail() { UnsupportedOperationException exception = new UnsupportedOperationException("Test exception on put"); Object key = SimpleKeyGenerator.generateKey(0L); given(this.cache.get(key)).willReturn(null); @@ -93,7 +93,7 @@ public class JCacheErrorHandlerTests { } @Test - public void getFailPutExceptionFail() { + void getFailPutExceptionFail() { UnsupportedOperationException exceptionOnPut = new UnsupportedOperationException("Test exception on put"); Object key = SimpleKeyGenerator.generateKey(0L); given(this.cache.get(key)).willReturn(null); @@ -110,7 +110,7 @@ public class JCacheErrorHandlerTests { } @Test - public void putFail() { + void putFail() { UnsupportedOperationException exception = new UnsupportedOperationException("Test exception on put"); Object key = SimpleKeyGenerator.generateKey(0L); willThrow(exception).given(this.cache).put(key, 234L); @@ -120,7 +120,7 @@ public class JCacheErrorHandlerTests { } @Test - public void evictFail() { + void evictFail() { UnsupportedOperationException exception = new UnsupportedOperationException("Test exception on evict"); Object key = SimpleKeyGenerator.generateKey(0L); willThrow(exception).given(this.cache).evict(key); @@ -130,7 +130,7 @@ public class JCacheErrorHandlerTests { } @Test - public void clearFail() { + void clearFail() { UnsupportedOperationException exception = new UnsupportedOperationException("Test exception on evict"); willThrow(exception).given(this.cache).clear(); @@ -183,7 +183,7 @@ public class JCacheErrorHandlerTests { private static final IllegalStateException TEST_EXCEPTION = new IllegalStateException("Test exception"); - private AtomicLong counter = new AtomicLong(); + private final AtomicLong counter = new AtomicLong(); @CacheResult public Object get(long id) { diff --git a/spring-context-support/src/test/java/org/springframework/cache/jcache/interceptor/JCacheInterceptorTests.java b/spring-context-support/src/test/java/org/springframework/cache/jcache/interceptor/JCacheInterceptorTests.java index 0c6671ebbb0..9b99bfb503a 100644 --- a/spring-context-support/src/test/java/org/springframework/cache/jcache/interceptor/JCacheInterceptorTests.java +++ b/spring-context-support/src/test/java/org/springframework/cache/jcache/interceptor/JCacheInterceptorTests.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. @@ -35,12 +35,12 @@ import static org.assertj.core.api.Assertions.assertThatIllegalStateException; /** * @author Stephane Nicoll */ -public class JCacheInterceptorTests extends AbstractJCacheTests { +class JCacheInterceptorTests extends AbstractJCacheTests { private final CacheOperationInvoker dummyInvoker = new DummyInvoker(null); @Test - public void severalCachesNotSupported() { + void severalCachesNotSupported() { JCacheInterceptor interceptor = createInterceptor(createOperationSource( cacheManager, new NamedCacheResolver(cacheManager, "default", "simpleCache"), defaultExceptionCacheResolver, defaultKeyGenerator)); @@ -54,7 +54,7 @@ public class JCacheInterceptorTests extends AbstractJCacheTests { } @Test - public void noCacheCouldBeResolved() { + void noCacheCouldBeResolved() { JCacheInterceptor interceptor = createInterceptor(createOperationSource( cacheManager, new NamedCacheResolver(cacheManager), // Returns empty list defaultExceptionCacheResolver, defaultKeyGenerator)); @@ -67,18 +67,18 @@ public class JCacheInterceptorTests extends AbstractJCacheTests { } @Test - public void cacheManagerMandatoryIfCacheResolverNotSet() { + void cacheManagerMandatoryIfCacheResolverNotSet() { assertThatIllegalStateException().isThrownBy(() -> createOperationSource(null, null, null, defaultKeyGenerator)); } @Test - public void cacheManagerOptionalIfCacheResolversSet() { + void cacheManagerOptionalIfCacheResolversSet() { createOperationSource(null, defaultCacheResolver, defaultExceptionCacheResolver, defaultKeyGenerator); } @Test - public void cacheResultReturnsProperType() throws Throwable { + void cacheResultReturnsProperType() { JCacheInterceptor interceptor = createInterceptor(createOperationSource( cacheManager, defaultCacheResolver, defaultExceptionCacheResolver, defaultKeyGenerator)); diff --git a/spring-context-support/src/test/java/org/springframework/cache/jcache/interceptor/JCacheKeyGeneratorTests.java b/spring-context-support/src/test/java/org/springframework/cache/jcache/interceptor/JCacheKeyGeneratorTests.java index 35db912df97..232a6b00762 100644 --- a/spring-context-support/src/test/java/org/springframework/cache/jcache/interceptor/JCacheKeyGeneratorTests.java +++ b/spring-context-support/src/test/java/org/springframework/cache/jcache/interceptor/JCacheKeyGeneratorTests.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. @@ -44,7 +44,7 @@ import static org.assertj.core.api.Assertions.assertThat; /** * @author Stephane Nicoll */ -public class JCacheKeyGeneratorTests { +class JCacheKeyGeneratorTests { private TestKeyGenerator keyGenerator; @@ -53,7 +53,7 @@ public class JCacheKeyGeneratorTests { private Cache cache; @BeforeEach - public void setup() { + void setup() { AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(Config.class); this.keyGenerator = context.getBean(TestKeyGenerator.class); this.simpleService = context.getBean(SimpleService.class); @@ -62,7 +62,7 @@ public class JCacheKeyGeneratorTests { } @Test - public void getSimple() { + void getSimple() { this.keyGenerator.expect(1L); Object first = this.simpleService.get(1L); Object second = this.simpleService.get(1L); @@ -73,7 +73,7 @@ public class JCacheKeyGeneratorTests { } @Test - public void getFlattenVararg() { + void getFlattenVararg() { this.keyGenerator.expect(1L, "foo", "bar"); Object first = this.simpleService.get(1L, "foo", "bar"); Object second = this.simpleService.get(1L, "foo", "bar"); @@ -84,7 +84,7 @@ public class JCacheKeyGeneratorTests { } @Test - public void getFiltered() { + void getFiltered() { this.keyGenerator.expect(1L); Object first = this.simpleService.getFiltered(1L, "foo", "bar"); Object second = this.simpleService.getFiltered(1L, "foo", "bar"); @@ -120,7 +120,7 @@ public class JCacheKeyGeneratorTests { @CacheDefaults(cacheName = "test") public static class SimpleService { - private AtomicLong counter = new AtomicLong(); + private final AtomicLong counter = new AtomicLong(); @CacheResult public Object get(long id) { diff --git a/spring-context-support/src/test/java/org/springframework/cache/transaction/AbstractTransactionSupportingCacheManagerTests.java b/spring-context-support/src/test/java/org/springframework/cache/transaction/AbstractTransactionSupportingCacheManagerTests.java index 46049d2296d..c5b03cf26bc 100644 --- a/spring-context-support/src/test/java/org/springframework/cache/transaction/AbstractTransactionSupportingCacheManagerTests.java +++ b/spring-context-support/src/test/java/org/springframework/cache/transaction/AbstractTransactionSupportingCacheManagerTests.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. @@ -71,12 +71,12 @@ public abstract class AbstractTransactionSupportingCacheManagerTests new TransactionAwareCacheDecorator(null)); } @Test - public void getTargetCache() { + void getTargetCache() { Cache target = new ConcurrentMapCache("testCache"); TransactionAwareCacheDecorator cache = new TransactionAwareCacheDecorator(target); assertThat(cache.getTargetCache()).isSameAs(target); } @Test - public void regularOperationsOnTarget() { + void regularOperationsOnTarget() { Cache target = new ConcurrentMapCache("testCache"); Cache cache = new TransactionAwareCacheDecorator(target); assertThat(cache.getName()).isEqualTo(target.getName()); @@ -64,7 +64,7 @@ public class TransactionAwareCacheDecoratorTests { } @Test - public void putNonTransactional() { + void putNonTransactional() { Cache target = new ConcurrentMapCache("testCache"); Cache cache = new TransactionAwareCacheDecorator(target); @@ -74,7 +74,7 @@ public class TransactionAwareCacheDecoratorTests { } @Test - public void putTransactional() { + void putTransactional() { Cache target = new ConcurrentMapCache("testCache"); Cache cache = new TransactionAwareCacheDecorator(target); Object key = new Object(); @@ -88,7 +88,7 @@ public class TransactionAwareCacheDecoratorTests { } @Test - public void putIfAbsentNonTransactional() { + void putIfAbsentNonTransactional() { Cache target = new ConcurrentMapCache("testCache"); Cache cache = new TransactionAwareCacheDecorator(target); @@ -101,7 +101,7 @@ public class TransactionAwareCacheDecoratorTests { } @Test - public void putIfAbsentTransactional() { // no transactional support for putIfAbsent + void putIfAbsentTransactional() { // no transactional support for putIfAbsent Cache target = new ConcurrentMapCache("testCache"); Cache cache = new TransactionAwareCacheDecorator(target); Object key = new Object(); @@ -118,7 +118,7 @@ public class TransactionAwareCacheDecoratorTests { } @Test - public void evictNonTransactional() { + void evictNonTransactional() { Cache target = new ConcurrentMapCache("testCache"); Cache cache = new TransactionAwareCacheDecorator(target); Object key = new Object(); @@ -129,7 +129,7 @@ public class TransactionAwareCacheDecoratorTests { } @Test - public void evictTransactional() { + void evictTransactional() { Cache target = new ConcurrentMapCache("testCache"); Cache cache = new TransactionAwareCacheDecorator(target); Object key = new Object(); @@ -144,7 +144,7 @@ public class TransactionAwareCacheDecoratorTests { } @Test - public void evictIfPresentNonTransactional() { + void evictIfPresentNonTransactional() { Cache target = new ConcurrentMapCache("testCache"); Cache cache = new TransactionAwareCacheDecorator(target); Object key = new Object(); @@ -155,7 +155,7 @@ public class TransactionAwareCacheDecoratorTests { } @Test - public void evictIfPresentTransactional() { // no transactional support for evictIfPresent + void evictIfPresentTransactional() { // no transactional support for evictIfPresent Cache target = new ConcurrentMapCache("testCache"); Cache cache = new TransactionAwareCacheDecorator(target); Object key = new Object(); @@ -170,7 +170,7 @@ public class TransactionAwareCacheDecoratorTests { } @Test - public void clearNonTransactional() { + void clearNonTransactional() { Cache target = new ConcurrentMapCache("testCache"); Cache cache = new TransactionAwareCacheDecorator(target); Object key = new Object(); @@ -181,7 +181,7 @@ public class TransactionAwareCacheDecoratorTests { } @Test - public void clearTransactional() { + void clearTransactional() { Cache target = new ConcurrentMapCache("testCache"); Cache cache = new TransactionAwareCacheDecorator(target); Object key = new Object(); @@ -196,7 +196,7 @@ public class TransactionAwareCacheDecoratorTests { } @Test - public void invalidateNonTransactional() { + void invalidateNonTransactional() { Cache target = new ConcurrentMapCache("testCache"); Cache cache = new TransactionAwareCacheDecorator(target); Object key = new Object(); @@ -207,7 +207,7 @@ public class TransactionAwareCacheDecoratorTests { } @Test - public void invalidateTransactional() { // no transactional support for invalidate + void invalidateTransactional() { // no transactional support for invalidate Cache target = new ConcurrentMapCache("testCache"); Cache cache = new TransactionAwareCacheDecorator(target); Object key = new Object(); diff --git a/spring-context-support/src/test/java/org/springframework/mail/SimpleMailMessageTests.java b/spring-context-support/src/test/java/org/springframework/mail/SimpleMailMessageTests.java index e0831d921c3..7fd2cfe272b 100644 --- a/spring-context-support/src/test/java/org/springframework/mail/SimpleMailMessageTests.java +++ b/spring-context-support/src/test/java/org/springframework/mail/SimpleMailMessageTests.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,10 +32,10 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException * @author Chris Beams * @since 10.09.2003 */ -public class SimpleMailMessageTests { +class SimpleMailMessageTests { @Test - public void testSimpleMessageCopyCtor() { + void testSimpleMessageCopyCtor() { SimpleMailMessage message = new SimpleMailMessage(); message.setFrom("me@mail.org"); message.setTo("you@mail.org"); @@ -45,8 +45,8 @@ public class SimpleMailMessageTests { assertThat(messageCopy.getTo()[0]).isEqualTo("you@mail.org"); message.setReplyTo("reply@mail.org"); - message.setCc(new String[]{"he@mail.org", "she@mail.org"}); - message.setBcc(new String[]{"us@mail.org", "them@mail.org"}); + message.setCc("he@mail.org", "she@mail.org"); + message.setBcc("us@mail.org", "them@mail.org"); Date sentDate = new Date(); message.setSentDate(sentDate); message.setSubject("my subject"); @@ -81,12 +81,12 @@ public class SimpleMailMessageTests { } @Test - public void testDeepCopyOfStringArrayTypedFieldsOnCopyCtor() throws Exception { + void testDeepCopyOfStringArrayTypedFieldsOnCopyCtor() { SimpleMailMessage original = new SimpleMailMessage(); - original.setTo(new String[]{"fiona@mail.org", "apple@mail.org"}); - original.setCc(new String[]{"he@mail.org", "she@mail.org"}); - original.setBcc(new String[]{"us@mail.org", "them@mail.org"}); + original.setTo("fiona@mail.org", "apple@mail.org"); + original.setCc("he@mail.org", "she@mail.org"); + original.setBcc("us@mail.org", "them@mail.org"); SimpleMailMessage copy = new SimpleMailMessage(original); @@ -160,13 +160,13 @@ public class SimpleMailMessageTests { } @Test - public void testCopyCtorChokesOnNullOriginalMessage() throws Exception { + void testCopyCtorChokesOnNullOriginalMessage() { assertThatIllegalArgumentException().isThrownBy(() -> new SimpleMailMessage(null)); } @Test - public void testCopyToChokesOnNullTargetMessage() throws Exception { + void testCopyToChokesOnNullTargetMessage() { assertThatIllegalArgumentException().isThrownBy(() -> new SimpleMailMessage().copyTo(null)); } diff --git a/spring-context-support/src/test/java/org/springframework/mail/javamail/ConfigurableMimeFileTypeMapTests.java b/spring-context-support/src/test/java/org/springframework/mail/javamail/ConfigurableMimeFileTypeMapTests.java index ebbf493cd5f..14385649418 100644 --- a/spring-context-support/src/test/java/org/springframework/mail/javamail/ConfigurableMimeFileTypeMapTests.java +++ b/spring-context-support/src/test/java/org/springframework/mail/javamail/ConfigurableMimeFileTypeMapTests.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. @@ -29,10 +29,10 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Rob Harrop * @author Juergen Hoeller */ -public class ConfigurableMimeFileTypeMapTests { +class ConfigurableMimeFileTypeMapTests { @Test - public void againstDefaultConfiguration() throws Exception { + void againstDefaultConfiguration() { ConfigurableMimeFileTypeMap ftm = new ConfigurableMimeFileTypeMap(); ftm.afterPropertiesSet(); @@ -45,15 +45,15 @@ public class ConfigurableMimeFileTypeMapTests { } @Test - public void againstDefaultConfigurationWithFilePath() throws Exception { + void againstDefaultConfigurationWithFilePath() { ConfigurableMimeFileTypeMap ftm = new ConfigurableMimeFileTypeMap(); assertThat(ftm.getContentType(new File("/tmp/foobar.HTM"))).as("Invalid content type for HTM").isEqualTo("text/html"); } @Test - public void withAdditionalMappings() throws Exception { + void withAdditionalMappings() { ConfigurableMimeFileTypeMap ftm = new ConfigurableMimeFileTypeMap(); - ftm.setMappings(new String[] {"foo/bar HTM foo", "foo/cpp c++"}); + ftm.setMappings("foo/bar HTM foo", "foo/cpp c++"); ftm.afterPropertiesSet(); assertThat(ftm.getContentType("foobar.HTM")).as("Invalid content type for HTM - override didn't work").isEqualTo("foo/bar"); @@ -62,7 +62,7 @@ public class ConfigurableMimeFileTypeMapTests { } @Test - public void withCustomMappingLocation() throws Exception { + void withCustomMappingLocation() { Resource resource = new ClassPathResource("test.mime.types", getClass()); ConfigurableMimeFileTypeMap ftm = new ConfigurableMimeFileTypeMap(); diff --git a/spring-context-support/src/test/java/org/springframework/mail/javamail/InternetAddressEditorTests.java b/spring-context-support/src/test/java/org/springframework/mail/javamail/InternetAddressEditorTests.java index cb321a09ecb..35d06261559 100644 --- a/spring-context-support/src/test/java/org/springframework/mail/javamail/InternetAddressEditorTests.java +++ b/spring-context-support/src/test/java/org/springframework/mail/javamail/InternetAddressEditorTests.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. @@ -26,7 +26,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException * @author Sam Brannen * @since 09.07.2005 */ -public class InternetAddressEditorTests { +class InternetAddressEditorTests { private static final String EMPTY = ""; private static final String SIMPLE = "nobody@nowhere.com"; @@ -36,42 +36,42 @@ public class InternetAddressEditorTests { @Test - public void uninitialized() { + void uninitialized() { assertThat(editor.getAsText()).as("Uninitialized editor did not return empty value string").isEmpty(); } @Test - public void setNull() { + void setNull() { editor.setAsText(null); assertThat(editor.getAsText()).as("Setting null did not result in empty value string").isEmpty(); } @Test - public void setEmpty() { + void setEmpty() { editor.setAsText(EMPTY); assertThat(editor.getAsText()).as("Setting empty string did not result in empty value string").isEmpty(); } @Test - public void allWhitespace() { + void allWhitespace() { editor.setAsText(" "); assertThat(editor.getAsText()).as("All whitespace was not recognized").isEmpty(); } @Test - public void simpleGoodAddress() { + void simpleGoodAddress() { editor.setAsText(SIMPLE); assertThat(editor.getAsText()).as("Simple email address failed").isEqualTo(SIMPLE); } @Test - public void excessWhitespace() { + void excessWhitespace() { editor.setAsText(" " + SIMPLE + " "); assertThat(editor.getAsText()).as("Whitespace was not stripped").isEqualTo(SIMPLE); } @Test - public void simpleBadAddress() { + void simpleBadAddress() { assertThatIllegalArgumentException().isThrownBy(() -> editor.setAsText(BAD)); } diff --git a/spring-context-support/src/test/java/org/springframework/mail/javamail/JavaMailSenderTests.java b/spring-context-support/src/test/java/org/springframework/mail/javamail/JavaMailSenderTests.java index ab5a36fdb18..8e26619b4d1 100644 --- a/spring-context-support/src/test/java/org/springframework/mail/javamail/JavaMailSenderTests.java +++ b/spring-context-support/src/test/java/org/springframework/mail/javamail/JavaMailSenderTests.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. @@ -456,7 +456,7 @@ class JavaMailSenderTests { private String connectedUsername = null; private String connectedPassword = null; private boolean closeCalled = false; - private List sentMessages = new ArrayList<>(); + private final List sentMessages = new ArrayList<>(); private MockTransport(Session session, URLName urlName) { super(session, urlName); @@ -504,7 +504,7 @@ class JavaMailSenderTests { @Override public synchronized void close() throws MessagingException { - if ("".equals(connectedHost)) { + if (this.connectedHost.isEmpty()) { throw new MessagingException("close failure"); } this.closeCalled = true; diff --git a/spring-context-support/src/test/java/org/springframework/scheduling/quartz/QuartzSchedulerLifecycleTests.java b/spring-context-support/src/test/java/org/springframework/scheduling/quartz/QuartzSchedulerLifecycleTests.java index 31426b1f6be..7d1af052ae7 100644 --- a/spring-context-support/src/test/java/org/springframework/scheduling/quartz/QuartzSchedulerLifecycleTests.java +++ b/spring-context-support/src/test/java/org/springframework/scheduling/quartz/QuartzSchedulerLifecycleTests.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. @@ -28,7 +28,7 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Mark Fisher * @since 3.0 */ -public class QuartzSchedulerLifecycleTests { +class QuartzSchedulerLifecycleTests { @Test // SPR-6354 public void destroyLazyInitSchedulerWithDefaultShutdownOrderDoesNotHang() { diff --git a/spring-context-support/src/test/java/org/springframework/scheduling/quartz/QuartzSupportTests.java b/spring-context-support/src/test/java/org/springframework/scheduling/quartz/QuartzSupportTests.java index 35ea29c98e6..b5b490524a4 100644 --- a/spring-context-support/src/test/java/org/springframework/scheduling/quartz/QuartzSupportTests.java +++ b/spring-context-support/src/test/java/org/springframework/scheduling/quartz/QuartzSupportTests.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. @@ -25,7 +25,6 @@ import javax.sql.DataSource; import org.junit.jupiter.api.Test; import org.quartz.Job; import org.quartz.JobExecutionContext; -import org.quartz.JobExecutionException; import org.quartz.Scheduler; import org.quartz.SchedulerContext; import org.quartz.SchedulerFactory; @@ -352,7 +351,6 @@ class QuartzSupportTests { } @Test - @SuppressWarnings("resource") void schedulerAutoStartsOnContextRefreshedEventByDefault() throws Exception { StaticApplicationContext context = new StaticApplicationContext(); context.registerBeanDefinition("scheduler", new RootBeanDefinition(SchedulerFactoryBean.class)); @@ -363,7 +361,6 @@ class QuartzSupportTests { } @Test - @SuppressWarnings("resource") void schedulerAutoStartupFalse() throws Exception { StaticApplicationContext context = new StaticApplicationContext(); BeanDefinition beanDefinition = BeanDefinitionBuilder.genericBeanDefinition(SchedulerFactoryBean.class) @@ -376,7 +373,7 @@ class QuartzSupportTests { } @Test - void schedulerRepositoryExposure() throws Exception { + void schedulerRepositoryExposure() { try (ClassPathXmlApplicationContext ctx = context("schedulerRepositoryExposure.xml")) { assertThat(ctx.getBean("scheduler")).isSameAs(SchedulerRepository.getInstance().lookup("myScheduler")); } @@ -387,7 +384,7 @@ class QuartzSupportTests { * TODO: Against Quartz 2.2, this test's job doesn't actually execute anymore... */ @Test - void schedulerWithHsqlDataSource() throws Exception { + void schedulerWithHsqlDataSource() { DummyJob.param = 0; DummyJob.count = 0; @@ -403,7 +400,6 @@ class QuartzSupportTests { } @Test - @SuppressWarnings("resource") void schedulerFactoryBeanWithCustomJobStore() throws Exception { StaticApplicationContext context = new StaticApplicationContext(); @@ -459,7 +455,7 @@ class QuartzSupportTests { } @Override - public synchronized void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException { + public synchronized void execute(JobExecutionContext jobExecutionContext) { count++; } } @@ -480,7 +476,7 @@ class QuartzSupportTests { } @Override - protected synchronized void executeInternal(JobExecutionContext jobExecutionContext) throws JobExecutionException { + protected synchronized void executeInternal(JobExecutionContext jobExecutionContext) { count++; } } diff --git a/spring-context-support/src/test/java/org/springframework/scheduling/quartz/SchedulerFactoryBeanRuntimeHintsTests.java b/spring-context-support/src/test/java/org/springframework/scheduling/quartz/SchedulerFactoryBeanRuntimeHintsTests.java index 7e422ed9b33..0f3fd26dd96 100644 --- a/spring-context-support/src/test/java/org/springframework/scheduling/quartz/SchedulerFactoryBeanRuntimeHintsTests.java +++ b/spring-context-support/src/test/java/org/springframework/scheduling/quartz/SchedulerFactoryBeanRuntimeHintsTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 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 static org.assertj.core.api.Assertions.assertThat; * * @author Sebastien Deleuze */ -public class SchedulerFactoryBeanRuntimeHintsTests { +class SchedulerFactoryBeanRuntimeHintsTests { private final RuntimeHints hints = new RuntimeHints(); diff --git a/spring-context-support/src/test/java/org/springframework/ui/freemarker/FreeMarkerConfigurationFactoryBeanTests.java b/spring-context-support/src/test/java/org/springframework/ui/freemarker/FreeMarkerConfigurationFactoryBeanTests.java index c0a07e448a0..0ab2045390f 100644 --- a/spring-context-support/src/test/java/org/springframework/ui/freemarker/FreeMarkerConfigurationFactoryBeanTests.java +++ b/spring-context-support/src/test/java/org/springframework/ui/freemarker/FreeMarkerConfigurationFactoryBeanTests.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. @@ -39,12 +39,12 @@ import static org.assertj.core.api.Assertions.assertThatIOException; * @author Issam El-atif * @author Sam Brannen */ -public class FreeMarkerConfigurationFactoryBeanTests { +class FreeMarkerConfigurationFactoryBeanTests { private final FreeMarkerConfigurationFactoryBean fcfb = new FreeMarkerConfigurationFactoryBean(); @Test - public void freeMarkerConfigurationFactoryBeanWithConfigLocation() throws Exception { + void freeMarkerConfigurationFactoryBeanWithConfigLocation() { fcfb.setConfigLocation(new FileSystemResource("myprops.properties")); Properties props = new Properties(); props.setProperty("myprop", "/mydir"); @@ -53,7 +53,7 @@ public class FreeMarkerConfigurationFactoryBeanTests { } @Test - public void freeMarkerConfigurationFactoryBeanWithResourceLoaderPath() throws Exception { + void freeMarkerConfigurationFactoryBeanWithResourceLoaderPath() throws Exception { fcfb.setTemplateLoaderPath("file:/mydir"); fcfb.afterPropertiesSet(); Configuration cfg = fcfb.getObject();