This commit is contained in:
Stéphane Nicoll 2024-01-04 14:44:59 +01:00
parent 2784f6008e
commit 4f599b7396
29 changed files with 172 additions and 177 deletions

View File

@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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"); CaffeineCacheManager cm = new CaffeineCacheManager("c1");
Cache cache1 = cm.getCache("c1"); Cache cache1 = cm.getCache("c1");
@SuppressWarnings("unchecked")
CacheLoader<Object, Object> loader = mock(); CacheLoader<Object, Object> loader = mock();
cm.setCacheLoader(loader); cm.setCacheLoader(loader);

View File

@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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 * @author Juergen Hoeller
* @since 6.1 * @since 6.1
*/ */
public class CaffeineReactiveCachingTests { class CaffeineReactiveCachingTests {
@ParameterizedTest @ParameterizedTest
@ValueSource(classes = {AsyncCacheModeConfig.class, AsyncCacheModeConfig.class}) @ValueSource(classes = {AsyncCacheModeConfig.class, AsyncCacheModeConfig.class})

View File

@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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 * @author Stephane Nicoll
*/ */
public class JCacheCacheManagerTests extends AbstractTransactionSupportingCacheManagerTests<JCacheCacheManager> { class JCacheCacheManagerTests extends AbstractTransactionSupportingCacheManagerTests<JCacheCacheManager> {
private CacheManagerMock cacheManagerMock; private CacheManagerMock cacheManagerMock;
@ -42,7 +42,7 @@ public class JCacheCacheManagerTests extends AbstractTransactionSupportingCacheM
@BeforeEach @BeforeEach
public void setupOnce() { void setupOnce() {
cacheManagerMock = new CacheManagerMock(); cacheManagerMock = new CacheManagerMock();
cacheManagerMock.addCache(CACHE_NAME); cacheManagerMock.addCache(CACHE_NAME);

View File

@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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 Stephane Nicoll
* @author Juergen Hoeller * @author Juergen Hoeller
*/ */
public class JCacheEhCacheAnnotationTests extends AbstractCacheAnnotationTests { class JCacheEhCacheAnnotationTests extends AbstractCacheAnnotationTests {
private final TransactionTemplate txTemplate = new TransactionTemplate(new CallCountingTransactionManager()); private final TransactionTemplate txTemplate = new TransactionTemplate(new CallCountingTransactionManager());
@ -68,7 +68,7 @@ public class JCacheEhCacheAnnotationTests extends AbstractCacheAnnotationTests {
} }
@AfterEach @AfterEach
public void shutdown() { void shutdown() {
if (jCacheManager != null) { if (jCacheManager != null) {
jCacheManager.close(); jCacheManager.close();
} }
@ -82,22 +82,22 @@ public class JCacheEhCacheAnnotationTests extends AbstractCacheAnnotationTests {
} }
@Test @Test
public void testEvictWithTransaction() { void testEvictWithTransaction() {
txTemplate.executeWithoutResult(s -> testEvict(this.cs, false)); txTemplate.executeWithoutResult(s -> testEvict(this.cs, false));
} }
@Test @Test
public void testEvictEarlyWithTransaction() { void testEvictEarlyWithTransaction() {
txTemplate.executeWithoutResult(s -> testEvictEarly(this.cs)); txTemplate.executeWithoutResult(s -> testEvictEarly(this.cs));
} }
@Test @Test
public void testEvictAllWithTransaction() { void testEvictAllWithTransaction() {
txTemplate.executeWithoutResult(s -> testEvictAll(this.cs, false)); txTemplate.executeWithoutResult(s -> testEvictAll(this.cs, false));
} }
@Test @Test
public void testEvictAllEarlyWithTransaction() { void testEvictAllEarlyWithTransaction() {
txTemplate.executeWithoutResult(s -> testEvictAllEarly(this.cs)); txTemplate.executeWithoutResult(s -> testEvictAllEarly(this.cs));
} }

View File

@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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 * @author Stephane Nicoll
*/ */
public class JCacheEhCacheApiTests extends AbstractValueAdaptingCacheTests<JCacheCache> { class JCacheEhCacheApiTests extends AbstractValueAdaptingCacheTests<JCacheCache> {
private CacheManager cacheManager; private CacheManager cacheManager;
@ -45,7 +45,7 @@ public class JCacheEhCacheApiTests extends AbstractValueAdaptingCacheTests<JCach
@BeforeEach @BeforeEach
public void setup() { void setup() {
this.cacheManager = getCachingProvider().getCacheManager(); this.cacheManager = getCachingProvider().getCacheManager();
this.cacheManager.createCache(CACHE_NAME, new MutableConfiguration<>()); this.cacheManager.createCache(CACHE_NAME, new MutableConfiguration<>());
this.cacheManager.createCache(CACHE_NAME_NO_NULL, new MutableConfiguration<>()); this.cacheManager.createCache(CACHE_NAME_NO_NULL, new MutableConfiguration<>());
@ -61,7 +61,7 @@ public class JCacheEhCacheApiTests extends AbstractValueAdaptingCacheTests<JCach
} }
@AfterEach @AfterEach
public void shutdown() { void shutdown() {
if (this.cacheManager != null) { if (this.cacheManager != null) {
this.cacheManager.close(); this.cacheManager.close();
} }

View File

@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -45,7 +45,7 @@ import static org.assertj.core.api.Assertions.assertThatRuntimeException;
/** /**
* @author Stephane Nicoll * @author Stephane Nicoll
*/ */
public class JCacheCustomInterceptorTests { class JCacheCustomInterceptorTests {
protected ConfigurableApplicationContext ctx; protected ConfigurableApplicationContext ctx;
@ -55,14 +55,14 @@ public class JCacheCustomInterceptorTests {
@BeforeEach @BeforeEach
public void setup() { void setup() {
ctx = new AnnotationConfigApplicationContext(EnableCachingConfig.class); ctx = new AnnotationConfigApplicationContext(EnableCachingConfig.class);
cs = ctx.getBean("service", JCacheableService.class); cs = ctx.getBean("service", JCacheableService.class);
exceptionCache = ctx.getBean("exceptionCache", Cache.class); exceptionCache = ctx.getBean("exceptionCache", Cache.class);
} }
@AfterEach @AfterEach
public void tearDown() { void tearDown() {
if (ctx != null) { if (ctx != null) {
ctx.close(); ctx.close();
} }
@ -70,7 +70,7 @@ public class JCacheCustomInterceptorTests {
@Test @Test
public void onlyOneInterceptorIsAvailable() { void onlyOneInterceptorIsAvailable() {
Map<String, JCacheInterceptor> interceptors = ctx.getBeansOfType(JCacheInterceptor.class); Map<String, JCacheInterceptor> interceptors = ctx.getBeansOfType(JCacheInterceptor.class);
assertThat(interceptors).as("Only one interceptor should be defined").hasSize(1); assertThat(interceptors).as("Only one interceptor should be defined").hasSize(1);
JCacheInterceptor interceptor = interceptors.values().iterator().next(); JCacheInterceptor interceptor = interceptors.values().iterator().next();
@ -78,14 +78,14 @@ public class JCacheCustomInterceptorTests {
} }
@Test @Test
public void customInterceptorAppliesWithRuntimeException() { void customInterceptorAppliesWithRuntimeException() {
Object o = cs.cacheWithException("id", true); Object o = cs.cacheWithException("id", true);
// See TestCacheInterceptor // See TestCacheInterceptor
assertThat(o).isEqualTo(55L); assertThat(o).isEqualTo(55L);
} }
@Test @Test
public void customInterceptorAppliesWithCheckedException() { void customInterceptorAppliesWithCheckedException() {
assertThatRuntimeException() assertThatRuntimeException()
.isThrownBy(() -> cs.cacheWithCheckedException("id", true)) .isThrownBy(() -> cs.cacheWithCheckedException("id", true))
.withCauseExactlyInstanceOf(IOException.class); .withCauseExactlyInstanceOf(IOException.class);

View File

@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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 * @author Stephane Nicoll
*/ */
public class JCacheJavaConfigTests extends AbstractJCacheAnnotationTests { class JCacheJavaConfigTests extends AbstractJCacheAnnotationTests {
@Override @Override
protected ApplicationContext getApplicationContext() { protected ApplicationContext getApplicationContext() {
@ -61,7 +61,7 @@ public class JCacheJavaConfigTests extends AbstractJCacheAnnotationTests {
@Test @Test
public void fullCachingConfig() throws Exception { void fullCachingConfig() {
AnnotationConfigApplicationContext context = AnnotationConfigApplicationContext context =
new AnnotationConfigApplicationContext(FullCachingConfig.class); new AnnotationConfigApplicationContext(FullCachingConfig.class);
@ -75,7 +75,7 @@ public class JCacheJavaConfigTests extends AbstractJCacheAnnotationTests {
} }
@Test @Test
public void emptyConfigSupport() { void emptyConfigSupport() {
ConfigurableApplicationContext context = ConfigurableApplicationContext context =
new AnnotationConfigApplicationContext(EmptyConfigSupportConfig.class); new AnnotationConfigApplicationContext(EmptyConfigSupportConfig.class);
@ -88,7 +88,7 @@ public class JCacheJavaConfigTests extends AbstractJCacheAnnotationTests {
} }
@Test @Test
public void bothSetOnlyResolverIsUsed() { void bothSetOnlyResolverIsUsed() {
ConfigurableApplicationContext context = ConfigurableApplicationContext context =
new AnnotationConfigApplicationContext(FullCachingConfigSupport.class); new AnnotationConfigApplicationContext(FullCachingConfigSupport.class);
@ -100,7 +100,7 @@ public class JCacheJavaConfigTests extends AbstractJCacheAnnotationTests {
} }
@Test @Test
public void exceptionCacheResolverLazilyRequired() { void exceptionCacheResolverLazilyRequired() {
try (ConfigurableApplicationContext context = new AnnotationConfigApplicationContext(NoExceptionCacheResolverConfig.class)) { try (ConfigurableApplicationContext context = new AnnotationConfigApplicationContext(NoExceptionCacheResolverConfig.class)) {
DefaultJCacheOperationSource cos = context.getBean(DefaultJCacheOperationSource.class); DefaultJCacheOperationSource cos = context.getBean(DefaultJCacheOperationSource.class);
assertThat(cos.getCacheResolver()).isSameAs(context.getBean("cacheResolver")); assertThat(cos.getCacheResolver()).isSameAs(context.getBean("cacheResolver"));

View File

@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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 * @author Stephane Nicoll
*/ */
public class JCacheNamespaceDrivenTests extends AbstractJCacheAnnotationTests { class JCacheNamespaceDrivenTests extends AbstractJCacheAnnotationTests {
@Override @Override
protected ApplicationContext getApplicationContext() { protected ApplicationContext getApplicationContext() {
@ -40,7 +40,7 @@ public class JCacheNamespaceDrivenTests extends AbstractJCacheAnnotationTests {
} }
@Test @Test
public void cacheResolver() { void cacheResolver() {
ConfigurableApplicationContext context = new GenericXmlApplicationContext( ConfigurableApplicationContext context = new GenericXmlApplicationContext(
"/org/springframework/cache/jcache/config/jCacheNamespaceDriven-resolver.xml"); "/org/springframework/cache/jcache/config/jCacheNamespaceDriven-resolver.xml");
@ -50,7 +50,7 @@ public class JCacheNamespaceDrivenTests extends AbstractJCacheAnnotationTests {
} }
@Test @Test
public void testCacheErrorHandler() { void testCacheErrorHandler() {
JCacheInterceptor ci = ctx.getBean(JCacheInterceptor.class); JCacheInterceptor ci = ctx.getBean(JCacheInterceptor.class);
assertThat(ci.getErrorHandler()).isSameAs(ctx.getBean("errorHandler", CacheErrorHandler.class)); assertThat(ci.getErrorHandler()).isSameAs(ctx.getBean("errorHandler", CacheErrorHandler.class));
} }

View File

@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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 * @author Stephane Nicoll
*/ */
public class JCacheStandaloneConfigTests extends AbstractJCacheAnnotationTests { class JCacheStandaloneConfigTests extends AbstractJCacheAnnotationTests {
@Override @Override
protected ApplicationContext getApplicationContext() { protected ApplicationContext getApplicationContext() {

View File

@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -42,7 +42,7 @@ public abstract class AbstractCacheOperationTests<O extends JCacheOperation<?>>
@Test @Test
public void simple() { void simple() {
O operation = createSimpleOperation(); O operation = createSimpleOperation();
assertThat(operation.getCacheName()).as("Wrong cache name").isEqualTo("simpleCache"); assertThat(operation.getCacheName()).as("Wrong cache name").isEqualTo("simpleCache");
assertThat(operation.getAnnotations()).as("Unexpected number of annotation on " + operation.getMethod()) assertThat(operation.getAnnotations()).as("Unexpected number of annotation on " + operation.getMethod())

View File

@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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 * @author Stephane Nicoll
*/ */
public class AnnotationCacheOperationSourceTests extends AbstractJCacheTests { class AnnotationCacheOperationSourceTests extends AbstractJCacheTests {
private final DefaultJCacheOperationSource source = new DefaultJCacheOperationSource(); private final DefaultJCacheOperationSource source = new DefaultJCacheOperationSource();
@ -54,7 +54,7 @@ public class AnnotationCacheOperationSourceTests extends AbstractJCacheTests {
@BeforeEach @BeforeEach
public void setup() { void setup() {
source.setCacheResolver(defaultCacheResolver); source.setCacheResolver(defaultCacheResolver);
source.setExceptionCacheResolver(defaultExceptionCacheResolver); source.setExceptionCacheResolver(defaultExceptionCacheResolver);
source.setKeyGenerator(defaultKeyGenerator); source.setKeyGenerator(defaultKeyGenerator);
@ -63,14 +63,14 @@ public class AnnotationCacheOperationSourceTests extends AbstractJCacheTests {
@Test @Test
public void cache() { void cache() {
CacheResultOperation op = getDefaultCacheOperation(CacheResultOperation.class, String.class); CacheResultOperation op = getDefaultCacheOperation(CacheResultOperation.class, String.class);
assertDefaults(op); assertDefaults(op);
assertThat(op.getExceptionCacheResolver()).as("Exception caching not enabled so resolver should not be set").isNull(); assertThat(op.getExceptionCacheResolver()).as("Exception caching not enabled so resolver should not be set").isNull();
} }
@Test @Test
public void cacheWithException() { void cacheWithException() {
CacheResultOperation op = getDefaultCacheOperation(CacheResultOperation.class, String.class, boolean.class); CacheResultOperation op = getDefaultCacheOperation(CacheResultOperation.class, String.class, boolean.class);
assertDefaults(op); assertDefaults(op);
assertThat(op.getExceptionCacheResolver()).isEqualTo(defaultExceptionCacheResolver); assertThat(op.getExceptionCacheResolver()).isEqualTo(defaultExceptionCacheResolver);
@ -78,41 +78,41 @@ public class AnnotationCacheOperationSourceTests extends AbstractJCacheTests {
} }
@Test @Test
public void put() { void put() {
CachePutOperation op = getDefaultCacheOperation(CachePutOperation.class, String.class, Object.class); CachePutOperation op = getDefaultCacheOperation(CachePutOperation.class, String.class, Object.class);
assertDefaults(op); assertDefaults(op);
} }
@Test @Test
public void remove() { void remove() {
CacheRemoveOperation op = getDefaultCacheOperation(CacheRemoveOperation.class, String.class); CacheRemoveOperation op = getDefaultCacheOperation(CacheRemoveOperation.class, String.class);
assertDefaults(op); assertDefaults(op);
} }
@Test @Test
public void removeAll() { void removeAll() {
CacheRemoveAllOperation op = getDefaultCacheOperation(CacheRemoveAllOperation.class); CacheRemoveAllOperation op = getDefaultCacheOperation(CacheRemoveAllOperation.class);
assertThat(op.getCacheResolver()).isEqualTo(defaultCacheResolver); assertThat(op.getCacheResolver()).isEqualTo(defaultCacheResolver);
} }
@Test @Test
public void noAnnotation() { void noAnnotation() {
assertThat(getCacheOperation(AnnotatedJCacheableService.class, this.cacheName)).isNull(); assertThat(getCacheOperation(AnnotatedJCacheableService.class, this.cacheName)).isNull();
} }
@Test @Test
public void multiAnnotations() { void multiAnnotations() {
assertThatIllegalStateException().isThrownBy(() -> getCacheOperation(InvalidCases.class, this.cacheName)); assertThatIllegalStateException().isThrownBy(() -> getCacheOperation(InvalidCases.class, this.cacheName));
} }
@Test @Test
public void defaultCacheNameWithCandidate() { void defaultCacheNameWithCandidate() {
Method method = ReflectionUtils.findMethod(Object.class, "toString"); Method method = ReflectionUtils.findMethod(Object.class, "toString");
assertThat(source.determineCacheName(method, null, "foo")).isEqualTo("foo"); assertThat(source.determineCacheName(method, null, "foo")).isEqualTo("foo");
} }
@Test @Test
public void defaultCacheNameWithDefaults() { void defaultCacheNameWithDefaults() {
Method method = ReflectionUtils.findMethod(Object.class, "toString"); Method method = ReflectionUtils.findMethod(Object.class, "toString");
CacheDefaults mock = mock(); CacheDefaults mock = mock();
given(mock.cacheName()).willReturn(""); given(mock.cacheName()).willReturn("");
@ -120,19 +120,19 @@ public class AnnotationCacheOperationSourceTests extends AbstractJCacheTests {
} }
@Test @Test
public void defaultCacheNameNoDefaults() { void defaultCacheNameNoDefaults() {
Method method = ReflectionUtils.findMethod(Object.class, "toString"); Method method = ReflectionUtils.findMethod(Object.class, "toString");
assertThat(source.determineCacheName(method, null, "")).isEqualTo("java.lang.Object.toString()"); assertThat(source.determineCacheName(method, null, "")).isEqualTo("java.lang.Object.toString()");
} }
@Test @Test
public void defaultCacheNameWithParameters() { void defaultCacheNameWithParameters() {
Method method = ReflectionUtils.findMethod(Comparator.class, "compare", Object.class, Object.class); 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)"); assertThat(source.determineCacheName(method, null, "")).isEqualTo("java.util.Comparator.compare(java.lang.Object,java.lang.Object)");
} }
@Test @Test
public void customCacheResolver() { void customCacheResolver() {
CacheResultOperation operation = CacheResultOperation operation =
getCacheOperation(CacheResultOperation.class, CustomService.class, this.cacheName, Long.class); getCacheOperation(CacheResultOperation.class, CustomService.class, this.cacheName, Long.class);
assertJCacheResolver(operation.getCacheResolver(), TestableCacheResolver.class); assertJCacheResolver(operation.getCacheResolver(), TestableCacheResolver.class);
@ -142,7 +142,7 @@ public class AnnotationCacheOperationSourceTests extends AbstractJCacheTests {
} }
@Test @Test
public void customKeyGenerator() { void customKeyGenerator() {
CacheResultOperation operation = CacheResultOperation operation =
getCacheOperation(CacheResultOperation.class, CustomService.class, this.cacheName, Long.class); getCacheOperation(CacheResultOperation.class, CustomService.class, this.cacheName, Long.class);
assertThat(operation.getCacheResolver()).isEqualTo(defaultCacheResolver); assertThat(operation.getCacheResolver()).isEqualTo(defaultCacheResolver);
@ -151,7 +151,7 @@ public class AnnotationCacheOperationSourceTests extends AbstractJCacheTests {
} }
@Test @Test
public void customKeyGeneratorSpringBean() { void customKeyGeneratorSpringBean() {
TestableCacheKeyGenerator bean = new TestableCacheKeyGenerator(); TestableCacheKeyGenerator bean = new TestableCacheKeyGenerator();
beanFactory.registerSingleton("fooBar", bean); beanFactory.registerSingleton("fooBar", bean);
CacheResultOperation operation = CacheResultOperation operation =
@ -164,7 +164,7 @@ public class AnnotationCacheOperationSourceTests extends AbstractJCacheTests {
} }
@Test @Test
public void customKeyGeneratorAndCacheResolver() { void customKeyGeneratorAndCacheResolver() {
CacheResultOperation operation = getCacheOperation(CacheResultOperation.class, CacheResultOperation operation = getCacheOperation(CacheResultOperation.class,
CustomServiceWithDefaults.class, this.cacheName, Long.class); CustomServiceWithDefaults.class, this.cacheName, Long.class);
assertJCacheResolver(operation.getCacheResolver(), TestableCacheResolver.class); assertJCacheResolver(operation.getCacheResolver(), TestableCacheResolver.class);
@ -173,7 +173,7 @@ public class AnnotationCacheOperationSourceTests extends AbstractJCacheTests {
} }
@Test @Test
public void customKeyGeneratorAndCacheResolverWithExceptionName() { void customKeyGeneratorAndCacheResolverWithExceptionName() {
CacheResultOperation operation = getCacheOperation(CacheResultOperation.class, CacheResultOperation operation = getCacheOperation(CacheResultOperation.class,
CustomServiceWithDefaults.class, this.cacheName, Long.class); CustomServiceWithDefaults.class, this.cacheName, Long.class);
assertJCacheResolver(operation.getCacheResolver(), TestableCacheResolver.class); assertJCacheResolver(operation.getCacheResolver(), TestableCacheResolver.class);

View File

@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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 * @author Stephane Nicoll
*/ */
public class CachePutOperationTests extends AbstractCacheOperationTests<CachePutOperation> { class CachePutOperationTests extends AbstractCacheOperationTests<CachePutOperation> {
@Override @Override
protected CachePutOperation createSimpleOperation() { protected CachePutOperation createSimpleOperation() {
@ -41,7 +41,7 @@ public class CachePutOperationTests extends AbstractCacheOperationTests<CachePut
} }
@Test @Test
public void simplePut() { void simplePut() {
CachePutOperation operation = createSimpleOperation(); CachePutOperation operation = createSimpleOperation();
CacheInvocationParameter[] allParameters = operation.getAllParameters(2L, sampleInstance); CacheInvocationParameter[] allParameters = operation.getAllParameters(2L, sampleInstance);
@ -55,7 +55,7 @@ public class CachePutOperationTests extends AbstractCacheOperationTests<CachePut
} }
@Test @Test
public void noCacheValue() { void noCacheValue() {
CacheMethodDetails<CachePut> methodDetails = create(CachePut.class, CacheMethodDetails<CachePut> methodDetails = create(CachePut.class,
SampleObject.class, "noCacheValue", Long.class); SampleObject.class, "noCacheValue", Long.class);
@ -64,7 +64,7 @@ public class CachePutOperationTests extends AbstractCacheOperationTests<CachePut
} }
@Test @Test
public void multiCacheValues() { void multiCacheValues() {
CacheMethodDetails<CachePut> methodDetails = create(CachePut.class, CacheMethodDetails<CachePut> methodDetails = create(CachePut.class,
SampleObject.class, "multiCacheValues", Long.class, SampleObject.class, SampleObject.class); SampleObject.class, "multiCacheValues", Long.class, SampleObject.class, SampleObject.class);
@ -73,7 +73,7 @@ public class CachePutOperationTests extends AbstractCacheOperationTests<CachePut
} }
@Test @Test
public void invokeWithWrongParameters() { void invokeWithWrongParameters() {
CachePutOperation operation = createSimpleOperation(); CachePutOperation operation = createSimpleOperation();
assertThatIllegalStateException().isThrownBy(() -> assertThatIllegalStateException().isThrownBy(() ->
@ -81,7 +81,7 @@ public class CachePutOperationTests extends AbstractCacheOperationTests<CachePut
} }
@Test @Test
public void fullPutConfig() { void fullPutConfig() {
CacheMethodDetails<CachePut> methodDetails = create(CachePut.class, CacheMethodDetails<CachePut> methodDetails = create(CachePut.class,
SampleObject.class, "fullPutConfig", Long.class, SampleObject.class); SampleObject.class, "fullPutConfig", Long.class, SampleObject.class);
CachePutOperation operation = createDefaultOperation(methodDetails); CachePutOperation operation = createDefaultOperation(methodDetails);

View File

@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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 * @author Stephane Nicoll
*/ */
public class CacheRemoveAllOperationTests extends AbstractCacheOperationTests<CacheRemoveAllOperation> { class CacheRemoveAllOperationTests extends AbstractCacheOperationTests<CacheRemoveAllOperation> {
@Override @Override
protected CacheRemoveAllOperation createSimpleOperation() { protected CacheRemoveAllOperation createSimpleOperation() {
@ -38,7 +38,7 @@ public class CacheRemoveAllOperationTests extends AbstractCacheOperationTests<Ca
} }
@Test @Test
public void simpleRemoveAll() { void simpleRemoveAll() {
CacheRemoveAllOperation operation = createSimpleOperation(); CacheRemoveAllOperation operation = createSimpleOperation();
CacheInvocationParameter[] allParameters = operation.getAllParameters(); CacheInvocationParameter[] allParameters = operation.getAllParameters();

View File

@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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 * @author Stephane Nicoll
*/ */
public class CacheRemoveOperationTests extends AbstractCacheOperationTests<CacheRemoveOperation> { class CacheRemoveOperationTests extends AbstractCacheOperationTests<CacheRemoveOperation> {
@Override @Override
protected CacheRemoveOperation createSimpleOperation() { protected CacheRemoveOperation createSimpleOperation() {
@ -38,7 +38,7 @@ public class CacheRemoveOperationTests extends AbstractCacheOperationTests<Cache
} }
@Test @Test
public void simpleRemove() { void simpleRemove() {
CacheRemoveOperation operation = createSimpleOperation(); CacheRemoveOperation operation = createSimpleOperation();
CacheInvocationParameter[] allParameters = operation.getAllParameters(2L); CacheInvocationParameter[] allParameters = operation.getAllParameters(2L);

View File

@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -38,10 +38,10 @@ import static org.mockito.Mockito.mock;
/** /**
* @author Stephane Nicoll * @author Stephane Nicoll
*/ */
public class CacheResolverAdapterTests extends AbstractJCacheTests { class CacheResolverAdapterTests extends AbstractJCacheTests {
@Test @Test
public void resolveSimpleCache() throws Exception { void resolveSimpleCache() throws Exception {
DefaultCacheInvocationContext<?> dummyContext = createDummyContext(); DefaultCacheInvocationContext<?> dummyContext = createDummyContext();
CacheResolverAdapter adapter = new CacheResolverAdapter(getCacheResolver(dummyContext, "testCache")); CacheResolverAdapter adapter = new CacheResolverAdapter(getCacheResolver(dummyContext, "testCache"));
Collection<? extends Cache> caches = adapter.resolveCaches(dummyContext); Collection<? extends Cache> caches = adapter.resolveCaches(dummyContext);
@ -51,7 +51,7 @@ public class CacheResolverAdapterTests extends AbstractJCacheTests {
} }
@Test @Test
public void resolveUnknownCache() throws Exception { void resolveUnknownCache() throws Exception {
DefaultCacheInvocationContext<?> dummyContext = createDummyContext(); DefaultCacheInvocationContext<?> dummyContext = createDummyContext();
CacheResolverAdapter adapter = new CacheResolverAdapter(getCacheResolver(dummyContext, null)); CacheResolverAdapter adapter = new CacheResolverAdapter(getCacheResolver(dummyContext, null));

View File

@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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 * @author Stephane Nicoll
*/ */
public class CacheResultOperationTests extends AbstractCacheOperationTests<CacheResultOperation> { class CacheResultOperationTests extends AbstractCacheOperationTests<CacheResultOperation> {
@Override @Override
protected CacheResultOperation createSimpleOperation() { protected CacheResultOperation createSimpleOperation() {
@ -47,7 +47,7 @@ public class CacheResultOperationTests extends AbstractCacheOperationTests<Cache
} }
@Test @Test
public void simpleGet() { void simpleGet() {
CacheResultOperation operation = createSimpleOperation(); CacheResultOperation operation = createSimpleOperation();
assertThat(operation.getKeyGenerator()).isNotNull(); assertThat(operation.getKeyGenerator()).isNotNull();
@ -66,7 +66,7 @@ public class CacheResultOperationTests extends AbstractCacheOperationTests<Cache
} }
@Test @Test
public void multiParameterKey() { void multiParameterKey() {
CacheMethodDetails<CacheResult> methodDetails = create(CacheResult.class, CacheMethodDetails<CacheResult> methodDetails = create(CacheResult.class,
SampleObject.class, "multiKeysGet", Long.class, Boolean.class, String.class); SampleObject.class, "multiKeysGet", Long.class, Boolean.class, String.class);
CacheResultOperation operation = createDefaultOperation(methodDetails); CacheResultOperation operation = createDefaultOperation(methodDetails);
@ -78,7 +78,7 @@ public class CacheResultOperationTests extends AbstractCacheOperationTests<Cache
} }
@Test @Test
public void invokeWithWrongParameters() { void invokeWithWrongParameters() {
CacheMethodDetails<CacheResult> methodDetails = create(CacheResult.class, CacheMethodDetails<CacheResult> methodDetails = create(CacheResult.class,
SampleObject.class, "anotherSimpleGet", String.class, Long.class); SampleObject.class, "anotherSimpleGet", String.class, Long.class);
CacheResultOperation operation = createDefaultOperation(methodDetails); CacheResultOperation operation = createDefaultOperation(methodDetails);
@ -89,7 +89,7 @@ public class CacheResultOperationTests extends AbstractCacheOperationTests<Cache
} }
@Test @Test
public void tooManyKeyValues() { void tooManyKeyValues() {
CacheMethodDetails<CacheResult> methodDetails = create(CacheResult.class, CacheMethodDetails<CacheResult> methodDetails = create(CacheResult.class,
SampleObject.class, "anotherSimpleGet", String.class, Long.class); SampleObject.class, "anotherSimpleGet", String.class, Long.class);
CacheResultOperation operation = createDefaultOperation(methodDetails); CacheResultOperation operation = createDefaultOperation(methodDetails);
@ -100,7 +100,7 @@ public class CacheResultOperationTests extends AbstractCacheOperationTests<Cache
} }
@Test @Test
public void annotatedGet() { void annotatedGet() {
CacheMethodDetails<CacheResult> methodDetails = create(CacheResult.class, CacheMethodDetails<CacheResult> methodDetails = create(CacheResult.class,
SampleObject.class, "annotatedGet", Long.class, String.class); SampleObject.class, "annotatedGet", Long.class, String.class);
CacheResultOperation operation = createDefaultOperation(methodDetails); CacheResultOperation operation = createDefaultOperation(methodDetails);
@ -116,7 +116,7 @@ public class CacheResultOperationTests extends AbstractCacheOperationTests<Cache
} }
@Test @Test
public void fullGetConfig() { void fullGetConfig() {
CacheMethodDetails<CacheResult> methodDetails = create(CacheResult.class, CacheMethodDetails<CacheResult> methodDetails = create(CacheResult.class,
SampleObject.class, "fullGetConfig", Long.class); SampleObject.class, "fullGetConfig", Long.class);
CacheResultOperation operation = createDefaultOperation(methodDetails); CacheResultOperation operation = createDefaultOperation(methodDetails);

View File

@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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 * @author Stephane Nicoll
*/ */
public class JCacheErrorHandlerTests { class JCacheErrorHandlerTests {
private Cache cache; private Cache cache;
@ -61,7 +61,7 @@ public class JCacheErrorHandlerTests {
@BeforeEach @BeforeEach
public void setup() { void setup() {
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(Config.class); AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(Config.class);
this.cache = context.getBean("mockCache", Cache.class); this.cache = context.getBean("mockCache", Cache.class);
this.errorCache = context.getBean("mockErrorCache", Cache.class); this.errorCache = context.getBean("mockErrorCache", Cache.class);
@ -72,7 +72,7 @@ public class JCacheErrorHandlerTests {
@Test @Test
public void getFail() { void getFail() {
UnsupportedOperationException exception = new UnsupportedOperationException("Test exception on get"); UnsupportedOperationException exception = new UnsupportedOperationException("Test exception on get");
Object key = SimpleKeyGenerator.generateKey(0L); Object key = SimpleKeyGenerator.generateKey(0L);
willThrow(exception).given(this.cache).get(key); willThrow(exception).given(this.cache).get(key);
@ -82,7 +82,7 @@ public class JCacheErrorHandlerTests {
} }
@Test @Test
public void getPutNewElementFail() { void getPutNewElementFail() {
UnsupportedOperationException exception = new UnsupportedOperationException("Test exception on put"); UnsupportedOperationException exception = new UnsupportedOperationException("Test exception on put");
Object key = SimpleKeyGenerator.generateKey(0L); Object key = SimpleKeyGenerator.generateKey(0L);
given(this.cache.get(key)).willReturn(null); given(this.cache.get(key)).willReturn(null);
@ -93,7 +93,7 @@ public class JCacheErrorHandlerTests {
} }
@Test @Test
public void getFailPutExceptionFail() { void getFailPutExceptionFail() {
UnsupportedOperationException exceptionOnPut = new UnsupportedOperationException("Test exception on put"); UnsupportedOperationException exceptionOnPut = new UnsupportedOperationException("Test exception on put");
Object key = SimpleKeyGenerator.generateKey(0L); Object key = SimpleKeyGenerator.generateKey(0L);
given(this.cache.get(key)).willReturn(null); given(this.cache.get(key)).willReturn(null);
@ -110,7 +110,7 @@ public class JCacheErrorHandlerTests {
} }
@Test @Test
public void putFail() { void putFail() {
UnsupportedOperationException exception = new UnsupportedOperationException("Test exception on put"); UnsupportedOperationException exception = new UnsupportedOperationException("Test exception on put");
Object key = SimpleKeyGenerator.generateKey(0L); Object key = SimpleKeyGenerator.generateKey(0L);
willThrow(exception).given(this.cache).put(key, 234L); willThrow(exception).given(this.cache).put(key, 234L);
@ -120,7 +120,7 @@ public class JCacheErrorHandlerTests {
} }
@Test @Test
public void evictFail() { void evictFail() {
UnsupportedOperationException exception = new UnsupportedOperationException("Test exception on evict"); UnsupportedOperationException exception = new UnsupportedOperationException("Test exception on evict");
Object key = SimpleKeyGenerator.generateKey(0L); Object key = SimpleKeyGenerator.generateKey(0L);
willThrow(exception).given(this.cache).evict(key); willThrow(exception).given(this.cache).evict(key);
@ -130,7 +130,7 @@ public class JCacheErrorHandlerTests {
} }
@Test @Test
public void clearFail() { void clearFail() {
UnsupportedOperationException exception = new UnsupportedOperationException("Test exception on evict"); UnsupportedOperationException exception = new UnsupportedOperationException("Test exception on evict");
willThrow(exception).given(this.cache).clear(); willThrow(exception).given(this.cache).clear();
@ -183,7 +183,7 @@ public class JCacheErrorHandlerTests {
private static final IllegalStateException TEST_EXCEPTION = new IllegalStateException("Test exception"); private static final IllegalStateException TEST_EXCEPTION = new IllegalStateException("Test exception");
private AtomicLong counter = new AtomicLong(); private final AtomicLong counter = new AtomicLong();
@CacheResult @CacheResult
public Object get(long id) { public Object get(long id) {

View File

@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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 * @author Stephane Nicoll
*/ */
public class JCacheInterceptorTests extends AbstractJCacheTests { class JCacheInterceptorTests extends AbstractJCacheTests {
private final CacheOperationInvoker dummyInvoker = new DummyInvoker(null); private final CacheOperationInvoker dummyInvoker = new DummyInvoker(null);
@Test @Test
public void severalCachesNotSupported() { void severalCachesNotSupported() {
JCacheInterceptor interceptor = createInterceptor(createOperationSource( JCacheInterceptor interceptor = createInterceptor(createOperationSource(
cacheManager, new NamedCacheResolver(cacheManager, "default", "simpleCache"), cacheManager, new NamedCacheResolver(cacheManager, "default", "simpleCache"),
defaultExceptionCacheResolver, defaultKeyGenerator)); defaultExceptionCacheResolver, defaultKeyGenerator));
@ -54,7 +54,7 @@ public class JCacheInterceptorTests extends AbstractJCacheTests {
} }
@Test @Test
public void noCacheCouldBeResolved() { void noCacheCouldBeResolved() {
JCacheInterceptor interceptor = createInterceptor(createOperationSource( JCacheInterceptor interceptor = createInterceptor(createOperationSource(
cacheManager, new NamedCacheResolver(cacheManager), // Returns empty list cacheManager, new NamedCacheResolver(cacheManager), // Returns empty list
defaultExceptionCacheResolver, defaultKeyGenerator)); defaultExceptionCacheResolver, defaultKeyGenerator));
@ -67,18 +67,18 @@ public class JCacheInterceptorTests extends AbstractJCacheTests {
} }
@Test @Test
public void cacheManagerMandatoryIfCacheResolverNotSet() { void cacheManagerMandatoryIfCacheResolverNotSet() {
assertThatIllegalStateException().isThrownBy(() -> assertThatIllegalStateException().isThrownBy(() ->
createOperationSource(null, null, null, defaultKeyGenerator)); createOperationSource(null, null, null, defaultKeyGenerator));
} }
@Test @Test
public void cacheManagerOptionalIfCacheResolversSet() { void cacheManagerOptionalIfCacheResolversSet() {
createOperationSource(null, defaultCacheResolver, defaultExceptionCacheResolver, defaultKeyGenerator); createOperationSource(null, defaultCacheResolver, defaultExceptionCacheResolver, defaultKeyGenerator);
} }
@Test @Test
public void cacheResultReturnsProperType() throws Throwable { void cacheResultReturnsProperType() {
JCacheInterceptor interceptor = createInterceptor(createOperationSource( JCacheInterceptor interceptor = createInterceptor(createOperationSource(
cacheManager, defaultCacheResolver, defaultExceptionCacheResolver, defaultKeyGenerator)); cacheManager, defaultCacheResolver, defaultExceptionCacheResolver, defaultKeyGenerator));

View File

@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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 * @author Stephane Nicoll
*/ */
public class JCacheKeyGeneratorTests { class JCacheKeyGeneratorTests {
private TestKeyGenerator keyGenerator; private TestKeyGenerator keyGenerator;
@ -53,7 +53,7 @@ public class JCacheKeyGeneratorTests {
private Cache cache; private Cache cache;
@BeforeEach @BeforeEach
public void setup() { void setup() {
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(Config.class); AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(Config.class);
this.keyGenerator = context.getBean(TestKeyGenerator.class); this.keyGenerator = context.getBean(TestKeyGenerator.class);
this.simpleService = context.getBean(SimpleService.class); this.simpleService = context.getBean(SimpleService.class);
@ -62,7 +62,7 @@ public class JCacheKeyGeneratorTests {
} }
@Test @Test
public void getSimple() { void getSimple() {
this.keyGenerator.expect(1L); this.keyGenerator.expect(1L);
Object first = this.simpleService.get(1L); Object first = this.simpleService.get(1L);
Object second = this.simpleService.get(1L); Object second = this.simpleService.get(1L);
@ -73,7 +73,7 @@ public class JCacheKeyGeneratorTests {
} }
@Test @Test
public void getFlattenVararg() { void getFlattenVararg() {
this.keyGenerator.expect(1L, "foo", "bar"); this.keyGenerator.expect(1L, "foo", "bar");
Object first = this.simpleService.get(1L, "foo", "bar"); Object first = this.simpleService.get(1L, "foo", "bar");
Object second = this.simpleService.get(1L, "foo", "bar"); Object second = this.simpleService.get(1L, "foo", "bar");
@ -84,7 +84,7 @@ public class JCacheKeyGeneratorTests {
} }
@Test @Test
public void getFiltered() { void getFiltered() {
this.keyGenerator.expect(1L); this.keyGenerator.expect(1L);
Object first = this.simpleService.getFiltered(1L, "foo", "bar"); Object first = this.simpleService.getFiltered(1L, "foo", "bar");
Object second = this.simpleService.getFiltered(1L, "foo", "bar"); Object second = this.simpleService.getFiltered(1L, "foo", "bar");
@ -120,7 +120,7 @@ public class JCacheKeyGeneratorTests {
@CacheDefaults(cacheName = "test") @CacheDefaults(cacheName = "test")
public static class SimpleService { public static class SimpleService {
private AtomicLong counter = new AtomicLong(); private final AtomicLong counter = new AtomicLong();
@CacheResult @CacheResult
public Object get(long id) { public Object get(long id) {

View File

@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -71,12 +71,12 @@ public abstract class AbstractTransactionSupportingCacheManagerTests<T extends C
@Test @Test
public void getOnExistingCache() { void getOnExistingCache() {
assertThat(getCacheManager(false).getCache(CACHE_NAME)).isInstanceOf(getCacheType()); assertThat(getCacheManager(false).getCache(CACHE_NAME)).isInstanceOf(getCacheType());
} }
@Test @Test
public void getOnNewCache() { void getOnNewCache() {
T cacheManager = getCacheManager(false); T cacheManager = getCacheManager(false);
addNativeCache(this.cacheName); addNativeCache(this.cacheName);
assertThat(cacheManager.getCacheNames()).doesNotContain(this.cacheName); assertThat(cacheManager.getCacheNames()).doesNotContain(this.cacheName);
@ -90,20 +90,20 @@ public abstract class AbstractTransactionSupportingCacheManagerTests<T extends C
} }
@Test @Test
public void getOnUnknownCache() { void getOnUnknownCache() {
T cacheManager = getCacheManager(false); T cacheManager = getCacheManager(false);
assertThat(cacheManager.getCacheNames()).doesNotContain(this.cacheName); assertThat(cacheManager.getCacheNames()).doesNotContain(this.cacheName);
assertThat(cacheManager.getCache(this.cacheName)).isNull(); assertThat(cacheManager.getCache(this.cacheName)).isNull();
} }
@Test @Test
public void getTransactionalOnExistingCache() { void getTransactionalOnExistingCache() {
assertThat(getCacheManager(true).getCache(CACHE_NAME)) assertThat(getCacheManager(true).getCache(CACHE_NAME))
.isInstanceOf(TransactionAwareCacheDecorator.class); .isInstanceOf(TransactionAwareCacheDecorator.class);
} }
@Test @Test
public void getTransactionalOnNewCache() { void getTransactionalOnNewCache() {
T cacheManager = getCacheManager(true); T cacheManager = getCacheManager(true);
assertThat(cacheManager.getCacheNames()).doesNotContain(this.cacheName); assertThat(cacheManager.getCacheNames()).doesNotContain(this.cacheName);
addNativeCache(this.cacheName); addNativeCache(this.cacheName);

View File

@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -30,25 +30,25 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
* @author Stephane Nicoll * @author Stephane Nicoll
* @author Juergen Hoeller * @author Juergen Hoeller
*/ */
public class TransactionAwareCacheDecoratorTests { class TransactionAwareCacheDecoratorTests {
private final TransactionTemplate txTemplate = new TransactionTemplate(new CallCountingTransactionManager()); private final TransactionTemplate txTemplate = new TransactionTemplate(new CallCountingTransactionManager());
@Test @Test
public void createWithNullTarget() { void createWithNullTarget() {
assertThatIllegalArgumentException().isThrownBy(() -> new TransactionAwareCacheDecorator(null)); assertThatIllegalArgumentException().isThrownBy(() -> new TransactionAwareCacheDecorator(null));
} }
@Test @Test
public void getTargetCache() { void getTargetCache() {
Cache target = new ConcurrentMapCache("testCache"); Cache target = new ConcurrentMapCache("testCache");
TransactionAwareCacheDecorator cache = new TransactionAwareCacheDecorator(target); TransactionAwareCacheDecorator cache = new TransactionAwareCacheDecorator(target);
assertThat(cache.getTargetCache()).isSameAs(target); assertThat(cache.getTargetCache()).isSameAs(target);
} }
@Test @Test
public void regularOperationsOnTarget() { void regularOperationsOnTarget() {
Cache target = new ConcurrentMapCache("testCache"); Cache target = new ConcurrentMapCache("testCache");
Cache cache = new TransactionAwareCacheDecorator(target); Cache cache = new TransactionAwareCacheDecorator(target);
assertThat(cache.getName()).isEqualTo(target.getName()); assertThat(cache.getName()).isEqualTo(target.getName());
@ -64,7 +64,7 @@ public class TransactionAwareCacheDecoratorTests {
} }
@Test @Test
public void putNonTransactional() { void putNonTransactional() {
Cache target = new ConcurrentMapCache("testCache"); Cache target = new ConcurrentMapCache("testCache");
Cache cache = new TransactionAwareCacheDecorator(target); Cache cache = new TransactionAwareCacheDecorator(target);
@ -74,7 +74,7 @@ public class TransactionAwareCacheDecoratorTests {
} }
@Test @Test
public void putTransactional() { void putTransactional() {
Cache target = new ConcurrentMapCache("testCache"); Cache target = new ConcurrentMapCache("testCache");
Cache cache = new TransactionAwareCacheDecorator(target); Cache cache = new TransactionAwareCacheDecorator(target);
Object key = new Object(); Object key = new Object();
@ -88,7 +88,7 @@ public class TransactionAwareCacheDecoratorTests {
} }
@Test @Test
public void putIfAbsentNonTransactional() { void putIfAbsentNonTransactional() {
Cache target = new ConcurrentMapCache("testCache"); Cache target = new ConcurrentMapCache("testCache");
Cache cache = new TransactionAwareCacheDecorator(target); Cache cache = new TransactionAwareCacheDecorator(target);
@ -101,7 +101,7 @@ public class TransactionAwareCacheDecoratorTests {
} }
@Test @Test
public void putIfAbsentTransactional() { // no transactional support for putIfAbsent void putIfAbsentTransactional() { // no transactional support for putIfAbsent
Cache target = new ConcurrentMapCache("testCache"); Cache target = new ConcurrentMapCache("testCache");
Cache cache = new TransactionAwareCacheDecorator(target); Cache cache = new TransactionAwareCacheDecorator(target);
Object key = new Object(); Object key = new Object();
@ -118,7 +118,7 @@ public class TransactionAwareCacheDecoratorTests {
} }
@Test @Test
public void evictNonTransactional() { void evictNonTransactional() {
Cache target = new ConcurrentMapCache("testCache"); Cache target = new ConcurrentMapCache("testCache");
Cache cache = new TransactionAwareCacheDecorator(target); Cache cache = new TransactionAwareCacheDecorator(target);
Object key = new Object(); Object key = new Object();
@ -129,7 +129,7 @@ public class TransactionAwareCacheDecoratorTests {
} }
@Test @Test
public void evictTransactional() { void evictTransactional() {
Cache target = new ConcurrentMapCache("testCache"); Cache target = new ConcurrentMapCache("testCache");
Cache cache = new TransactionAwareCacheDecorator(target); Cache cache = new TransactionAwareCacheDecorator(target);
Object key = new Object(); Object key = new Object();
@ -144,7 +144,7 @@ public class TransactionAwareCacheDecoratorTests {
} }
@Test @Test
public void evictIfPresentNonTransactional() { void evictIfPresentNonTransactional() {
Cache target = new ConcurrentMapCache("testCache"); Cache target = new ConcurrentMapCache("testCache");
Cache cache = new TransactionAwareCacheDecorator(target); Cache cache = new TransactionAwareCacheDecorator(target);
Object key = new Object(); Object key = new Object();
@ -155,7 +155,7 @@ public class TransactionAwareCacheDecoratorTests {
} }
@Test @Test
public void evictIfPresentTransactional() { // no transactional support for evictIfPresent void evictIfPresentTransactional() { // no transactional support for evictIfPresent
Cache target = new ConcurrentMapCache("testCache"); Cache target = new ConcurrentMapCache("testCache");
Cache cache = new TransactionAwareCacheDecorator(target); Cache cache = new TransactionAwareCacheDecorator(target);
Object key = new Object(); Object key = new Object();
@ -170,7 +170,7 @@ public class TransactionAwareCacheDecoratorTests {
} }
@Test @Test
public void clearNonTransactional() { void clearNonTransactional() {
Cache target = new ConcurrentMapCache("testCache"); Cache target = new ConcurrentMapCache("testCache");
Cache cache = new TransactionAwareCacheDecorator(target); Cache cache = new TransactionAwareCacheDecorator(target);
Object key = new Object(); Object key = new Object();
@ -181,7 +181,7 @@ public class TransactionAwareCacheDecoratorTests {
} }
@Test @Test
public void clearTransactional() { void clearTransactional() {
Cache target = new ConcurrentMapCache("testCache"); Cache target = new ConcurrentMapCache("testCache");
Cache cache = new TransactionAwareCacheDecorator(target); Cache cache = new TransactionAwareCacheDecorator(target);
Object key = new Object(); Object key = new Object();
@ -196,7 +196,7 @@ public class TransactionAwareCacheDecoratorTests {
} }
@Test @Test
public void invalidateNonTransactional() { void invalidateNonTransactional() {
Cache target = new ConcurrentMapCache("testCache"); Cache target = new ConcurrentMapCache("testCache");
Cache cache = new TransactionAwareCacheDecorator(target); Cache cache = new TransactionAwareCacheDecorator(target);
Object key = new Object(); Object key = new Object();
@ -207,7 +207,7 @@ public class TransactionAwareCacheDecoratorTests {
} }
@Test @Test
public void invalidateTransactional() { // no transactional support for invalidate void invalidateTransactional() { // no transactional support for invalidate
Cache target = new ConcurrentMapCache("testCache"); Cache target = new ConcurrentMapCache("testCache");
Cache cache = new TransactionAwareCacheDecorator(target); Cache cache = new TransactionAwareCacheDecorator(target);
Object key = new Object(); Object key = new Object();

View File

@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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 * @author Chris Beams
* @since 10.09.2003 * @since 10.09.2003
*/ */
public class SimpleMailMessageTests { class SimpleMailMessageTests {
@Test @Test
public void testSimpleMessageCopyCtor() { void testSimpleMessageCopyCtor() {
SimpleMailMessage message = new SimpleMailMessage(); SimpleMailMessage message = new SimpleMailMessage();
message.setFrom("me@mail.org"); message.setFrom("me@mail.org");
message.setTo("you@mail.org"); message.setTo("you@mail.org");
@ -45,8 +45,8 @@ public class SimpleMailMessageTests {
assertThat(messageCopy.getTo()[0]).isEqualTo("you@mail.org"); assertThat(messageCopy.getTo()[0]).isEqualTo("you@mail.org");
message.setReplyTo("reply@mail.org"); message.setReplyTo("reply@mail.org");
message.setCc(new String[]{"he@mail.org", "she@mail.org"}); message.setCc("he@mail.org", "she@mail.org");
message.setBcc(new String[]{"us@mail.org", "them@mail.org"}); message.setBcc("us@mail.org", "them@mail.org");
Date sentDate = new Date(); Date sentDate = new Date();
message.setSentDate(sentDate); message.setSentDate(sentDate);
message.setSubject("my subject"); message.setSubject("my subject");
@ -81,12 +81,12 @@ public class SimpleMailMessageTests {
} }
@Test @Test
public void testDeepCopyOfStringArrayTypedFieldsOnCopyCtor() throws Exception { void testDeepCopyOfStringArrayTypedFieldsOnCopyCtor() {
SimpleMailMessage original = new SimpleMailMessage(); SimpleMailMessage original = new SimpleMailMessage();
original.setTo(new String[]{"fiona@mail.org", "apple@mail.org"}); original.setTo("fiona@mail.org", "apple@mail.org");
original.setCc(new String[]{"he@mail.org", "she@mail.org"}); original.setCc("he@mail.org", "she@mail.org");
original.setBcc(new String[]{"us@mail.org", "them@mail.org"}); original.setBcc("us@mail.org", "them@mail.org");
SimpleMailMessage copy = new SimpleMailMessage(original); SimpleMailMessage copy = new SimpleMailMessage(original);
@ -160,13 +160,13 @@ public class SimpleMailMessageTests {
} }
@Test @Test
public void testCopyCtorChokesOnNullOriginalMessage() throws Exception { void testCopyCtorChokesOnNullOriginalMessage() {
assertThatIllegalArgumentException().isThrownBy(() -> assertThatIllegalArgumentException().isThrownBy(() ->
new SimpleMailMessage(null)); new SimpleMailMessage(null));
} }
@Test @Test
public void testCopyToChokesOnNullTargetMessage() throws Exception { void testCopyToChokesOnNullTargetMessage() {
assertThatIllegalArgumentException().isThrownBy(() -> assertThatIllegalArgumentException().isThrownBy(() ->
new SimpleMailMessage().copyTo(null)); new SimpleMailMessage().copyTo(null));
} }

View File

@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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 Rob Harrop
* @author Juergen Hoeller * @author Juergen Hoeller
*/ */
public class ConfigurableMimeFileTypeMapTests { class ConfigurableMimeFileTypeMapTests {
@Test @Test
public void againstDefaultConfiguration() throws Exception { void againstDefaultConfiguration() {
ConfigurableMimeFileTypeMap ftm = new ConfigurableMimeFileTypeMap(); ConfigurableMimeFileTypeMap ftm = new ConfigurableMimeFileTypeMap();
ftm.afterPropertiesSet(); ftm.afterPropertiesSet();
@ -45,15 +45,15 @@ public class ConfigurableMimeFileTypeMapTests {
} }
@Test @Test
public void againstDefaultConfigurationWithFilePath() throws Exception { void againstDefaultConfigurationWithFilePath() {
ConfigurableMimeFileTypeMap ftm = new ConfigurableMimeFileTypeMap(); ConfigurableMimeFileTypeMap ftm = new ConfigurableMimeFileTypeMap();
assertThat(ftm.getContentType(new File("/tmp/foobar.HTM"))).as("Invalid content type for HTM").isEqualTo("text/html"); assertThat(ftm.getContentType(new File("/tmp/foobar.HTM"))).as("Invalid content type for HTM").isEqualTo("text/html");
} }
@Test @Test
public void withAdditionalMappings() throws Exception { void withAdditionalMappings() {
ConfigurableMimeFileTypeMap ftm = new ConfigurableMimeFileTypeMap(); 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(); ftm.afterPropertiesSet();
assertThat(ftm.getContentType("foobar.HTM")).as("Invalid content type for HTM - override didn't work").isEqualTo("foo/bar"); 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 @Test
public void withCustomMappingLocation() throws Exception { void withCustomMappingLocation() {
Resource resource = new ClassPathResource("test.mime.types", getClass()); Resource resource = new ClassPathResource("test.mime.types", getClass());
ConfigurableMimeFileTypeMap ftm = new ConfigurableMimeFileTypeMap(); ConfigurableMimeFileTypeMap ftm = new ConfigurableMimeFileTypeMap();

View File

@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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 * @author Sam Brannen
* @since 09.07.2005 * @since 09.07.2005
*/ */
public class InternetAddressEditorTests { class InternetAddressEditorTests {
private static final String EMPTY = ""; private static final String EMPTY = "";
private static final String SIMPLE = "nobody@nowhere.com"; private static final String SIMPLE = "nobody@nowhere.com";
@ -36,42 +36,42 @@ public class InternetAddressEditorTests {
@Test @Test
public void uninitialized() { void uninitialized() {
assertThat(editor.getAsText()).as("Uninitialized editor did not return empty value string").isEmpty(); assertThat(editor.getAsText()).as("Uninitialized editor did not return empty value string").isEmpty();
} }
@Test @Test
public void setNull() { void setNull() {
editor.setAsText(null); editor.setAsText(null);
assertThat(editor.getAsText()).as("Setting null did not result in empty value string").isEmpty(); assertThat(editor.getAsText()).as("Setting null did not result in empty value string").isEmpty();
} }
@Test @Test
public void setEmpty() { void setEmpty() {
editor.setAsText(EMPTY); editor.setAsText(EMPTY);
assertThat(editor.getAsText()).as("Setting empty string did not result in empty value string").isEmpty(); assertThat(editor.getAsText()).as("Setting empty string did not result in empty value string").isEmpty();
} }
@Test @Test
public void allWhitespace() { void allWhitespace() {
editor.setAsText(" "); editor.setAsText(" ");
assertThat(editor.getAsText()).as("All whitespace was not recognized").isEmpty(); assertThat(editor.getAsText()).as("All whitespace was not recognized").isEmpty();
} }
@Test @Test
public void simpleGoodAddress() { void simpleGoodAddress() {
editor.setAsText(SIMPLE); editor.setAsText(SIMPLE);
assertThat(editor.getAsText()).as("Simple email address failed").isEqualTo(SIMPLE); assertThat(editor.getAsText()).as("Simple email address failed").isEqualTo(SIMPLE);
} }
@Test @Test
public void excessWhitespace() { void excessWhitespace() {
editor.setAsText(" " + SIMPLE + " "); editor.setAsText(" " + SIMPLE + " ");
assertThat(editor.getAsText()).as("Whitespace was not stripped").isEqualTo(SIMPLE); assertThat(editor.getAsText()).as("Whitespace was not stripped").isEqualTo(SIMPLE);
} }
@Test @Test
public void simpleBadAddress() { void simpleBadAddress() {
assertThatIllegalArgumentException().isThrownBy(() -> assertThatIllegalArgumentException().isThrownBy(() ->
editor.setAsText(BAD)); editor.setAsText(BAD));
} }

View File

@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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 connectedUsername = null;
private String connectedPassword = null; private String connectedPassword = null;
private boolean closeCalled = false; private boolean closeCalled = false;
private List<Message> sentMessages = new ArrayList<>(); private final List<Message> sentMessages = new ArrayList<>();
private MockTransport(Session session, URLName urlName) { private MockTransport(Session session, URLName urlName) {
super(session, urlName); super(session, urlName);
@ -504,7 +504,7 @@ class JavaMailSenderTests {
@Override @Override
public synchronized void close() throws MessagingException { public synchronized void close() throws MessagingException {
if ("".equals(connectedHost)) { if (this.connectedHost.isEmpty()) {
throw new MessagingException("close failure"); throw new MessagingException("close failure");
} }
this.closeCalled = true; this.closeCalled = true;

View File

@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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 * @author Mark Fisher
* @since 3.0 * @since 3.0
*/ */
public class QuartzSchedulerLifecycleTests { class QuartzSchedulerLifecycleTests {
@Test // SPR-6354 @Test // SPR-6354
public void destroyLazyInitSchedulerWithDefaultShutdownOrderDoesNotHang() { public void destroyLazyInitSchedulerWithDefaultShutdownOrderDoesNotHang() {

View File

@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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.junit.jupiter.api.Test;
import org.quartz.Job; import org.quartz.Job;
import org.quartz.JobExecutionContext; import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.quartz.Scheduler; import org.quartz.Scheduler;
import org.quartz.SchedulerContext; import org.quartz.SchedulerContext;
import org.quartz.SchedulerFactory; import org.quartz.SchedulerFactory;
@ -352,7 +351,6 @@ class QuartzSupportTests {
} }
@Test @Test
@SuppressWarnings("resource")
void schedulerAutoStartsOnContextRefreshedEventByDefault() throws Exception { void schedulerAutoStartsOnContextRefreshedEventByDefault() throws Exception {
StaticApplicationContext context = new StaticApplicationContext(); StaticApplicationContext context = new StaticApplicationContext();
context.registerBeanDefinition("scheduler", new RootBeanDefinition(SchedulerFactoryBean.class)); context.registerBeanDefinition("scheduler", new RootBeanDefinition(SchedulerFactoryBean.class));
@ -363,7 +361,6 @@ class QuartzSupportTests {
} }
@Test @Test
@SuppressWarnings("resource")
void schedulerAutoStartupFalse() throws Exception { void schedulerAutoStartupFalse() throws Exception {
StaticApplicationContext context = new StaticApplicationContext(); StaticApplicationContext context = new StaticApplicationContext();
BeanDefinition beanDefinition = BeanDefinitionBuilder.genericBeanDefinition(SchedulerFactoryBean.class) BeanDefinition beanDefinition = BeanDefinitionBuilder.genericBeanDefinition(SchedulerFactoryBean.class)
@ -376,7 +373,7 @@ class QuartzSupportTests {
} }
@Test @Test
void schedulerRepositoryExposure() throws Exception { void schedulerRepositoryExposure() {
try (ClassPathXmlApplicationContext ctx = context("schedulerRepositoryExposure.xml")) { try (ClassPathXmlApplicationContext ctx = context("schedulerRepositoryExposure.xml")) {
assertThat(ctx.getBean("scheduler")).isSameAs(SchedulerRepository.getInstance().lookup("myScheduler")); 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... * TODO: Against Quartz 2.2, this test's job doesn't actually execute anymore...
*/ */
@Test @Test
void schedulerWithHsqlDataSource() throws Exception { void schedulerWithHsqlDataSource() {
DummyJob.param = 0; DummyJob.param = 0;
DummyJob.count = 0; DummyJob.count = 0;
@ -403,7 +400,6 @@ class QuartzSupportTests {
} }
@Test @Test
@SuppressWarnings("resource")
void schedulerFactoryBeanWithCustomJobStore() throws Exception { void schedulerFactoryBeanWithCustomJobStore() throws Exception {
StaticApplicationContext context = new StaticApplicationContext(); StaticApplicationContext context = new StaticApplicationContext();
@ -459,7 +455,7 @@ class QuartzSupportTests {
} }
@Override @Override
public synchronized void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException { public synchronized void execute(JobExecutionContext jobExecutionContext) {
count++; count++;
} }
} }
@ -480,7 +476,7 @@ class QuartzSupportTests {
} }
@Override @Override
protected synchronized void executeInternal(JobExecutionContext jobExecutionContext) throws JobExecutionException { protected synchronized void executeInternal(JobExecutionContext jobExecutionContext) {
count++; count++;
} }
} }

View File

@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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 * @author Sebastien Deleuze
*/ */
public class SchedulerFactoryBeanRuntimeHintsTests { class SchedulerFactoryBeanRuntimeHintsTests {
private final RuntimeHints hints = new RuntimeHints(); private final RuntimeHints hints = new RuntimeHints();

View File

@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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 Issam El-atif
* @author Sam Brannen * @author Sam Brannen
*/ */
public class FreeMarkerConfigurationFactoryBeanTests { class FreeMarkerConfigurationFactoryBeanTests {
private final FreeMarkerConfigurationFactoryBean fcfb = new FreeMarkerConfigurationFactoryBean(); private final FreeMarkerConfigurationFactoryBean fcfb = new FreeMarkerConfigurationFactoryBean();
@Test @Test
public void freeMarkerConfigurationFactoryBeanWithConfigLocation() throws Exception { void freeMarkerConfigurationFactoryBeanWithConfigLocation() {
fcfb.setConfigLocation(new FileSystemResource("myprops.properties")); fcfb.setConfigLocation(new FileSystemResource("myprops.properties"));
Properties props = new Properties(); Properties props = new Properties();
props.setProperty("myprop", "/mydir"); props.setProperty("myprop", "/mydir");
@ -53,7 +53,7 @@ public class FreeMarkerConfigurationFactoryBeanTests {
} }
@Test @Test
public void freeMarkerConfigurationFactoryBeanWithResourceLoaderPath() throws Exception { void freeMarkerConfigurationFactoryBeanWithResourceLoaderPath() throws Exception {
fcfb.setTemplateLoaderPath("file:/mydir"); fcfb.setTemplateLoaderPath("file:/mydir");
fcfb.afterPropertiesSet(); fcfb.afterPropertiesSet();
Configuration cfg = fcfb.getObject(); Configuration cfg = fcfb.getObject();