This commit is contained in:
Stéphane Nicoll
2024-01-17 17:43:47 +01:00
parent 699da7c383
commit f5b0d9509d
45 changed files with 373 additions and 411 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");
* you may not use this file except in compliance with the License.
@@ -47,9 +47,6 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
*/
public abstract class AbstractApplicationContextTests extends AbstractListableBeanFactoryTests {
/** Must be supplied as XML */
public static final String TEST_NAMESPACE = "testNamespace";
protected ConfigurableApplicationContext applicationContext;
/** Subclass must register this */
@@ -59,17 +56,17 @@ public abstract class AbstractApplicationContextTests extends AbstractListableBe
@BeforeEach
public void setup() throws Exception {
protected void setup() throws Exception {
this.applicationContext = createContext();
}
@Override
protected BeanFactory getBeanFactory() {
return applicationContext;
return this.applicationContext;
}
protected ApplicationContext getApplicationContext() {
return applicationContext;
return this.applicationContext;
}
/**
@@ -82,7 +79,7 @@ public abstract class AbstractApplicationContextTests extends AbstractListableBe
@Test
public void contextAwareSingletonWasCalledBack() throws Exception {
protected void contextAwareSingletonWasCalledBack() {
ACATester aca = (ACATester) applicationContext.getBean("aca");
assertThat(aca.getApplicationContext()).as("has had context set").isSameAs(applicationContext);
Object aca2 = applicationContext.getBean("aca");
@@ -91,7 +88,7 @@ public abstract class AbstractApplicationContextTests extends AbstractListableBe
}
@Test
public void contextAwarePrototypeWasCalledBack() throws Exception {
protected void contextAwarePrototypeWasCalledBack() {
ACATester aca = (ACATester) applicationContext.getBean("aca-prototype");
assertThat(aca.getApplicationContext()).as("has had context set").isSameAs(applicationContext);
Object aca2 = applicationContext.getBean("aca-prototype");
@@ -101,35 +98,35 @@ public abstract class AbstractApplicationContextTests extends AbstractListableBe
}
@Test
public void parentNonNull() {
protected void parentNonNull() {
assertThat(applicationContext.getParent()).as("parent isn't null").isNotNull();
}
@Test
public void grandparentNull() {
protected void grandparentNull() {
assertThat(applicationContext.getParent().getParent()).as("grandparent is null").isNull();
}
@Test
public void overrideWorked() throws Exception {
protected void overrideWorked() {
TestBean rod = (TestBean) applicationContext.getParent().getBean("rod");
assertThat(rod.getName().equals("Roderick")).as("Parent's name differs").isTrue();
}
@Test
public void grandparentDefinitionFound() throws Exception {
protected void grandparentDefinitionFound() {
TestBean dad = (TestBean) applicationContext.getBean("father");
assertThat(dad.getName().equals("Albert")).as("Dad has correct name").isTrue();
}
@Test
public void grandparentTypedDefinitionFound() throws Exception {
protected void grandparentTypedDefinitionFound() {
TestBean dad = applicationContext.getBean("father", TestBean.class);
assertThat(dad.getName().equals("Albert")).as("Dad has correct name").isTrue();
}
@Test
public void closeTriggersDestroy() {
protected void closeTriggersDestroy() {
LifecycleBean lb = (LifecycleBean) applicationContext.getBean("lifecycle");
boolean condition = !lb.isDestroyed();
assertThat(condition).as("Not destroyed").isTrue();
@@ -146,7 +143,7 @@ public abstract class AbstractApplicationContextTests extends AbstractListableBe
}
@Test
public void messageSource() throws NoSuchMessageException {
protected void messageSource() throws NoSuchMessageException {
assertThat(applicationContext.getMessage("code1", null, Locale.getDefault())).isEqualTo("message1");
assertThat(applicationContext.getMessage("code2", null, Locale.getDefault())).isEqualTo("message2");
assertThatExceptionOfType(NoSuchMessageException.class).isThrownBy(() ->
@@ -154,12 +151,12 @@ public abstract class AbstractApplicationContextTests extends AbstractListableBe
}
@Test
public void events() throws Exception {
protected void events() throws Exception {
doTestEvents(this.listener, this.parentListener, new MyEvent(this));
}
@Test
public void eventsWithNoSource() throws Exception {
protected void eventsWithNoSource() throws Exception {
// See SPR-10945 Serialized events result in a null source
MyEvent event = new MyEvent(this);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
@@ -184,7 +181,7 @@ public abstract class AbstractApplicationContextTests extends AbstractListableBe
}
@Test
public void beanAutomaticallyHearsEvents() throws Exception {
protected void beanAutomaticallyHearsEvents() {
//String[] listenerNames = ((ListableBeanFactory) applicationContext).getBeanDefinitionNames(ApplicationListener.class);
//assertTrue("listeners include beanThatListens", Arrays.asList(listenerNames).contains("beanThatListens"));
BeanThatListens b = (BeanThatListens) applicationContext.getBean("beanThatListens");

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");
* you may not use this file except in compliance with the License.
@@ -446,7 +446,7 @@ public abstract class AbstractCacheAnnotationTests {
protected void testMultiEvict(CacheableService<?> service) {
Object o1 = new Object();
Object o2 = o1.toString() + "A";
Object o2 = o1 + "A";
Object r1 = service.multiCache(o1);
@@ -571,132 +571,132 @@ public abstract class AbstractCacheAnnotationTests {
}
@Test
public void testCacheable() {
protected void testCacheable() {
testCacheable(this.cs);
}
@Test
public void testCacheableNull() {
protected void testCacheableNull() {
testCacheableNull(this.cs);
}
@Test
public void testCacheableSync() {
protected void testCacheableSync() {
testCacheableSync(this.cs);
}
@Test
public void testCacheableSyncNull() {
protected void testCacheableSyncNull() {
testCacheableSyncNull(this.cs);
}
@Test
public void testEvict() {
protected void testEvict() {
testEvict(this.cs, true);
}
@Test
public void testEvictEarly() {
protected void testEvictEarly() {
testEvictEarly(this.cs);
}
@Test
public void testEvictWithException() {
protected void testEvictWithException() {
testEvictException(this.cs);
}
@Test
public void testEvictAll() {
protected void testEvictAll() {
testEvictAll(this.cs, true);
}
@Test
public void testEvictAllEarly() {
protected void testEvictAllEarly() {
testEvictAllEarly(this.cs);
}
@Test
public void testEvictWithKey() {
protected void testEvictWithKey() {
testEvictWithKey(this.cs);
}
@Test
public void testEvictWithKeyEarly() {
protected void testEvictWithKeyEarly() {
testEvictWithKeyEarly(this.cs);
}
@Test
public void testConditionalExpression() {
protected void testConditionalExpression() {
testConditionalExpression(this.cs);
}
@Test
public void testConditionalExpressionSync() {
protected void testConditionalExpressionSync() {
testConditionalExpressionSync(this.cs);
}
@Test
public void testUnlessExpression() {
protected void testUnlessExpression() {
testUnlessExpression(this.cs);
}
@Test
public void testClassCacheUnlessExpression() {
protected void testClassCacheUnlessExpression() {
testUnlessExpression(this.cs);
}
@Test
public void testKeyExpression() {
protected void testKeyExpression() {
testKeyExpression(this.cs);
}
@Test
public void testVarArgsKey() {
protected void testVarArgsKey() {
testVarArgsKey(this.cs);
}
@Test
public void testClassCacheCacheable() {
protected void testClassCacheCacheable() {
testCacheable(this.ccs);
}
@Test
public void testClassCacheEvict() {
protected void testClassCacheEvict() {
testEvict(this.ccs, true);
}
@Test
public void testClassEvictEarly() {
protected void testClassEvictEarly() {
testEvictEarly(this.ccs);
}
@Test
public void testClassEvictAll() {
protected void testClassEvictAll() {
testEvictAll(this.ccs, true);
}
@Test
public void testClassEvictWithException() {
protected void testClassEvictWithException() {
testEvictException(this.ccs);
}
@Test
public void testClassCacheEvictWithWKey() {
protected void testClassCacheEvictWithWKey() {
testEvictWithKey(this.ccs);
}
@Test
public void testClassEvictWithKeyEarly() {
protected void testClassEvictWithKeyEarly() {
testEvictWithKeyEarly(this.ccs);
}
@Test
public void testNullValue() {
protected void testNullValue() {
testNullValue(this.cs);
}
@Test
public void testClassNullValue() {
protected void testClassNullValue() {
Object key = new Object();
assertThat(this.ccs.nullValue(key)).isNull();
int nr = this.ccs.nullInvocations().intValue();
@@ -709,27 +709,27 @@ public abstract class AbstractCacheAnnotationTests {
}
@Test
public void testMethodName() {
protected void testMethodName() {
testMethodName(this.cs, "name");
}
@Test
public void testClassMethodName() {
protected void testClassMethodName() {
testMethodName(this.ccs, "nametestCache");
}
@Test
public void testRootVars() {
protected void testRootVars() {
testRootVars(this.cs);
}
@Test
public void testClassRootVars() {
protected void testClassRootVars() {
testRootVars(this.ccs);
}
@Test
public void testCustomKeyGenerator() {
protected void testCustomKeyGenerator() {
Object param = new Object();
Object r1 = this.cs.customKeyGenerator(param);
assertThat(this.cs.customKeyGenerator(param)).isSameAs(r1);
@@ -740,14 +740,14 @@ public abstract class AbstractCacheAnnotationTests {
}
@Test
public void testUnknownCustomKeyGenerator() {
protected void testUnknownCustomKeyGenerator() {
Object param = new Object();
assertThatExceptionOfType(NoSuchBeanDefinitionException.class).isThrownBy(() ->
this.cs.unknownCustomKeyGenerator(param));
}
@Test
public void testCustomCacheManager() {
protected void testCustomCacheManager() {
CacheManager customCm = this.ctx.getBean("customCacheManager", CacheManager.class);
Object key = new Object();
Object r1 = this.cs.customCacheManager(key);
@@ -758,159 +758,159 @@ public abstract class AbstractCacheAnnotationTests {
}
@Test
public void testUnknownCustomCacheManager() {
protected void testUnknownCustomCacheManager() {
Object param = new Object();
assertThatExceptionOfType(NoSuchBeanDefinitionException.class).isThrownBy(() ->
this.cs.unknownCustomCacheManager(param));
}
@Test
public void testNullArg() {
protected void testNullArg() {
testNullArg(this.cs);
}
@Test
public void testClassNullArg() {
protected void testClassNullArg() {
testNullArg(this.ccs);
}
@Test
public void testCheckedException() {
protected void testCheckedException() {
testCheckedThrowable(this.cs);
}
@Test
public void testClassCheckedException() {
protected void testClassCheckedException() {
testCheckedThrowable(this.ccs);
}
@Test
public void testCheckedExceptionSync() {
protected void testCheckedExceptionSync() {
testCheckedThrowableSync(this.cs);
}
@Test
public void testClassCheckedExceptionSync() {
protected void testClassCheckedExceptionSync() {
testCheckedThrowableSync(this.ccs);
}
@Test
public void testUncheckedException() {
protected void testUncheckedException() {
testUncheckedThrowable(this.cs);
}
@Test
public void testClassUncheckedException() {
protected void testClassUncheckedException() {
testUncheckedThrowable(this.ccs);
}
@Test
public void testUncheckedExceptionSync() {
protected void testUncheckedExceptionSync() {
testUncheckedThrowableSync(this.cs);
}
@Test
public void testClassUncheckedExceptionSync() {
protected void testClassUncheckedExceptionSync() {
testUncheckedThrowableSync(this.ccs);
}
@Test
public void testUpdate() {
protected void testUpdate() {
testCacheUpdate(this.cs);
}
@Test
public void testClassUpdate() {
protected void testClassUpdate() {
testCacheUpdate(this.ccs);
}
@Test
public void testConditionalUpdate() {
protected void testConditionalUpdate() {
testConditionalCacheUpdate(this.cs);
}
@Test
public void testClassConditionalUpdate() {
protected void testClassConditionalUpdate() {
testConditionalCacheUpdate(this.ccs);
}
@Test
public void testMultiCache() {
protected void testMultiCache() {
testMultiCache(this.cs);
}
@Test
public void testClassMultiCache() {
protected void testClassMultiCache() {
testMultiCache(this.ccs);
}
@Test
public void testMultiEvict() {
protected void testMultiEvict() {
testMultiEvict(this.cs);
}
@Test
public void testClassMultiEvict() {
protected void testClassMultiEvict() {
testMultiEvict(this.ccs);
}
@Test
public void testMultiPut() {
protected void testMultiPut() {
testMultiPut(this.cs);
}
@Test
public void testClassMultiPut() {
protected void testClassMultiPut() {
testMultiPut(this.ccs);
}
@Test
public void testPutRefersToResult() {
protected void testPutRefersToResult() {
testPutRefersToResult(this.cs);
}
@Test
public void testPutRefersToResultWithUnless() {
protected void testPutRefersToResultWithUnless() {
testPutRefersToResultWithUnless(this.cs);
}
@Test
public void testPutEvaluatesUnlessBeforeKey() {
protected void testPutEvaluatesUnlessBeforeKey() {
testPutEvaluatesUnlessBeforeKey(this.cs);
}
@Test
public void testClassPutRefersToResult() {
protected void testClassPutRefersToResult() {
testPutRefersToResult(this.ccs);
}
@Test
public void testClassPutRefersToResultWithUnless(){
protected void testClassPutRefersToResultWithUnless(){
testPutRefersToResultWithUnless(this.ccs);
}
@Test
public void testClassPutEvaluatesUnlessBeforeKey(){
protected void testClassPutEvaluatesUnlessBeforeKey(){
testPutEvaluatesUnlessBeforeKey(this.ccs);
}
@Test
public void testMultiCacheAndEvict() {
protected void testMultiCacheAndEvict() {
testMultiCacheAndEvict(this.cs);
}
@Test
public void testClassMultiCacheAndEvict() {
protected void testClassMultiCacheAndEvict() {
testMultiCacheAndEvict(this.ccs);
}
@Test
public void testMultiConditionalCacheAndEvict() {
protected void testMultiConditionalCacheAndEvict() {
testMultiConditionalCacheAndEvict(this.cs);
}
@Test
public void testClassMultiConditionalCacheAndEvict() {
protected void testClassMultiConditionalCacheAndEvict() {
testMultiConditionalCacheAndEvict(this.ccs);
}

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");
* you may not use this file except in compliance with the License.
@@ -41,17 +41,17 @@ public abstract class AbstractCacheTests<T extends Cache> {
@Test
public void testCacheName() throws Exception {
protected void testCacheName() {
assertThat(getCache().getName()).isEqualTo(CACHE_NAME);
}
@Test
public void testNativeCache() throws Exception {
protected void testNativeCache() {
assertThat(getCache().getNativeCache()).isSameAs(getNativeCache());
}
@Test
public void testCachePut() throws Exception {
protected void testCachePut() {
T cache = getCache();
String key = createRandomKey();
@@ -75,7 +75,7 @@ public abstract class AbstractCacheTests<T extends Cache> {
}
@Test
public void testCachePutIfAbsent() throws Exception {
protected void testCachePutIfAbsent() {
T cache = getCache();
String key = createRandomKey();
@@ -90,7 +90,7 @@ public abstract class AbstractCacheTests<T extends Cache> {
}
@Test
public void testCacheRemove() throws Exception {
protected void testCacheRemove() {
T cache = getCache();
String key = createRandomKey();
@@ -101,7 +101,7 @@ public abstract class AbstractCacheTests<T extends Cache> {
}
@Test
public void testCacheClear() throws Exception {
protected void testCacheClear() {
T cache = getCache();
assertThat(cache.get("enescu")).isNull();
@@ -114,12 +114,12 @@ public abstract class AbstractCacheTests<T extends Cache> {
}
@Test
public void testCacheGetCallable() {
protected void testCacheGetCallable() {
doTestCacheGetCallable("test");
}
@Test
public void testCacheGetCallableWithNull() {
protected void testCacheGetCallableWithNull() {
doTestCacheGetCallable(null);
}
@@ -135,12 +135,12 @@ public abstract class AbstractCacheTests<T extends Cache> {
}
@Test
public void testCacheGetCallableNotInvokedWithHit() {
protected void testCacheGetCallableNotInvokedWithHit() {
doTestCacheGetCallableNotInvokedWithHit("existing");
}
@Test
public void testCacheGetCallableNotInvokedWithHitNull() {
protected void testCacheGetCallableNotInvokedWithHitNull() {
doTestCacheGetCallableNotInvokedWithHit(null);
}
@@ -157,7 +157,7 @@ public abstract class AbstractCacheTests<T extends Cache> {
}
@Test
public void testCacheGetCallableFail() {
protected void testCacheGetCallableFail() {
T cache = getCache();
String key = createRandomKey();
@@ -179,7 +179,7 @@ public abstract class AbstractCacheTests<T extends Cache> {
* invocations.
*/
@Test
public void testCacheGetSynchronized() throws InterruptedException {
protected void testCacheGetSynchronized() throws InterruptedException {
T cache = getCache();
final AtomicInteger counter = new AtomicInteger();
final List<Object> results = new CopyOnWriteArrayList<>();

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");
* you may not use this file except in compliance with the License.
@@ -33,7 +33,7 @@ public abstract class AbstractValueAdaptingCacheTests<T extends AbstractValueAda
protected abstract T getCache(boolean allowNull);
@Test
public void testCachePutNullValueAllowNullFalse() {
protected void testCachePutNullValueAllowNullFalse() {
T cache = getCache(false);
String key = createRandomKey();
assertThatIllegalArgumentException().isThrownBy(() ->