mirror of
https://github.com/spring-projects/spring-framework.git
synced 2026-09-17 16:39:29 +00:00
Merge branch '7.0.x'
This commit is contained in:
+4
-4
@@ -67,25 +67,25 @@ class AroundAdviceBindingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testOneIntArg() {
|
||||
void oneIntArg() {
|
||||
testBeanProxy.setAge(5);
|
||||
verify(mockCollaborator).oneIntArg(5);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testOneObjectArgBoundToTarget() {
|
||||
void oneObjectArgBoundToTarget() {
|
||||
testBeanProxy.getAge();
|
||||
verify(mockCollaborator).oneObjectArg(this.testBeanTarget);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testOneIntAndOneObjectArgs() {
|
||||
void oneIntAndOneObjectArgs() {
|
||||
testBeanProxy.setAge(5);
|
||||
verify(mockCollaborator).oneIntAndOneObject(5, this.testBeanProxy);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testJustJoinPoint() {
|
||||
void justJoinPoint() {
|
||||
testBeanProxy.getAge();
|
||||
verify(mockCollaborator).justJoinPoint("getAge");
|
||||
}
|
||||
|
||||
+1
-1
@@ -29,7 +29,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
class AroundAdviceCircularTests extends AroundAdviceBindingTests {
|
||||
|
||||
@Test
|
||||
void testBothBeansAreProxies() {
|
||||
void bothBeansAreProxies() {
|
||||
Object tb = ctx.getBean("testBean");
|
||||
assertThat(AopUtils.isAopProxy(tb)).isTrue();
|
||||
Object tb2 = ctx.getBean("testBean2");
|
||||
|
||||
+1
-1
@@ -66,7 +66,7 @@ class AspectAndAdvicePrecedenceTests {
|
||||
|
||||
|
||||
@Test
|
||||
void testAdviceOrder() {
|
||||
void adviceOrder() {
|
||||
PrecedenceTestAspect.Collaborator collaborator = new PrecedenceVerifyingCollaborator();
|
||||
this.highPrecedenceAspect.setCollaborator(collaborator);
|
||||
this.lowPrecedenceAspect.setCollaborator(collaborator);
|
||||
|
||||
+6
-6
@@ -74,7 +74,7 @@ class BeanNamePointcutTests {
|
||||
// We don't need to test all combination of pointcuts due to BeanNamePointcutMatchingTests
|
||||
|
||||
@Test
|
||||
void testMatchingBeanName() {
|
||||
void matchingBeanName() {
|
||||
boolean condition = this.testBean1 instanceof Advised;
|
||||
assertThat(condition).as("Matching bean must be advised (proxied)").isTrue();
|
||||
// Call two methods to test for SPR-3953-like condition
|
||||
@@ -84,7 +84,7 @@ class BeanNamePointcutTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testNonMatchingBeanName() {
|
||||
void nonMatchingBeanName() {
|
||||
boolean condition = this.testBean2 instanceof Advised;
|
||||
assertThat(condition).as("Non-matching bean must *not* be advised (proxied)").isFalse();
|
||||
this.testBean2.setAge(20);
|
||||
@@ -92,13 +92,13 @@ class BeanNamePointcutTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testNonMatchingNestedBeanName() {
|
||||
void nonMatchingNestedBeanName() {
|
||||
boolean condition = this.testBeanContainingNestedBean.getDoctor() instanceof Advised;
|
||||
assertThat(condition).as("Non-matching bean must *not* be advised (proxied)").isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testMatchingFactoryBeanObject() {
|
||||
void matchingFactoryBeanObject() {
|
||||
boolean condition1 = this.testFactoryBean1 instanceof Advised;
|
||||
assertThat(condition1).as("Matching bean must be advised (proxied)").isTrue();
|
||||
assertThat(this.testFactoryBean1.get("myKey")).isEqualTo("myValue");
|
||||
@@ -110,7 +110,7 @@ class BeanNamePointcutTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testMatchingFactoryBeanItself() {
|
||||
void matchingFactoryBeanItself() {
|
||||
boolean condition1 = !(this.testFactoryBean2 instanceof Advised);
|
||||
assertThat(condition1).as("Matching bean must *not* be advised (proxied)").isTrue();
|
||||
FactoryBean<?> fb = (FactoryBean<?>) ctx.getBean("&testFactoryBean2");
|
||||
@@ -122,7 +122,7 @@ class BeanNamePointcutTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testPointcutAdvisorCombination() {
|
||||
void pointcutAdvisorCombination() {
|
||||
boolean condition = this.interceptThis instanceof Advised;
|
||||
assertThat(condition).as("Matching bean must be advised (proxied)").isTrue();
|
||||
boolean condition1 = this.dontInterceptThis instanceof Advised;
|
||||
|
||||
+1
-1
@@ -34,7 +34,7 @@ import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
class ImplicitJPArgumentMatchingAtAspectJTests {
|
||||
|
||||
@Test
|
||||
void testAspect() {
|
||||
void aspect() {
|
||||
// nothing to really test; it is enough if we don't get error while creating the app context
|
||||
new ClassPathXmlApplicationContext(getClass().getSimpleName() + ".xml", getClass());
|
||||
}
|
||||
|
||||
+1
-1
@@ -32,7 +32,7 @@ class ImplicitJPArgumentMatchingTests {
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("resource")
|
||||
void testAspect() {
|
||||
void aspect() {
|
||||
// nothing to really test; it is enough if we don't get error while creating app context
|
||||
new ClassPathXmlApplicationContext(getClass().getSimpleName() + ".xml", getClass());
|
||||
}
|
||||
|
||||
+2
-2
@@ -34,13 +34,13 @@ class OverloadedAdviceTests {
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("resource")
|
||||
void testConfigParsingWithMismatchedAdviceMethod() {
|
||||
void configParsingWithMismatchedAdviceMethod() {
|
||||
new ClassPathXmlApplicationContext(getClass().getSimpleName() + ".xml", getClass());
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("resource")
|
||||
void testExceptionOnConfigParsingWithAmbiguousAdviceMethod() {
|
||||
void exceptionOnConfigParsingWithAmbiguousAdviceMethod() {
|
||||
assertThatExceptionOfType(BeanCreationException.class)
|
||||
.isThrownBy(() -> new ClassPathXmlApplicationContext(getClass().getSimpleName() + "-ambiguous.xml", getClass()))
|
||||
.havingRootCause()
|
||||
|
||||
@@ -60,19 +60,19 @@ class ProceedTests {
|
||||
|
||||
|
||||
@Test
|
||||
void testSimpleProceedWithChangedArgs() {
|
||||
void simpleProceedWithChangedArgs() {
|
||||
this.testBean.setName("abc");
|
||||
assertThat(this.testBean.getName()).as("Name changed in around advice").isEqualTo("ABC");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGetArgsIsDefensive() {
|
||||
void getArgsIsDefensive() {
|
||||
this.testBean.setAge(5);
|
||||
assertThat(this.testBean.getAge()).as("getArgs is defensive").isEqualTo(5);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testProceedWithArgsInSameAspect() {
|
||||
void proceedWithArgsInSameAspect() {
|
||||
this.testBean.setMyFloat(1.0F);
|
||||
assertThat(this.testBean.getMyFloat()).as("value changed in around advice").isGreaterThan(1.9F);
|
||||
assertThat(this.firstTestAspect.getLastBeforeFloatValue()).as("changed value visible to next advice in chain")
|
||||
@@ -80,7 +80,7 @@ class ProceedTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testProceedWithArgsAcrossAspects() {
|
||||
void proceedWithArgsAcrossAspects() {
|
||||
this.testBean.setSex("male");
|
||||
assertThat(this.testBean.getSex()).as("value changed in around advice").isEqualTo("MALE");
|
||||
assertThat(this.secondTestAspect.getLastBeforeStringValue()).as("changed value visible to next before advice in chain").isEqualTo("MALE");
|
||||
|
||||
+1
-1
@@ -32,7 +32,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
class AspectJAutoProxyCreatorAndLazyInitTargetSourceTests {
|
||||
|
||||
@Test
|
||||
void testAdrian() {
|
||||
void adrian() {
|
||||
ClassPathXmlApplicationContext ctx =
|
||||
new ClassPathXmlApplicationContext(getClass().getSimpleName() + "-context.xml", getClass());
|
||||
|
||||
|
||||
+3
-3
@@ -48,19 +48,19 @@ class AtAspectJAnnotationBindingTests {
|
||||
|
||||
|
||||
@Test
|
||||
void testAnnotationBindingInAroundAdvice() {
|
||||
void annotationBindingInAroundAdvice() {
|
||||
assertThat(testBean.doThis()).isEqualTo("this value doThis");
|
||||
assertThat(testBean.doThat()).isEqualTo("that value doThat");
|
||||
assertThat(testBean.doArray()).hasSize(2);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testNoMatchingWithoutAnnotationPresent() {
|
||||
void noMatchingWithoutAnnotationPresent() {
|
||||
assertThat(testBean.doTheOther()).isEqualTo("doTheOther");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testPointcutEvaluatedAgainstArray() {
|
||||
void pointcutEvaluatedAgainstArray() {
|
||||
ctx.getBean("arrayFactoryBean");
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -33,13 +33,13 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
class GenericBridgeMethodMatchingClassProxyTests extends GenericBridgeMethodMatchingTests {
|
||||
|
||||
@Test
|
||||
void testGenericDerivedInterfaceMethodThroughClass() {
|
||||
void genericDerivedInterfaceMethodThroughClass() {
|
||||
((DerivedStringParameterizedClass) testBean).genericDerivedInterfaceMethod("");
|
||||
assertThat(counterAspect.count).isEqualTo(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGenericBaseInterfaceMethodThroughClass() {
|
||||
void genericBaseInterfaceMethodThroughClass() {
|
||||
((DerivedStringParameterizedClass) testBean).genericBaseInterfaceMethod("");
|
||||
assertThat(counterAspect.count).isEqualTo(1);
|
||||
}
|
||||
|
||||
+2
-2
@@ -68,13 +68,13 @@ class GenericBridgeMethodMatchingTests {
|
||||
|
||||
|
||||
@Test
|
||||
void testGenericDerivedInterfaceMethodThroughInterface() {
|
||||
void genericDerivedInterfaceMethodThroughInterface() {
|
||||
testBean.genericDerivedInterfaceMethod("");
|
||||
assertThat(counterAspect.count).isEqualTo(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGenericBaseInterfaceMethodThroughInterface() {
|
||||
void genericBaseInterfaceMethodThroughInterface() {
|
||||
testBean.genericBaseInterfaceMethod("");
|
||||
assertThat(counterAspect.count).isEqualTo(1);
|
||||
}
|
||||
|
||||
+3
-3
@@ -61,19 +61,19 @@ class GenericParameterMatchingTests {
|
||||
|
||||
|
||||
@Test
|
||||
void testGenericInterfaceGenericArgExecution() {
|
||||
void genericInterfaceGenericArgExecution() {
|
||||
testBean.save("");
|
||||
assertThat(counterAspect.genericInterfaceGenericArgExecutionCount).isEqualTo(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGenericInterfaceGenericCollectionArgExecution() {
|
||||
void genericInterfaceGenericCollectionArgExecution() {
|
||||
testBean.saveAll(null);
|
||||
assertThat(counterAspect.genericInterfaceGenericCollectionArgExecutionCount).isEqualTo(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGenericInterfaceSubtypeGenericCollectionArgExecution() {
|
||||
void genericInterfaceSubtypeGenericCollectionArgExecution() {
|
||||
testBean.saveAll(null);
|
||||
assertThat(counterAspect.genericInterfaceSubtypeGenericCollectionArgExecutionCount).isEqualTo(1);
|
||||
}
|
||||
|
||||
+2
-2
@@ -31,12 +31,12 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
class AopNamespaceHandlerAdviceTypeTests {
|
||||
|
||||
@Test
|
||||
void testParsingOfAdviceTypes() {
|
||||
void parsingOfAdviceTypes() {
|
||||
new ClassPathXmlApplicationContext(getClass().getSimpleName() + "-ok.xml", getClass());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testParsingOfAdviceTypesWithError() {
|
||||
void parsingOfAdviceTypesWithError() {
|
||||
assertThatExceptionOfType(BeanDefinitionStoreException.class).isThrownBy(() ->
|
||||
new ClassPathXmlApplicationContext(getClass().getSimpleName() + "-error.xml", getClass()))
|
||||
.matches(ex -> ex.contains(SAXParseException.class));
|
||||
|
||||
+2
-2
@@ -30,12 +30,12 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
class AopNamespaceHandlerArgNamesTests {
|
||||
|
||||
@Test
|
||||
void testArgNamesOK() {
|
||||
void argNamesOK() {
|
||||
new ClassPathXmlApplicationContext(getClass().getSimpleName() + "-ok.xml", getClass());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testArgNamesError() {
|
||||
void argNamesError() {
|
||||
assertThatExceptionOfType(BeanCreationException.class).isThrownBy(() ->
|
||||
new ClassPathXmlApplicationContext(getClass().getSimpleName() + "-error.xml", getClass()))
|
||||
.matches(ex -> ex.contains(IllegalArgumentException.class));
|
||||
|
||||
+1
-1
@@ -31,7 +31,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
class AopNamespaceHandlerProxyTargetClassTests extends AopNamespaceHandlerTests {
|
||||
|
||||
@Test
|
||||
void testIsClassProxy() {
|
||||
void isClassProxy() {
|
||||
ITestBean bean = getTestBean();
|
||||
assertThat(AopUtils.isCglibProxy(bean)).as("Should be a CGLIB proxy").isTrue();
|
||||
assertThat(((Advised) bean).isExposeProxy()).as("Should expose proxy").isTrue();
|
||||
|
||||
+2
-2
@@ -31,12 +31,12 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
class AopNamespaceHandlerReturningTests {
|
||||
|
||||
@Test
|
||||
void testReturningOnReturningAdvice() {
|
||||
void returningOnReturningAdvice() {
|
||||
new ClassPathXmlApplicationContext(getClass().getSimpleName() + "-ok.xml", getClass());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testParseReturningOnOtherAdviceType() {
|
||||
void parseReturningOnOtherAdviceType() {
|
||||
assertThatExceptionOfType(BeanDefinitionStoreException.class).isThrownBy(() ->
|
||||
new ClassPathXmlApplicationContext(getClass().getSimpleName() + "-error.xml", getClass()))
|
||||
.matches(ex -> ex.contains(SAXParseException.class));
|
||||
|
||||
+5
-5
@@ -53,7 +53,7 @@ class AopNamespaceHandlerTests {
|
||||
|
||||
|
||||
@Test
|
||||
void testIsProxy() {
|
||||
void isProxy() {
|
||||
ITestBean bean = getTestBean();
|
||||
|
||||
assertThat(AopUtils.isAopProxy(bean)).as("Bean is not a proxy").isTrue();
|
||||
@@ -66,7 +66,7 @@ class AopNamespaceHandlerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testAdviceInvokedCorrectly() {
|
||||
void adviceInvokedCorrectly() {
|
||||
CountingBeforeAdvice getAgeCounter = (CountingBeforeAdvice) this.context.getBean("getAgeCounter");
|
||||
CountingBeforeAdvice getNameCounter = (CountingBeforeAdvice) this.context.getBean("getNameCounter");
|
||||
|
||||
@@ -87,7 +87,7 @@ class AopNamespaceHandlerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testAspectApplied() {
|
||||
void aspectApplied() {
|
||||
ITestBean bean = getTestBean();
|
||||
|
||||
CountingAspectJAdvice advice = (CountingAspectJAdvice) this.context.getBean("countingAdvice");
|
||||
@@ -107,7 +107,7 @@ class AopNamespaceHandlerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testAspectAppliedForInitializeBeanWithEmptyName() {
|
||||
void aspectAppliedForInitializeBeanWithEmptyName() {
|
||||
ITestBean bean = (ITestBean) this.context.getAutowireCapableBeanFactory().initializeBean(new TestBean(), "");
|
||||
|
||||
CountingAspectJAdvice advice = (CountingAspectJAdvice) this.context.getBean("countingAdvice");
|
||||
@@ -127,7 +127,7 @@ class AopNamespaceHandlerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testAspectAppliedForInitializeBeanWithNullName() {
|
||||
void aspectAppliedForInitializeBeanWithNullName() {
|
||||
ITestBean bean = (ITestBean) this.context.getAutowireCapableBeanFactory().initializeBean(new TestBean(), null);
|
||||
|
||||
CountingAspectJAdvice advice = (CountingAspectJAdvice) this.context.getBean("countingAdvice");
|
||||
|
||||
+2
-2
@@ -31,12 +31,12 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
class AopNamespaceHandlerThrowingTests {
|
||||
|
||||
@Test
|
||||
void testThrowingOnThrowingAdvice() {
|
||||
void throwingOnThrowingAdvice() {
|
||||
new ClassPathXmlApplicationContext(getClass().getSimpleName() + "-ok.xml", getClass());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testParseThrowingOnOtherAdviceType() {
|
||||
void parseThrowingOnOtherAdviceType() {
|
||||
assertThatExceptionOfType(BeanDefinitionStoreException.class).isThrownBy(() ->
|
||||
new ClassPathXmlApplicationContext(getClass().getSimpleName() + "-error.xml", getClass()))
|
||||
.matches(ex -> ex.contains(SAXParseException.class));
|
||||
|
||||
+9
-9
@@ -40,24 +40,24 @@ class MethodLocatingFactoryBeanTests {
|
||||
|
||||
|
||||
@Test
|
||||
void testIsSingleton() {
|
||||
void isSingleton() {
|
||||
assertThat(factory.isSingleton()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGetObjectType() {
|
||||
void getObjectType() {
|
||||
assertThat(factory.getObjectType()).isEqualTo(Method.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testWithNullTargetBeanName() {
|
||||
void withNullTargetBeanName() {
|
||||
factory.setMethodName("toString()");
|
||||
assertThatIllegalArgumentException().isThrownBy(() ->
|
||||
factory.setBeanFactory(beanFactory));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testWithEmptyTargetBeanName() {
|
||||
void withEmptyTargetBeanName() {
|
||||
factory.setTargetBeanName("");
|
||||
factory.setMethodName("toString()");
|
||||
assertThatIllegalArgumentException().isThrownBy(() ->
|
||||
@@ -65,14 +65,14 @@ class MethodLocatingFactoryBeanTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testWithNullTargetMethodName() {
|
||||
void withNullTargetMethodName() {
|
||||
factory.setTargetBeanName(BEAN_NAME);
|
||||
assertThatIllegalArgumentException().isThrownBy(() ->
|
||||
factory.setBeanFactory(beanFactory));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testWithEmptyTargetMethodName() {
|
||||
void withEmptyTargetMethodName() {
|
||||
factory.setTargetBeanName(BEAN_NAME);
|
||||
factory.setMethodName("");
|
||||
assertThatIllegalArgumentException().isThrownBy(() ->
|
||||
@@ -80,7 +80,7 @@ class MethodLocatingFactoryBeanTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testWhenTargetBeanClassCannotBeResolved() {
|
||||
void whenTargetBeanClassCannotBeResolved() {
|
||||
factory.setTargetBeanName(BEAN_NAME);
|
||||
factory.setMethodName("toString()");
|
||||
assertThatIllegalArgumentException().isThrownBy(() ->
|
||||
@@ -90,7 +90,7 @@ class MethodLocatingFactoryBeanTests {
|
||||
|
||||
@Test
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
void testSunnyDayPath() throws Exception {
|
||||
void sunnyDayPath() throws Exception {
|
||||
given(beanFactory.getType(BEAN_NAME)).willReturn((Class)String.class);
|
||||
factory.setTargetBeanName(BEAN_NAME);
|
||||
factory.setMethodName("toString()");
|
||||
@@ -105,7 +105,7 @@ class MethodLocatingFactoryBeanTests {
|
||||
|
||||
@Test
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
void testWhereMethodCannotBeResolved() {
|
||||
void whereMethodCannotBeResolved() {
|
||||
given(beanFactory.getType(BEAN_NAME)).willReturn((Class)String.class);
|
||||
factory.setTargetBeanName(BEAN_NAME);
|
||||
factory.setMethodName("loadOfOld()");
|
||||
|
||||
+1
-1
@@ -337,7 +337,7 @@ abstract class AbstractAopProxyTests {
|
||||
|
||||
@Test
|
||||
// Should fail to get proxy as exposeProxy wasn't set to true
|
||||
public void targetCantGetProxyByDefault() {
|
||||
void targetCantGetProxyByDefault() {
|
||||
NeedsToSeeProxy et = new NeedsToSeeProxy();
|
||||
ProxyFactory pf1 = new ProxyFactory(et);
|
||||
assertThat(pf1.isExposeProxy()).isFalse();
|
||||
|
||||
+43
-42
@@ -102,25 +102,25 @@ class ProxyFactoryBeanTests {
|
||||
|
||||
|
||||
@Test
|
||||
void testIsDynamicProxyWhenInterfaceSpecified() {
|
||||
void isDynamicProxyWhenInterfaceSpecified() {
|
||||
ITestBean test1 = (ITestBean) factory.getBean("test1");
|
||||
assertThat(Proxy.isProxyClass(test1.getClass())).as("test1 is a dynamic proxy").isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testIsDynamicProxyWhenInterfaceSpecifiedForPrototype() {
|
||||
void isDynamicProxyWhenInterfaceSpecifiedForPrototype() {
|
||||
ITestBean test1 = (ITestBean) factory.getBean("test2");
|
||||
assertThat(Proxy.isProxyClass(test1.getClass())).as("test2 is a dynamic proxy").isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testIsDynamicProxyWhenAutodetectingInterfaces() {
|
||||
void isDynamicProxyWhenAutodetectingInterfaces() {
|
||||
ITestBean test1 = (ITestBean) factory.getBean("test3");
|
||||
assertThat(Proxy.isProxyClass(test1.getClass())).as("test3 is a dynamic proxy").isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testIsDynamicProxyWhenAutodetectingInterfacesForPrototype() {
|
||||
void isDynamicProxyWhenAutodetectingInterfacesForPrototype() {
|
||||
ITestBean test1 = (ITestBean) factory.getBean("test4");
|
||||
assertThat(Proxy.isProxyClass(test1.getClass())).as("test4 is a dynamic proxy").isTrue();
|
||||
}
|
||||
@@ -130,17 +130,18 @@ class ProxyFactoryBeanTests {
|
||||
* interceptor chain and targetSource property.
|
||||
*/
|
||||
@Test
|
||||
void testDoubleTargetSourcesAreRejected() {
|
||||
testDoubleTargetSourceIsRejected("doubleTarget");
|
||||
void doubleTargetSourcesAreRejected() {
|
||||
assertDoubleTargetSourceIsRejected("doubleTarget");
|
||||
// Now with conversion from arbitrary bean to a TargetSource
|
||||
testDoubleTargetSourceIsRejected("arbitraryTarget");
|
||||
assertDoubleTargetSourceIsRejected("arbitraryTarget");
|
||||
}
|
||||
|
||||
private void testDoubleTargetSourceIsRejected(String name) {
|
||||
private static void assertDoubleTargetSourceIsRejected(String name) {
|
||||
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
|
||||
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(new ClassPathResource(DBL_TARGETSOURCE_CONTEXT, CLASS));
|
||||
|
||||
assertThatExceptionOfType(BeanCreationException.class).as("Should not allow TargetSource to be specified in interceptorNames as well as targetSource property")
|
||||
assertThatExceptionOfType(BeanCreationException.class)
|
||||
.as("Should not allow TargetSource to be specified in interceptorNames as well as targetSource property")
|
||||
.isThrownBy(() -> bf.getBean(name))
|
||||
.havingCause()
|
||||
.isInstanceOf(AopConfigException.class)
|
||||
@@ -148,7 +149,7 @@ class ProxyFactoryBeanTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testTargetSourceNotAtEndOfInterceptorNamesIsRejected() {
|
||||
void targetSourceNotAtEndOfInterceptorNamesIsRejected() {
|
||||
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
|
||||
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(new ClassPathResource(NOTLAST_TARGETSOURCE_CONTEXT, CLASS));
|
||||
|
||||
@@ -160,7 +161,7 @@ class ProxyFactoryBeanTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGetObjectTypeWithDirectTarget() {
|
||||
void getObjectTypeWithDirectTarget() {
|
||||
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
|
||||
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(new ClassPathResource(TARGETSOURCE_CONTEXT, CLASS));
|
||||
|
||||
@@ -177,7 +178,7 @@ class ProxyFactoryBeanTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGetObjectTypeWithTargetViaTargetSource() {
|
||||
void getObjectTypeWithTargetViaTargetSource() {
|
||||
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
|
||||
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(new ClassPathResource(TARGETSOURCE_CONTEXT, CLASS));
|
||||
ITestBean tb = (ITestBean) bf.getBean("viaTargetSource");
|
||||
@@ -187,7 +188,7 @@ class ProxyFactoryBeanTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGetObjectTypeWithNoTargetOrTargetSource() {
|
||||
void getObjectTypeWithNoTargetOrTargetSource() {
|
||||
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
|
||||
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(new ClassPathResource(TARGETSOURCE_CONTEXT, CLASS));
|
||||
|
||||
@@ -198,7 +199,7 @@ class ProxyFactoryBeanTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGetObjectTypeOnUninitializedFactoryBean() {
|
||||
void getObjectTypeOnUninitializedFactoryBean() {
|
||||
ProxyFactoryBean pfb = new ProxyFactoryBean();
|
||||
assertThat(pfb.getObjectType()).isNull();
|
||||
}
|
||||
@@ -208,7 +209,7 @@ class ProxyFactoryBeanTests {
|
||||
* Interceptors and interfaces and the target are the same.
|
||||
*/
|
||||
@Test
|
||||
void testSingletonInstancesAreEqual() {
|
||||
void singletonInstancesAreEqual() {
|
||||
ITestBean test1 = (ITestBean) factory.getBean("test1");
|
||||
ITestBean test1_1 = (ITestBean) factory.getBean("test1");
|
||||
//assertTrue("Singleton instances ==", test1 == test1_1);
|
||||
@@ -232,7 +233,7 @@ class ProxyFactoryBeanTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testPrototypeInstancesAreNotEqual() {
|
||||
void prototypeInstancesAreNotEqual() {
|
||||
assertThat(factory.getType("prototype")).isAssignableTo(ITestBean.class);
|
||||
ITestBean test2 = (ITestBean) factory.getBean("prototype");
|
||||
ITestBean test2_1 = (ITestBean) factory.getBean("prototype");
|
||||
@@ -246,7 +247,7 @@ class ProxyFactoryBeanTests {
|
||||
* @param beanName name of the ProxyFactoryBean definition that should
|
||||
* be a prototype
|
||||
*/
|
||||
private Object testPrototypeInstancesAreIndependent(String beanName) {
|
||||
private static Object assertPrototypeInstancesAreIndependent(String beanName) {
|
||||
// Initial count value set in bean factory XML
|
||||
int INITIAL_COUNT = 10;
|
||||
|
||||
@@ -276,8 +277,8 @@ class ProxyFactoryBeanTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCglibPrototypeInstance() {
|
||||
Object prototype = testPrototypeInstancesAreIndependent("cglibPrototype");
|
||||
void cglibPrototypeInstance() {
|
||||
Object prototype = assertPrototypeInstancesAreIndependent("cglibPrototype");
|
||||
assertThat(AopUtils.isCglibProxy(prototype)).as("It's a cglib proxy").isTrue();
|
||||
assertThat(AopUtils.isJdkDynamicProxy(prototype)).as("It's not a dynamic proxy").isFalse();
|
||||
}
|
||||
@@ -286,7 +287,7 @@ class ProxyFactoryBeanTests {
|
||||
* Test invoker is automatically added to manipulate target.
|
||||
*/
|
||||
@Test
|
||||
void testAutoInvoker() {
|
||||
void autoInvoker() {
|
||||
String name = "Hieronymous";
|
||||
TestBean target = (TestBean) factory.getBean("test");
|
||||
target.setName(name);
|
||||
@@ -295,7 +296,7 @@ class ProxyFactoryBeanTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCanGetFactoryReferenceAndManipulate() {
|
||||
void canGetFactoryReferenceAndManipulate() {
|
||||
ProxyFactoryBean config = (ProxyFactoryBean) factory.getBean("&test1");
|
||||
assertThat(config.getObjectType()).isAssignableTo(ITestBean.class);
|
||||
assertThat(factory.getType("test1")).isAssignableTo(ITestBean.class);
|
||||
@@ -327,7 +328,7 @@ class ProxyFactoryBeanTests {
|
||||
* autowire without ambiguity from target and proxy
|
||||
*/
|
||||
@Test
|
||||
void testTargetAsInnerBean() {
|
||||
void targetAsInnerBean() {
|
||||
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
|
||||
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(new ClassPathResource(INNER_BEAN_TARGET_CONTEXT, CLASS));
|
||||
ITestBean itb = (ITestBean) bf.getBean("testBean");
|
||||
@@ -343,7 +344,7 @@ class ProxyFactoryBeanTests {
|
||||
* Each instance will be independent.
|
||||
*/
|
||||
@Test
|
||||
void testCanAddAndRemoveAspectInterfacesOnPrototype() {
|
||||
void canAddAndRemoveAspectInterfacesOnPrototype() {
|
||||
assertThat(factory.getBean("test2")).as("Shouldn't implement TimeStamped before manipulation")
|
||||
.isNotInstanceOf(TimeStamped.class);
|
||||
|
||||
@@ -402,7 +403,7 @@ class ProxyFactoryBeanTests {
|
||||
* singleton.
|
||||
*/
|
||||
@Test
|
||||
void testCanAddAndRemoveAdvicesOnSingleton() {
|
||||
void canAddAndRemoveAdvicesOnSingleton() {
|
||||
ITestBean it = (ITestBean) factory.getBean("test1");
|
||||
Advised pc = (Advised) it;
|
||||
it.getAge();
|
||||
@@ -415,7 +416,7 @@ class ProxyFactoryBeanTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testMethodPointcuts() {
|
||||
void methodPointcuts() {
|
||||
ITestBean tb = (ITestBean) factory.getBean("pointcuts");
|
||||
PointcutForVoid.reset();
|
||||
assertThat(PointcutForVoid.methodNames).as("No methods intercepted").isEmpty();
|
||||
@@ -430,7 +431,7 @@ class ProxyFactoryBeanTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCanAddThrowsAdviceWithoutAdvisor() {
|
||||
void canAddThrowsAdviceWithoutAdvisor() {
|
||||
DefaultListableBeanFactory f = new DefaultListableBeanFactory();
|
||||
new XmlBeanDefinitionReader(f).loadBeanDefinitions(new ClassPathResource(THROWS_ADVICE_CONTEXT, CLASS));
|
||||
MyThrowsHandler th = (MyThrowsHandler) f.getBean("throwsAdvice");
|
||||
@@ -463,19 +464,19 @@ class ProxyFactoryBeanTests {
|
||||
// TODO put in sep file to check quality of error message
|
||||
/*
|
||||
@Test
|
||||
void testNoInterceptorNamesWithoutTarget() {
|
||||
void noInterceptorNamesWithoutTarget() {
|
||||
assertThatExceptionOfType(AopConfigurationException.class).as("Should require interceptor names").isThrownBy(() ->
|
||||
ITestBean tb = (ITestBean) factory.getBean("noInterceptorNamesWithoutTarget"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testNoInterceptorNamesWithTarget() {
|
||||
void noInterceptorNamesWithTarget() {
|
||||
ITestBean tb = (ITestBean) factory.getBean("noInterceptorNamesWithoutTarget");
|
||||
}
|
||||
*/
|
||||
|
||||
@Test
|
||||
void testEmptyInterceptorNames() {
|
||||
void emptyInterceptorNames() {
|
||||
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
|
||||
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(new ClassPathResource(INVALID_CONTEXT, CLASS));
|
||||
assertThat(bf.getBean("emptyInterceptorNames")).isInstanceOf(ITestBean.class);
|
||||
@@ -486,7 +487,7 @@ class ProxyFactoryBeanTests {
|
||||
* Globals must be followed by a target.
|
||||
*/
|
||||
@Test
|
||||
void testGlobalsWithoutTarget() {
|
||||
void globalsWithoutTarget() {
|
||||
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
|
||||
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(new ClassPathResource(INVALID_CONTEXT, CLASS));
|
||||
assertThatExceptionOfType(BeanCreationException.class).as("Should require target name").isThrownBy(() ->
|
||||
@@ -501,7 +502,7 @@ class ProxyFactoryBeanTests {
|
||||
* to be included in proxiedInterface [].
|
||||
*/
|
||||
@Test
|
||||
void testGlobalsCanAddAspectInterfaces() {
|
||||
void globalsCanAddAspectInterfaces() {
|
||||
AddedGlobalInterface agi = (AddedGlobalInterface) factory.getBean("autoInvoker");
|
||||
assertThat(agi.globalsAdded()).isEqualTo(-1);
|
||||
|
||||
@@ -520,7 +521,7 @@ class ProxyFactoryBeanTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSerializableSingletonProxy() throws Exception {
|
||||
void serializableSingletonProxy() throws Exception {
|
||||
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
|
||||
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(new ClassPathResource(SERIALIZATION_CONTEXT, CLASS));
|
||||
Person p = (Person) bf.getBean("serializableSingleton");
|
||||
@@ -543,7 +544,7 @@ class ProxyFactoryBeanTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSerializablePrototypeProxy() throws Exception {
|
||||
void serializablePrototypeProxy() throws Exception {
|
||||
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
|
||||
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(new ClassPathResource(SERIALIZATION_CONTEXT, CLASS));
|
||||
Person p = (Person) bf.getBean("serializablePrototype");
|
||||
@@ -555,7 +556,7 @@ class ProxyFactoryBeanTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSerializableSingletonProxyFactoryBean() throws Exception {
|
||||
void serializableSingletonProxyFactoryBean() throws Exception {
|
||||
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
|
||||
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(new ClassPathResource(SERIALIZATION_CONTEXT, CLASS));
|
||||
Person p = (Person) bf.getBean("serializableSingleton");
|
||||
@@ -568,7 +569,7 @@ class ProxyFactoryBeanTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testProxyNotSerializableBecauseOfAdvice() throws Exception {
|
||||
void proxyNotSerializableBecauseOfAdvice() throws Exception {
|
||||
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
|
||||
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(new ClassPathResource(SERIALIZATION_CONTEXT, CLASS));
|
||||
Person p = (Person) bf.getBean("interceptorNotSerializableSingleton");
|
||||
@@ -576,7 +577,7 @@ class ProxyFactoryBeanTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testPrototypeAdvisor() {
|
||||
void prototypeAdvisor() {
|
||||
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
|
||||
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(new ClassPathResource(CONTEXT, CLASS));
|
||||
|
||||
@@ -597,7 +598,7 @@ class ProxyFactoryBeanTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testPrototypeInterceptorSingletonTarget() {
|
||||
void prototypeInterceptorSingletonTarget() {
|
||||
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
|
||||
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(new ClassPathResource(CONTEXT, CLASS));
|
||||
|
||||
@@ -622,14 +623,14 @@ class ProxyFactoryBeanTests {
|
||||
* Checks for correct use of getType() by bean factory.
|
||||
*/
|
||||
@Test
|
||||
void testInnerBeanTargetUsingAutowiring() {
|
||||
void innerBeanTargetUsingAutowiring() {
|
||||
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
|
||||
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(new ClassPathResource(AUTOWIRING_CONTEXT, CLASS));
|
||||
bf.getBean("testBean");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFrozenFactoryBean() {
|
||||
void frozenFactoryBean() {
|
||||
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
|
||||
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(new ClassPathResource(FROZEN_CONTEXT, CLASS));
|
||||
|
||||
@@ -638,7 +639,7 @@ class ProxyFactoryBeanTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testDetectsInterfaces() {
|
||||
void detectsInterfaces() {
|
||||
ProxyFactoryBean fb = new ProxyFactoryBean();
|
||||
fb.setTarget(new TestBean());
|
||||
fb.addAdvice(new DebugInterceptor());
|
||||
@@ -649,7 +650,7 @@ class ProxyFactoryBeanTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testWithInterceptorNames() {
|
||||
void withInterceptorNames() {
|
||||
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
|
||||
bf.registerSingleton("debug", new DebugInterceptor());
|
||||
|
||||
@@ -663,7 +664,7 @@ class ProxyFactoryBeanTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testWithLateInterceptorNames() {
|
||||
void withLateInterceptorNames() {
|
||||
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
|
||||
bf.registerSingleton("debug", new DebugInterceptor());
|
||||
|
||||
|
||||
+11
-11
@@ -71,7 +71,7 @@ class CommonsPool2TargetSourceTests {
|
||||
this.beanFactory.destroySingletons();
|
||||
}
|
||||
|
||||
private void testFunctionality(String name) {
|
||||
private void assertFunctionality(String name) {
|
||||
SideEffectBean pooled = (SideEffectBean) beanFactory.getBean(name);
|
||||
assertThat(pooled.getCount()).isEqualTo(INITIAL_COUNT);
|
||||
pooled.doWork();
|
||||
@@ -85,17 +85,17 @@ class CommonsPool2TargetSourceTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFunctionality() {
|
||||
testFunctionality("pooled");
|
||||
void functionality() {
|
||||
assertFunctionality("pooled");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFunctionalityWithNoInterceptors() {
|
||||
testFunctionality("pooledNoInterceptors");
|
||||
void functionalityWithNoInterceptors() {
|
||||
assertFunctionality("pooledNoInterceptors");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testConfigMixin() {
|
||||
void configMixin() {
|
||||
SideEffectBean pooled = (SideEffectBean) beanFactory.getBean("pooledWithMixin");
|
||||
assertThat(pooled.getCount()).isEqualTo(INITIAL_COUNT);
|
||||
PoolingConfig conf = (PoolingConfig) beanFactory.getBean("pooledWithMixin");
|
||||
@@ -110,7 +110,7 @@ class CommonsPool2TargetSourceTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testTargetSourceSerializableWithoutConfigMixin() throws Exception {
|
||||
void targetSourceSerializableWithoutConfigMixin() throws Exception {
|
||||
CommonsPool2TargetSource cpts = (CommonsPool2TargetSource) beanFactory.getBean("personPoolTargetSource");
|
||||
|
||||
SingletonTargetSource serialized = SerializationTestUtils.serializeAndDeserialize(cpts, SingletonTargetSource.class);
|
||||
@@ -118,7 +118,7 @@ class CommonsPool2TargetSourceTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testProxySerializableWithoutConfigMixin() throws Exception {
|
||||
void proxySerializableWithoutConfigMixin() throws Exception {
|
||||
Person pooled = (Person) beanFactory.getBean("pooledPerson");
|
||||
|
||||
boolean condition1 = ((Advised) pooled).getTargetSource() instanceof CommonsPool2TargetSource;
|
||||
@@ -133,7 +133,7 @@ class CommonsPool2TargetSourceTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testHitMaxSize() throws Exception {
|
||||
void hitMaxSize() throws Exception {
|
||||
int maxSize = 10;
|
||||
|
||||
CommonsPool2TargetSource targetSource = new CommonsPool2TargetSource();
|
||||
@@ -164,7 +164,7 @@ class CommonsPool2TargetSourceTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testHitMaxSizeLoadedFromContext() throws Exception {
|
||||
void hitMaxSizeLoadedFromContext() throws Exception {
|
||||
Advised person = (Advised) beanFactory.getBean("maxSizePooledPerson");
|
||||
CommonsPool2TargetSource targetSource = (CommonsPool2TargetSource) person.getTargetSource();
|
||||
|
||||
@@ -192,7 +192,7 @@ class CommonsPool2TargetSourceTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSetWhenExhaustedAction() {
|
||||
void setWhenExhaustedAction() {
|
||||
CommonsPool2TargetSource targetSource = new CommonsPool2TargetSource();
|
||||
targetSource.setBlockWhenExhausted(true);
|
||||
assertThat(targetSource.isBlockWhenExhausted()).isTrue();
|
||||
|
||||
+2
-2
@@ -49,7 +49,7 @@ class LookupMethodWrappedByCglibProxyTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testAutoProxiedLookup() {
|
||||
void autoProxiedLookup() {
|
||||
OverloadLookup olup = (OverloadLookup) applicationContext.getBean("autoProxiedOverload");
|
||||
ITestBean jenny = olup.newTestBean();
|
||||
assertThat(jenny.getName()).isEqualTo("Jenny");
|
||||
@@ -58,7 +58,7 @@ class LookupMethodWrappedByCglibProxyTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testRegularlyProxiedLookup() {
|
||||
void regularlyProxiedLookup() {
|
||||
OverloadLookup olup = (OverloadLookup) applicationContext.getBean("regularlyProxiedOverload");
|
||||
ITestBean jenny = olup.newTestBean();
|
||||
assertThat(jenny.getName()).isEqualTo("Jenny");
|
||||
|
||||
+13
-13
@@ -53,7 +53,7 @@ class QualifierAnnotationTests {
|
||||
|
||||
|
||||
@Test
|
||||
void testNonQualifiedFieldFails() {
|
||||
void nonQualifiedFieldFails() {
|
||||
StaticApplicationContext context = new StaticApplicationContext();
|
||||
BeanDefinitionReader reader = new XmlBeanDefinitionReader(context);
|
||||
reader.loadBeanDefinitions(CONFIG_LOCATION);
|
||||
@@ -65,7 +65,7 @@ class QualifierAnnotationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testQualifiedByValue() {
|
||||
void qualifiedByValue() {
|
||||
StaticApplicationContext context = new StaticApplicationContext();
|
||||
BeanDefinitionReader reader = new XmlBeanDefinitionReader(context);
|
||||
reader.loadBeanDefinitions(CONFIG_LOCATION);
|
||||
@@ -77,7 +77,7 @@ class QualifierAnnotationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testQualifiedByParentValue() {
|
||||
void qualifiedByParentValue() {
|
||||
StaticApplicationContext parent = new StaticApplicationContext();
|
||||
GenericBeanDefinition parentLarry = new GenericBeanDefinition();
|
||||
parentLarry.setBeanClass(Person.class);
|
||||
@@ -102,7 +102,7 @@ class QualifierAnnotationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testQualifiedByBeanName() {
|
||||
void qualifiedByBeanName() {
|
||||
StaticApplicationContext context = new StaticApplicationContext();
|
||||
BeanDefinitionReader reader = new XmlBeanDefinitionReader(context);
|
||||
reader.loadBeanDefinitions(CONFIG_LOCATION);
|
||||
@@ -116,7 +116,7 @@ class QualifierAnnotationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testQualifiedByFieldName() {
|
||||
void qualifiedByFieldName() {
|
||||
StaticApplicationContext context = new StaticApplicationContext();
|
||||
BeanDefinitionReader reader = new XmlBeanDefinitionReader(context);
|
||||
reader.loadBeanDefinitions(CONFIG_LOCATION);
|
||||
@@ -128,7 +128,7 @@ class QualifierAnnotationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testQualifiedByParameterName() {
|
||||
void qualifiedByParameterName() {
|
||||
StaticApplicationContext context = new StaticApplicationContext();
|
||||
BeanDefinitionReader reader = new XmlBeanDefinitionReader(context);
|
||||
reader.loadBeanDefinitions(CONFIG_LOCATION);
|
||||
@@ -140,7 +140,7 @@ class QualifierAnnotationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testQualifiedByAlias() {
|
||||
void qualifiedByAlias() {
|
||||
StaticApplicationContext context = new StaticApplicationContext();
|
||||
BeanDefinitionReader reader = new XmlBeanDefinitionReader(context);
|
||||
reader.loadBeanDefinitions(CONFIG_LOCATION);
|
||||
@@ -152,7 +152,7 @@ class QualifierAnnotationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testQualifiedByAnnotation() {
|
||||
void qualifiedByAnnotation() {
|
||||
StaticApplicationContext context = new StaticApplicationContext();
|
||||
BeanDefinitionReader reader = new XmlBeanDefinitionReader(context);
|
||||
reader.loadBeanDefinitions(CONFIG_LOCATION);
|
||||
@@ -164,7 +164,7 @@ class QualifierAnnotationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testQualifiedByCustomValue() {
|
||||
void qualifiedByCustomValue() {
|
||||
StaticApplicationContext context = new StaticApplicationContext();
|
||||
BeanDefinitionReader reader = new XmlBeanDefinitionReader(context);
|
||||
reader.loadBeanDefinitions(CONFIG_LOCATION);
|
||||
@@ -176,7 +176,7 @@ class QualifierAnnotationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testQualifiedByAnnotationValue() {
|
||||
void qualifiedByAnnotationValue() {
|
||||
StaticApplicationContext context = new StaticApplicationContext();
|
||||
BeanDefinitionReader reader = new XmlBeanDefinitionReader(context);
|
||||
reader.loadBeanDefinitions(CONFIG_LOCATION);
|
||||
@@ -188,7 +188,7 @@ class QualifierAnnotationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testQualifiedByAttributesFailsWithoutCustomQualifierRegistered() {
|
||||
void qualifiedByAttributesFailsWithoutCustomQualifierRegistered() {
|
||||
StaticApplicationContext context = new StaticApplicationContext();
|
||||
BeanDefinitionReader reader = new XmlBeanDefinitionReader(context);
|
||||
reader.loadBeanDefinitions(CONFIG_LOCATION);
|
||||
@@ -200,7 +200,7 @@ class QualifierAnnotationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testQualifiedByAttributesWithCustomQualifierRegistered() {
|
||||
void qualifiedByAttributesWithCustomQualifierRegistered() {
|
||||
StaticApplicationContext context = new StaticApplicationContext();
|
||||
BeanDefinitionReader reader = new XmlBeanDefinitionReader(context);
|
||||
reader.loadBeanDefinitions(CONFIG_LOCATION);
|
||||
@@ -217,7 +217,7 @@ class QualifierAnnotationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testInterfaceWithOneQualifiedFactoryAndOneQualifiedBean() {
|
||||
void interfaceWithOneQualifiedFactoryAndOneQualifiedBean() {
|
||||
StaticApplicationContext context = new StaticApplicationContext();
|
||||
BeanDefinitionReader reader = new XmlBeanDefinitionReader(context);
|
||||
reader.loadBeanDefinitions(CONFIG_LOCATION);
|
||||
|
||||
+9
-9
@@ -98,19 +98,19 @@ class CustomNamespaceHandlerTests {
|
||||
|
||||
|
||||
@Test
|
||||
void testSimpleParser() {
|
||||
void simpleParser() {
|
||||
TestBean bean = (TestBean) this.beanFactory.getBean("testBean");
|
||||
assertTestBean(bean);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSimpleDecorator() {
|
||||
void simpleDecorator() {
|
||||
TestBean bean = (TestBean) this.beanFactory.getBean("customisedTestBean");
|
||||
assertTestBean(bean);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testProxyingDecorator() {
|
||||
void proxyingDecorator() {
|
||||
ITestBean bean = (ITestBean) this.beanFactory.getBean("debuggingTestBean");
|
||||
assertTestBean(bean);
|
||||
assertThat(AopUtils.isAopProxy(bean)).isTrue();
|
||||
@@ -120,7 +120,7 @@ class CustomNamespaceHandlerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testProxyingDecoratorNoInstance() {
|
||||
void proxyingDecoratorNoInstance() {
|
||||
String[] beanNames = this.beanFactory.getBeanNamesForType(ApplicationListener.class);
|
||||
assertThat(Arrays.asList(beanNames)).contains("debuggingTestBeanNoInstance");
|
||||
assertThat(this.beanFactory.getType("debuggingTestBeanNoInstance")).isEqualTo(ApplicationListener.class);
|
||||
@@ -131,7 +131,7 @@ class CustomNamespaceHandlerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testChainedDecorators() {
|
||||
void chainedDecorators() {
|
||||
ITestBean bean = (ITestBean) this.beanFactory.getBean("chainedTestBean");
|
||||
assertTestBean(bean);
|
||||
assertThat(AopUtils.isAopProxy(bean)).isTrue();
|
||||
@@ -142,27 +142,27 @@ class CustomNamespaceHandlerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testDecorationViaAttribute() {
|
||||
void decorationViaAttribute() {
|
||||
BeanDefinition beanDefinition = this.beanFactory.getBeanDefinition("decorateWithAttribute");
|
||||
assertThat(beanDefinition.getAttribute("objectName")).isEqualTo("foo");
|
||||
}
|
||||
|
||||
@Test // SPR-2728
|
||||
public void testCustomElementNestedWithinUtilList() {
|
||||
void customElementNestedWithinUtilList() {
|
||||
List<?> things = (List<?>) this.beanFactory.getBean("list.of.things");
|
||||
assertThat(things).isNotNull();
|
||||
assertThat(things).hasSize(2);
|
||||
}
|
||||
|
||||
@Test // SPR-2728
|
||||
public void testCustomElementNestedWithinUtilSet() {
|
||||
void customElementNestedWithinUtilSet() {
|
||||
Set<?> things = (Set<?>) this.beanFactory.getBean("set.of.things");
|
||||
assertThat(things).isNotNull();
|
||||
assertThat(things).hasSize(2);
|
||||
}
|
||||
|
||||
@Test // SPR-2728
|
||||
public void testCustomElementNestedWithinUtilMap() {
|
||||
void customElementNestedWithinUtilMap() {
|
||||
Map<?, ?> things = (Map<?, ?>) this.beanFactory.getBean("map.of.things");
|
||||
assertThat(things).isNotNull();
|
||||
assertThat(things).hasSize(2);
|
||||
|
||||
+5
-5
@@ -35,14 +35,14 @@ class NoOpCacheManagerTests {
|
||||
private final CacheManager manager = new NoOpCacheManager();
|
||||
|
||||
@Test
|
||||
void testGetCache() {
|
||||
void getCache() {
|
||||
Cache cache = this.manager.getCache("bucket");
|
||||
assertThat(cache).isNotNull();
|
||||
assertThat(this.manager.getCache("bucket")).isSameAs(cache);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testNoOpCache() {
|
||||
void noOpCache() {
|
||||
String name = createRandomKey();
|
||||
Cache cache = this.manager.getCache(name);
|
||||
assertThat(cache.getName()).isEqualTo(name);
|
||||
@@ -54,7 +54,7 @@ class NoOpCacheManagerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCacheName() {
|
||||
void cacheName() {
|
||||
String name = "bucket";
|
||||
assertThat(this.manager.getCacheNames()).doesNotContain(name);
|
||||
this.manager.getCache(name);
|
||||
@@ -62,7 +62,7 @@ class NoOpCacheManagerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCacheCallable() {
|
||||
void cacheCallable() {
|
||||
String name = createRandomKey();
|
||||
Cache cache = this.manager.getCache(name);
|
||||
Object returnValue = new Object();
|
||||
@@ -71,7 +71,7 @@ class NoOpCacheManagerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCacheGetCallableFail() {
|
||||
void cacheGetCallableFail() {
|
||||
Cache cache = this.manager.getCache(createRandomKey());
|
||||
String key = createRandomKey();
|
||||
try {
|
||||
|
||||
+3
-3
@@ -29,7 +29,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
class ConcurrentMapCacheManagerTests {
|
||||
|
||||
@Test
|
||||
void testDynamicMode() {
|
||||
void dynamicMode() {
|
||||
ConcurrentMapCacheManager cm = new ConcurrentMapCacheManager();
|
||||
Cache cache1 = cm.getCache("c1");
|
||||
assertThat(cache1).isInstanceOf(ConcurrentMapCache.class);
|
||||
@@ -75,7 +75,7 @@ class ConcurrentMapCacheManagerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testStaticMode() {
|
||||
void staticMode() {
|
||||
ConcurrentMapCacheManager cm = new ConcurrentMapCacheManager("c1", "c2");
|
||||
Cache cache1 = cm.getCache("c1");
|
||||
assertThat(cache1).isInstanceOf(ConcurrentMapCache.class);
|
||||
@@ -135,7 +135,7 @@ class ConcurrentMapCacheManagerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testChangeStoreByValue() {
|
||||
void changeStoreByValue() {
|
||||
ConcurrentMapCacheManager cm = new ConcurrentMapCacheManager("c1", "c2");
|
||||
assertThat(cm.isStoreByValue()).isFalse();
|
||||
Cache cache1 = cm.getCache("c1");
|
||||
|
||||
Vendored
+4
-4
@@ -73,13 +73,13 @@ class ConcurrentMapCacheTests extends AbstractValueAdaptingCacheTests<Concurrent
|
||||
|
||||
|
||||
@Test
|
||||
void testIsStoreByReferenceByDefault() {
|
||||
void isStoreByReferenceByDefault() {
|
||||
assertThat(this.cache.isStoreByValue()).isFalse();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Test
|
||||
void testSerializer() {
|
||||
void serializer() {
|
||||
ConcurrentMapCache serializeCache = createCacheWithStoreByValue();
|
||||
assertThat(serializeCache.isStoreByValue()).isTrue();
|
||||
|
||||
@@ -93,7 +93,7 @@ class ConcurrentMapCacheTests extends AbstractValueAdaptingCacheTests<Concurrent
|
||||
}
|
||||
|
||||
@Test
|
||||
void testNonSerializableContent() {
|
||||
void nonSerializableContent() {
|
||||
ConcurrentMapCache serializeCache = createCacheWithStoreByValue();
|
||||
|
||||
assertThatIllegalArgumentException().isThrownBy(() ->
|
||||
@@ -104,7 +104,7 @@ class ConcurrentMapCacheTests extends AbstractValueAdaptingCacheTests<Concurrent
|
||||
}
|
||||
|
||||
@Test
|
||||
void testInvalidSerializedContent() {
|
||||
void invalidSerializedContent() {
|
||||
ConcurrentMapCache serializeCache = createCacheWithStoreByValue();
|
||||
|
||||
String key = createRandomKey();
|
||||
|
||||
Vendored
+2
-2
@@ -40,7 +40,7 @@ class AnnotationNamespaceDrivenTests extends AbstractCacheAnnotationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testKeyStrategy() {
|
||||
void keyStrategy() {
|
||||
CacheInterceptor ci = this.ctx.getBean(
|
||||
"org.springframework.cache.interceptor.CacheInterceptor#0", CacheInterceptor.class);
|
||||
assertThat(ci.getKeyGenerator()).isSameAs(this.ctx.getBean("keyGenerator"));
|
||||
@@ -67,7 +67,7 @@ class AnnotationNamespaceDrivenTests extends AbstractCacheAnnotationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCacheErrorHandler() {
|
||||
void cacheErrorHandler() {
|
||||
CacheInterceptor ci = this.ctx.getBean(
|
||||
"org.springframework.cache.interceptor.CacheInterceptor#0", CacheInterceptor.class);
|
||||
assertThat(ci.getErrorHandler()).isSameAs(this.ctx.getBean("errorHandler", CacheErrorHandler.class));
|
||||
|
||||
Vendored
+1
-1
@@ -38,7 +38,7 @@ class CacheAdviceNamespaceTests extends AbstractCacheAnnotationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testKeyStrategy() {
|
||||
void keyStrategy() {
|
||||
CacheInterceptor bean = this.ctx.getBean("cacheAdviceClass", CacheInterceptor.class);
|
||||
assertThat(bean.getKeyGenerator()).isSameAs(this.ctx.getBean("keyGenerator"));
|
||||
}
|
||||
|
||||
Vendored
+1
-1
@@ -86,7 +86,7 @@ class EnableCachingIntegrationTests {
|
||||
}
|
||||
|
||||
@Test // gh-31238
|
||||
public void cglibProxyClassIsCachedAcrossApplicationContexts() {
|
||||
void cglibProxyClassIsCachedAcrossApplicationContexts() {
|
||||
ConfigurableApplicationContext ctx;
|
||||
|
||||
// Round #1
|
||||
|
||||
spring-context/src/test/java/org/springframework/cache/config/ExpressionCachingIntegrationTests.java
Vendored
+1
-1
@@ -35,7 +35,7 @@ class ExpressionCachingIntegrationTests {
|
||||
|
||||
@Test // SPR-11692
|
||||
@SuppressWarnings("unchecked")
|
||||
public void expressionIsCacheBasedOnActualMethod() {
|
||||
void expressionIsCacheBasedOnActualMethod() {
|
||||
ConfigurableApplicationContext context =
|
||||
new AnnotationConfigApplicationContext(SharedConfig.class, Spr11692Config.class);
|
||||
|
||||
|
||||
Vendored
+4
-4
@@ -95,7 +95,7 @@ class CacheErrorHandlerTests {
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void getSyncFail() {
|
||||
void getSyncFail() {
|
||||
UnsupportedOperationException exception = new UnsupportedOperationException("Test exception on get");
|
||||
willThrow(exception).given(this.cache).get(eq(0L), any(Callable.class));
|
||||
|
||||
@@ -106,7 +106,7 @@ class CacheErrorHandlerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getCompletableFutureFail() {
|
||||
void getCompletableFutureFail() {
|
||||
UnsupportedOperationException exception = new UnsupportedOperationException("Test exception on get");
|
||||
willThrow(exception).given(this.cache).retrieve(eq(0L));
|
||||
|
||||
@@ -117,7 +117,7 @@ class CacheErrorHandlerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getMonoFail() {
|
||||
void getMonoFail() {
|
||||
UnsupportedOperationException exception = new UnsupportedOperationException("Test exception on get");
|
||||
willThrow(exception).given(this.cache).retrieve(eq(0L));
|
||||
|
||||
@@ -128,7 +128,7 @@ class CacheErrorHandlerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getFluxFail() {
|
||||
void getFluxFail() {
|
||||
UnsupportedOperationException exception = new UnsupportedOperationException("Test exception on get");
|
||||
willThrow(exception).given(this.cache).retrieve(eq(0L));
|
||||
|
||||
|
||||
+2
-2
@@ -61,7 +61,7 @@ class CacheOperationExpressionEvaluatorTests {
|
||||
|
||||
|
||||
@Test
|
||||
void testMultipleCachingSource() {
|
||||
void multipleCachingSource() {
|
||||
Collection<CacheOperation> ops = getOps("multipleCaching");
|
||||
assertThat(ops).hasSize(2);
|
||||
Iterator<CacheOperation> it = ops.iterator();
|
||||
@@ -76,7 +76,7 @@ class CacheOperationExpressionEvaluatorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testMultipleCachingEval() {
|
||||
void multipleCachingEval() {
|
||||
AnnotatedClass target = new AnnotatedClass();
|
||||
Method method = ReflectionUtils.findMethod(
|
||||
AnnotatedClass.class, "multipleCaching", Object.class, Object.class);
|
||||
|
||||
+30
-30
@@ -64,7 +64,7 @@ class ClassPathBeanDefinitionScannerTests {
|
||||
|
||||
|
||||
@Test
|
||||
void testSimpleScanWithDefaultFiltersAndPostProcessors() {
|
||||
void simpleScanWithDefaultFiltersAndPostProcessors() {
|
||||
GenericApplicationContext context = new GenericApplicationContext();
|
||||
ClassPathBeanDefinitionScanner scanner = new ClassPathBeanDefinitionScanner(context);
|
||||
int beanCount = scanner.scan(BASE_PACKAGE);
|
||||
@@ -91,7 +91,7 @@ class ClassPathBeanDefinitionScannerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSimpleScanWithDefaultFiltersAndPrimaryLazyBean() {
|
||||
void simpleScanWithDefaultFiltersAndPrimaryLazyBean() {
|
||||
GenericApplicationContext context = new GenericApplicationContext();
|
||||
ClassPathBeanDefinitionScanner scanner = new ClassPathBeanDefinitionScanner(context);
|
||||
scanner.scan(BASE_PACKAGE);
|
||||
@@ -113,7 +113,7 @@ class ClassPathBeanDefinitionScannerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSimpleScanWithIndex() {
|
||||
void simpleScanWithIndex() {
|
||||
GenericApplicationContext context = new GenericApplicationContext();
|
||||
context.setClassLoader(CandidateComponentsTestClassLoader.index(
|
||||
ClassPathScanningCandidateComponentProviderTests.class.getClassLoader(),
|
||||
@@ -132,7 +132,7 @@ class ClassPathBeanDefinitionScannerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testDoubleScan() {
|
||||
void doubleScan() {
|
||||
GenericApplicationContext context = new GenericApplicationContext();
|
||||
ClassPathBeanDefinitionScanner scanner = new ClassPathBeanDefinitionScanner(context);
|
||||
int beanCount = scanner.scan(BASE_PACKAGE);
|
||||
@@ -157,7 +157,7 @@ class ClassPathBeanDefinitionScannerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testDoubleScanWithIndex() {
|
||||
void doubleScanWithIndex() {
|
||||
GenericApplicationContext context = new GenericApplicationContext();
|
||||
context.setClassLoader(CandidateComponentsTestClassLoader.index(
|
||||
ClassPathScanningCandidateComponentProviderTests.class.getClassLoader(),
|
||||
@@ -186,7 +186,7 @@ class ClassPathBeanDefinitionScannerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSimpleScanWithDefaultFiltersAndNoPostProcessors() {
|
||||
void simpleScanWithDefaultFiltersAndNoPostProcessors() {
|
||||
GenericApplicationContext context = new GenericApplicationContext();
|
||||
ClassPathBeanDefinitionScanner scanner = new ClassPathBeanDefinitionScanner(context);
|
||||
scanner.setIncludeAnnotationConfig(false);
|
||||
@@ -201,7 +201,7 @@ class ClassPathBeanDefinitionScannerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSimpleScanWithDefaultFiltersAndOverridingBean() {
|
||||
void simpleScanWithDefaultFiltersAndOverridingBean() {
|
||||
GenericApplicationContext context = new GenericApplicationContext();
|
||||
context.setAllowBeanDefinitionOverriding(true);
|
||||
context.registerBeanDefinition("stubFooDao", new RootBeanDefinition(TestBean.class));
|
||||
@@ -213,7 +213,7 @@ class ClassPathBeanDefinitionScannerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSimpleScanWithDefaultFiltersAndOverridingBeanNotAllowed() {
|
||||
void simpleScanWithDefaultFiltersAndOverridingBeanNotAllowed() {
|
||||
GenericApplicationContext context = new GenericApplicationContext();
|
||||
context.getDefaultListableBeanFactory().setAllowBeanDefinitionOverriding(false);
|
||||
context.registerBeanDefinition("stubFooDao", new RootBeanDefinition(TestBean.class));
|
||||
@@ -226,7 +226,7 @@ class ClassPathBeanDefinitionScannerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSimpleScanWithDefaultFiltersAndOverridingBeanAcceptedForSameBeanClass() {
|
||||
void simpleScanWithDefaultFiltersAndOverridingBeanAcceptedForSameBeanClass() {
|
||||
GenericApplicationContext context = new GenericApplicationContext();
|
||||
context.getDefaultListableBeanFactory().setAllowBeanDefinitionOverriding(false);
|
||||
context.registerBeanDefinition("stubFooDao", new RootBeanDefinition(StubFooDao.class));
|
||||
@@ -238,7 +238,7 @@ class ClassPathBeanDefinitionScannerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSimpleScanWithDefaultFiltersAndDefaultBeanNameClash() {
|
||||
void simpleScanWithDefaultFiltersAndDefaultBeanNameClash() {
|
||||
GenericApplicationContext context = new GenericApplicationContext();
|
||||
ClassPathBeanDefinitionScanner scanner = new ClassPathBeanDefinitionScanner(context);
|
||||
scanner.setIncludeAnnotationConfig(false);
|
||||
@@ -250,7 +250,7 @@ class ClassPathBeanDefinitionScannerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSimpleScanWithDefaultFiltersAndOverriddenEqualNamedBean() {
|
||||
void simpleScanWithDefaultFiltersAndOverriddenEqualNamedBean() {
|
||||
GenericApplicationContext context = new GenericApplicationContext();
|
||||
context.registerBeanDefinition("myNamedDao", new RootBeanDefinition(NamedStubDao.class));
|
||||
int initialBeanCount = context.getBeanDefinitionCount();
|
||||
@@ -268,7 +268,7 @@ class ClassPathBeanDefinitionScannerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSimpleScanWithDefaultFiltersAndOverriddenCompatibleNamedBean() {
|
||||
void simpleScanWithDefaultFiltersAndOverriddenCompatibleNamedBean() {
|
||||
GenericApplicationContext context = new GenericApplicationContext();
|
||||
RootBeanDefinition bd = new RootBeanDefinition(NamedStubDao.class);
|
||||
bd.setScope(BeanDefinition.SCOPE_PROTOTYPE);
|
||||
@@ -288,7 +288,7 @@ class ClassPathBeanDefinitionScannerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSimpleScanWithDefaultFiltersAndSameBeanTwice() {
|
||||
void simpleScanWithDefaultFiltersAndSameBeanTwice() {
|
||||
GenericApplicationContext context = new GenericApplicationContext();
|
||||
ClassPathBeanDefinitionScanner scanner = new ClassPathBeanDefinitionScanner(context);
|
||||
scanner.setIncludeAnnotationConfig(false);
|
||||
@@ -298,7 +298,7 @@ class ClassPathBeanDefinitionScannerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSimpleScanWithDefaultFiltersAndSpecifiedBeanNameClash() {
|
||||
void simpleScanWithDefaultFiltersAndSpecifiedBeanNameClash() {
|
||||
GenericApplicationContext context = new GenericApplicationContext();
|
||||
ClassPathBeanDefinitionScanner scanner = new ClassPathBeanDefinitionScanner(context);
|
||||
scanner.setIncludeAnnotationConfig(false);
|
||||
@@ -311,7 +311,7 @@ class ClassPathBeanDefinitionScannerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCustomIncludeFilterWithoutDefaultsButIncludingPostProcessors() {
|
||||
void customIncludeFilterWithoutDefaultsButIncludingPostProcessors() {
|
||||
GenericApplicationContext context = new GenericApplicationContext();
|
||||
ClassPathBeanDefinitionScanner scanner = new ClassPathBeanDefinitionScanner(context, false);
|
||||
scanner.addIncludeFilter(new AnnotationTypeFilter(CustomComponent.class));
|
||||
@@ -326,7 +326,7 @@ class ClassPathBeanDefinitionScannerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCustomIncludeFilterWithoutDefaultsAndNoPostProcessors() {
|
||||
void customIncludeFilterWithoutDefaultsAndNoPostProcessors() {
|
||||
GenericApplicationContext context = new GenericApplicationContext();
|
||||
ClassPathBeanDefinitionScanner scanner = new ClassPathBeanDefinitionScanner(context, false);
|
||||
scanner.addIncludeFilter(new AnnotationTypeFilter(CustomComponent.class));
|
||||
@@ -346,7 +346,7 @@ class ClassPathBeanDefinitionScannerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCustomIncludeFilterAndDefaults() {
|
||||
void customIncludeFilterAndDefaults() {
|
||||
GenericApplicationContext context = new GenericApplicationContext();
|
||||
ClassPathBeanDefinitionScanner scanner = new ClassPathBeanDefinitionScanner(context, true);
|
||||
scanner.addIncludeFilter(new AnnotationTypeFilter(CustomComponent.class));
|
||||
@@ -366,7 +366,7 @@ class ClassPathBeanDefinitionScannerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCustomAnnotationExcludeFilterAndDefaults() {
|
||||
void customAnnotationExcludeFilterAndDefaults() {
|
||||
GenericApplicationContext context = new GenericApplicationContext();
|
||||
ClassPathBeanDefinitionScanner scanner = new ClassPathBeanDefinitionScanner(context, true);
|
||||
scanner.addExcludeFilter(new AnnotationTypeFilter(Aspect.class));
|
||||
@@ -384,7 +384,7 @@ class ClassPathBeanDefinitionScannerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCustomAssignableTypeExcludeFilterAndDefaults() {
|
||||
void customAssignableTypeExcludeFilterAndDefaults() {
|
||||
GenericApplicationContext context = new GenericApplicationContext();
|
||||
ClassPathBeanDefinitionScanner scanner = new ClassPathBeanDefinitionScanner(context, true);
|
||||
scanner.addExcludeFilter(new AssignableTypeFilter(FooService.class));
|
||||
@@ -403,7 +403,7 @@ class ClassPathBeanDefinitionScannerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCustomAssignableTypeExcludeFilterAndDefaultsWithoutPostProcessors() {
|
||||
void customAssignableTypeExcludeFilterAndDefaultsWithoutPostProcessors() {
|
||||
GenericApplicationContext context = new GenericApplicationContext();
|
||||
ClassPathBeanDefinitionScanner scanner = new ClassPathBeanDefinitionScanner(context, true);
|
||||
scanner.setIncludeAnnotationConfig(false);
|
||||
@@ -421,7 +421,7 @@ class ClassPathBeanDefinitionScannerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testMultipleCustomExcludeFiltersAndDefaults() {
|
||||
void multipleCustomExcludeFiltersAndDefaults() {
|
||||
GenericApplicationContext context = new GenericApplicationContext();
|
||||
ClassPathBeanDefinitionScanner scanner = new ClassPathBeanDefinitionScanner(context, true);
|
||||
scanner.addExcludeFilter(new AssignableTypeFilter(FooService.class));
|
||||
@@ -441,7 +441,7 @@ class ClassPathBeanDefinitionScannerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCustomBeanNameGenerator() {
|
||||
void customBeanNameGenerator() {
|
||||
GenericApplicationContext context = new GenericApplicationContext();
|
||||
ClassPathBeanDefinitionScanner scanner = new ClassPathBeanDefinitionScanner(context);
|
||||
scanner.setBeanNameGenerator(new TestBeanNameGenerator());
|
||||
@@ -461,7 +461,7 @@ class ClassPathBeanDefinitionScannerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testMultipleBasePackagesWithDefaultsOnly() {
|
||||
void multipleBasePackagesWithDefaultsOnly() {
|
||||
GenericApplicationContext singlePackageContext = new GenericApplicationContext();
|
||||
ClassPathBeanDefinitionScanner singlePackageScanner = new ClassPathBeanDefinitionScanner(singlePackageContext);
|
||||
GenericApplicationContext multiPackageContext = new GenericApplicationContext();
|
||||
@@ -473,7 +473,7 @@ class ClassPathBeanDefinitionScannerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testMultipleScanCalls() {
|
||||
void multipleScanCalls() {
|
||||
GenericApplicationContext context = new GenericApplicationContext();
|
||||
ClassPathBeanDefinitionScanner scanner = new ClassPathBeanDefinitionScanner(context);
|
||||
int initialBeanCount = context.getBeanDefinitionCount();
|
||||
@@ -485,7 +485,7 @@ class ClassPathBeanDefinitionScannerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testBeanAutowiredWithAnnotationConfigEnabled() {
|
||||
void beanAutowiredWithAnnotationConfigEnabled() {
|
||||
GenericApplicationContext context = new GenericApplicationContext();
|
||||
context.registerBeanDefinition("myBf", new RootBeanDefinition(StaticListableBeanFactory.class));
|
||||
ClassPathBeanDefinitionScanner scanner = new ClassPathBeanDefinitionScanner(context);
|
||||
@@ -514,7 +514,7 @@ class ClassPathBeanDefinitionScannerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testBeanNotAutowiredWithAnnotationConfigDisabled() {
|
||||
void beanNotAutowiredWithAnnotationConfigDisabled() {
|
||||
GenericApplicationContext context = new GenericApplicationContext();
|
||||
ClassPathBeanDefinitionScanner scanner = new ClassPathBeanDefinitionScanner(context);
|
||||
scanner.setIncludeAnnotationConfig(false);
|
||||
@@ -534,7 +534,7 @@ class ClassPathBeanDefinitionScannerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testAutowireCandidatePatternMatches() {
|
||||
void autowireCandidatePatternMatches() {
|
||||
GenericApplicationContext context = new GenericApplicationContext();
|
||||
ClassPathBeanDefinitionScanner scanner = new ClassPathBeanDefinitionScanner(context);
|
||||
scanner.setIncludeAnnotationConfig(true);
|
||||
@@ -549,7 +549,7 @@ class ClassPathBeanDefinitionScannerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testAutowireCandidatePatternDoesNotMatch() {
|
||||
void autowireCandidatePatternDoesNotMatch() {
|
||||
GenericApplicationContext context = new GenericApplicationContext();
|
||||
ClassPathBeanDefinitionScanner scanner = new ClassPathBeanDefinitionScanner(context);
|
||||
scanner.setIncludeAnnotationConfig(true);
|
||||
@@ -564,7 +564,7 @@ class ClassPathBeanDefinitionScannerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testWithManualProgrammaticIndex() {
|
||||
void withManualProgrammaticIndex() {
|
||||
// Pre-populating an index in order to replace a runtime scan
|
||||
|
||||
GenericApplicationContext context = new GenericApplicationContext();
|
||||
@@ -589,7 +589,7 @@ class ClassPathBeanDefinitionScannerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testWithDerivedProgrammaticIndex() {
|
||||
void withDerivedProgrammaticIndex() {
|
||||
// Recording an index from a scan (e.g. during refreshForAotProcessing)
|
||||
|
||||
GenericApplicationContext context = new GenericApplicationContext();
|
||||
|
||||
+1
-1
@@ -43,7 +43,7 @@ class ClassPathFactoryBeanDefinitionScannerTests {
|
||||
|
||||
|
||||
@Test
|
||||
void testSingletonScopedFactoryMethod() {
|
||||
void singletonScopedFactoryMethod() {
|
||||
GenericApplicationContext context = new GenericApplicationContext();
|
||||
ClassPathBeanDefinitionScanner scanner = new ClassPathBeanDefinitionScanner(context);
|
||||
|
||||
|
||||
+12
-12
@@ -43,7 +43,7 @@ class ComponentScanParserBeanDefinitionDefaultsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testDefaultLazyInit() {
|
||||
void defaultLazyInit() {
|
||||
GenericApplicationContext context = new GenericApplicationContext();
|
||||
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(context);
|
||||
reader.loadBeanDefinitions(LOCATION_PREFIX + "defaultWithNoOverridesTests.xml");
|
||||
@@ -54,7 +54,7 @@ class ComponentScanParserBeanDefinitionDefaultsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testLazyInitTrue() {
|
||||
void lazyInitTrue() {
|
||||
GenericApplicationContext context = new GenericApplicationContext();
|
||||
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(context);
|
||||
reader.loadBeanDefinitions(LOCATION_PREFIX + "defaultLazyInitTrueTests.xml");
|
||||
@@ -67,7 +67,7 @@ class ComponentScanParserBeanDefinitionDefaultsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testLazyInitFalse() {
|
||||
void lazyInitFalse() {
|
||||
GenericApplicationContext context = new GenericApplicationContext();
|
||||
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(context);
|
||||
reader.loadBeanDefinitions(LOCATION_PREFIX + "defaultLazyInitFalseTests.xml");
|
||||
@@ -78,7 +78,7 @@ class ComponentScanParserBeanDefinitionDefaultsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testDefaultAutowire() {
|
||||
void defaultAutowire() {
|
||||
GenericApplicationContext context = new GenericApplicationContext();
|
||||
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(context);
|
||||
reader.loadBeanDefinitions(LOCATION_PREFIX + "defaultWithNoOverridesTests.xml");
|
||||
@@ -90,7 +90,7 @@ class ComponentScanParserBeanDefinitionDefaultsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testAutowireNo() {
|
||||
void autowireNo() {
|
||||
GenericApplicationContext context = new GenericApplicationContext();
|
||||
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(context);
|
||||
reader.loadBeanDefinitions(LOCATION_PREFIX + "defaultAutowireNoTests.xml");
|
||||
@@ -102,7 +102,7 @@ class ComponentScanParserBeanDefinitionDefaultsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testAutowireConstructor() {
|
||||
void autowireConstructor() {
|
||||
GenericApplicationContext context = new GenericApplicationContext();
|
||||
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(context);
|
||||
reader.loadBeanDefinitions(LOCATION_PREFIX + "defaultAutowireConstructorTests.xml");
|
||||
@@ -115,7 +115,7 @@ class ComponentScanParserBeanDefinitionDefaultsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testAutowireByType() {
|
||||
void autowireByType() {
|
||||
GenericApplicationContext context = new GenericApplicationContext();
|
||||
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(context);
|
||||
reader.loadBeanDefinitions(LOCATION_PREFIX + "defaultAutowireByTypeTests.xml");
|
||||
@@ -124,7 +124,7 @@ class ComponentScanParserBeanDefinitionDefaultsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testAutowireByName() {
|
||||
void autowireByName() {
|
||||
GenericApplicationContext context = new GenericApplicationContext();
|
||||
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(context);
|
||||
reader.loadBeanDefinitions(LOCATION_PREFIX + "defaultAutowireByNameTests.xml");
|
||||
@@ -137,7 +137,7 @@ class ComponentScanParserBeanDefinitionDefaultsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testDefaultDependencyCheck() {
|
||||
void defaultDependencyCheck() {
|
||||
GenericApplicationContext context = new GenericApplicationContext();
|
||||
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(context);
|
||||
reader.loadBeanDefinitions(LOCATION_PREFIX + "defaultWithNoOverridesTests.xml");
|
||||
@@ -149,7 +149,7 @@ class ComponentScanParserBeanDefinitionDefaultsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testDefaultInitAndDestroyMethodsNotDefined() {
|
||||
void defaultInitAndDestroyMethodsNotDefined() {
|
||||
GenericApplicationContext context = new GenericApplicationContext();
|
||||
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(context);
|
||||
reader.loadBeanDefinitions(LOCATION_PREFIX + "defaultWithNoOverridesTests.xml");
|
||||
@@ -161,7 +161,7 @@ class ComponentScanParserBeanDefinitionDefaultsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testDefaultInitAndDestroyMethodsDefined() {
|
||||
void defaultInitAndDestroyMethodsDefined() {
|
||||
GenericApplicationContext context = new GenericApplicationContext();
|
||||
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(context);
|
||||
reader.loadBeanDefinitions(LOCATION_PREFIX + "defaultInitAndDestroyMethodsTests.xml");
|
||||
@@ -173,7 +173,7 @@ class ComponentScanParserBeanDefinitionDefaultsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testDefaultNonExistingInitAndDestroyMethodsDefined() {
|
||||
void defaultNonExistingInitAndDestroyMethodsDefined() {
|
||||
GenericApplicationContext context = new GenericApplicationContext();
|
||||
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(context);
|
||||
reader.loadBeanDefinitions(LOCATION_PREFIX + "defaultNonExistingInitAndDestroyMethodsTests.xml");
|
||||
|
||||
+5
-5
@@ -37,7 +37,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
class ComponentScanParserScopedProxyTests {
|
||||
|
||||
@Test
|
||||
void testDefaultScopedProxy() {
|
||||
void defaultScopedProxy() {
|
||||
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
"org/springframework/context/annotation/scopedProxyDefaultTests.xml");
|
||||
context.getBeanFactory().registerScope("myScope", new SimpleMapScope());
|
||||
@@ -49,7 +49,7 @@ class ComponentScanParserScopedProxyTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testNoScopedProxy() {
|
||||
void noScopedProxy() {
|
||||
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
"org/springframework/context/annotation/scopedProxyNoTests.xml");
|
||||
context.getBeanFactory().registerScope("myScope", new SimpleMapScope());
|
||||
@@ -61,7 +61,7 @@ class ComponentScanParserScopedProxyTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testInterfacesScopedProxy() throws Exception {
|
||||
void interfacesScopedProxy() throws Exception {
|
||||
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
"org/springframework/context/annotation/scopedProxyInterfacesTests.xml");
|
||||
context.getBeanFactory().registerScope("myScope", new SimpleMapScope());
|
||||
@@ -79,7 +79,7 @@ class ComponentScanParserScopedProxyTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testTargetClassScopedProxy() throws Exception {
|
||||
void targetClassScopedProxy() throws Exception {
|
||||
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
"org/springframework/context/annotation/scopedProxyTargetClassTests.xml");
|
||||
context.getBeanFactory().registerScope("myScope", new SimpleMapScope());
|
||||
@@ -97,7 +97,7 @@ class ComponentScanParserScopedProxyTests {
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("resource")
|
||||
public void testInvalidConfigScopedProxy() {
|
||||
void invalidConfigScopedProxy() {
|
||||
assertThatExceptionOfType(BeanDefinitionParsingException.class).isThrownBy(() ->
|
||||
new ClassPathXmlApplicationContext("org/springframework/context/annotation/scopedProxyInvalidConfigTests.xml"))
|
||||
.withMessageContaining("Cannot define both 'scope-resolver' and 'scoped-proxy' on <component-scan> tag")
|
||||
|
||||
+1
-1
@@ -34,7 +34,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
class SimpleConfigTests {
|
||||
|
||||
@Test
|
||||
void testFooService() throws Exception {
|
||||
void fooService() throws Exception {
|
||||
ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(getConfigLocations(), getClass());
|
||||
|
||||
FooService fooService = ctx.getBean("fooServiceImpl", FooService.class);
|
||||
|
||||
+1
-1
@@ -36,7 +36,7 @@ class SimpleScanTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFooService() {
|
||||
void fooService() {
|
||||
ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(getConfigLocations(), getClass());
|
||||
|
||||
FooService fooService = (FooService) ctx.getBean("fooServiceImpl");
|
||||
|
||||
+1
-1
@@ -27,7 +27,7 @@ import org.springframework.core.type.AnnotatedTypeMetadata;
|
||||
class Spr16217Tests {
|
||||
|
||||
@Test
|
||||
public void baseConfigurationIsIncludedWhenFirstSuperclassReferenceIsSkippedInRegisterBeanPhase() {
|
||||
void baseConfigurationIsIncludedWhenFirstSuperclassReferenceIsSkippedInRegisterBeanPhase() {
|
||||
try (AnnotationConfigApplicationContext context =
|
||||
new AnnotationConfigApplicationContext(RegisterBeanPhaseImportingConfiguration.class)) {
|
||||
context.getBean("someBean");
|
||||
|
||||
+2
-2
@@ -34,12 +34,12 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
class Spr6602Tests {
|
||||
|
||||
@Test
|
||||
void testXmlBehavior() throws Exception {
|
||||
void xmlBehavior() throws Exception {
|
||||
doAssertions(new ClassPathXmlApplicationContext("Spr6602Tests-context.xml", Spr6602Tests.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testConfigurationClassBehavior() throws Exception {
|
||||
void configurationClassBehavior() throws Exception {
|
||||
doAssertions(new AnnotationConfigApplicationContext(FooConfig.class));
|
||||
}
|
||||
|
||||
|
||||
+18
-18
@@ -63,7 +63,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
class AutowiredConfigurationTests {
|
||||
|
||||
@Test
|
||||
void testAutowiredConfigurationDependencies() {
|
||||
void autowiredConfigurationDependencies() {
|
||||
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
AutowiredConfigurationTests.class.getSimpleName() + ".xml", AutowiredConfigurationTests.class);
|
||||
|
||||
@@ -73,7 +73,7 @@ class AutowiredConfigurationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testAutowiredConfigurationMethodDependencies() {
|
||||
void autowiredConfigurationMethodDependencies() {
|
||||
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(
|
||||
AutowiredMethodConfig.class, ColorConfig.class);
|
||||
|
||||
@@ -83,7 +83,7 @@ class AutowiredConfigurationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testAutowiredConfigurationMethodDependenciesWithOptionalAndAvailable() {
|
||||
void autowiredConfigurationMethodDependenciesWithOptionalAndAvailable() {
|
||||
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(
|
||||
OptionalAutowiredMethodConfig.class, ColorConfig.class);
|
||||
|
||||
@@ -93,7 +93,7 @@ class AutowiredConfigurationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testAutowiredConfigurationMethodDependenciesWithOptionalAndNotAvailable() {
|
||||
void autowiredConfigurationMethodDependenciesWithOptionalAndNotAvailable() {
|
||||
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(
|
||||
OptionalAutowiredMethodConfig.class);
|
||||
|
||||
@@ -103,7 +103,7 @@ class AutowiredConfigurationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testAutowiredConfigurationMethodDependenciesWithQualifier() {
|
||||
void autowiredConfigurationMethodDependenciesWithQualifier() {
|
||||
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(
|
||||
QualifiedAutowiredMethodConfig.class);
|
||||
|
||||
@@ -113,7 +113,7 @@ class AutowiredConfigurationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testAutowiredSingleConstructorSupported() {
|
||||
void autowiredSingleConstructorSupported() {
|
||||
DefaultListableBeanFactory factory = new DefaultListableBeanFactory();
|
||||
new XmlBeanDefinitionReader(factory).loadBeanDefinitions(
|
||||
new ClassPathResource("annotation-config.xml", AutowiredConstructorConfig.class));
|
||||
@@ -126,7 +126,7 @@ class AutowiredConfigurationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testObjectFactoryConstructorWithTypeVariable() {
|
||||
void objectFactoryConstructorWithTypeVariable() {
|
||||
DefaultListableBeanFactory factory = new DefaultListableBeanFactory();
|
||||
new XmlBeanDefinitionReader(factory).loadBeanDefinitions(
|
||||
new ClassPathResource("annotation-config.xml", ObjectFactoryConstructorConfig.class));
|
||||
@@ -139,7 +139,7 @@ class AutowiredConfigurationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testAutowiredAnnotatedConstructorSupported() {
|
||||
void autowiredAnnotatedConstructorSupported() {
|
||||
DefaultListableBeanFactory factory = new DefaultListableBeanFactory();
|
||||
new XmlBeanDefinitionReader(factory).loadBeanDefinitions(
|
||||
new ClassPathResource("annotation-config.xml", MultipleConstructorConfig.class));
|
||||
@@ -152,7 +152,7 @@ class AutowiredConfigurationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testValueInjection() {
|
||||
void valueInjection() {
|
||||
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
"ValueInjectionTests.xml", AutowiredConfigurationTests.class);
|
||||
doTestValueInjection(context);
|
||||
@@ -160,7 +160,7 @@ class AutowiredConfigurationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testValueInjectionWithMetaAnnotation() {
|
||||
void valueInjectionWithMetaAnnotation() {
|
||||
AnnotationConfigApplicationContext context =
|
||||
new AnnotationConfigApplicationContext(ValueConfigWithMetaAnnotation.class);
|
||||
doTestValueInjection(context);
|
||||
@@ -168,7 +168,7 @@ class AutowiredConfigurationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testValueInjectionWithAliasedMetaAnnotation() {
|
||||
void valueInjectionWithAliasedMetaAnnotation() {
|
||||
AnnotationConfigApplicationContext context =
|
||||
new AnnotationConfigApplicationContext(ValueConfigWithAliasedMetaAnnotation.class);
|
||||
doTestValueInjection(context);
|
||||
@@ -176,7 +176,7 @@ class AutowiredConfigurationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testValueInjectionWithProviderFields() {
|
||||
void valueInjectionWithProviderFields() {
|
||||
AnnotationConfigApplicationContext context =
|
||||
new AnnotationConfigApplicationContext(ValueConfigWithProviderFields.class);
|
||||
doTestValueInjection(context);
|
||||
@@ -184,7 +184,7 @@ class AutowiredConfigurationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testValueInjectionWithProviderConstructorArguments() {
|
||||
void valueInjectionWithProviderConstructorArguments() {
|
||||
AnnotationConfigApplicationContext context =
|
||||
new AnnotationConfigApplicationContext(ValueConfigWithProviderConstructorArguments.class);
|
||||
doTestValueInjection(context);
|
||||
@@ -192,7 +192,7 @@ class AutowiredConfigurationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testValueInjectionWithProviderMethodArguments() {
|
||||
void valueInjectionWithProviderMethodArguments() {
|
||||
AnnotationConfigApplicationContext context =
|
||||
new AnnotationConfigApplicationContext(ValueConfigWithProviderMethodArguments.class);
|
||||
doTestValueInjection(context);
|
||||
@@ -200,7 +200,7 @@ class AutowiredConfigurationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testValueInjectionWithAccidentalAutowiredAnnotations() {
|
||||
void valueInjectionWithAccidentalAutowiredAnnotations() {
|
||||
assertThatExceptionOfType(BeanDefinitionParsingException.class).isThrownBy(() ->
|
||||
new AnnotationConfigApplicationContext(ValueConfigWithAccidentalAutowiredAnnotations.class));
|
||||
}
|
||||
@@ -232,7 +232,7 @@ class AutowiredConfigurationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCustomPropertiesWithClassPathContext() throws IOException {
|
||||
void customPropertiesWithClassPathContext() throws IOException {
|
||||
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
"AutowiredConfigurationTests-custom.xml", AutowiredConfigurationTests.class);
|
||||
|
||||
@@ -243,7 +243,7 @@ class AutowiredConfigurationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCustomPropertiesWithGenericContext() throws IOException {
|
||||
void customPropertiesWithGenericContext() throws IOException {
|
||||
GenericApplicationContext context = new GenericApplicationContext();
|
||||
new XmlBeanDefinitionReader(context).loadBeanDefinitions(
|
||||
new ClassPathResource("AutowiredConfigurationTests-custom.xml", AutowiredConfigurationTests.class));
|
||||
@@ -256,7 +256,7 @@ class AutowiredConfigurationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testValueInjectionWithRecord() {
|
||||
void valueInjectionWithRecord() {
|
||||
System.setProperty("recordBeanName", "enigma");
|
||||
try (GenericApplicationContext context = new AnnotationConfigApplicationContext(RecordBean.class)) {
|
||||
assertThat(context.getBean(RecordBean.class).name()).isEqualTo("enigma");
|
||||
|
||||
+5
-5
@@ -61,7 +61,7 @@ class ConfigurationClassWithPlaceholderConfigurerBeanTests {
|
||||
*/
|
||||
@Test
|
||||
@SuppressWarnings("resource")
|
||||
public void valueFieldsAreNotProcessedWhenPlaceholderConfigurerIsIntegrated() {
|
||||
void valueFieldsAreNotProcessedWhenPlaceholderConfigurerIsIntegrated() {
|
||||
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
|
||||
ctx.register(ConfigWithValueFieldAndPlaceholderConfigurer.class);
|
||||
System.setProperty("test.name", "foo");
|
||||
@@ -75,7 +75,7 @@ class ConfigurationClassWithPlaceholderConfigurerBeanTests {
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("resource")
|
||||
public void valueFieldsAreProcessedWhenStaticPlaceholderConfigurerIsIntegrated() {
|
||||
void valueFieldsAreProcessedWhenStaticPlaceholderConfigurerIsIntegrated() {
|
||||
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
|
||||
ctx.register(ConfigWithValueFieldAndStaticPlaceholderConfigurer.class);
|
||||
System.setProperty("test.name", "foo");
|
||||
@@ -88,7 +88,7 @@ class ConfigurationClassWithPlaceholderConfigurerBeanTests {
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("resource")
|
||||
public void valueFieldsAreProcessedWhenPlaceholderConfigurerIsSegregated() {
|
||||
void valueFieldsAreProcessedWhenPlaceholderConfigurerIsSegregated() {
|
||||
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
|
||||
ctx.register(ConfigWithValueField.class);
|
||||
ctx.register(ConfigWithPlaceholderConfigurer.class);
|
||||
@@ -102,7 +102,7 @@ class ConfigurationClassWithPlaceholderConfigurerBeanTests {
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("resource")
|
||||
public void valueFieldsResolveToPlaceholderSpecifiedDefaultValuesWithPlaceholderConfigurer() {
|
||||
void valueFieldsResolveToPlaceholderSpecifiedDefaultValuesWithPlaceholderConfigurer() {
|
||||
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
|
||||
ctx.register(ConfigWithValueField.class);
|
||||
ctx.register(ConfigWithPlaceholderConfigurer.class);
|
||||
@@ -114,7 +114,7 @@ class ConfigurationClassWithPlaceholderConfigurerBeanTests {
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("resource")
|
||||
public void valueFieldsResolveToPlaceholderSpecifiedDefaultValuesWithoutPlaceholderConfigurer() {
|
||||
void valueFieldsResolveToPlaceholderSpecifiedDefaultValuesWithoutPlaceholderConfigurer() {
|
||||
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
|
||||
ctx.register(ConfigWithValueField.class);
|
||||
// ctx.register(ConfigWithPlaceholderConfigurer.class);
|
||||
|
||||
+6
-6
@@ -86,12 +86,12 @@ class ScopingTests {
|
||||
|
||||
|
||||
@Test
|
||||
void testScopeOnClasses() {
|
||||
void scopeOnClasses() {
|
||||
genericTestScope("scopedClass");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testScopeOnInterfaces() {
|
||||
void scopeOnInterfaces() {
|
||||
genericTestScope("scopedInterface");
|
||||
}
|
||||
|
||||
@@ -130,7 +130,7 @@ class ScopingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSameScopeOnDifferentBeans() {
|
||||
void sameScopeOnDifferentBeans() {
|
||||
Object beanAInScope = ctx.getBean("scopedClass");
|
||||
Object beanBInScope = ctx.getBean("scopedInterface");
|
||||
|
||||
@@ -147,7 +147,7 @@ class ScopingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testRawScopes() {
|
||||
void rawScopes() {
|
||||
String beanName = "scopedProxyInterface";
|
||||
|
||||
// get hidden bean
|
||||
@@ -158,7 +158,7 @@ class ScopingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testScopedProxyConfiguration() {
|
||||
void scopedProxyConfiguration() {
|
||||
TestBean singleton = (TestBean) ctx.getBean("singletonWithScopedInterfaceDep");
|
||||
ITestBean spouse = singleton.getSpouse();
|
||||
boolean condition = spouse instanceof ScopedObject;
|
||||
@@ -191,7 +191,7 @@ class ScopingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testScopedProxyConfigurationWithClasses() {
|
||||
void scopedProxyConfigurationWithClasses() {
|
||||
TestBean singleton = (TestBean) ctx.getBean("singletonWithScopedClassDep");
|
||||
ITestBean spouse = singleton.getSpouse();
|
||||
boolean condition = spouse instanceof ScopedObject;
|
||||
|
||||
+1
-1
@@ -34,7 +34,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
class Spr10668Tests {
|
||||
|
||||
@Test
|
||||
void testSelfInjectHierarchy() {
|
||||
void selfInjectHierarchy() {
|
||||
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(ChildConfig.class);
|
||||
assertThat(context.getBean(MyComponent.class)).isNotNull();
|
||||
context.close();
|
||||
|
||||
+1
-1
@@ -41,7 +41,7 @@ class Spr10744Tests {
|
||||
|
||||
|
||||
@Test
|
||||
void testSpr10744() {
|
||||
void spr10744() {
|
||||
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
|
||||
context.getBeanFactory().registerScope("myTestScope", new MyTestScope());
|
||||
context.register(MyTestConfiguration.class);
|
||||
|
||||
+1
-1
@@ -35,7 +35,7 @@ import static org.springframework.beans.factory.config.ConfigurableBeanFactory.S
|
||||
class Spr12526Tests {
|
||||
|
||||
@Test
|
||||
void testInjection() {
|
||||
void injection() {
|
||||
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(TestContext.class);
|
||||
CustomCondition condition = ctx.getBean(CustomCondition.class);
|
||||
|
||||
|
||||
+1
-1
@@ -28,7 +28,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
class ConversionServiceContextConfigTests {
|
||||
|
||||
@Test
|
||||
void testConfigOk() {
|
||||
void configOk() {
|
||||
try (ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("org/springframework/context/conversionservice/conversionService.xml")) {
|
||||
TestClient client = context.getBean("testClient", TestClient.class);
|
||||
assertThat(client.getBars()).hasSize(2);
|
||||
|
||||
+6
-6
@@ -248,7 +248,7 @@ class ApplicationContextEventTests extends AbstractApplicationEventListenerTests
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void proxiedListeners() {
|
||||
void proxiedListeners() {
|
||||
MyOrderedListener1 listener1 = new MyOrderedListener1();
|
||||
MyOrderedListener2 listener2 = new MyOrderedListener2(listener1);
|
||||
ApplicationListener<ApplicationEvent> proxy1 = (ApplicationListener<ApplicationEvent>) new ProxyFactory(listener1).getProxy();
|
||||
@@ -265,7 +265,7 @@ class ApplicationContextEventTests extends AbstractApplicationEventListenerTests
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void proxiedListenersMixedWithTargetListeners() {
|
||||
void proxiedListenersMixedWithTargetListeners() {
|
||||
MyOrderedListener1 listener1 = new MyOrderedListener1();
|
||||
MyOrderedListener2 listener2 = new MyOrderedListener2(listener1);
|
||||
ApplicationListener<ApplicationEvent> proxy1 = (ApplicationListener<ApplicationEvent>) new ProxyFactory(listener1).getProxy();
|
||||
@@ -301,7 +301,7 @@ class ApplicationContextEventTests extends AbstractApplicationEventListenerTests
|
||||
}
|
||||
|
||||
@Test
|
||||
void testEventPublicationInterceptorWithEventClass() throws Throwable {
|
||||
void eventPublicationInterceptorWithEventClass() throws Throwable {
|
||||
MethodInvocation invocation = mock();
|
||||
ApplicationContext ctx = mock();
|
||||
|
||||
@@ -317,7 +317,7 @@ class ApplicationContextEventTests extends AbstractApplicationEventListenerTests
|
||||
}
|
||||
|
||||
@Test
|
||||
void testEventPublicationInterceptorWithEventFactory() throws Throwable {
|
||||
void eventPublicationInterceptorWithEventFactory() throws Throwable {
|
||||
MethodInvocation invocation = mock();
|
||||
ApplicationContext ctx = mock();
|
||||
|
||||
@@ -333,7 +333,7 @@ class ApplicationContextEventTests extends AbstractApplicationEventListenerTests
|
||||
}
|
||||
|
||||
@Test
|
||||
void testEventPublicationInterceptorWithMethodFailure() throws Throwable {
|
||||
void eventPublicationInterceptorWithMethodFailure() throws Throwable {
|
||||
MethodInvocation invocation = mock();
|
||||
ApplicationContext ctx = mock();
|
||||
|
||||
@@ -347,7 +347,7 @@ class ApplicationContextEventTests extends AbstractApplicationEventListenerTests
|
||||
}
|
||||
|
||||
@Test
|
||||
void testEventPublicationInterceptorWithCustomFailure() throws Throwable {
|
||||
void eventPublicationInterceptorWithCustomFailure() throws Throwable {
|
||||
MethodInvocation invocation = mock();
|
||||
ApplicationContext ctx = mock();
|
||||
|
||||
|
||||
+6
-6
@@ -57,27 +57,27 @@ class GenericApplicationListenerAdapterTests extends AbstractApplicationEventLis
|
||||
}
|
||||
|
||||
@Test // Demonstrates we can't inject that event because the generic type is lost
|
||||
public void genericListenerStrictTypeTypeErasure() {
|
||||
void genericListenerStrictTypeTypeErasure() {
|
||||
GenericTestEvent<String> stringEvent = createGenericTestEvent("test");
|
||||
ResolvableType eventType = ResolvableType.forType(stringEvent.getClass());
|
||||
supportsEventType(false, StringEventListener.class, eventType);
|
||||
}
|
||||
|
||||
@Test // But it works if we specify the type properly
|
||||
public void genericListenerStrictTypeAndResolvableType() {
|
||||
void genericListenerStrictTypeAndResolvableType() {
|
||||
ResolvableType eventType = ResolvableType
|
||||
.forClassWithGenerics(GenericTestEvent.class, String.class);
|
||||
supportsEventType(true, StringEventListener.class, eventType);
|
||||
}
|
||||
|
||||
@Test // or if the event provides its precise type
|
||||
public void genericListenerStrictTypeAndResolvableTypeProvider() {
|
||||
void genericListenerStrictTypeAndResolvableTypeProvider() {
|
||||
ResolvableType eventType = new SmartGenericTestEvent<>(this, "foo").getResolvableType();
|
||||
supportsEventType(true, StringEventListener.class, eventType);
|
||||
}
|
||||
|
||||
@Test // Demonstrates it works if we actually use the subtype
|
||||
public void genericListenerStrictTypeEventSubType() {
|
||||
void genericListenerStrictTypeEventSubType() {
|
||||
StringEvent stringEvent = new StringEvent(this, "test");
|
||||
ResolvableType eventType = ResolvableType.forType(stringEvent.getClass());
|
||||
supportsEventType(true, StringEventListener.class, eventType);
|
||||
@@ -127,7 +127,7 @@ class GenericApplicationListenerAdapterTests extends AbstractApplicationEventLis
|
||||
}
|
||||
|
||||
@Test // Demonstrates we cannot inject that event because the listener has a wildcard
|
||||
public void genericListenerWildcardTypeTypeErasure() {
|
||||
void genericListenerWildcardTypeTypeErasure() {
|
||||
GenericTestEvent<String> stringEvent = createGenericTestEvent("test");
|
||||
ResolvableType eventType = ResolvableType.forType(stringEvent.getClass());
|
||||
supportsEventType(true, GenericEventListener.class, eventType);
|
||||
@@ -140,7 +140,7 @@ class GenericApplicationListenerAdapterTests extends AbstractApplicationEventLis
|
||||
}
|
||||
|
||||
@Test // Demonstrates we cannot inject that event because the listener has a raw type
|
||||
public void genericListenerRawTypeTypeErasure() {
|
||||
void genericListenerRawTypeTypeErasure() {
|
||||
GenericTestEvent<String> stringEvent = createGenericTestEvent("test");
|
||||
ResolvableType eventType = ResolvableType.forType(stringEvent.getClass());
|
||||
supportsEventType(true, RawApplicationListener.class, eventType);
|
||||
|
||||
+12
-12
@@ -71,7 +71,7 @@ class PayloadApplicationEventTests {
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("resource")
|
||||
void testEventClassWithPayloadType() {
|
||||
void eventClassWithPayloadType() {
|
||||
ConfigurableApplicationContext ac = new AnnotationConfigApplicationContext(NumberHolderListener.class);
|
||||
|
||||
PayloadApplicationEvent<NumberHolder<Integer>> event = new PayloadApplicationEvent<>(this,
|
||||
@@ -83,7 +83,7 @@ class PayloadApplicationEventTests {
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("resource")
|
||||
void testEventClassWithPayloadTypeOnParentContext() {
|
||||
void eventClassWithPayloadTypeOnParentContext() {
|
||||
ConfigurableApplicationContext parent = new AnnotationConfigApplicationContext(NumberHolderListener.class);
|
||||
ConfigurableApplicationContext ac = new GenericApplicationContext(parent);
|
||||
ac.refresh();
|
||||
@@ -98,7 +98,7 @@ class PayloadApplicationEventTests {
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("resource")
|
||||
void testPayloadObjectWithPayloadType() {
|
||||
void payloadObjectWithPayloadType() {
|
||||
final NumberHolder<Integer> payload = new NumberHolder<>(42);
|
||||
|
||||
AnnotationConfigApplicationContext ac = new AnnotationConfigApplicationContext(NumberHolderListener.class) {
|
||||
@@ -116,7 +116,7 @@ class PayloadApplicationEventTests {
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("resource")
|
||||
void testPayloadObjectWithPayloadTypeOnParentContext() {
|
||||
void payloadObjectWithPayloadTypeOnParentContext() {
|
||||
final NumberHolder<Integer> payload = new NumberHolder<>(42);
|
||||
|
||||
ConfigurableApplicationContext parent = new AnnotationConfigApplicationContext(NumberHolderListener.class);
|
||||
@@ -137,7 +137,7 @@ class PayloadApplicationEventTests {
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("resource")
|
||||
void testEventClassWithInterface() {
|
||||
void eventClassWithInterface() {
|
||||
ConfigurableApplicationContext ac = new AnnotationConfigApplicationContext(AuditableListener.class);
|
||||
|
||||
AuditablePayloadEvent<String> event = new AuditablePayloadEvent<>(this, "xyz");
|
||||
@@ -148,7 +148,7 @@ class PayloadApplicationEventTests {
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("resource")
|
||||
void testEventClassWithInterfaceOnParentContext() {
|
||||
void eventClassWithInterfaceOnParentContext() {
|
||||
ConfigurableApplicationContext parent = new AnnotationConfigApplicationContext(AuditableListener.class);
|
||||
ConfigurableApplicationContext ac = new GenericApplicationContext(parent);
|
||||
ac.refresh();
|
||||
@@ -162,7 +162,7 @@ class PayloadApplicationEventTests {
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("resource")
|
||||
void testProgrammaticEventListener() {
|
||||
void programmaticEventListener() {
|
||||
List<Auditable> events = new ArrayList<>();
|
||||
ApplicationListener<AuditablePayloadEvent<String>> listener = events::add;
|
||||
ApplicationListener<AuditablePayloadEvent<Integer>> mismatch = (PayloadApplicationEvent::getPayload);
|
||||
@@ -180,7 +180,7 @@ class PayloadApplicationEventTests {
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("resource")
|
||||
void testProgrammaticEventListenerOnParentContext() {
|
||||
void programmaticEventListenerOnParentContext() {
|
||||
List<Auditable> events = new ArrayList<>();
|
||||
ApplicationListener<AuditablePayloadEvent<String>> listener = events::add;
|
||||
ApplicationListener<AuditablePayloadEvent<Integer>> mismatch = (PayloadApplicationEvent::getPayload);
|
||||
@@ -201,7 +201,7 @@ class PayloadApplicationEventTests {
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("resource")
|
||||
void testProgrammaticPayloadListener() {
|
||||
void programmaticPayloadListener() {
|
||||
List<String> events = new ArrayList<>();
|
||||
ApplicationListener<PayloadApplicationEvent<String>> listener = ApplicationListener.forPayload(events::add);
|
||||
ApplicationListener<PayloadApplicationEvent<Integer>> mismatch = ApplicationListener.forPayload(Integer::intValue);
|
||||
@@ -219,7 +219,7 @@ class PayloadApplicationEventTests {
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("resource")
|
||||
void testProgrammaticPayloadListenerOnParentContext() {
|
||||
void programmaticPayloadListenerOnParentContext() {
|
||||
List<String> events = new ArrayList<>();
|
||||
ApplicationListener<PayloadApplicationEvent<String>> listener = ApplicationListener.forPayload(events::add);
|
||||
ApplicationListener<PayloadApplicationEvent<Integer>> mismatch = ApplicationListener.forPayload(Integer::intValue);
|
||||
@@ -240,7 +240,7 @@ class PayloadApplicationEventTests {
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("resource")
|
||||
void testPlainPayloadListener() {
|
||||
void plainPayloadListener() {
|
||||
ConfigurableApplicationContext ac = new AnnotationConfigApplicationContext(PlainPayloadListener.class);
|
||||
|
||||
String payload = "xyz";
|
||||
@@ -251,7 +251,7 @@ class PayloadApplicationEventTests {
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("resource")
|
||||
void testPlainPayloadListenerOnParentContext() {
|
||||
void plainPayloadListenerOnParentContext() {
|
||||
ConfigurableApplicationContext parent = new AnnotationConfigApplicationContext(PlainPayloadListener.class);
|
||||
ConfigurableApplicationContext ac = new GenericApplicationContext(parent);
|
||||
ac.refresh();
|
||||
|
||||
+5
-5
@@ -29,7 +29,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
class LocaleContextHolderTests {
|
||||
|
||||
@Test
|
||||
void testSetLocaleContext() {
|
||||
void setLocaleContext() {
|
||||
LocaleContext lc = new SimpleLocaleContext(Locale.GERMAN);
|
||||
LocaleContextHolder.setLocaleContext(lc);
|
||||
assertThat(LocaleContextHolder.getLocaleContext()).isSameAs(lc);
|
||||
@@ -49,7 +49,7 @@ class LocaleContextHolderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSetTimeZoneAwareLocaleContext() {
|
||||
void setTimeZoneAwareLocaleContext() {
|
||||
LocaleContext lc = new SimpleTimeZoneAwareLocaleContext(Locale.GERMANY, TimeZone.getTimeZone("GMT+1"));
|
||||
LocaleContextHolder.setLocaleContext(lc);
|
||||
assertThat(LocaleContextHolder.getLocaleContext()).isSameAs(lc);
|
||||
@@ -63,7 +63,7 @@ class LocaleContextHolderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSetLocale() {
|
||||
void setLocale() {
|
||||
LocaleContextHolder.setLocale(Locale.GERMAN);
|
||||
assertThat(LocaleContextHolder.getLocale()).isEqualTo(Locale.GERMAN);
|
||||
assertThat(LocaleContextHolder.getTimeZone()).isEqualTo(TimeZone.getDefault());
|
||||
@@ -90,7 +90,7 @@ class LocaleContextHolderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSetTimeZone() {
|
||||
void setTimeZone() {
|
||||
LocaleContextHolder.setTimeZone(TimeZone.getTimeZone("GMT+1"));
|
||||
assertThat(LocaleContextHolder.getLocale()).isEqualTo(Locale.getDefault());
|
||||
assertThat(LocaleContextHolder.getTimeZone()).isEqualTo(TimeZone.getTimeZone("GMT+1"));
|
||||
@@ -119,7 +119,7 @@ class LocaleContextHolderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSetLocaleAndSetTimeZoneMixed() {
|
||||
void setLocaleAndSetTimeZoneMixed() {
|
||||
LocaleContextHolder.setLocale(Locale.GERMANY);
|
||||
assertThat(LocaleContextHolder.getLocale()).isEqualTo(Locale.GERMANY);
|
||||
assertThat(LocaleContextHolder.getTimeZone()).isEqualTo(TimeZone.getDefault());
|
||||
|
||||
+5
-5
@@ -241,7 +241,7 @@ class PropertySourcesPlaceholderConfigurerTests {
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("serial")
|
||||
public void explicitPropertySourcesExcludesLocalProperties() {
|
||||
void explicitPropertySourcesExcludesLocalProperties() {
|
||||
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
|
||||
bf.registerBeanDefinition("testBean",
|
||||
genericBeanDefinition(TestBean.class)
|
||||
@@ -294,7 +294,7 @@ class PropertySourcesPlaceholderConfigurerTests {
|
||||
|
||||
@Test
|
||||
// https://github.com/spring-projects/spring-framework/issues/27947
|
||||
public void ignoreUnresolvablePlaceholdersInAtValueAnnotation__falseIsDefault() {
|
||||
void ignoreUnresolvablePlaceholdersInAtValueAnnotation__falseIsDefault() {
|
||||
MockPropertySource mockPropertySource = new MockPropertySource("test");
|
||||
mockPropertySource.setProperty("my.key", "${enigma}");
|
||||
@SuppressWarnings("resource")
|
||||
@@ -311,7 +311,7 @@ class PropertySourcesPlaceholderConfigurerTests {
|
||||
|
||||
@Test
|
||||
// https://github.com/spring-projects/spring-framework/issues/27947
|
||||
public void ignoreUnresolvablePlaceholdersInAtValueAnnotation_true() {
|
||||
void ignoreUnresolvablePlaceholdersInAtValueAnnotation_true() {
|
||||
MockPropertySource mockPropertySource = new MockPropertySource("test");
|
||||
mockPropertySource.setProperty("my.key", "${enigma}");
|
||||
@SuppressWarnings("resource")
|
||||
@@ -326,7 +326,7 @@ class PropertySourcesPlaceholderConfigurerTests {
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("serial")
|
||||
public void nestedUnresolvablePlaceholder() {
|
||||
void nestedUnresolvablePlaceholder() {
|
||||
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
|
||||
bf.registerBeanDefinition("testBean",
|
||||
genericBeanDefinition(TestBean.class)
|
||||
@@ -343,7 +343,7 @@ class PropertySourcesPlaceholderConfigurerTests {
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("serial")
|
||||
public void ignoredNestedUnresolvablePlaceholder() {
|
||||
void ignoredNestedUnresolvablePlaceholder() {
|
||||
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
|
||||
bf.registerBeanDefinition("testBean",
|
||||
genericBeanDefinition(TestBean.class)
|
||||
|
||||
+2
-2
@@ -81,13 +81,13 @@ class StaticApplicationContextMulticasterTests extends AbstractApplicationContex
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void count() {
|
||||
protected void count() {
|
||||
assertCount(15);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void events() throws Exception {
|
||||
protected void events() throws Exception {
|
||||
TestApplicationEventMulticaster.counter = 0;
|
||||
super.events();
|
||||
assertThat(TestApplicationEventMulticaster.counter).isEqualTo(1);
|
||||
|
||||
+1
-1
@@ -70,7 +70,7 @@ class StaticApplicationContextTests extends AbstractApplicationContextTests {
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void count() {
|
||||
protected void count() {
|
||||
assertCount(15);
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -57,14 +57,14 @@ class StaticMessageSourceTests extends AbstractApplicationContextTests {
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void count() {
|
||||
protected void count() {
|
||||
assertCount(15);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
@Disabled("Do nothing here since super is looking for errorCodes we do NOT have in the Context")
|
||||
public void messageSource() throws NoSuchMessageException {
|
||||
protected void messageSource() throws NoSuchMessageException {
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
+3
-3
@@ -51,21 +51,21 @@ class JeeNamespaceHandlerEventTests {
|
||||
|
||||
|
||||
@Test
|
||||
void testJndiLookupComponentEventReceived() {
|
||||
void jndiLookupComponentEventReceived() {
|
||||
ComponentDefinition component = this.eventListener.getComponentDefinition("simple");
|
||||
boolean condition = component instanceof BeanComponentDefinition;
|
||||
assertThat(condition).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testLocalSlsbComponentEventReceived() {
|
||||
void localSlsbComponentEventReceived() {
|
||||
ComponentDefinition component = this.eventListener.getComponentDefinition("simpleLocalEjb");
|
||||
boolean condition = component instanceof BeanComponentDefinition;
|
||||
assertThat(condition).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testRemoteSlsbComponentEventReceived() {
|
||||
void remoteSlsbComponentEventReceived() {
|
||||
ComponentDefinition component = this.eventListener.getComponentDefinition("simpleRemoteEjb");
|
||||
boolean condition = component instanceof BeanComponentDefinition;
|
||||
assertThat(condition).isTrue();
|
||||
|
||||
+9
-9
@@ -57,7 +57,7 @@ class JeeNamespaceHandlerTests {
|
||||
|
||||
|
||||
@Test
|
||||
void testSimpleDefinition() {
|
||||
void simpleDefinition() {
|
||||
BeanDefinition beanDefinition = this.beanFactory.getMergedBeanDefinition("simple");
|
||||
assertThat(beanDefinition.getBeanClassName()).isEqualTo(JndiObjectFactoryBean.class.getName());
|
||||
assertPropertyValue(beanDefinition, "jndiName", "jdbc/MyDataSource");
|
||||
@@ -65,7 +65,7 @@ class JeeNamespaceHandlerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testComplexDefinition() {
|
||||
void complexDefinition() {
|
||||
BeanDefinition beanDefinition = this.beanFactory.getMergedBeanDefinition("complex");
|
||||
assertThat(beanDefinition.getBeanClassName()).isEqualTo(JndiObjectFactoryBean.class.getName());
|
||||
assertPropertyValue(beanDefinition, "jndiName", "jdbc/MyDataSource");
|
||||
@@ -79,21 +79,21 @@ class JeeNamespaceHandlerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testWithEnvironment() {
|
||||
void withEnvironment() {
|
||||
BeanDefinition beanDefinition = this.beanFactory.getMergedBeanDefinition("withEnvironment");
|
||||
assertPropertyValue(beanDefinition, "jndiEnvironment", "foo=bar");
|
||||
assertPropertyValue(beanDefinition, "defaultObject", new RuntimeBeanReference("myBean"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testWithReferencedEnvironment() {
|
||||
void withReferencedEnvironment() {
|
||||
BeanDefinition beanDefinition = this.beanFactory.getMergedBeanDefinition("withReferencedEnvironment");
|
||||
assertPropertyValue(beanDefinition, "jndiEnvironment", new RuntimeBeanReference("myEnvironment"));
|
||||
assertThat(beanDefinition.getPropertyValues().contains("environmentRef")).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSimpleLocalSlsb() {
|
||||
void simpleLocalSlsb() {
|
||||
BeanDefinition beanDefinition = this.beanFactory.getMergedBeanDefinition("simpleLocalEjb");
|
||||
assertThat(beanDefinition.getBeanClassName()).isEqualTo(JndiObjectFactoryBean.class.getName());
|
||||
assertPropertyValue(beanDefinition, "jndiName", "ejb/MyLocalBean");
|
||||
@@ -104,7 +104,7 @@ class JeeNamespaceHandlerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSimpleRemoteSlsb() {
|
||||
void simpleRemoteSlsb() {
|
||||
BeanDefinition beanDefinition = this.beanFactory.getMergedBeanDefinition("simpleRemoteEjb");
|
||||
assertThat(beanDefinition.getBeanClassName()).isEqualTo(JndiObjectFactoryBean.class.getName());
|
||||
assertPropertyValue(beanDefinition, "jndiName", "ejb/MyRemoteBean");
|
||||
@@ -115,7 +115,7 @@ class JeeNamespaceHandlerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testComplexLocalSlsb() {
|
||||
void complexLocalSlsb() {
|
||||
BeanDefinition beanDefinition = this.beanFactory.getMergedBeanDefinition("complexLocalEjb");
|
||||
assertThat(beanDefinition.getBeanClassName()).isEqualTo(JndiObjectFactoryBean.class.getName());
|
||||
assertPropertyValue(beanDefinition, "jndiName", "ejb/MyLocalBean");
|
||||
@@ -126,7 +126,7 @@ class JeeNamespaceHandlerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testComplexRemoteSlsb() {
|
||||
void complexRemoteSlsb() {
|
||||
BeanDefinition beanDefinition = this.beanFactory.getMergedBeanDefinition("complexRemoteEjb");
|
||||
assertThat(beanDefinition.getBeanClassName()).isEqualTo(JndiObjectFactoryBean.class.getName());
|
||||
assertPropertyValue(beanDefinition, "jndiName", "ejb/MyRemoteBean");
|
||||
@@ -137,7 +137,7 @@ class JeeNamespaceHandlerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testLazyInitJndiLookup() {
|
||||
void lazyInitJndiLookup() {
|
||||
BeanDefinition definition = this.beanFactory.getMergedBeanDefinition("lazyDataSource");
|
||||
assertThat(definition.isLazyInit()).isTrue();
|
||||
definition = this.beanFactory.getMergedBeanDefinition("lazyLocalBean");
|
||||
|
||||
+14
-14
@@ -83,7 +83,7 @@ class DateFormattingTests {
|
||||
|
||||
|
||||
@Test
|
||||
void testBindLong() {
|
||||
void bindLong() {
|
||||
MutablePropertyValues propertyValues = new MutablePropertyValues();
|
||||
propertyValues.add("millis", "1256961600");
|
||||
binder.bind(propertyValues);
|
||||
@@ -92,7 +92,7 @@ class DateFormattingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testBindLongAnnotated() {
|
||||
void bindLongAnnotated() {
|
||||
MutablePropertyValues propertyValues = new MutablePropertyValues();
|
||||
propertyValues.add("styleMillis", "10/31/09");
|
||||
binder.bind(propertyValues);
|
||||
@@ -101,7 +101,7 @@ class DateFormattingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testBindCalendarAnnotated() {
|
||||
void bindCalendarAnnotated() {
|
||||
MutablePropertyValues propertyValues = new MutablePropertyValues();
|
||||
propertyValues.add("styleCalendar", "10/31/09");
|
||||
binder.bind(propertyValues);
|
||||
@@ -110,7 +110,7 @@ class DateFormattingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testBindDateAnnotated() {
|
||||
void bindDateAnnotated() {
|
||||
MutablePropertyValues propertyValues = new MutablePropertyValues();
|
||||
propertyValues.add("styleDate", "10/31/09");
|
||||
binder.bind(propertyValues);
|
||||
@@ -152,7 +152,7 @@ class DateFormattingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testBindDateArray() {
|
||||
void bindDateArray() {
|
||||
MutablePropertyValues propertyValues = new MutablePropertyValues();
|
||||
propertyValues.add("styleDate", new String[]{"10/31/09 12:00 PM"});
|
||||
binder.bind(propertyValues);
|
||||
@@ -160,7 +160,7 @@ class DateFormattingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testBindDateAnnotatedWithError() {
|
||||
void bindDateAnnotatedWithError() {
|
||||
MutablePropertyValues propertyValues = new MutablePropertyValues();
|
||||
propertyValues.add("styleDate", "Oct X31, 2009");
|
||||
binder.bind(propertyValues);
|
||||
@@ -170,7 +170,7 @@ class DateFormattingTests {
|
||||
|
||||
@Test
|
||||
@Disabled
|
||||
void testBindDateAnnotatedWithFallbackError() {
|
||||
void bindDateAnnotatedWithFallbackError() {
|
||||
// TODO This currently passes because the Date(String) constructor fallback is used
|
||||
MutablePropertyValues propertyValues = new MutablePropertyValues();
|
||||
propertyValues.add("styleDate", "Oct 031, 2009");
|
||||
@@ -180,7 +180,7 @@ class DateFormattingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testBindDateTimePatternAnnotated() {
|
||||
void bindDateTimePatternAnnotated() {
|
||||
MutablePropertyValues propertyValues = new MutablePropertyValues();
|
||||
propertyValues.add("patternDate", "10/31/09 1:05");
|
||||
binder.bind(propertyValues);
|
||||
@@ -189,7 +189,7 @@ class DateFormattingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testBindDateTimePatternAnnotatedWithGlobalFormat() {
|
||||
void bindDateTimePatternAnnotatedWithGlobalFormat() {
|
||||
DateFormatterRegistrar registrar = new DateFormatterRegistrar();
|
||||
DateFormatter dateFormatter = new DateFormatter();
|
||||
dateFormatter.setIso(ISO.DATE_TIME);
|
||||
@@ -204,7 +204,7 @@ class DateFormattingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testBindDateTimePatternAnnotatedWithOverflow() {
|
||||
void bindDateTimePatternAnnotatedWithOverflow() {
|
||||
MutablePropertyValues propertyValues = new MutablePropertyValues();
|
||||
propertyValues.add("patternDate", "02/29/09 12:00 PM");
|
||||
binder.bind(propertyValues);
|
||||
@@ -212,7 +212,7 @@ class DateFormattingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testBindISODate() {
|
||||
void bindISODate() {
|
||||
MutablePropertyValues propertyValues = new MutablePropertyValues();
|
||||
propertyValues.add("isoDate", "2009-10-31");
|
||||
binder.bind(propertyValues);
|
||||
@@ -221,7 +221,7 @@ class DateFormattingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testBindISOTime() {
|
||||
void bindISOTime() {
|
||||
MutablePropertyValues propertyValues = new MutablePropertyValues();
|
||||
propertyValues.add("isoTime", "12:00:00.000-05:00");
|
||||
binder.bind(propertyValues);
|
||||
@@ -230,7 +230,7 @@ class DateFormattingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testBindISODateTime() {
|
||||
void bindISODateTime() {
|
||||
MutablePropertyValues propertyValues = new MutablePropertyValues();
|
||||
propertyValues.add("isoDateTime", "2009-10-31T12:00:00.000-08:00");
|
||||
binder.bind(propertyValues);
|
||||
@@ -239,7 +239,7 @@ class DateFormattingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testBindNestedDateAnnotated() {
|
||||
void bindNestedDateAnnotated() {
|
||||
MutablePropertyValues propertyValues = new MutablePropertyValues();
|
||||
propertyValues.add("children[0].styleDate", "10/31/09");
|
||||
binder.bind(propertyValues);
|
||||
|
||||
+43
-43
@@ -113,7 +113,7 @@ class DateTimeFormattingTests {
|
||||
|
||||
|
||||
@Test
|
||||
void testBindLocalDate() {
|
||||
void bindLocalDate() {
|
||||
MutablePropertyValues propertyValues = new MutablePropertyValues();
|
||||
propertyValues.add("localDate", "10/31/09");
|
||||
binder.bind(propertyValues);
|
||||
@@ -122,7 +122,7 @@ class DateTimeFormattingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testBindLocalDateWithISO() {
|
||||
void bindLocalDateWithISO() {
|
||||
MutablePropertyValues propertyValues = new MutablePropertyValues();
|
||||
propertyValues.add("localDate", "2009-10-31");
|
||||
binder.bind(propertyValues);
|
||||
@@ -131,7 +131,7 @@ class DateTimeFormattingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testBindLocalDateWithSpecificStyle() {
|
||||
void bindLocalDateWithSpecificStyle() {
|
||||
DateTimeFormatterRegistrar registrar = new DateTimeFormatterRegistrar();
|
||||
registrar.setDateStyle(FormatStyle.LONG);
|
||||
setup(registrar);
|
||||
@@ -143,7 +143,7 @@ class DateTimeFormattingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testBindLocalDateWithSpecificFormatter() {
|
||||
void bindLocalDateWithSpecificFormatter() {
|
||||
DateTimeFormatterRegistrar registrar = new DateTimeFormatterRegistrar();
|
||||
registrar.setDateFormatter(DateTimeFormatter.ofPattern("yyyyMMdd"));
|
||||
setup(registrar);
|
||||
@@ -155,7 +155,7 @@ class DateTimeFormattingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testBindLocalDateArray() {
|
||||
void bindLocalDateArray() {
|
||||
MutablePropertyValues propertyValues = new MutablePropertyValues();
|
||||
propertyValues.add("localDate", new String[] {"10/31/09"});
|
||||
binder.bind(propertyValues);
|
||||
@@ -163,7 +163,7 @@ class DateTimeFormattingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testBindLocalDateAnnotated() {
|
||||
void bindLocalDateAnnotated() {
|
||||
MutablePropertyValues propertyValues = new MutablePropertyValues();
|
||||
propertyValues.add("styleLocalDate", "Oct 31, 2009");
|
||||
binder.bind(propertyValues);
|
||||
@@ -172,7 +172,7 @@ class DateTimeFormattingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testBindLocalDateAnnotatedWithError() {
|
||||
void bindLocalDateAnnotatedWithError() {
|
||||
MutablePropertyValues propertyValues = new MutablePropertyValues();
|
||||
propertyValues.add("styleLocalDate", "Oct -31, 2009");
|
||||
binder.bind(propertyValues);
|
||||
@@ -181,7 +181,7 @@ class DateTimeFormattingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testBindNestedLocalDateAnnotated() {
|
||||
void bindNestedLocalDateAnnotated() {
|
||||
MutablePropertyValues propertyValues = new MutablePropertyValues();
|
||||
propertyValues.add("children[0].styleLocalDate", "Oct 31, 2009");
|
||||
binder.bind(propertyValues);
|
||||
@@ -190,7 +190,7 @@ class DateTimeFormattingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testBindLocalDateAnnotatedWithDirectFieldAccess() {
|
||||
void bindLocalDateAnnotatedWithDirectFieldAccess() {
|
||||
binder.initDirectFieldAccess();
|
||||
MutablePropertyValues propertyValues = new MutablePropertyValues();
|
||||
propertyValues.add("styleLocalDate", "Oct 31, 2009");
|
||||
@@ -200,7 +200,7 @@ class DateTimeFormattingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testBindLocalDateAnnotatedWithDirectFieldAccessAndError() {
|
||||
void bindLocalDateAnnotatedWithDirectFieldAccessAndError() {
|
||||
binder.initDirectFieldAccess();
|
||||
MutablePropertyValues propertyValues = new MutablePropertyValues();
|
||||
propertyValues.add("styleLocalDate", "Oct -31, 2009");
|
||||
@@ -210,7 +210,7 @@ class DateTimeFormattingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testBindLocalDateFromJavaUtilCalendar() {
|
||||
void bindLocalDateFromJavaUtilCalendar() {
|
||||
MutablePropertyValues propertyValues = new MutablePropertyValues();
|
||||
propertyValues.add("localDate", new GregorianCalendar(2009, 9, 31, 0, 0));
|
||||
binder.bind(propertyValues);
|
||||
@@ -219,7 +219,7 @@ class DateTimeFormattingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testBindLocalTime() {
|
||||
void bindLocalTime() {
|
||||
MutablePropertyValues propertyValues = new MutablePropertyValues();
|
||||
propertyValues.add("localTime", "12:00%sPM".formatted(TIME_SEPARATOR));
|
||||
binder.bind(propertyValues);
|
||||
@@ -229,7 +229,7 @@ class DateTimeFormattingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testBindLocalTimeWithISO() {
|
||||
void bindLocalTimeWithISO() {
|
||||
MutablePropertyValues propertyValues = new MutablePropertyValues();
|
||||
propertyValues.add("localTime", "12:00:00");
|
||||
binder.bind(propertyValues);
|
||||
@@ -239,7 +239,7 @@ class DateTimeFormattingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testBindLocalTimeWithSpecificStyle() {
|
||||
void bindLocalTimeWithSpecificStyle() {
|
||||
DateTimeFormatterRegistrar registrar = new DateTimeFormatterRegistrar();
|
||||
registrar.setTimeStyle(FormatStyle.MEDIUM);
|
||||
setup(registrar);
|
||||
@@ -252,7 +252,7 @@ class DateTimeFormattingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testBindLocalTimeWithSpecificFormatter() {
|
||||
void bindLocalTimeWithSpecificFormatter() {
|
||||
DateTimeFormatterRegistrar registrar = new DateTimeFormatterRegistrar();
|
||||
registrar.setTimeFormatter(DateTimeFormatter.ofPattern("HHmmss"));
|
||||
setup(registrar);
|
||||
@@ -264,7 +264,7 @@ class DateTimeFormattingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testBindLocalTimeAnnotated() {
|
||||
void bindLocalTimeAnnotated() {
|
||||
MutablePropertyValues propertyValues = new MutablePropertyValues();
|
||||
propertyValues.add("styleLocalTime", "12:00:00%sPM".formatted(TIME_SEPARATOR));
|
||||
binder.bind(propertyValues);
|
||||
@@ -274,7 +274,7 @@ class DateTimeFormattingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testBindLocalTimeFromJavaUtilCalendar() {
|
||||
void bindLocalTimeFromJavaUtilCalendar() {
|
||||
MutablePropertyValues propertyValues = new MutablePropertyValues();
|
||||
propertyValues.add("localTime", new GregorianCalendar(1970, 0, 0, 12, 0));
|
||||
binder.bind(propertyValues);
|
||||
@@ -284,7 +284,7 @@ class DateTimeFormattingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testBindLocalDateTime() {
|
||||
void bindLocalDateTime() {
|
||||
MutablePropertyValues propertyValues = new MutablePropertyValues();
|
||||
propertyValues.add("localDateTime", LocalDateTime.of(2009, 10, 31, 12, 0));
|
||||
binder.bind(propertyValues);
|
||||
@@ -295,7 +295,7 @@ class DateTimeFormattingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testBindLocalDateTimeWithISO() {
|
||||
void bindLocalDateTimeWithISO() {
|
||||
MutablePropertyValues propertyValues = new MutablePropertyValues();
|
||||
propertyValues.add("localDateTime", "2009-10-31T12:00:00");
|
||||
binder.bind(propertyValues);
|
||||
@@ -306,7 +306,7 @@ class DateTimeFormattingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testBindLocalDateTimeAnnotated() {
|
||||
void bindLocalDateTimeAnnotated() {
|
||||
MutablePropertyValues propertyValues = new MutablePropertyValues();
|
||||
propertyValues.add("styleLocalDateTime", LocalDateTime.of(2009, 10, 31, 12, 0));
|
||||
binder.bind(propertyValues);
|
||||
@@ -317,7 +317,7 @@ class DateTimeFormattingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testBindLocalDateTimeFromJavaUtilCalendar() {
|
||||
void bindLocalDateTimeFromJavaUtilCalendar() {
|
||||
MutablePropertyValues propertyValues = new MutablePropertyValues();
|
||||
propertyValues.add("localDateTime", new GregorianCalendar(2009, 9, 31, 12, 0));
|
||||
binder.bind(propertyValues);
|
||||
@@ -328,7 +328,7 @@ class DateTimeFormattingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testBindDateTimeWithSpecificStyle() {
|
||||
void bindDateTimeWithSpecificStyle() {
|
||||
DateTimeFormatterRegistrar registrar = new DateTimeFormatterRegistrar();
|
||||
registrar.setDateTimeStyle(FormatStyle.MEDIUM);
|
||||
setup(registrar);
|
||||
@@ -342,7 +342,7 @@ class DateTimeFormattingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testBindPatternLocalDateTime() {
|
||||
void bindPatternLocalDateTime() {
|
||||
MutablePropertyValues propertyValues = new MutablePropertyValues();
|
||||
propertyValues.add("patternLocalDateTime", "10/31/09 12:00 PM");
|
||||
binder.bind(propertyValues);
|
||||
@@ -351,7 +351,7 @@ class DateTimeFormattingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testBindDateTimeOverflow() {
|
||||
void bindDateTimeOverflow() {
|
||||
MutablePropertyValues propertyValues = new MutablePropertyValues();
|
||||
propertyValues.add("patternLocalDateTime", "02/29/09 12:00 PM");
|
||||
binder.bind(propertyValues);
|
||||
@@ -359,7 +359,7 @@ class DateTimeFormattingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testBindISODate() {
|
||||
void bindISODate() {
|
||||
MutablePropertyValues propertyValues = new MutablePropertyValues();
|
||||
propertyValues.add("isoLocalDate", "2009-10-31");
|
||||
binder.bind(propertyValues);
|
||||
@@ -398,7 +398,7 @@ class DateTimeFormattingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testBindISOTime() {
|
||||
void bindISOTime() {
|
||||
MutablePropertyValues propertyValues = new MutablePropertyValues();
|
||||
propertyValues.add("isoLocalTime", "12:00:00");
|
||||
binder.bind(propertyValues);
|
||||
@@ -407,7 +407,7 @@ class DateTimeFormattingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testBindISOTimeWithZone() {
|
||||
void bindISOTimeWithZone() {
|
||||
MutablePropertyValues propertyValues = new MutablePropertyValues();
|
||||
propertyValues.add("isoLocalTime", "12:00:00.000-05:00");
|
||||
binder.bind(propertyValues);
|
||||
@@ -416,7 +416,7 @@ class DateTimeFormattingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testBindISODateTime() {
|
||||
void bindISODateTime() {
|
||||
MutablePropertyValues propertyValues = new MutablePropertyValues();
|
||||
propertyValues.add("isoLocalDateTime", "2009-10-31T12:00:00");
|
||||
binder.bind(propertyValues);
|
||||
@@ -425,7 +425,7 @@ class DateTimeFormattingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testBindISODateTimeWithZone() {
|
||||
void bindISODateTimeWithZone() {
|
||||
MutablePropertyValues propertyValues = new MutablePropertyValues();
|
||||
propertyValues.add("isoLocalDateTime", "2009-10-31T12:00:00.000Z");
|
||||
binder.bind(propertyValues);
|
||||
@@ -434,7 +434,7 @@ class DateTimeFormattingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testBindInstant() {
|
||||
void bindInstant() {
|
||||
MutablePropertyValues propertyValues = new MutablePropertyValues();
|
||||
propertyValues.add("instant", "2009-10-31T12:00:00.000Z");
|
||||
binder.bind(propertyValues);
|
||||
@@ -443,7 +443,7 @@ class DateTimeFormattingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testBindInstantAnnotated() {
|
||||
void bindInstantAnnotated() {
|
||||
MutablePropertyValues propertyValues = new MutablePropertyValues();
|
||||
propertyValues.add("styleInstant", "2017-02-21T13:00");
|
||||
binder.bind(propertyValues);
|
||||
@@ -453,7 +453,7 @@ class DateTimeFormattingTests {
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("deprecation")
|
||||
void testBindInstantFromJavaUtilDate() {
|
||||
void bindInstantFromJavaUtilDate() {
|
||||
TimeZone defaultZone = TimeZone.getDefault();
|
||||
TimeZone.setDefault(TimeZone.getTimeZone("GMT"));
|
||||
try {
|
||||
@@ -469,7 +469,7 @@ class DateTimeFormattingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testBindPeriod() {
|
||||
void bindPeriod() {
|
||||
MutablePropertyValues propertyValues = new MutablePropertyValues();
|
||||
propertyValues.add("period", "P6Y3M1D");
|
||||
binder.bind(propertyValues);
|
||||
@@ -478,7 +478,7 @@ class DateTimeFormattingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testBindDuration() {
|
||||
void bindDuration() {
|
||||
MutablePropertyValues propertyValues = new MutablePropertyValues();
|
||||
propertyValues.add("duration", "PT8H6M12.345S");
|
||||
binder.bind(propertyValues);
|
||||
@@ -487,7 +487,7 @@ class DateTimeFormattingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testBindDurationAnnotated() {
|
||||
void bindDurationAnnotated() {
|
||||
MutablePropertyValues propertyValues = new MutablePropertyValues();
|
||||
propertyValues.add("styleDuration", "2ms");
|
||||
binder.bind(propertyValues);
|
||||
@@ -498,7 +498,7 @@ class DateTimeFormattingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testBindYear() {
|
||||
void bindYear() {
|
||||
MutablePropertyValues propertyValues = new MutablePropertyValues();
|
||||
propertyValues.add("year", "2007");
|
||||
binder.bind(propertyValues);
|
||||
@@ -507,7 +507,7 @@ class DateTimeFormattingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testBindMonth() {
|
||||
void bindMonth() {
|
||||
MutablePropertyValues propertyValues = new MutablePropertyValues();
|
||||
propertyValues.add("month", "JULY");
|
||||
binder.bind(propertyValues);
|
||||
@@ -516,7 +516,7 @@ class DateTimeFormattingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testBindMonthInAnyCase() {
|
||||
void bindMonthInAnyCase() {
|
||||
MutablePropertyValues propertyValues = new MutablePropertyValues();
|
||||
propertyValues.add("month", "July");
|
||||
binder.bind(propertyValues);
|
||||
@@ -525,7 +525,7 @@ class DateTimeFormattingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testBindYearMonth() {
|
||||
void bindYearMonth() {
|
||||
MutablePropertyValues propertyValues = new MutablePropertyValues();
|
||||
propertyValues.add("yearMonth", "2007-12");
|
||||
binder.bind(propertyValues);
|
||||
@@ -534,7 +534,7 @@ class DateTimeFormattingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testBindYearMonthAnnotatedPattern() {
|
||||
void bindYearMonthAnnotatedPattern() {
|
||||
MutablePropertyValues propertyValues = new MutablePropertyValues();
|
||||
propertyValues.add("yearMonthAnnotatedPattern", "12/2007");
|
||||
binder.bind(propertyValues);
|
||||
@@ -544,7 +544,7 @@ class DateTimeFormattingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testBindMonthDay() {
|
||||
void bindMonthDay() {
|
||||
MutablePropertyValues propertyValues = new MutablePropertyValues();
|
||||
propertyValues.add("monthDay", "--12-03");
|
||||
binder.bind(propertyValues);
|
||||
@@ -553,7 +553,7 @@ class DateTimeFormattingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testBindMonthDayAnnotatedPattern() {
|
||||
void bindMonthDayAnnotatedPattern() {
|
||||
MutablePropertyValues propertyValues = new MutablePropertyValues();
|
||||
propertyValues.add("monthDayAnnotatedPattern", "1/3");
|
||||
binder.bind(propertyValues);
|
||||
@@ -695,7 +695,7 @@ class DateTimeFormattingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testBindInstantAsLongEpochMillis() {
|
||||
void bindInstantAsLongEpochMillis() {
|
||||
MutablePropertyValues propertyValues = new MutablePropertyValues();
|
||||
propertyValues.add("instant", 1234L);
|
||||
binder.bind(propertyValues);
|
||||
|
||||
+9
-9
@@ -70,7 +70,7 @@ class NumberFormattingTests {
|
||||
|
||||
|
||||
@Test
|
||||
void testDefaultNumberFormatting() {
|
||||
void defaultNumberFormatting() {
|
||||
MutablePropertyValues propertyValues = new MutablePropertyValues();
|
||||
propertyValues.add("numberDefault", "3,339.12");
|
||||
binder.bind(propertyValues);
|
||||
@@ -79,7 +79,7 @@ class NumberFormattingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testDefaultNumberFormattingAnnotated() {
|
||||
void defaultNumberFormattingAnnotated() {
|
||||
MutablePropertyValues propertyValues = new MutablePropertyValues();
|
||||
propertyValues.add("numberDefaultAnnotated", "3,339.12");
|
||||
binder.bind(propertyValues);
|
||||
@@ -88,7 +88,7 @@ class NumberFormattingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCurrencyFormatting() {
|
||||
void currencyFormatting() {
|
||||
MutablePropertyValues propertyValues = new MutablePropertyValues();
|
||||
propertyValues.add("currency", "$3,339.12");
|
||||
binder.bind(propertyValues);
|
||||
@@ -97,7 +97,7 @@ class NumberFormattingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testPercentFormatting() {
|
||||
void percentFormatting() {
|
||||
MutablePropertyValues propertyValues = new MutablePropertyValues();
|
||||
propertyValues.add("percent", "53%");
|
||||
binder.bind(propertyValues);
|
||||
@@ -106,7 +106,7 @@ class NumberFormattingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testPatternFormatting() {
|
||||
void patternFormatting() {
|
||||
MutablePropertyValues propertyValues = new MutablePropertyValues();
|
||||
propertyValues.add("pattern", "1,25.00");
|
||||
binder.bind(propertyValues);
|
||||
@@ -115,7 +115,7 @@ class NumberFormattingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testPatternArrayFormatting() {
|
||||
void patternArrayFormatting() {
|
||||
MutablePropertyValues propertyValues = new MutablePropertyValues();
|
||||
propertyValues.add("patternArray", new String[] { "1,25.00", "2,35.00" });
|
||||
binder.bind(propertyValues);
|
||||
@@ -133,7 +133,7 @@ class NumberFormattingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testPatternListFormatting() {
|
||||
void patternListFormatting() {
|
||||
MutablePropertyValues propertyValues = new MutablePropertyValues();
|
||||
propertyValues.add("patternList", new String[] { "1,25.00", "2,35.00" });
|
||||
binder.bind(propertyValues);
|
||||
@@ -151,7 +151,7 @@ class NumberFormattingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testPatternList2FormattingListElement() {
|
||||
void patternList2FormattingListElement() {
|
||||
MutablePropertyValues propertyValues = new MutablePropertyValues();
|
||||
propertyValues.add("patternList2[0]", "1,25.00");
|
||||
propertyValues.add("patternList2[1]", "2,35.00");
|
||||
@@ -162,7 +162,7 @@ class NumberFormattingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testPatternList2FormattingList() {
|
||||
void patternList2FormattingList() {
|
||||
MutablePropertyValues propertyValues = new MutablePropertyValues();
|
||||
propertyValues.add("patternList2[0]", "1,25.00");
|
||||
propertyValues.add("patternList2[1]", "2,35.00");
|
||||
|
||||
+6
-6
@@ -55,7 +55,7 @@ class MoneyFormattingTests {
|
||||
|
||||
|
||||
@Test
|
||||
void testAmountAndUnit() {
|
||||
void amountAndUnit() {
|
||||
MoneyHolder bean = new MoneyHolder();
|
||||
DataBinder binder = new DataBinder(bean);
|
||||
binder.setConversionService(conversionService);
|
||||
@@ -81,7 +81,7 @@ class MoneyFormattingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testAmountWithNumberFormat1() {
|
||||
void amountWithNumberFormat1() {
|
||||
FormattedMoneyHolder1 bean = new FormattedMoneyHolder1();
|
||||
DataBinder binder = new DataBinder(bean);
|
||||
binder.setConversionService(conversionService);
|
||||
@@ -104,7 +104,7 @@ class MoneyFormattingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testAmountWithNumberFormat2() {
|
||||
void amountWithNumberFormat2() {
|
||||
FormattedMoneyHolder2 bean = new FormattedMoneyHolder2();
|
||||
DataBinder binder = new DataBinder(bean);
|
||||
binder.setConversionService(conversionService);
|
||||
@@ -119,7 +119,7 @@ class MoneyFormattingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testAmountWithNumberFormat3() {
|
||||
void amountWithNumberFormat3() {
|
||||
FormattedMoneyHolder3 bean = new FormattedMoneyHolder3();
|
||||
DataBinder binder = new DataBinder(bean);
|
||||
binder.setConversionService(conversionService);
|
||||
@@ -134,7 +134,7 @@ class MoneyFormattingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testAmountWithNumberFormat4() {
|
||||
void amountWithNumberFormat4() {
|
||||
FormattedMoneyHolder4 bean = new FormattedMoneyHolder4();
|
||||
DataBinder binder = new DataBinder(bean);
|
||||
binder.setConversionService(conversionService);
|
||||
@@ -149,7 +149,7 @@ class MoneyFormattingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testAmountWithNumberFormat5() {
|
||||
void amountWithNumberFormat5() {
|
||||
FormattedMoneyHolder5 bean = new FormattedMoneyHolder5();
|
||||
DataBinder binder = new DataBinder(bean);
|
||||
binder.setConversionService(conversionService);
|
||||
|
||||
+5
-5
@@ -49,7 +49,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
|
||||
class FormattingConversionServiceFactoryBeanTests {
|
||||
|
||||
@Test
|
||||
void testDefaultFormattersOn() throws Exception {
|
||||
void defaultFormattersOn() throws Exception {
|
||||
FormattingConversionServiceFactoryBean factory = new FormattingConversionServiceFactoryBean();
|
||||
factory.afterPropertiesSet();
|
||||
FormattingConversionService fcs = factory.getObject();
|
||||
@@ -68,7 +68,7 @@ class FormattingConversionServiceFactoryBeanTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testDefaultFormattersOff() throws Exception {
|
||||
void defaultFormattersOff() throws Exception {
|
||||
FormattingConversionServiceFactoryBean factory = new FormattingConversionServiceFactoryBean();
|
||||
factory.setRegisterDefaultFormatters(false);
|
||||
factory.afterPropertiesSet();
|
||||
@@ -81,7 +81,7 @@ class FormattingConversionServiceFactoryBeanTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCustomFormatter() throws Exception {
|
||||
void customFormatter() throws Exception {
|
||||
FormattingConversionServiceFactoryBean factory = new FormattingConversionServiceFactoryBean();
|
||||
Set<Object> formatters = new HashSet<>();
|
||||
formatters.add(new TestBeanFormatter());
|
||||
@@ -102,7 +102,7 @@ class FormattingConversionServiceFactoryBeanTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFormatterRegistrar() {
|
||||
void formatterRegistrar() {
|
||||
FormattingConversionServiceFactoryBean factory = new FormattingConversionServiceFactoryBean();
|
||||
Set<FormatterRegistrar> registrars = new HashSet<>();
|
||||
registrars.add(new TestFormatterRegistrar());
|
||||
@@ -116,7 +116,7 @@ class FormattingConversionServiceFactoryBeanTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testInvalidFormatter() {
|
||||
void invalidFormatter() {
|
||||
FormattingConversionServiceFactoryBean factory = new FormattingConversionServiceFactoryBean();
|
||||
Set<Object> formatters = new HashSet<>();
|
||||
formatters.add(new Object());
|
||||
|
||||
+1
-1
@@ -30,7 +30,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
class InstrumentableClassLoaderTests {
|
||||
|
||||
@Test
|
||||
void testDefaultLoadTimeWeaver() {
|
||||
void defaultLoadTimeWeaver() {
|
||||
ClassLoader loader = new SimpleInstrumentableClassLoader(ClassUtils.getDefaultClassLoader());
|
||||
ReflectiveLoadTimeWeaver handler = new ReflectiveLoadTimeWeaver(loader);
|
||||
assertThat(handler.getInstrumentableClassLoader()).isSameAs(loader);
|
||||
|
||||
+6
-6
@@ -34,19 +34,19 @@ import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
|
||||
class ReflectiveLoadTimeWeaverTests {
|
||||
|
||||
@Test
|
||||
void testCtorWithNullClassLoader() {
|
||||
void ctorWithNullClassLoader() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() ->
|
||||
new ReflectiveLoadTimeWeaver(null));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCtorWithClassLoaderThatDoesNotExposeAnAddTransformerMethod() {
|
||||
void ctorWithClassLoaderThatDoesNotExposeAnAddTransformerMethod() {
|
||||
assertThatIllegalStateException().isThrownBy(() ->
|
||||
new ReflectiveLoadTimeWeaver(getClass().getClassLoader()));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCtorWithClassLoaderThatDoesNotExposeAGetThrowawayClassLoaderMethodIsOkay() {
|
||||
void ctorWithClassLoaderThatDoesNotExposeAGetThrowawayClassLoaderMethodIsOkay() {
|
||||
JustAddTransformerClassLoader classLoader = new JustAddTransformerClassLoader();
|
||||
ReflectiveLoadTimeWeaver weaver = new ReflectiveLoadTimeWeaver(classLoader);
|
||||
weaver.addTransformer(new ClassFileTransformer() {
|
||||
@@ -59,20 +59,20 @@ class ReflectiveLoadTimeWeaverTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testAddTransformerWithNullTransformer() {
|
||||
void addTransformerWithNullTransformer() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() ->
|
||||
new ReflectiveLoadTimeWeaver(new JustAddTransformerClassLoader()).addTransformer(null));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGetThrowawayClassLoaderWithClassLoaderThatDoesNotExposeAGetThrowawayClassLoaderMethodYieldsFallbackClassLoader() {
|
||||
void getThrowawayClassLoaderWithClassLoaderThatDoesNotExposeAGetThrowawayClassLoaderMethodYieldsFallbackClassLoader() {
|
||||
ReflectiveLoadTimeWeaver weaver = new ReflectiveLoadTimeWeaver(new JustAddTransformerClassLoader());
|
||||
ClassLoader throwawayClassLoader = weaver.getThrowawayClassLoader();
|
||||
assertThat(throwawayClassLoader).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGetThrowawayClassLoaderWithTotallyCompliantClassLoader() {
|
||||
void getThrowawayClassLoaderWithTotallyCompliantClassLoader() {
|
||||
TotallyCompliantClassLoader classLoader = new TotallyCompliantClassLoader();
|
||||
ReflectiveLoadTimeWeaver weaver = new ReflectiveLoadTimeWeaver(classLoader);
|
||||
ClassLoader throwawayClassLoader = weaver.getThrowawayClassLoader();
|
||||
|
||||
+6
-6
@@ -38,40 +38,40 @@ class ResourceOverridingShadowingClassLoaderTests {
|
||||
|
||||
|
||||
@Test
|
||||
void testFindsExistingResourceWithGetResourceAndNoOverrides() {
|
||||
void findsExistingResourceWithGetResourceAndNoOverrides() {
|
||||
assertThat(thisClassLoader.getResource(EXISTING_RESOURCE)).isNotNull();
|
||||
assertThat(overridingLoader.getResource(EXISTING_RESOURCE)).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testDoesNotFindExistingResourceWithGetResourceAndNullOverride() {
|
||||
void doesNotFindExistingResourceWithGetResourceAndNullOverride() {
|
||||
assertThat(thisClassLoader.getResource(EXISTING_RESOURCE)).isNotNull();
|
||||
overridingLoader.override(EXISTING_RESOURCE, null);
|
||||
assertThat(overridingLoader.getResource(EXISTING_RESOURCE)).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFindsExistingResourceWithGetResourceAsStreamAndNoOverrides() {
|
||||
void findsExistingResourceWithGetResourceAsStreamAndNoOverrides() {
|
||||
assertThat(thisClassLoader.getResourceAsStream(EXISTING_RESOURCE)).isNotNull();
|
||||
assertThat(overridingLoader.getResourceAsStream(EXISTING_RESOURCE)).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testDoesNotFindExistingResourceWithGetResourceAsStreamAndNullOverride() {
|
||||
void doesNotFindExistingResourceWithGetResourceAsStreamAndNullOverride() {
|
||||
assertThat(thisClassLoader.getResourceAsStream(EXISTING_RESOURCE)).isNotNull();
|
||||
overridingLoader.override(EXISTING_RESOURCE, null);
|
||||
assertThat(overridingLoader.getResourceAsStream(EXISTING_RESOURCE)).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFindsExistingResourceWithGetResourcesAndNoOverrides() throws IOException {
|
||||
void findsExistingResourceWithGetResourcesAndNoOverrides() throws IOException {
|
||||
assertThat(thisClassLoader.getResources(EXISTING_RESOURCE)).isNotNull();
|
||||
assertThat(overridingLoader.getResources(EXISTING_RESOURCE)).isNotNull();
|
||||
assertThat(countElements(overridingLoader.getResources(EXISTING_RESOURCE))).isEqualTo(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testDoesNotFindExistingResourceWithGetResourcesAndNullOverride() throws IOException {
|
||||
void doesNotFindExistingResourceWithGetResourcesAndNullOverride() throws IOException {
|
||||
assertThat(thisClassLoader.getResources(EXISTING_RESOURCE)).isNotNull();
|
||||
overridingLoader.override(EXISTING_RESOURCE, null);
|
||||
assertThat(countElements(overridingLoader.getResources(EXISTING_RESOURCE))).isEqualTo(0);
|
||||
|
||||
+4
-4
@@ -39,7 +39,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
class MBeanExporterOperationsTests extends AbstractMBeanServerTests {
|
||||
|
||||
@Test
|
||||
void testRegisterManagedResourceWithUserSuppliedObjectName() throws Exception {
|
||||
void registerManagedResourceWithUserSuppliedObjectName() throws Exception {
|
||||
ObjectName objectName = ObjectNameManager.getInstance("spring:name=Foo");
|
||||
|
||||
JmxTestBean bean = new JmxTestBean();
|
||||
@@ -54,7 +54,7 @@ class MBeanExporterOperationsTests extends AbstractMBeanServerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testRegisterExistingMBeanWithUserSuppliedObjectName() throws Exception {
|
||||
void registerExistingMBeanWithUserSuppliedObjectName() throws Exception {
|
||||
ObjectName objectName = ObjectNameManager.getInstance("spring:name=Foo");
|
||||
ModelMBeanInfo info = new ModelMBeanInfoSupport("myClass", "myDescription", null, null, null, null);
|
||||
RequiredModelMBean bean = new RequiredModelMBean(info);
|
||||
@@ -68,7 +68,7 @@ class MBeanExporterOperationsTests extends AbstractMBeanServerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testRegisterManagedResourceWithGeneratedObjectName() throws Exception {
|
||||
void registerManagedResourceWithGeneratedObjectName() throws Exception {
|
||||
final ObjectName objectNameTemplate = ObjectNameManager.getInstance("spring:type=Test");
|
||||
|
||||
MBeanExporter exporter = new MBeanExporter();
|
||||
@@ -89,7 +89,7 @@ class MBeanExporterOperationsTests extends AbstractMBeanServerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testRegisterManagedResourceWithGeneratedObjectNameWithoutUniqueness() throws Exception {
|
||||
void registerManagedResourceWithGeneratedObjectNameWithoutUniqueness() throws Exception {
|
||||
final ObjectName objectNameTemplate = ObjectNameManager.getInstance("spring:type=Test");
|
||||
|
||||
MBeanExporter exporter = new MBeanExporter();
|
||||
|
||||
+13
-13
@@ -46,7 +46,7 @@ class NotificationListenerTests extends AbstractMBeanServerTests {
|
||||
|
||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||
@Test
|
||||
void testRegisterNotificationListenerForMBean() throws Exception {
|
||||
void registerNotificationListenerForMBean() throws Exception {
|
||||
ObjectName objectName = ObjectName.getInstance("spring:name=Test");
|
||||
JmxTestBean bean = new JmxTestBean();
|
||||
|
||||
@@ -72,7 +72,7 @@ class NotificationListenerTests extends AbstractMBeanServerTests {
|
||||
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
@Test
|
||||
void testRegisterNotificationListenerWithWildcard() throws Exception {
|
||||
void registerNotificationListenerWithWildcard() throws Exception {
|
||||
ObjectName objectName = ObjectName.getInstance("spring:name=Test");
|
||||
JmxTestBean bean = new JmxTestBean();
|
||||
|
||||
@@ -97,7 +97,7 @@ class NotificationListenerTests extends AbstractMBeanServerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testRegisterNotificationListenerWithHandback() throws Exception {
|
||||
void registerNotificationListenerWithHandback() throws Exception {
|
||||
String objectName = "spring:name=Test";
|
||||
JmxTestBean bean = new JmxTestBean();
|
||||
|
||||
@@ -128,7 +128,7 @@ class NotificationListenerTests extends AbstractMBeanServerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testRegisterNotificationListenerForAllMBeans() throws Exception {
|
||||
void registerNotificationListenerForAllMBeans() throws Exception {
|
||||
ObjectName objectName = ObjectName.getInstance("spring:name=Test");
|
||||
JmxTestBean bean = new JmxTestBean();
|
||||
|
||||
@@ -155,7 +155,7 @@ class NotificationListenerTests extends AbstractMBeanServerTests {
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
@Test
|
||||
void testRegisterNotificationListenerWithFilter() throws Exception {
|
||||
void registerNotificationListenerWithFilter() throws Exception {
|
||||
ObjectName objectName = ObjectName.getInstance("spring:name=Test");
|
||||
JmxTestBean bean = new JmxTestBean();
|
||||
|
||||
@@ -193,14 +193,14 @@ class NotificationListenerTests extends AbstractMBeanServerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCreationWithNoNotificationListenerSet() {
|
||||
void creationWithNoNotificationListenerSet() {
|
||||
assertThatIllegalArgumentException().as("no NotificationListener supplied").isThrownBy(
|
||||
new NotificationListenerBean()::afterPropertiesSet);
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
@Test
|
||||
void testRegisterNotificationListenerWithBeanNameAndBeanNameInBeansMap() throws Exception {
|
||||
void registerNotificationListenerWithBeanNameAndBeanNameInBeansMap() throws Exception {
|
||||
String beanName = "testBean";
|
||||
ObjectName objectName = ObjectName.getInstance("spring:name=Test");
|
||||
|
||||
@@ -231,7 +231,7 @@ class NotificationListenerTests extends AbstractMBeanServerTests {
|
||||
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
@Test
|
||||
void testRegisterNotificationListenerWithBeanNameAndBeanInstanceInBeansMap() throws Exception {
|
||||
void registerNotificationListenerWithBeanNameAndBeanInstanceInBeansMap() throws Exception {
|
||||
String beanName = "testBean";
|
||||
ObjectName objectName = ObjectName.getInstance("spring:name=Test");
|
||||
|
||||
@@ -262,7 +262,7 @@ class NotificationListenerTests extends AbstractMBeanServerTests {
|
||||
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
@Test
|
||||
void testRegisterNotificationListenerWithBeanNameBeforeObjectNameMappedToSameBeanInstance() throws Exception {
|
||||
void registerNotificationListenerWithBeanNameBeforeObjectNameMappedToSameBeanInstance() throws Exception {
|
||||
String beanName = "testBean";
|
||||
ObjectName objectName = ObjectName.getInstance("spring:name=Test");
|
||||
|
||||
@@ -294,7 +294,7 @@ class NotificationListenerTests extends AbstractMBeanServerTests {
|
||||
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
@Test
|
||||
void testRegisterNotificationListenerWithObjectNameBeforeBeanNameMappedToSameBeanInstance() throws Exception {
|
||||
void registerNotificationListenerWithObjectNameBeforeBeanNameMappedToSameBeanInstance() throws Exception {
|
||||
String beanName = "testBean";
|
||||
ObjectName objectName = ObjectName.getInstance("spring:name=Test");
|
||||
|
||||
@@ -326,7 +326,7 @@ class NotificationListenerTests extends AbstractMBeanServerTests {
|
||||
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
@Test
|
||||
void testRegisterNotificationListenerWithTwoBeanNamesMappedToDifferentBeanInstances() throws Exception {
|
||||
void registerNotificationListenerWithTwoBeanNamesMappedToDifferentBeanInstances() throws Exception {
|
||||
String beanName1 = "testBean1";
|
||||
String beanName2 = "testBean2";
|
||||
|
||||
@@ -369,7 +369,7 @@ class NotificationListenerTests extends AbstractMBeanServerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testNotificationListenerRegistrar() throws Exception {
|
||||
void notificationListenerRegistrar() throws Exception {
|
||||
ObjectName objectName = ObjectName.getInstance("spring:name=Test");
|
||||
JmxTestBean bean = new JmxTestBean();
|
||||
|
||||
@@ -402,7 +402,7 @@ class NotificationListenerTests extends AbstractMBeanServerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testNotificationListenerRegistrarWithMultipleNames() throws Exception {
|
||||
void notificationListenerRegistrarWithMultipleNames() throws Exception {
|
||||
ObjectName objectName = ObjectName.getInstance("spring:name=Test");
|
||||
ObjectName objectName2 = ObjectName.getInstance("spring:name=Test2");
|
||||
JmxTestBean bean = new JmxTestBean();
|
||||
|
||||
+5
-5
@@ -49,7 +49,7 @@ class NotificationPublisherTests extends AbstractMBeanServerTests {
|
||||
private CountingNotificationListener listener = new CountingNotificationListener();
|
||||
|
||||
@Test
|
||||
void testSimpleBean() throws Exception {
|
||||
void simpleBean() throws Exception {
|
||||
// start the MBeanExporter
|
||||
ConfigurableApplicationContext ctx = loadContext("org/springframework/jmx/export/notificationPublisherTests.xml");
|
||||
this.server.addNotificationListener(ObjectNameManager.getInstance("spring:type=Publisher"), listener, null,
|
||||
@@ -62,7 +62,7 @@ class NotificationPublisherTests extends AbstractMBeanServerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSimpleBeanRegisteredManually() throws Exception {
|
||||
void simpleBeanRegisteredManually() throws Exception {
|
||||
// start the MBeanExporter
|
||||
ConfigurableApplicationContext ctx = loadContext("org/springframework/jmx/export/notificationPublisherTests.xml");
|
||||
MBeanExporter exporter = (MBeanExporter) ctx.getBean("exporter");
|
||||
@@ -77,7 +77,7 @@ class NotificationPublisherTests extends AbstractMBeanServerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testMBean() throws Exception {
|
||||
void mBean() throws Exception {
|
||||
// start the MBeanExporter
|
||||
ConfigurableApplicationContext ctx = loadContext("org/springframework/jmx/export/notificationPublisherTests.xml");
|
||||
this.server.addNotificationListener(ObjectNameManager.getInstance("spring:type=PublisherMBean"), listener,
|
||||
@@ -90,7 +90,7 @@ class NotificationPublisherTests extends AbstractMBeanServerTests {
|
||||
|
||||
/*
|
||||
@Test
|
||||
void testStandardMBean() throws Exception {
|
||||
void standardMBean() throws Exception {
|
||||
// start the MBeanExporter
|
||||
ApplicationContext ctx = new ClassPathXmlApplicationContext("org/springframework/jmx/export/notificationPublisherTests.xml");
|
||||
this.server.addNotificationListener(ObjectNameManager.getInstance("spring:type=PublisherStandardMBean"), listener, null, null);
|
||||
@@ -102,7 +102,7 @@ class NotificationPublisherTests extends AbstractMBeanServerTests {
|
||||
*/
|
||||
|
||||
@Test
|
||||
void testLazyInit() throws Exception {
|
||||
void lazyInit() throws Exception {
|
||||
// start the MBeanExporter
|
||||
ConfigurableApplicationContext ctx = loadContext("org/springframework/jmx/export/notificationPublisherLazyTests.xml");
|
||||
assertThat(ctx.getBeanFactory().containsSingleton("publisher")).as("Should not have instantiated the bean yet").isFalse();
|
||||
|
||||
+4
-4
@@ -50,7 +50,7 @@ class AnnotationMetadataAssemblerTests extends AbstractMetadataAssemblerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testAttributeFromInterface() throws Exception {
|
||||
void attributeFromInterface() throws Exception {
|
||||
ModelMBeanInfo inf = getMBeanInfoFromAssembler();
|
||||
ModelMBeanAttributeInfo attr = inf.getAttribute("Colour");
|
||||
assertThat(attr.isWritable()).as("The name attribute should be writable").isTrue();
|
||||
@@ -58,21 +58,21 @@ class AnnotationMetadataAssemblerTests extends AbstractMetadataAssemblerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testOperationFromInterface() throws Exception {
|
||||
void operationFromInterface() throws Exception {
|
||||
ModelMBeanInfo inf = getMBeanInfoFromAssembler();
|
||||
ModelMBeanOperationInfo op = inf.getOperation("fromInterface");
|
||||
assertThat(op).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testOperationOnGetter() throws Exception {
|
||||
void operationOnGetter() throws Exception {
|
||||
ModelMBeanInfo inf = getMBeanInfoFromAssembler();
|
||||
ModelMBeanOperationInfo op = inf.getOperation("getExpensiveToCalculate");
|
||||
assertThat(op).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testRegistrationOnInterface() throws Exception {
|
||||
void registrationOnInterface() throws Exception {
|
||||
Object bean = getContext().getBean("testInterfaceBean");
|
||||
ModelMBeanInfo inf = getAssembler().getMBeanInfo(bean, "bean:name=interfaceTestBean");
|
||||
assertThat(inf).isNotNull();
|
||||
|
||||
+8
-8
@@ -63,7 +63,7 @@ class EnableMBeanExportConfigurationTests {
|
||||
|
||||
|
||||
@Test
|
||||
void testLazyNaming() throws Exception {
|
||||
void lazyNaming() throws Exception {
|
||||
load(LazyNamingConfiguration.class);
|
||||
validateAnnotationTestBean();
|
||||
}
|
||||
@@ -73,14 +73,14 @@ class EnableMBeanExportConfigurationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testOnlyTargetClassIsExposed() throws Exception {
|
||||
void onlyTargetClassIsExposed() throws Exception {
|
||||
load(ProxyConfiguration.class);
|
||||
validateAnnotationTestBean();
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("resource")
|
||||
public void testPackagePrivateExtensionCantBeExposed() {
|
||||
void packagePrivateExtensionCantBeExposed() {
|
||||
assertThatExceptionOfType(InvalidMetadataException.class).isThrownBy(() ->
|
||||
new AnnotationConfigApplicationContext(PackagePrivateConfiguration.class))
|
||||
.withMessageContaining(PackagePrivateTestBean.class.getName())
|
||||
@@ -89,7 +89,7 @@ class EnableMBeanExportConfigurationTests {
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("resource")
|
||||
public void testPackagePrivateImplementationCantBeExposed() {
|
||||
void packagePrivateImplementationCantBeExposed() {
|
||||
assertThatExceptionOfType(InvalidMetadataException.class).isThrownBy(() ->
|
||||
new AnnotationConfigApplicationContext(PackagePrivateInterfaceImplementationConfiguration.class))
|
||||
.withMessageContaining(PackagePrivateAnnotationTestBean.class.getName())
|
||||
@@ -97,13 +97,13 @@ class EnableMBeanExportConfigurationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testPackagePrivateClassExtensionCanBeExposed() throws Exception {
|
||||
void packagePrivateClassExtensionCanBeExposed() throws Exception {
|
||||
load(PackagePrivateExtensionConfiguration.class);
|
||||
validateAnnotationTestBean();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testPlaceholderBased() throws Exception {
|
||||
void placeholderBased() throws Exception {
|
||||
MockEnvironment env = new MockEnvironment();
|
||||
env.setProperty("serverName", "server");
|
||||
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
|
||||
@@ -115,7 +115,7 @@ class EnableMBeanExportConfigurationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testLazyAssembling() throws Exception {
|
||||
void lazyAssembling() throws Exception {
|
||||
System.setProperty("domain", "bean");
|
||||
load(LazyAssemblingConfiguration.class);
|
||||
try {
|
||||
@@ -132,7 +132,7 @@ class EnableMBeanExportConfigurationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testComponentScan() throws Exception {
|
||||
void componentScan() throws Exception {
|
||||
load(ComponentScanConfiguration.class);
|
||||
MBeanServer server = (MBeanServer) this.ctx.getBean("server");
|
||||
validateMBeanAttribute(server, "bean:name=testBean4", null);
|
||||
|
||||
+15
-15
@@ -49,20 +49,20 @@ public abstract class AbstractMetadataAssemblerTests extends AbstractJmxAssemble
|
||||
protected static final String CACHE_ENTRIES_METRIC = "CacheEntries";
|
||||
|
||||
@Test
|
||||
void testDescription() throws Exception {
|
||||
void description() throws Exception {
|
||||
ModelMBeanInfo info = getMBeanInfoFromAssembler();
|
||||
assertThat(info.getDescription()).as("The descriptions are not the same").isEqualTo("My Managed Bean");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testAttributeDescriptionOnSetter() throws Exception {
|
||||
void attributeDescriptionOnSetter() throws Exception {
|
||||
ModelMBeanInfo inf = getMBeanInfoFromAssembler();
|
||||
ModelMBeanAttributeInfo attr = inf.getAttribute(AGE_ATTRIBUTE);
|
||||
assertThat(attr.getDescription()).as("The description for the age attribute is incorrect").isEqualTo("The Age Attribute");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testAttributeDescriptionOnGetter() throws Exception {
|
||||
void attributeDescriptionOnGetter() throws Exception {
|
||||
ModelMBeanInfo inf = getMBeanInfoFromAssembler();
|
||||
ModelMBeanAttributeInfo attr = inf.getAttribute(NAME_ATTRIBUTE);
|
||||
assertThat(attr.getDescription()).as("The description for the name attribute is incorrect").isEqualTo("The Name Attribute");
|
||||
@@ -72,14 +72,14 @@ public abstract class AbstractMetadataAssemblerTests extends AbstractJmxAssemble
|
||||
* Tests the situation where the attribute is only defined on the getter.
|
||||
*/
|
||||
@Test
|
||||
void testReadOnlyAttribute() throws Exception {
|
||||
void readOnlyAttribute() throws Exception {
|
||||
ModelMBeanInfo inf = getMBeanInfoFromAssembler();
|
||||
ModelMBeanAttributeInfo attr = inf.getAttribute(AGE_ATTRIBUTE);
|
||||
assertThat(attr.isWritable()).as("The age attribute should not be writable").isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testReadWriteAttribute() throws Exception {
|
||||
void readWriteAttribute() throws Exception {
|
||||
ModelMBeanInfo inf = getMBeanInfoFromAssembler();
|
||||
ModelMBeanAttributeInfo attr = inf.getAttribute(NAME_ATTRIBUTE);
|
||||
assertThat(attr.isWritable()).as("The name attribute should be writable").isTrue();
|
||||
@@ -90,7 +90,7 @@ public abstract class AbstractMetadataAssemblerTests extends AbstractJmxAssemble
|
||||
* Tests the situation where the property only has a getter.
|
||||
*/
|
||||
@Test
|
||||
void testWithOnlySetter() throws Exception {
|
||||
void withOnlySetter() throws Exception {
|
||||
ModelMBeanInfo inf = getMBeanInfoFromAssembler();
|
||||
ModelMBeanAttributeInfo attr = inf.getAttribute("NickName");
|
||||
assertThat(attr).as("Attribute should not be null").isNotNull();
|
||||
@@ -100,14 +100,14 @@ public abstract class AbstractMetadataAssemblerTests extends AbstractJmxAssemble
|
||||
* Tests the situation where the property only has a setter.
|
||||
*/
|
||||
@Test
|
||||
void testWithOnlyGetter() throws Exception {
|
||||
void withOnlyGetter() throws Exception {
|
||||
ModelMBeanInfo info = getMBeanInfoFromAssembler();
|
||||
ModelMBeanAttributeInfo attr = info.getAttribute("Superman");
|
||||
assertThat(attr).as("Attribute should not be null").isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testManagedResourceDescriptor() throws Exception {
|
||||
void managedResourceDescriptor() throws Exception {
|
||||
ModelMBeanInfo info = getMBeanInfoFromAssembler();
|
||||
Descriptor desc = info.getMBeanDescriptor();
|
||||
|
||||
@@ -121,7 +121,7 @@ public abstract class AbstractMetadataAssemblerTests extends AbstractJmxAssemble
|
||||
}
|
||||
|
||||
@Test
|
||||
void testAttributeDescriptor() throws Exception {
|
||||
void attributeDescriptor() throws Exception {
|
||||
ModelMBeanInfo info = getMBeanInfoFromAssembler();
|
||||
Descriptor desc = info.getAttribute(NAME_ATTRIBUTE).getDescriptor();
|
||||
|
||||
@@ -132,7 +132,7 @@ public abstract class AbstractMetadataAssemblerTests extends AbstractJmxAssemble
|
||||
}
|
||||
|
||||
@Test
|
||||
void testOperationDescriptor() throws Exception {
|
||||
void operationDescriptor() throws Exception {
|
||||
ModelMBeanInfo info = getMBeanInfoFromAssembler();
|
||||
Descriptor desc = info.getOperation("myOperation").getDescriptor();
|
||||
|
||||
@@ -141,7 +141,7 @@ public abstract class AbstractMetadataAssemblerTests extends AbstractJmxAssemble
|
||||
}
|
||||
|
||||
@Test
|
||||
void testOperationParameterMetadata() throws Exception {
|
||||
void operationParameterMetadata() throws Exception {
|
||||
ModelMBeanInfo info = getMBeanInfoFromAssembler();
|
||||
ModelMBeanOperationInfo oper = info.getOperation("add");
|
||||
MBeanParameterInfo[] params = oper.getSignature();
|
||||
@@ -155,7 +155,7 @@ public abstract class AbstractMetadataAssemblerTests extends AbstractJmxAssemble
|
||||
}
|
||||
|
||||
@Test
|
||||
void testWithCglibProxy() throws Exception {
|
||||
void withCglibProxy() throws Exception {
|
||||
Object tb = createJmxTestBean();
|
||||
ProxyFactory pf = new ProxyFactory();
|
||||
pf.setTarget(tb);
|
||||
@@ -183,7 +183,7 @@ public abstract class AbstractMetadataAssemblerTests extends AbstractJmxAssemble
|
||||
}
|
||||
|
||||
@Test
|
||||
void testMetricDescription() throws Exception {
|
||||
void metricDescription() throws Exception {
|
||||
ModelMBeanInfo inf = getMBeanInfoFromAssembler();
|
||||
ModelMBeanAttributeInfo metric = inf.getAttribute(QUEUE_SIZE_METRIC);
|
||||
ModelMBeanOperationInfo operation = inf.getOperation("getQueueSize");
|
||||
@@ -192,7 +192,7 @@ public abstract class AbstractMetadataAssemblerTests extends AbstractJmxAssemble
|
||||
}
|
||||
|
||||
@Test
|
||||
void testMetricDescriptor() throws Exception {
|
||||
void metricDescriptor() throws Exception {
|
||||
ModelMBeanInfo info = getMBeanInfoFromAssembler();
|
||||
Descriptor desc = info.getAttribute(QUEUE_SIZE_METRIC).getDescriptor();
|
||||
assertThat(desc.getFieldValue("currencyTimeLimit")).as("Currency Time Limit should be 20").isEqualTo("20");
|
||||
@@ -205,7 +205,7 @@ public abstract class AbstractMetadataAssemblerTests extends AbstractJmxAssemble
|
||||
}
|
||||
|
||||
@Test
|
||||
void testMetricDescriptorDefaults() throws Exception {
|
||||
void metricDescriptorDefaults() throws Exception {
|
||||
ModelMBeanInfo info = getMBeanInfoFromAssembler();
|
||||
Descriptor desc = info.getAttribute(CACHE_ENTRIES_METRIC).getDescriptor();
|
||||
assertThat(desc.getFieldValue("currencyTimeLimit")).as("Currency Time Limit should not be populated").isNull();
|
||||
|
||||
+1
-1
@@ -55,7 +55,7 @@ class InterfaceBasedMBeanInfoAssemblerCustomTests extends AbstractJmxAssemblerTe
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGetAgeIsReadOnly() throws Exception {
|
||||
void getAgeIsReadOnly() throws Exception {
|
||||
ModelMBeanInfo info = getMBeanInfoFromAssembler();
|
||||
ModelMBeanAttributeInfo attr = info.getAttribute(AGE_ATTRIBUTE);
|
||||
|
||||
|
||||
+5
-5
@@ -36,7 +36,7 @@ class InterfaceBasedMBeanInfoAssemblerMappedTests extends AbstractJmxAssemblerTe
|
||||
protected static final String OBJECT_NAME = "bean:name=testBean4";
|
||||
|
||||
@Test
|
||||
void testGetAgeIsReadOnly() throws Exception {
|
||||
void getAgeIsReadOnly() throws Exception {
|
||||
ModelMBeanInfo info = getMBeanInfoFromAssembler();
|
||||
ModelMBeanAttributeInfo attr = info.getAttribute(AGE_ATTRIBUTE);
|
||||
|
||||
@@ -45,19 +45,19 @@ class InterfaceBasedMBeanInfoAssemblerMappedTests extends AbstractJmxAssemblerTe
|
||||
}
|
||||
|
||||
@Test
|
||||
void testWithUnknownClass() {
|
||||
void withUnknownClass() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() ->
|
||||
getWithMapping("com.foo.bar.Unknown"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testWithNonInterface() {
|
||||
void withNonInterface() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() ->
|
||||
getWithMapping("JmxTestBean"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testWithFallThrough() throws Exception {
|
||||
void withFallThrough() throws Exception {
|
||||
InterfaceBasedMBeanInfoAssembler assembler =
|
||||
getWithMapping("foobar", "org.springframework.jmx.export.assembler.ICustomJmxBean");
|
||||
assembler.setManagedInterfaces(new Class<?>[] {IAdditionalTestMethods.class});
|
||||
@@ -69,7 +69,7 @@ class InterfaceBasedMBeanInfoAssemblerMappedTests extends AbstractJmxAssemblerTe
|
||||
}
|
||||
|
||||
@Test
|
||||
void testNickNameIsExposed() throws Exception {
|
||||
void nickNameIsExposed() throws Exception {
|
||||
ModelMBeanInfo inf = (ModelMBeanInfo) getMBeanInfo();
|
||||
MBeanAttributeInfo attr = inf.getAttribute("NickName");
|
||||
|
||||
|
||||
+2
-2
@@ -36,7 +36,7 @@ class MethodExclusionMBeanInfoAssemblerComboTests extends AbstractJmxAssemblerTe
|
||||
protected static final String OBJECT_NAME = "bean:name=testBean4";
|
||||
|
||||
@Test
|
||||
void testGetAgeIsReadOnly() throws Exception {
|
||||
void getAgeIsReadOnly() throws Exception {
|
||||
ModelMBeanInfo info = getMBeanInfoFromAssembler();
|
||||
ModelMBeanAttributeInfo attr = info.getAttribute(AGE_ATTRIBUTE);
|
||||
assertThat(attr.isReadable()).as("Age is not readable").isTrue();
|
||||
@@ -44,7 +44,7 @@ class MethodExclusionMBeanInfoAssemblerComboTests extends AbstractJmxAssemblerTe
|
||||
}
|
||||
|
||||
@Test
|
||||
void testNickNameIsExposed() throws Exception {
|
||||
void nickNameIsExposed() throws Exception {
|
||||
ModelMBeanInfo inf = (ModelMBeanInfo) getMBeanInfo();
|
||||
MBeanAttributeInfo attr = inf.getAttribute("NickName");
|
||||
assertThat(attr).as("Nick Name should not be null").isNotNull();
|
||||
|
||||
+2
-2
@@ -35,7 +35,7 @@ class MethodExclusionMBeanInfoAssemblerMappedTests extends AbstractJmxAssemblerT
|
||||
protected static final String OBJECT_NAME = "bean:name=testBean4";
|
||||
|
||||
@Test
|
||||
void testGetAgeIsReadOnly() throws Exception {
|
||||
void getAgeIsReadOnly() throws Exception {
|
||||
ModelMBeanInfo info = getMBeanInfoFromAssembler();
|
||||
ModelMBeanAttributeInfo attr = info.getAttribute(AGE_ATTRIBUTE);
|
||||
assertThat(attr.isReadable()).as("Age is not readable").isTrue();
|
||||
@@ -43,7 +43,7 @@ class MethodExclusionMBeanInfoAssemblerMappedTests extends AbstractJmxAssemblerT
|
||||
}
|
||||
|
||||
@Test
|
||||
void testNickNameIsExposed() throws Exception {
|
||||
void nickNameIsExposed() throws Exception {
|
||||
ModelMBeanInfo inf = (ModelMBeanInfo) getMBeanInfo();
|
||||
MBeanAttributeInfo attr = inf.getAttribute("NickName");
|
||||
assertThat(attr).as("Nick Name should not be null").isNotNull();
|
||||
|
||||
+2
-2
@@ -36,7 +36,7 @@ class MethodExclusionMBeanInfoAssemblerNotMappedTests extends AbstractJmxAssembl
|
||||
protected static final String OBJECT_NAME = "bean:name=testBean4";
|
||||
|
||||
@Test
|
||||
void testGetAgeIsReadOnly() throws Exception {
|
||||
void getAgeIsReadOnly() throws Exception {
|
||||
ModelMBeanInfo info = getMBeanInfoFromAssembler();
|
||||
ModelMBeanAttributeInfo attr = info.getAttribute(AGE_ATTRIBUTE);
|
||||
assertThat(attr.isReadable()).as("Age is not readable").isTrue();
|
||||
@@ -44,7 +44,7 @@ class MethodExclusionMBeanInfoAssemblerNotMappedTests extends AbstractJmxAssembl
|
||||
}
|
||||
|
||||
@Test
|
||||
void testNickNameIsExposed() throws Exception {
|
||||
void nickNameIsExposed() throws Exception {
|
||||
ModelMBeanInfo inf = (ModelMBeanInfo) getMBeanInfo();
|
||||
MBeanAttributeInfo attr = inf.getAttribute("NickName");
|
||||
assertThat(attr).as("Nick Name should not be null").isNotNull();
|
||||
|
||||
+2
-2
@@ -66,7 +66,7 @@ class MethodExclusionMBeanInfoAssemblerTests extends AbstractJmxAssemblerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSupermanIsReadOnly() throws Exception {
|
||||
void supermanIsReadOnly() throws Exception {
|
||||
ModelMBeanInfo info = getMBeanInfoFromAssembler();
|
||||
ModelMBeanAttributeInfo attr = info.getAttribute("Superman");
|
||||
|
||||
@@ -78,7 +78,7 @@ class MethodExclusionMBeanInfoAssemblerTests extends AbstractJmxAssemblerTests {
|
||||
* https://opensource.atlassian.com/projects/spring/browse/SPR-2754
|
||||
*/
|
||||
@Test
|
||||
void testIsNotIgnoredDoesntIgnoreUnspecifiedBeanMethods() throws Exception {
|
||||
void isNotIgnoredDoesntIgnoreUnspecifiedBeanMethods() throws Exception {
|
||||
final String beanKey = "myTestBean";
|
||||
MethodExclusionMBeanInfoAssembler assembler = new MethodExclusionMBeanInfoAssembler();
|
||||
Properties ignored = new Properties();
|
||||
|
||||
+3
-3
@@ -36,7 +36,7 @@ class MethodNameBasedMBeanInfoAssemblerMappedTests extends AbstractJmxAssemblerT
|
||||
|
||||
|
||||
@Test
|
||||
void testGetAgeIsReadOnly() throws Exception {
|
||||
void getAgeIsReadOnly() throws Exception {
|
||||
ModelMBeanInfo info = getMBeanInfoFromAssembler();
|
||||
ModelMBeanAttributeInfo attr = info.getAttribute(AGE_ATTRIBUTE);
|
||||
|
||||
@@ -45,7 +45,7 @@ class MethodNameBasedMBeanInfoAssemblerMappedTests extends AbstractJmxAssemblerT
|
||||
}
|
||||
|
||||
@Test
|
||||
void testWithFallThrough() throws Exception {
|
||||
void withFallThrough() throws Exception {
|
||||
MethodNameBasedMBeanInfoAssembler assembler =
|
||||
getWithMapping("foobar", "add,myOperation,getName,setName,getAge");
|
||||
assembler.setManagedMethods("getNickName", "setNickName");
|
||||
@@ -57,7 +57,7 @@ class MethodNameBasedMBeanInfoAssemblerMappedTests extends AbstractJmxAssemblerT
|
||||
}
|
||||
|
||||
@Test
|
||||
void testNickNameIsExposed() throws Exception {
|
||||
void nickNameIsExposed() throws Exception {
|
||||
ModelMBeanInfo inf = (ModelMBeanInfo) getMBeanInfo();
|
||||
MBeanAttributeInfo attr = inf.getAttribute("NickName");
|
||||
|
||||
|
||||
+2
-2
@@ -57,7 +57,7 @@ class MethodNameBasedMBeanInfoAssemblerTests extends AbstractJmxAssemblerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGetAgeIsReadOnly() throws Exception {
|
||||
void getAgeIsReadOnly() throws Exception {
|
||||
ModelMBeanInfo info = getMBeanInfoFromAssembler();
|
||||
ModelMBeanAttributeInfo attr = info.getAttribute(AGE_ATTRIBUTE);
|
||||
|
||||
@@ -66,7 +66,7 @@ class MethodNameBasedMBeanInfoAssemblerTests extends AbstractJmxAssemblerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSetNameParameterIsNamed() throws Exception {
|
||||
void setNameParameterIsNamed() throws Exception {
|
||||
ModelMBeanInfo info = getMBeanInfoFromAssembler();
|
||||
|
||||
MBeanOperationInfo operationSetAge = info.getOperation("setName");
|
||||
|
||||
+7
-7
@@ -37,25 +37,25 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
|
||||
class ModelMBeanNotificationPublisherTests {
|
||||
|
||||
@Test
|
||||
void testCtorWithNullMBean() {
|
||||
void ctorWithNullMBean() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() ->
|
||||
new ModelMBeanNotificationPublisher(null, createObjectName(), this));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCtorWithNullObjectName() {
|
||||
void ctorWithNullObjectName() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() ->
|
||||
new ModelMBeanNotificationPublisher(new SpringModelMBean(), null, this));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCtorWithNullManagedResource() {
|
||||
void ctorWithNullManagedResource() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() ->
|
||||
new ModelMBeanNotificationPublisher(new SpringModelMBean(), createObjectName(), null));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSendNullNotification() throws Exception {
|
||||
void sendNullNotification() throws Exception {
|
||||
NotificationPublisher publisher
|
||||
= new ModelMBeanNotificationPublisher(new SpringModelMBean(), createObjectName(), this);
|
||||
assertThatIllegalArgumentException().isThrownBy(() ->
|
||||
@@ -63,7 +63,7 @@ class ModelMBeanNotificationPublisherTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSendVanillaNotification() throws Exception {
|
||||
void sendVanillaNotification() throws Exception {
|
||||
StubSpringModelMBean mbean = new StubSpringModelMBean();
|
||||
Notification notification = new Notification("network.alarm.router", mbean, 1872);
|
||||
ObjectName objectName = createObjectName();
|
||||
@@ -77,7 +77,7 @@ class ModelMBeanNotificationPublisherTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSendAttributeChangeNotification() throws Exception {
|
||||
void sendAttributeChangeNotification() throws Exception {
|
||||
StubSpringModelMBean mbean = new StubSpringModelMBean();
|
||||
Notification notification = new AttributeChangeNotification(mbean, 1872, System.currentTimeMillis(), "Shall we break for some tea?", "agree", "java.lang.Boolean", Boolean.FALSE, Boolean.TRUE);
|
||||
ObjectName objectName = createObjectName();
|
||||
@@ -93,7 +93,7 @@ class ModelMBeanNotificationPublisherTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSendAttributeChangeNotificationWhereSourceIsNotTheManagedResource() throws Exception {
|
||||
void sendAttributeChangeNotificationWhereSourceIsNotTheManagedResource() throws Exception {
|
||||
StubSpringModelMBean mbean = new StubSpringModelMBean();
|
||||
Notification notification = new AttributeChangeNotification(this, 1872, System.currentTimeMillis(), "Shall we break for some tea?", "agree", "java.lang.Boolean", Boolean.FALSE, Boolean.TRUE);
|
||||
ObjectName objectName = createObjectName();
|
||||
|
||||
+25
-25
@@ -44,13 +44,13 @@ import static org.mockito.Mockito.verify;
|
||||
class JndiObjectFactoryBeanTests {
|
||||
|
||||
@Test
|
||||
void testNoJndiName() {
|
||||
void noJndiName() {
|
||||
JndiObjectFactoryBean jof = new JndiObjectFactoryBean();
|
||||
assertThatIllegalArgumentException().isThrownBy(jof::afterPropertiesSet);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testLookupWithFullNameAndResourceRefTrue() throws Exception {
|
||||
void lookupWithFullNameAndResourceRefTrue() throws Exception {
|
||||
JndiObjectFactoryBean jof = new JndiObjectFactoryBean();
|
||||
Object o = new Object();
|
||||
jof.setJndiTemplate(new ExpectedLookupTemplate("java:comp/env/foo", o));
|
||||
@@ -61,7 +61,7 @@ class JndiObjectFactoryBeanTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testLookupWithFullNameAndResourceRefFalse() throws Exception {
|
||||
void lookupWithFullNameAndResourceRefFalse() throws Exception {
|
||||
JndiObjectFactoryBean jof = new JndiObjectFactoryBean();
|
||||
Object o = new Object();
|
||||
jof.setJndiTemplate(new ExpectedLookupTemplate("java:comp/env/foo", o));
|
||||
@@ -72,7 +72,7 @@ class JndiObjectFactoryBeanTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testLookupWithSchemeNameAndResourceRefTrue() throws Exception {
|
||||
void lookupWithSchemeNameAndResourceRefTrue() throws Exception {
|
||||
JndiObjectFactoryBean jof = new JndiObjectFactoryBean();
|
||||
Object o = new Object();
|
||||
jof.setJndiTemplate(new ExpectedLookupTemplate("java:foo", o));
|
||||
@@ -83,7 +83,7 @@ class JndiObjectFactoryBeanTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testLookupWithSchemeNameAndResourceRefFalse() throws Exception {
|
||||
void lookupWithSchemeNameAndResourceRefFalse() throws Exception {
|
||||
JndiObjectFactoryBean jof = new JndiObjectFactoryBean();
|
||||
Object o = new Object();
|
||||
jof.setJndiTemplate(new ExpectedLookupTemplate("java:foo", o));
|
||||
@@ -94,7 +94,7 @@ class JndiObjectFactoryBeanTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testLookupWithShortNameAndResourceRefTrue() throws Exception {
|
||||
void lookupWithShortNameAndResourceRefTrue() throws Exception {
|
||||
JndiObjectFactoryBean jof = new JndiObjectFactoryBean();
|
||||
Object o = new Object();
|
||||
jof.setJndiTemplate(new ExpectedLookupTemplate("java:comp/env/foo", o));
|
||||
@@ -105,7 +105,7 @@ class JndiObjectFactoryBeanTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testLookupWithShortNameAndResourceRefFalse() {
|
||||
void lookupWithShortNameAndResourceRefFalse() {
|
||||
JndiObjectFactoryBean jof = new JndiObjectFactoryBean();
|
||||
Object o = new Object();
|
||||
jof.setJndiTemplate(new ExpectedLookupTemplate("java:comp/env/foo", o));
|
||||
@@ -115,7 +115,7 @@ class JndiObjectFactoryBeanTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testLookupWithArbitraryNameAndResourceRefFalse() throws Exception {
|
||||
void lookupWithArbitraryNameAndResourceRefFalse() throws Exception {
|
||||
JndiObjectFactoryBean jof = new JndiObjectFactoryBean();
|
||||
Object o = new Object();
|
||||
jof.setJndiTemplate(new ExpectedLookupTemplate("foo", o));
|
||||
@@ -126,7 +126,7 @@ class JndiObjectFactoryBeanTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testLookupWithExpectedTypeAndMatch() throws Exception {
|
||||
void lookupWithExpectedTypeAndMatch() throws Exception {
|
||||
JndiObjectFactoryBean jof = new JndiObjectFactoryBean();
|
||||
String s = "";
|
||||
jof.setJndiTemplate(new ExpectedLookupTemplate("foo", s));
|
||||
@@ -137,7 +137,7 @@ class JndiObjectFactoryBeanTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testLookupWithExpectedTypeAndNoMatch() {
|
||||
void lookupWithExpectedTypeAndNoMatch() {
|
||||
JndiObjectFactoryBean jof = new JndiObjectFactoryBean();
|
||||
jof.setJndiTemplate(new ExpectedLookupTemplate("foo", new Object()));
|
||||
jof.setJndiName("foo");
|
||||
@@ -148,7 +148,7 @@ class JndiObjectFactoryBeanTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testLookupWithDefaultObject() throws Exception {
|
||||
void lookupWithDefaultObject() throws Exception {
|
||||
JndiObjectFactoryBean jof = new JndiObjectFactoryBean();
|
||||
jof.setJndiTemplate(new ExpectedLookupTemplate("foo", ""));
|
||||
jof.setJndiName("myFoo");
|
||||
@@ -159,7 +159,7 @@ class JndiObjectFactoryBeanTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testLookupWithDefaultObjectAndExpectedType() throws Exception {
|
||||
void lookupWithDefaultObjectAndExpectedType() throws Exception {
|
||||
JndiObjectFactoryBean jof = new JndiObjectFactoryBean();
|
||||
jof.setJndiTemplate(new ExpectedLookupTemplate("foo", ""));
|
||||
jof.setJndiName("myFoo");
|
||||
@@ -170,7 +170,7 @@ class JndiObjectFactoryBeanTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testLookupWithDefaultObjectAndExpectedTypeConversion() throws Exception {
|
||||
void lookupWithDefaultObjectAndExpectedTypeConversion() throws Exception {
|
||||
JndiObjectFactoryBean jof = new JndiObjectFactoryBean();
|
||||
jof.setJndiTemplate(new ExpectedLookupTemplate("foo", ""));
|
||||
jof.setJndiName("myFoo");
|
||||
@@ -181,7 +181,7 @@ class JndiObjectFactoryBeanTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testLookupWithDefaultObjectAndExpectedTypeConversionViaBeanFactory() throws Exception {
|
||||
void lookupWithDefaultObjectAndExpectedTypeConversionViaBeanFactory() throws Exception {
|
||||
JndiObjectFactoryBean jof = new JndiObjectFactoryBean();
|
||||
jof.setJndiTemplate(new ExpectedLookupTemplate("foo", ""));
|
||||
jof.setJndiName("myFoo");
|
||||
@@ -193,7 +193,7 @@ class JndiObjectFactoryBeanTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testLookupWithDefaultObjectAndExpectedTypeNoMatch() {
|
||||
void lookupWithDefaultObjectAndExpectedTypeNoMatch() {
|
||||
JndiObjectFactoryBean jof = new JndiObjectFactoryBean();
|
||||
jof.setJndiTemplate(new ExpectedLookupTemplate("foo", ""));
|
||||
jof.setJndiName("myFoo");
|
||||
@@ -203,7 +203,7 @@ class JndiObjectFactoryBeanTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testLookupWithProxyInterface() throws Exception {
|
||||
void lookupWithProxyInterface() throws Exception {
|
||||
JndiObjectFactoryBean jof = new JndiObjectFactoryBean();
|
||||
TestBean tb = new TestBean();
|
||||
jof.setJndiTemplate(new ExpectedLookupTemplate("foo", tb));
|
||||
@@ -219,7 +219,7 @@ class JndiObjectFactoryBeanTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testLookupWithProxyInterfaceAndDefaultObject() {
|
||||
void lookupWithProxyInterfaceAndDefaultObject() {
|
||||
JndiObjectFactoryBean jof = new JndiObjectFactoryBean();
|
||||
TestBean tb = new TestBean();
|
||||
jof.setJndiTemplate(new ExpectedLookupTemplate("foo", tb));
|
||||
@@ -230,7 +230,7 @@ class JndiObjectFactoryBeanTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testLookupWithProxyInterfaceAndLazyLookup() throws Exception {
|
||||
void lookupWithProxyInterfaceAndLazyLookup() throws Exception {
|
||||
JndiObjectFactoryBean jof = new JndiObjectFactoryBean();
|
||||
final TestBean tb = new TestBean();
|
||||
jof.setJndiTemplate(new JndiTemplate() {
|
||||
@@ -258,7 +258,7 @@ class JndiObjectFactoryBeanTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testLookupWithProxyInterfaceWithNotCache() throws Exception {
|
||||
void lookupWithProxyInterfaceWithNotCache() throws Exception {
|
||||
JndiObjectFactoryBean jof = new JndiObjectFactoryBean();
|
||||
final TestBean tb = new TestBean();
|
||||
jof.setJndiTemplate(new JndiTemplate() {
|
||||
@@ -288,7 +288,7 @@ class JndiObjectFactoryBeanTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testLookupWithProxyInterfaceWithLazyLookupAndNotCache() throws Exception {
|
||||
void lookupWithProxyInterfaceWithLazyLookupAndNotCache() throws Exception {
|
||||
JndiObjectFactoryBean jof = new JndiObjectFactoryBean();
|
||||
final TestBean tb = new TestBean();
|
||||
jof.setJndiTemplate(new JndiTemplate() {
|
||||
@@ -322,7 +322,7 @@ class JndiObjectFactoryBeanTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testLazyLookupWithoutProxyInterface() {
|
||||
void lazyLookupWithoutProxyInterface() {
|
||||
JndiObjectFactoryBean jof = new JndiObjectFactoryBean();
|
||||
jof.setJndiName("foo");
|
||||
jof.setLookupOnStartup(false);
|
||||
@@ -330,7 +330,7 @@ class JndiObjectFactoryBeanTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testNotCacheWithoutProxyInterface() {
|
||||
void notCacheWithoutProxyInterface() {
|
||||
JndiObjectFactoryBean jof = new JndiObjectFactoryBean();
|
||||
jof.setJndiName("foo");
|
||||
jof.setCache(false);
|
||||
@@ -339,7 +339,7 @@ class JndiObjectFactoryBeanTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testLookupWithProxyInterfaceAndExpectedTypeAndMatch() throws Exception {
|
||||
void lookupWithProxyInterfaceAndExpectedTypeAndMatch() throws Exception {
|
||||
JndiObjectFactoryBean jof = new JndiObjectFactoryBean();
|
||||
TestBean tb = new TestBean();
|
||||
jof.setJndiTemplate(new ExpectedLookupTemplate("foo", tb));
|
||||
@@ -356,7 +356,7 @@ class JndiObjectFactoryBeanTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testLookupWithProxyInterfaceAndExpectedTypeAndNoMatch() {
|
||||
void lookupWithProxyInterfaceAndExpectedTypeAndNoMatch() {
|
||||
JndiObjectFactoryBean jof = new JndiObjectFactoryBean();
|
||||
TestBean tb = new TestBean();
|
||||
jof.setJndiTemplate(new ExpectedLookupTemplate("foo", tb));
|
||||
@@ -369,7 +369,7 @@ class JndiObjectFactoryBeanTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testLookupWithExposeAccessContext() throws Exception {
|
||||
void lookupWithExposeAccessContext() throws Exception {
|
||||
JndiObjectFactoryBean jof = new JndiObjectFactoryBean();
|
||||
TestBean tb = new TestBean();
|
||||
final Context mockCtx = mock();
|
||||
|
||||
@@ -28,13 +28,13 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
|
||||
class JndiTemplateEditorTests {
|
||||
|
||||
@Test
|
||||
void testNullIsIllegalArgument() {
|
||||
void nullIsIllegalArgument() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() ->
|
||||
new JndiTemplateEditor().setAsText(null));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testEmptyStringMeansNullEnvironment() {
|
||||
void emptyStringMeansNullEnvironment() {
|
||||
JndiTemplateEditor je = new JndiTemplateEditor();
|
||||
je.setAsText("");
|
||||
JndiTemplate jt = (JndiTemplate) je.getValue();
|
||||
@@ -42,7 +42,7 @@ class JndiTemplateEditorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCustomEnvironment() {
|
||||
void customEnvironment() {
|
||||
JndiTemplateEditor je = new JndiTemplateEditor();
|
||||
// These properties are meaningless for JNDI, but we don't worry about that:
|
||||
// the underlying JNDI implementation will throw exceptions when the user tries
|
||||
|
||||
@@ -36,7 +36,7 @@ import static org.mockito.Mockito.verify;
|
||||
class JndiTemplateTests {
|
||||
|
||||
@Test
|
||||
void testLookupSucceeds() throws Exception {
|
||||
void lookupSucceeds() throws Exception {
|
||||
Object o = new Object();
|
||||
String name = "foo";
|
||||
final Context context = mock();
|
||||
@@ -55,7 +55,7 @@ class JndiTemplateTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testLookupFails() throws Exception {
|
||||
void lookupFails() throws Exception {
|
||||
NameNotFoundException ne = new NameNotFoundException();
|
||||
String name = "foo";
|
||||
final Context context = mock();
|
||||
@@ -74,7 +74,7 @@ class JndiTemplateTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testLookupReturnsNull() throws Exception {
|
||||
void lookupReturnsNull() throws Exception {
|
||||
String name = "foo";
|
||||
final Context context = mock();
|
||||
given(context.lookup(name)).willReturn(null);
|
||||
@@ -92,7 +92,7 @@ class JndiTemplateTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testLookupFailsWithTypeMismatch() throws Exception {
|
||||
void lookupFailsWithTypeMismatch() throws Exception {
|
||||
Object o = new Object();
|
||||
String name = "foo";
|
||||
final Context context = mock();
|
||||
@@ -111,7 +111,7 @@ class JndiTemplateTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testBind() throws Exception {
|
||||
void bind() throws Exception {
|
||||
Object o = new Object();
|
||||
String name = "foo";
|
||||
final Context context = mock();
|
||||
@@ -129,7 +129,7 @@ class JndiTemplateTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testRebind() throws Exception {
|
||||
void rebind() throws Exception {
|
||||
Object o = new Object();
|
||||
String name = "foo";
|
||||
final Context context = mock();
|
||||
@@ -147,7 +147,7 @@ class JndiTemplateTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testUnbind() throws Exception {
|
||||
void unbind() throws Exception {
|
||||
String name = "something";
|
||||
final Context context = mock();
|
||||
|
||||
|
||||
+1
-1
@@ -34,7 +34,7 @@ class AnnotationAsyncExecutionInterceptorTests {
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("unused")
|
||||
public void testGetExecutorQualifier() throws SecurityException, NoSuchMethodException {
|
||||
void getExecutorQualifier() throws SecurityException, NoSuchMethodException {
|
||||
AnnotationAsyncExecutionInterceptor i = new AnnotationAsyncExecutionInterceptor(null);
|
||||
{ // method level
|
||||
class C { @Async("qMethod") void m() { } }
|
||||
|
||||
+1
-1
@@ -188,7 +188,7 @@ class AsyncAnnotationBeanPostProcessorTests {
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("resource")
|
||||
public void handleExceptionWithFuture() {
|
||||
void handleExceptionWithFuture() {
|
||||
ConfigurableApplicationContext context =
|
||||
new AnnotationConfigApplicationContext(ConfigWithExceptionHandler.class);
|
||||
ITestBean testBean = context.getBean("target", ITestBean.class);
|
||||
|
||||
+3
-3
@@ -314,7 +314,7 @@ class EnableAsyncTests {
|
||||
}
|
||||
|
||||
@Test // SPR-14949
|
||||
public void findOnInterfaceWithInterfaceProxy() {
|
||||
void findOnInterfaceWithInterfaceProxy() {
|
||||
// Arrange
|
||||
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(Spr14949ConfigA.class);
|
||||
AsyncInterface asyncBean = ctx.getBean(AsyncInterface.class);
|
||||
@@ -330,7 +330,7 @@ class EnableAsyncTests {
|
||||
}
|
||||
|
||||
@Test // SPR-14949
|
||||
public void findOnInterfaceWithCglibProxy() {
|
||||
void findOnInterfaceWithCglibProxy() {
|
||||
// Arrange
|
||||
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(Spr14949ConfigB.class);
|
||||
AsyncInterface asyncBean = ctx.getBean(AsyncInterface.class);
|
||||
@@ -347,7 +347,7 @@ class EnableAsyncTests {
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("resource")
|
||||
public void exceptionThrownWithBeanNotOfRequiredTypeRootCause() {
|
||||
void exceptionThrownWithBeanNotOfRequiredTypeRootCause() {
|
||||
assertThatExceptionOfType(Throwable.class).isThrownBy(() ->
|
||||
new AnnotationConfigApplicationContext(JdkProxyConfiguration.class))
|
||||
.withCauseInstanceOf(BeanNotOfRequiredTypeException.class);
|
||||
|
||||
+3
-3
@@ -35,21 +35,21 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
class BshScriptEvaluatorTests {
|
||||
|
||||
@Test
|
||||
void testBshScriptFromString() {
|
||||
void bshScriptFromString() {
|
||||
ScriptEvaluator evaluator = new BshScriptEvaluator();
|
||||
Object result = evaluator.evaluate(new StaticScriptSource("return 3 * 2;"));
|
||||
assertThat(result).isEqualTo(6);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testBshScriptFromFile() {
|
||||
void bshScriptFromFile() {
|
||||
ScriptEvaluator evaluator = new BshScriptEvaluator();
|
||||
Object result = evaluator.evaluate(new ResourceScriptSource(new ClassPathResource("simple.bsh", getClass())));
|
||||
assertThat(result).isEqualTo(6);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGroovyScriptWithArguments() {
|
||||
void groovyScriptWithArguments() {
|
||||
ScriptEvaluator evaluator = new BshScriptEvaluator();
|
||||
Map<String, Object> arguments = new HashMap<>();
|
||||
arguments.put("a", 3);
|
||||
|
||||
+3
-3
@@ -94,9 +94,9 @@ class GroovyAspectTests {
|
||||
TestService bean = (TestService) factory.getProxy();
|
||||
|
||||
assertThat(logAdvice.getCountThrows()).isEqualTo(0);
|
||||
assertThatExceptionOfType(TestException.class).isThrownBy(
|
||||
bean::sayHello)
|
||||
.withMessage(message);
|
||||
assertThatExceptionOfType(TestException.class)
|
||||
.isThrownBy(bean::sayHello)
|
||||
.withMessage(message);
|
||||
assertThat(logAdvice.getCountThrows()).isEqualTo(1);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -34,7 +34,7 @@ class GroovyClassLoadingTests {
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("resource")
|
||||
public void classLoading() throws Exception {
|
||||
void classLoading() throws Exception {
|
||||
StaticApplicationContext context = new StaticApplicationContext();
|
||||
|
||||
GroovyClassLoader gcl = new GroovyClassLoader();
|
||||
|
||||
+8
-8
@@ -36,21 +36,21 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
class GroovyScriptEvaluatorTests {
|
||||
|
||||
@Test
|
||||
void testGroovyScriptFromString() {
|
||||
void groovyScriptFromString() {
|
||||
ScriptEvaluator evaluator = new GroovyScriptEvaluator();
|
||||
Object result = evaluator.evaluate(new StaticScriptSource("return 3 * 2"));
|
||||
assertThat(result).isEqualTo(6);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGroovyScriptFromFile() {
|
||||
void groovyScriptFromFile() {
|
||||
ScriptEvaluator evaluator = new GroovyScriptEvaluator();
|
||||
Object result = evaluator.evaluate(new ResourceScriptSource(new ClassPathResource("simple.groovy", getClass())));
|
||||
assertThat(result).isEqualTo(6);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGroovyScriptWithArguments() {
|
||||
void groovyScriptWithArguments() {
|
||||
ScriptEvaluator evaluator = new GroovyScriptEvaluator();
|
||||
Map<String, Object> arguments = new HashMap<>();
|
||||
arguments.put("a", 3);
|
||||
@@ -60,7 +60,7 @@ class GroovyScriptEvaluatorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGroovyScriptWithCompilerConfiguration() {
|
||||
void groovyScriptWithCompilerConfiguration() {
|
||||
GroovyScriptEvaluator evaluator = new GroovyScriptEvaluator();
|
||||
MyBytecodeProcessor processor = new MyBytecodeProcessor();
|
||||
evaluator.getCompilerConfiguration().setBytecodePostprocessor(processor);
|
||||
@@ -70,7 +70,7 @@ class GroovyScriptEvaluatorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGroovyScriptWithImportCustomizer() {
|
||||
void groovyScriptWithImportCustomizer() {
|
||||
GroovyScriptEvaluator evaluator = new GroovyScriptEvaluator();
|
||||
ImportCustomizer importCustomizer = new ImportCustomizer();
|
||||
importCustomizer.addStarImports("org.springframework.util");
|
||||
@@ -80,7 +80,7 @@ class GroovyScriptEvaluatorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGroovyScriptFromStringUsingJsr223() {
|
||||
void groovyScriptFromStringUsingJsr223() {
|
||||
StandardScriptEvaluator evaluator = new StandardScriptEvaluator();
|
||||
evaluator.setLanguage("Groovy");
|
||||
Object result = evaluator.evaluate(new StaticScriptSource("return 3 * 2"));
|
||||
@@ -88,14 +88,14 @@ class GroovyScriptEvaluatorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGroovyScriptFromFileUsingJsr223() {
|
||||
void groovyScriptFromFileUsingJsr223() {
|
||||
ScriptEvaluator evaluator = new StandardScriptEvaluator();
|
||||
Object result = evaluator.evaluate(new ResourceScriptSource(new ClassPathResource("simple.groovy", getClass())));
|
||||
assertThat(result).isEqualTo(6);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGroovyScriptWithArgumentsUsingJsr223() {
|
||||
void groovyScriptWithArgumentsUsingJsr223() {
|
||||
StandardScriptEvaluator evaluator = new StandardScriptEvaluator();
|
||||
evaluator.setLanguage("Groovy");
|
||||
Map<String, Object> arguments = new HashMap<>();
|
||||
|
||||
+38
-38
@@ -66,7 +66,7 @@ import static org.mockito.Mockito.mock;
|
||||
public class GroovyScriptFactoryTests {
|
||||
|
||||
@Test
|
||||
void testStaticScript() {
|
||||
void staticScript() {
|
||||
ApplicationContext ctx = new ClassPathXmlApplicationContext("groovyContext.xml", getClass());
|
||||
|
||||
assertThat(Arrays.asList(ctx.getBeanNamesForType(Calculator.class))).contains("calculator");
|
||||
@@ -95,7 +95,7 @@ public class GroovyScriptFactoryTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testStaticScriptUsingJsr223() {
|
||||
void staticScriptUsingJsr223() {
|
||||
ApplicationContext ctx = new ClassPathXmlApplicationContext("groovyContextWithJsr223.xml", getClass());
|
||||
|
||||
assertThat(Arrays.asList(ctx.getBeanNamesForType(Calculator.class))).contains("calculator");
|
||||
@@ -124,7 +124,7 @@ public class GroovyScriptFactoryTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testStaticPrototypeScript() {
|
||||
void staticPrototypeScript() {
|
||||
ApplicationContext ctx = new ClassPathXmlApplicationContext("groovyContext.xml", getClass());
|
||||
ConfigurableMessenger messenger = (ConfigurableMessenger) ctx.getBean("messengerPrototype");
|
||||
ConfigurableMessenger messenger2 = (ConfigurableMessenger) ctx.getBean("messengerPrototype");
|
||||
@@ -143,7 +143,7 @@ public class GroovyScriptFactoryTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testStaticPrototypeScriptUsingJsr223() {
|
||||
void staticPrototypeScriptUsingJsr223() {
|
||||
ApplicationContext ctx = new ClassPathXmlApplicationContext("groovyContextWithJsr223.xml", getClass());
|
||||
ConfigurableMessenger messenger = (ConfigurableMessenger) ctx.getBean("messengerPrototype");
|
||||
ConfigurableMessenger messenger2 = (ConfigurableMessenger) ctx.getBean("messengerPrototype");
|
||||
@@ -162,7 +162,7 @@ public class GroovyScriptFactoryTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testStaticScriptWithInstance() {
|
||||
void staticScriptWithInstance() {
|
||||
ApplicationContext ctx = new ClassPathXmlApplicationContext("groovyContext.xml", getClass());
|
||||
assertThat(Arrays.asList(ctx.getBeanNamesForType(Messenger.class))).contains("messengerInstance");
|
||||
Messenger messenger = (Messenger) ctx.getBean("messengerInstance");
|
||||
@@ -176,7 +176,7 @@ public class GroovyScriptFactoryTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testStaticScriptWithInstanceUsingJsr223() {
|
||||
void staticScriptWithInstanceUsingJsr223() {
|
||||
ApplicationContext ctx = new ClassPathXmlApplicationContext("groovyContextWithJsr223.xml", getClass());
|
||||
assertThat(Arrays.asList(ctx.getBeanNamesForType(Messenger.class))).contains("messengerInstance");
|
||||
Messenger messenger = (Messenger) ctx.getBean("messengerInstance");
|
||||
@@ -190,7 +190,7 @@ public class GroovyScriptFactoryTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testStaticScriptWithInlineDefinedInstance() {
|
||||
void staticScriptWithInlineDefinedInstance() {
|
||||
ApplicationContext ctx = new ClassPathXmlApplicationContext("groovyContext.xml", getClass());
|
||||
assertThat(Arrays.asList(ctx.getBeanNamesForType(Messenger.class))).contains("messengerInstanceInline");
|
||||
Messenger messenger = (Messenger) ctx.getBean("messengerInstanceInline");
|
||||
@@ -204,7 +204,7 @@ public class GroovyScriptFactoryTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testStaticScriptWithInlineDefinedInstanceUsingJsr223() {
|
||||
void staticScriptWithInlineDefinedInstanceUsingJsr223() {
|
||||
ApplicationContext ctx = new ClassPathXmlApplicationContext("groovyContextWithJsr223.xml", getClass());
|
||||
assertThat(Arrays.asList(ctx.getBeanNamesForType(Messenger.class))).contains("messengerInstanceInline");
|
||||
Messenger messenger = (Messenger) ctx.getBean("messengerInstanceInline");
|
||||
@@ -218,7 +218,7 @@ public class GroovyScriptFactoryTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testNonStaticScript() {
|
||||
void nonStaticScript() {
|
||||
ApplicationContext ctx = new ClassPathXmlApplicationContext("groovyRefreshableContext.xml", getClass());
|
||||
Messenger messenger = (Messenger) ctx.getBean("messenger");
|
||||
|
||||
@@ -236,7 +236,7 @@ public class GroovyScriptFactoryTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testNonStaticPrototypeScript() {
|
||||
void nonStaticPrototypeScript() {
|
||||
ApplicationContext ctx = new ClassPathXmlApplicationContext("groovyRefreshableContext.xml", getClass());
|
||||
ConfigurableMessenger messenger = (ConfigurableMessenger) ctx.getBean("messengerPrototype");
|
||||
ConfigurableMessenger messenger2 = (ConfigurableMessenger) ctx.getBean("messengerPrototype");
|
||||
@@ -260,14 +260,14 @@ public class GroovyScriptFactoryTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testScriptCompilationException() {
|
||||
void scriptCompilationException() {
|
||||
assertThatExceptionOfType(NestedRuntimeException.class)
|
||||
.isThrownBy(() -> new ClassPathXmlApplicationContext("org/springframework/scripting/groovy/groovyBrokenContext.xml"))
|
||||
.matches(ex -> ex.contains(ScriptCompilationException.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testScriptedClassThatDoesNotHaveANoArgCtor() throws Exception {
|
||||
void scriptedClassThatDoesNotHaveANoArgCtor() throws Exception {
|
||||
ScriptSource script = mock();
|
||||
String badScript = "class Foo { public Foo(String foo) {}}";
|
||||
given(script.getScriptAsString()).willReturn(badScript);
|
||||
@@ -279,7 +279,7 @@ public class GroovyScriptFactoryTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testScriptedClassThatHasNoPublicNoArgCtor() throws Exception {
|
||||
void scriptedClassThatHasNoPublicNoArgCtor() throws Exception {
|
||||
ScriptSource script = mock();
|
||||
String badScript = "class Foo { protected Foo() {} \n String toString() { 'X' }}";
|
||||
given(script.getScriptAsString()).willReturn(badScript);
|
||||
@@ -289,7 +289,7 @@ public class GroovyScriptFactoryTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testWithTwoClassesDefinedInTheOneGroovyFile_CorrectClassFirst() {
|
||||
void withTwoClassesDefinedInTheOneGroovyFile_CorrectClassFirst() {
|
||||
ApplicationContext ctx = new ClassPathXmlApplicationContext("twoClassesCorrectOneFirst.xml", getClass());
|
||||
Messenger messenger = (Messenger) ctx.getBean("messenger");
|
||||
assertThat(messenger).isNotNull();
|
||||
@@ -301,7 +301,7 @@ public class GroovyScriptFactoryTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testWithTwoClassesDefinedInTheOneGroovyFile_WrongClassFirst() {
|
||||
void withTwoClassesDefinedInTheOneGroovyFile_WrongClassFirst() {
|
||||
assertThatException().as("two classes defined in GroovyScriptFactory source, non-Messenger class defined first").isThrownBy(() -> {
|
||||
ApplicationContext ctx = new ClassPathXmlApplicationContext("twoClassesWrongOneFirst.xml", getClass());
|
||||
ctx.getBean("messenger", Messenger.class);
|
||||
@@ -309,29 +309,29 @@ public class GroovyScriptFactoryTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCtorWithNullScriptSourceLocator() {
|
||||
void ctorWithNullScriptSourceLocator() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> new GroovyScriptFactory(null));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCtorWithEmptyScriptSourceLocator() {
|
||||
void ctorWithEmptyScriptSourceLocator() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> new GroovyScriptFactory(""));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCtorWithWhitespacedScriptSourceLocator() {
|
||||
void ctorWithWhitespacedScriptSourceLocator() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> new GroovyScriptFactory("\n "));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testWithInlineScriptWithLeadingWhitespace() {
|
||||
void withInlineScriptWithLeadingWhitespace() {
|
||||
assertThatExceptionOfType(BeanCreationException.class).as("'inline:' prefix was preceded by whitespace")
|
||||
.isThrownBy(() -> new ClassPathXmlApplicationContext("lwspBadGroovyContext.xml", getClass()))
|
||||
.matches(ex -> ex.contains(FileNotFoundException.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGetScriptedObjectDoesNotChokeOnNullInterfacesBeingPassedIn() throws Exception {
|
||||
void getScriptedObjectDoesNotChokeOnNullInterfacesBeingPassedIn() throws Exception {
|
||||
ScriptSource script = mock();
|
||||
given(script.getScriptAsString()).willReturn("class Bar {}");
|
||||
given(script.suggestedClassName()).willReturn("someName");
|
||||
@@ -342,14 +342,14 @@ public class GroovyScriptFactoryTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGetScriptedObjectDoesChokeOnNullScriptSourceBeingPassedIn() {
|
||||
void getScriptedObjectDoesChokeOnNullScriptSourceBeingPassedIn() {
|
||||
GroovyScriptFactory factory = new GroovyScriptFactory("a script source locator (doesn't matter here)");
|
||||
assertThatNullPointerException().as("NullPointerException as per contract ('null' ScriptSource supplied)")
|
||||
.isThrownBy(() -> factory.getScriptedObject(null));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testResourceScriptFromTag() {
|
||||
void resourceScriptFromTag() {
|
||||
ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("groovy-with-xsd.xml", getClass());
|
||||
Messenger messenger = (Messenger) ctx.getBean("messenger");
|
||||
CallCounter countingAspect = (CallCounter) ctx.getBean("getMessageAspect");
|
||||
@@ -365,7 +365,7 @@ public class GroovyScriptFactoryTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testPrototypeScriptFromTag() {
|
||||
void prototypeScriptFromTag() {
|
||||
ApplicationContext ctx = new ClassPathXmlApplicationContext("groovy-with-xsd.xml", getClass());
|
||||
ConfigurableMessenger messenger = (ConfigurableMessenger) ctx.getBean("messengerPrototype");
|
||||
ConfigurableMessenger messenger2 = (ConfigurableMessenger) ctx.getBean("messengerPrototype");
|
||||
@@ -381,7 +381,7 @@ public class GroovyScriptFactoryTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testInlineScriptFromTag() {
|
||||
void inlineScriptFromTag() {
|
||||
ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("groovy-with-xsd.xml", getClass());
|
||||
BeanDefinition bd = ctx.getBeanFactory().getBeanDefinition("calculator");
|
||||
assertThat(ObjectUtils.containsElement(bd.getDependsOn(), "messenger")).isTrue();
|
||||
@@ -391,7 +391,7 @@ public class GroovyScriptFactoryTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testRefreshableFromTag() {
|
||||
void refreshableFromTag() {
|
||||
ApplicationContext ctx = new ClassPathXmlApplicationContext("groovy-with-xsd.xml", getClass());
|
||||
assertThat(Arrays.asList(ctx.getBeanNamesForType(Messenger.class))).contains("refreshableMessenger");
|
||||
|
||||
@@ -408,7 +408,7 @@ public class GroovyScriptFactoryTests {
|
||||
}
|
||||
|
||||
@Test // SPR-6268
|
||||
public void testRefreshableFromTagProxyTargetClass() {
|
||||
void refreshableFromTagProxyTargetClass() {
|
||||
ApplicationContext ctx = new ClassPathXmlApplicationContext("groovy-with-xsd-proxy-target-class.xml",
|
||||
getClass());
|
||||
assertThat(Arrays.asList(ctx.getBeanNamesForType(Messenger.class))).contains("refreshableMessenger");
|
||||
@@ -426,7 +426,7 @@ public class GroovyScriptFactoryTests {
|
||||
}
|
||||
|
||||
@Test // SPR-6268
|
||||
public void testProxyTargetClassNotAllowedIfNotGroovy() {
|
||||
void proxyTargetClassNotAllowedIfNotGroovy() {
|
||||
try {
|
||||
new ClassPathXmlApplicationContext("groovy-with-xsd-proxy-target-class.xml", getClass());
|
||||
}
|
||||
@@ -436,7 +436,7 @@ public class GroovyScriptFactoryTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testAnonymousScriptDetected() {
|
||||
void anonymousScriptDetected() {
|
||||
ApplicationContext ctx = new ClassPathXmlApplicationContext("groovy-with-xsd.xml", getClass());
|
||||
Map<?, Messenger> beans = ctx.getBeansOfType(Messenger.class);
|
||||
assertThat(beans).hasSize(4);
|
||||
@@ -445,7 +445,7 @@ public class GroovyScriptFactoryTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testJsr223FromTag() {
|
||||
void jsr223FromTag() {
|
||||
ApplicationContext ctx = new ClassPathXmlApplicationContext("groovy-with-xsd-jsr223.xml", getClass());
|
||||
assertThat(Arrays.asList(ctx.getBeanNamesForType(Messenger.class))).contains("messenger");
|
||||
Messenger messenger = (Messenger) ctx.getBean("messenger");
|
||||
@@ -454,7 +454,7 @@ public class GroovyScriptFactoryTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testJsr223FromTagWithInterface() {
|
||||
void jsr223FromTagWithInterface() {
|
||||
ApplicationContext ctx = new ClassPathXmlApplicationContext("groovy-with-xsd-jsr223.xml", getClass());
|
||||
assertThat(Arrays.asList(ctx.getBeanNamesForType(Messenger.class))).contains("messengerWithInterface");
|
||||
Messenger messenger = (Messenger) ctx.getBean("messengerWithInterface");
|
||||
@@ -462,7 +462,7 @@ public class GroovyScriptFactoryTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testRefreshableJsr223FromTag() {
|
||||
void refreshableJsr223FromTag() {
|
||||
ApplicationContext ctx = new ClassPathXmlApplicationContext("groovy-with-xsd-jsr223.xml", getClass());
|
||||
assertThat(Arrays.asList(ctx.getBeanNamesForType(Messenger.class))).contains("refreshableMessenger");
|
||||
Messenger messenger = (Messenger) ctx.getBean("refreshableMessenger");
|
||||
@@ -472,7 +472,7 @@ public class GroovyScriptFactoryTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testInlineJsr223FromTag() {
|
||||
void inlineJsr223FromTag() {
|
||||
ApplicationContext ctx = new ClassPathXmlApplicationContext("groovy-with-xsd-jsr223.xml", getClass());
|
||||
assertThat(Arrays.asList(ctx.getBeanNamesForType(Messenger.class))).contains("inlineMessenger");
|
||||
Messenger messenger = (Messenger) ctx.getBean("inlineMessenger");
|
||||
@@ -480,7 +480,7 @@ public class GroovyScriptFactoryTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testInlineJsr223FromTagWithInterface() {
|
||||
void inlineJsr223FromTagWithInterface() {
|
||||
ApplicationContext ctx = new ClassPathXmlApplicationContext("groovy-with-xsd-jsr223.xml", getClass());
|
||||
assertThat(Arrays.asList(ctx.getBeanNamesForType(Messenger.class))).contains("inlineMessengerWithInterface");
|
||||
Messenger messenger = (Messenger) ctx.getBean("inlineMessengerWithInterface");
|
||||
@@ -492,7 +492,7 @@ public class GroovyScriptFactoryTests {
|
||||
* passed to a scripted bean :(
|
||||
*/
|
||||
@Test
|
||||
void testCanPassInMoreThanOneProperty() {
|
||||
void canPassInMoreThanOneProperty() {
|
||||
ApplicationContext ctx = new ClassPathXmlApplicationContext("groovy-multiple-properties.xml", getClass());
|
||||
TestBean tb = (TestBean) ctx.getBean("testBean");
|
||||
|
||||
@@ -508,12 +508,12 @@ public class GroovyScriptFactoryTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testMetaClassWithBeans() {
|
||||
void metaClassWithBeans() {
|
||||
testMetaClass("org/springframework/scripting/groovy/calculators.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testMetaClassWithXsd() {
|
||||
void metaClassWithXsd() {
|
||||
testMetaClass("org/springframework/scripting/groovy/calculators-with-xsd.xml");
|
||||
}
|
||||
|
||||
@@ -527,7 +527,7 @@ public class GroovyScriptFactoryTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFactoryBean() {
|
||||
void factoryBean() {
|
||||
ApplicationContext context = new ClassPathXmlApplicationContext("groovyContext.xml", getClass());
|
||||
Object factory = context.getBean("&factory");
|
||||
assertThat(factory instanceof FactoryBean).isTrue();
|
||||
@@ -536,7 +536,7 @@ public class GroovyScriptFactoryTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testRefreshableFactoryBean() {
|
||||
void refreshableFactoryBean() {
|
||||
ApplicationContext context = new ClassPathXmlApplicationContext("groovyContext.xml", getClass());
|
||||
Object factory = context.getBean("&refreshableFactory");
|
||||
assertThat(factory instanceof FactoryBean).isTrue();
|
||||
|
||||
+9
-9
@@ -80,18 +80,18 @@ class ScriptFactoryPostProcessorTests {
|
||||
|
||||
|
||||
@Test
|
||||
void testDoesNothingWhenPostProcessingNonScriptFactoryTypeBeforeInstantiation() {
|
||||
void doesNothingWhenPostProcessingNonScriptFactoryTypeBeforeInstantiation() {
|
||||
assertThat(new ScriptFactoryPostProcessor().postProcessBeforeInstantiation(getClass(), "a.bean")).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testThrowsExceptionIfGivenNonAbstractBeanFactoryImplementation() {
|
||||
void throwsExceptionIfGivenNonAbstractBeanFactoryImplementation() {
|
||||
assertThatIllegalStateException().isThrownBy(() ->
|
||||
new ScriptFactoryPostProcessor().setBeanFactory(mock()));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testChangeScriptWithRefreshableBeanFunctionality() {
|
||||
void changeScriptWithRefreshableBeanFunctionality() {
|
||||
BeanDefinition processorBeanDefinition = createScriptFactoryPostProcessor(true);
|
||||
BeanDefinition scriptedBeanDefinition = createScriptedGroovyBean();
|
||||
|
||||
@@ -112,7 +112,7 @@ class ScriptFactoryPostProcessorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testChangeScriptWithNoRefreshableBeanFunctionality() {
|
||||
void changeScriptWithNoRefreshableBeanFunctionality() {
|
||||
BeanDefinition processorBeanDefinition = createScriptFactoryPostProcessor(false);
|
||||
BeanDefinition scriptedBeanDefinition = createScriptedGroovyBean();
|
||||
|
||||
@@ -132,7 +132,7 @@ class ScriptFactoryPostProcessorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testRefreshedScriptReferencePropagatesToCollaborators() {
|
||||
void refreshedScriptReferencePropagatesToCollaborators() {
|
||||
BeanDefinition processorBeanDefinition = createScriptFactoryPostProcessor(true);
|
||||
BeanDefinition scriptedBeanDefinition = createScriptedGroovyBean();
|
||||
BeanDefinitionBuilder collaboratorBuilder = BeanDefinitionBuilder.rootBeanDefinition(DefaultMessengerService.class);
|
||||
@@ -161,7 +161,7 @@ class ScriptFactoryPostProcessorTests {
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("resource")
|
||||
void testReferencesAcrossAContainerHierarchy() {
|
||||
void referencesAcrossAContainerHierarchy() {
|
||||
GenericApplicationContext businessContext = new GenericApplicationContext();
|
||||
businessContext.registerBeanDefinition("messenger", BeanDefinitionBuilder.rootBeanDefinition(StubMessenger.class).getBeanDefinition());
|
||||
businessContext.refresh();
|
||||
@@ -178,13 +178,13 @@ class ScriptFactoryPostProcessorTests {
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("resource")
|
||||
void testScriptHavingAReferenceToAnotherBean() {
|
||||
void scriptHavingAReferenceToAnotherBean() {
|
||||
// just tests that the (singleton) script-backed bean is able to be instantiated with references to its collaborators
|
||||
new ClassPathXmlApplicationContext("org/springframework/scripting/support/groovyReferences.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testForRefreshedScriptHavingErrorPickedUpOnFirstCall() {
|
||||
void forRefreshedScriptHavingErrorPickedUpOnFirstCall() {
|
||||
BeanDefinition processorBeanDefinition = createScriptFactoryPostProcessor(true);
|
||||
BeanDefinition scriptedBeanDefinition = createScriptedGroovyBean();
|
||||
BeanDefinitionBuilder collaboratorBuilder = BeanDefinitionBuilder.rootBeanDefinition(DefaultMessengerService.class);
|
||||
@@ -211,7 +211,7 @@ class ScriptFactoryPostProcessorTests {
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("resource")
|
||||
void testPrototypeScriptedBean() {
|
||||
void prototypeScriptedBean() {
|
||||
GenericApplicationContext ctx = new GenericApplicationContext();
|
||||
ctx.registerBeanDefinition("messenger", BeanDefinitionBuilder.rootBeanDefinition(StubMessenger.class).getBeanDefinition());
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
|
||||
class ModelMapTests {
|
||||
|
||||
@Test
|
||||
void testNoArgCtorYieldsEmptyModel() {
|
||||
void noArgCtorYieldsEmptyModel() {
|
||||
assertThat(new ModelMap()).isEmpty();
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ class ModelMapTests {
|
||||
* SPR-2185 - Null model assertion causes backwards compatibility issue
|
||||
*/
|
||||
@Test
|
||||
void testAddNullObjectWithExplicitKey() {
|
||||
void addNullObjectWithExplicitKey() {
|
||||
ModelMap model = new ModelMap();
|
||||
model.addAttribute("foo", null);
|
||||
assertThat(model.containsKey("foo")).isTrue();
|
||||
@@ -63,14 +63,14 @@ class ModelMapTests {
|
||||
* SPR-2185 - Null model assertion causes backwards compatibility issue
|
||||
*/
|
||||
@Test
|
||||
void testAddNullObjectViaCtorWithExplicitKey() {
|
||||
void addNullObjectViaCtorWithExplicitKey() {
|
||||
ModelMap model = new ModelMap("foo", null);
|
||||
assertThat(model.containsKey("foo")).isTrue();
|
||||
assertThat(model.get("foo")).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testNamedObjectCtor() {
|
||||
void namedObjectCtor() {
|
||||
ModelMap model = new ModelMap("foo", "bing");
|
||||
assertThat(model).hasSize(1);
|
||||
String bing = (String) model.get("foo");
|
||||
@@ -79,7 +79,7 @@ class ModelMapTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testUnnamedCtorScalar() {
|
||||
void unnamedCtorScalar() {
|
||||
ModelMap model = new ModelMap("foo", "bing");
|
||||
assertThat(model).hasSize(1);
|
||||
String bing = (String) model.get("foo");
|
||||
@@ -88,7 +88,7 @@ class ModelMapTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testOneArgCtorWithScalar() {
|
||||
void oneArgCtorWithScalar() {
|
||||
ModelMap model = new ModelMap("bing");
|
||||
assertThat(model).hasSize(1);
|
||||
String string = (String) model.get("string");
|
||||
@@ -97,14 +97,14 @@ class ModelMapTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testOneArgCtorWithNull() {
|
||||
void oneArgCtorWithNull() {
|
||||
//Null model arguments added without a name being explicitly supplied are not allowed
|
||||
assertThatIllegalArgumentException().isThrownBy(() ->
|
||||
new ModelMap(null));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testOneArgCtorWithCollection() {
|
||||
void oneArgCtorWithCollection() {
|
||||
ModelMap model = new ModelMap(new String[]{"foo", "boing"});
|
||||
assertThat(model).hasSize(1);
|
||||
String[] strings = (String[]) model.get("stringList");
|
||||
@@ -115,14 +115,14 @@ class ModelMapTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testOneArgCtorWithEmptyCollection() {
|
||||
void oneArgCtorWithEmptyCollection() {
|
||||
ModelMap model = new ModelMap(new HashSet<>());
|
||||
// must not add if collection is empty...
|
||||
assertThat(model).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testAddObjectWithNull() {
|
||||
void addObjectWithNull() {
|
||||
// Null model arguments added without a name being explicitly supplied are not allowed
|
||||
ModelMap model = new ModelMap();
|
||||
assertThatIllegalArgumentException().isThrownBy(() ->
|
||||
@@ -130,7 +130,7 @@ class ModelMapTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testAddObjectWithEmptyArray() {
|
||||
void addObjectWithEmptyArray() {
|
||||
ModelMap model = new ModelMap(new int[]{});
|
||||
assertThat(model).hasSize(1);
|
||||
int[] ints = (int[]) model.get("intList");
|
||||
@@ -139,21 +139,21 @@ class ModelMapTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testAddAllObjectsWithNullMap() {
|
||||
void addAllObjectsWithNullMap() {
|
||||
ModelMap model = new ModelMap();
|
||||
model.addAllAttributes((Map<String, ?>) null);
|
||||
assertThat(model).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testAddAllObjectsWithNullCollection() {
|
||||
void addAllObjectsWithNullCollection() {
|
||||
ModelMap model = new ModelMap();
|
||||
model.addAllAttributes((Collection<Object>) null);
|
||||
assertThat(model).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testAddAllObjectsWithSparseArrayList() {
|
||||
void addAllObjectsWithSparseArrayList() {
|
||||
// Null model arguments added without a name being explicitly supplied are not allowed
|
||||
ModelMap model = new ModelMap();
|
||||
ArrayList<String> list = new ArrayList<>();
|
||||
@@ -164,7 +164,7 @@ class ModelMapTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testAddMap() {
|
||||
void addMap() {
|
||||
Map<String, String> map = new HashMap<>();
|
||||
map.put("one", "one-value");
|
||||
map.put("two", "two-value");
|
||||
@@ -176,7 +176,7 @@ class ModelMapTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testAddObjectNoKeyOfSameTypeOverrides() {
|
||||
void addObjectNoKeyOfSameTypeOverrides() {
|
||||
ModelMap model = new ModelMap();
|
||||
model.addAttribute("foo");
|
||||
model.addAttribute("bar");
|
||||
@@ -186,7 +186,7 @@ class ModelMapTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testAddListOfTheSameObjects() {
|
||||
void addListOfTheSameObjects() {
|
||||
List<TestBean> beans = new ArrayList<>();
|
||||
beans.add(new TestBean("one"));
|
||||
beans.add(new TestBean("two"));
|
||||
@@ -197,7 +197,7 @@ class ModelMapTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testMergeMapWithOverriding() {
|
||||
void mergeMapWithOverriding() {
|
||||
Map<String, TestBean> beans = new HashMap<>();
|
||||
beans.put("one", new TestBean("one"));
|
||||
beans.put("two", new TestBean("two"));
|
||||
@@ -210,7 +210,7 @@ class ModelMapTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testInnerClass() {
|
||||
void innerClass() {
|
||||
ModelMap map = new ModelMap();
|
||||
SomeInnerClass inner = new SomeInnerClass();
|
||||
map.addAttribute(inner);
|
||||
@@ -218,7 +218,7 @@ class ModelMapTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testInnerClassWithTwoUpperCaseLetters() {
|
||||
void innerClassWithTwoUpperCaseLetters() {
|
||||
ModelMap map = new ModelMap();
|
||||
UKInnerClass inner = new UKInnerClass();
|
||||
map.addAttribute(inner);
|
||||
@@ -226,7 +226,7 @@ class ModelMapTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testAopCglibProxy() {
|
||||
void aopCglibProxy() {
|
||||
ModelMap map = new ModelMap();
|
||||
ProxyFactory factory = new ProxyFactory();
|
||||
SomeInnerClass val = new SomeInnerClass();
|
||||
@@ -238,7 +238,7 @@ class ModelMapTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testAopJdkProxy() {
|
||||
void aopJdkProxy() {
|
||||
ModelMap map = new ModelMap();
|
||||
ProxyFactory factory = new ProxyFactory();
|
||||
Map<?, ?> target = new HashMap<>();
|
||||
@@ -250,7 +250,7 @@ class ModelMapTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testAopJdkProxyWithMultipleInterfaces() {
|
||||
void aopJdkProxyWithMultipleInterfaces() {
|
||||
ModelMap map = new ModelMap();
|
||||
Map<?, ?> target = new HashMap<>();
|
||||
ProxyFactory factory = new ProxyFactory();
|
||||
@@ -265,7 +265,7 @@ class ModelMapTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testAopJdkProxyWithDetectedInterfaces() {
|
||||
void aopJdkProxyWithDetectedInterfaces() {
|
||||
ModelMap map = new ModelMap();
|
||||
Map<?, ?> target = new HashMap<>();
|
||||
ProxyFactory factory = new ProxyFactory(target);
|
||||
@@ -275,7 +275,7 @@ class ModelMapTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testRawJdkProxy() {
|
||||
void rawJdkProxy() {
|
||||
ModelMap map = new ModelMap();
|
||||
Object proxy = Proxy.newProxyInstance(
|
||||
getClass().getClassLoader(),
|
||||
|
||||
+9
-9
@@ -43,7 +43,7 @@ class ValidationUtilsTests {
|
||||
|
||||
|
||||
@Test
|
||||
void testInvokeValidatorWithNullValidator() {
|
||||
void invokeValidatorWithNullValidator() {
|
||||
TestBean tb = new TestBean();
|
||||
Errors errors = new SimpleErrors(tb);
|
||||
assertThatIllegalArgumentException().isThrownBy(() ->
|
||||
@@ -51,14 +51,14 @@ class ValidationUtilsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testInvokeValidatorWithNullErrors() {
|
||||
void invokeValidatorWithNullErrors() {
|
||||
TestBean tb = new TestBean();
|
||||
assertThatIllegalArgumentException().isThrownBy(() ->
|
||||
ValidationUtils.invokeValidator(emptyValidator, tb, null));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testInvokeValidatorSunnyDay() {
|
||||
void invokeValidatorSunnyDay() {
|
||||
TestBean tb = new TestBean();
|
||||
Errors errors = new SimpleErrors(tb);
|
||||
ValidationUtils.invokeValidator(emptyValidator, tb, errors);
|
||||
@@ -67,7 +67,7 @@ class ValidationUtilsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testValidationUtilsSunnyDay() {
|
||||
void validationUtilsSunnyDay() {
|
||||
TestBean tb = new TestBean("");
|
||||
|
||||
tb.setName(" ");
|
||||
@@ -83,7 +83,7 @@ class ValidationUtilsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testValidationUtilsNull() {
|
||||
void validationUtilsNull() {
|
||||
TestBean tb = new TestBean();
|
||||
Errors errors = emptyValidator.validateObject(tb);
|
||||
assertThat(errors.hasFieldErrors("name")).isTrue();
|
||||
@@ -95,7 +95,7 @@ class ValidationUtilsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testValidationUtilsEmpty() {
|
||||
void validationUtilsEmpty() {
|
||||
TestBean tb = new TestBean("");
|
||||
Errors errors = emptyValidator.validateObject(tb);
|
||||
assertThat(errors.hasFieldErrors("name")).isTrue();
|
||||
@@ -107,7 +107,7 @@ class ValidationUtilsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testValidationUtilsEmptyVariants() {
|
||||
void validationUtilsEmptyVariants() {
|
||||
TestBean tb = new TestBean();
|
||||
|
||||
Errors errors = new SimpleErrors(tb);
|
||||
@@ -125,7 +125,7 @@ class ValidationUtilsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testValidationUtilsEmptyOrWhitespace() {
|
||||
void validationUtilsEmptyOrWhitespace() {
|
||||
TestBean tb = new TestBean();
|
||||
|
||||
// Test null
|
||||
@@ -152,7 +152,7 @@ class ValidationUtilsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testValidationUtilsEmptyOrWhitespaceVariants() {
|
||||
void validationUtilsEmptyOrWhitespaceVariants() {
|
||||
TestBean tb = new TestBean();
|
||||
tb.setName(" ");
|
||||
|
||||
|
||||
@@ -28,14 +28,14 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
class ValidatorTests {
|
||||
|
||||
@Test
|
||||
void testSupportsForInstanceOf() {
|
||||
void supportsForInstanceOf() {
|
||||
Validator validator = Validator.forInstanceOf(TestBean.class, (testBean, errors) -> {});
|
||||
assertThat(validator.supports(TestBean.class)).isTrue();
|
||||
assertThat(validator.supports(TestBeanSubclass.class)).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSupportsForType() {
|
||||
void supportsForType() {
|
||||
Validator validator = Validator.forType(TestBean.class, (testBean, errors) -> {});
|
||||
assertThat(validator.supports(TestBean.class)).isTrue();
|
||||
assertThat(validator.supports(TestBeanSubclass.class)).isFalse();
|
||||
|
||||
+6
-6
@@ -39,7 +39,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
class BeanValidationPostProcessorTests {
|
||||
|
||||
@Test
|
||||
void testNotNullConstraint() {
|
||||
void notNullConstraint() {
|
||||
GenericApplicationContext ac = new GenericApplicationContext();
|
||||
ac.registerBeanDefinition("bvpp", new RootBeanDefinition(BeanValidationPostProcessor.class));
|
||||
ac.registerBeanDefinition("capp", new RootBeanDefinition(CommonAnnotationBeanPostProcessor.class));
|
||||
@@ -52,7 +52,7 @@ class BeanValidationPostProcessorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testNotNullConstraintSatisfied() {
|
||||
void notNullConstraintSatisfied() {
|
||||
GenericApplicationContext ac = new GenericApplicationContext();
|
||||
ac.registerBeanDefinition("bvpp", new RootBeanDefinition(BeanValidationPostProcessor.class));
|
||||
ac.registerBeanDefinition("capp", new RootBeanDefinition(CommonAnnotationBeanPostProcessor.class));
|
||||
@@ -64,7 +64,7 @@ class BeanValidationPostProcessorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testNotNullConstraintAfterInitialization() {
|
||||
void notNullConstraintAfterInitialization() {
|
||||
GenericApplicationContext ac = new GenericApplicationContext();
|
||||
RootBeanDefinition bvpp = new RootBeanDefinition(BeanValidationPostProcessor.class);
|
||||
bvpp.getPropertyValues().add("afterInitialization", true);
|
||||
@@ -76,7 +76,7 @@ class BeanValidationPostProcessorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testNotNullConstraintAfterInitializationWithProxy() {
|
||||
void notNullConstraintAfterInitializationWithProxy() {
|
||||
GenericApplicationContext ac = new GenericApplicationContext();
|
||||
RootBeanDefinition bvpp = new RootBeanDefinition(BeanValidationPostProcessor.class);
|
||||
bvpp.getPropertyValues().add("afterInitialization", true);
|
||||
@@ -90,7 +90,7 @@ class BeanValidationPostProcessorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSizeConstraint() {
|
||||
void sizeConstraint() {
|
||||
GenericApplicationContext ac = new GenericApplicationContext();
|
||||
ac.registerBeanDefinition("bvpp", new RootBeanDefinition(BeanValidationPostProcessor.class));
|
||||
RootBeanDefinition bd = new RootBeanDefinition(NotNullConstrainedBean.class);
|
||||
@@ -105,7 +105,7 @@ class BeanValidationPostProcessorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSizeConstraintSatisfied() {
|
||||
void sizeConstraintSatisfied() {
|
||||
GenericApplicationContext ac = new GenericApplicationContext();
|
||||
ac.registerBeanDefinition("bvpp", new RootBeanDefinition(BeanValidationPostProcessor.class));
|
||||
RootBeanDefinition bd = new RootBeanDefinition(NotNullConstrainedBean.class);
|
||||
|
||||
+6
-6
@@ -66,7 +66,7 @@ class MethodValidationProxyTests {
|
||||
@ParameterizedTest
|
||||
@ValueSource(booleans = {true, false})
|
||||
@SuppressWarnings("unchecked")
|
||||
void testMethodValidationInterceptor(boolean adaptViolations) {
|
||||
void methodValidationInterceptor(boolean adaptViolations) {
|
||||
MyValidBean bean = new MyValidBean();
|
||||
ProxyFactory factory = new ProxyFactory(bean);
|
||||
factory.addAdvice(adaptViolations ?
|
||||
@@ -80,7 +80,7 @@ class MethodValidationProxyTests {
|
||||
@ParameterizedTest
|
||||
@ValueSource(booleans = {true, false})
|
||||
@SuppressWarnings("unchecked")
|
||||
void testMethodValidationPostProcessor(boolean adaptViolations) {
|
||||
void methodValidationPostProcessor(boolean adaptViolations) {
|
||||
StaticApplicationContext context = new StaticApplicationContext();
|
||||
context.registerBean(MethodValidationPostProcessor.class, adaptViolations ?
|
||||
() -> {
|
||||
@@ -101,7 +101,7 @@ class MethodValidationProxyTests {
|
||||
|
||||
@Test // gh-29782
|
||||
@SuppressWarnings("unchecked")
|
||||
public void testMethodValidationPostProcessorForInterfaceOnlyProxy() {
|
||||
void methodValidationPostProcessorForInterfaceOnlyProxy() {
|
||||
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
|
||||
context.register(MethodValidationPostProcessor.class);
|
||||
context.registerBean(MyValidInterface.class, () ->
|
||||
@@ -125,17 +125,17 @@ class MethodValidationProxyTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testLazyValidatorForMethodValidation() {
|
||||
void lazyValidatorForMethodValidation() {
|
||||
doTestLazyValidatorForMethodValidation(LazyMethodValidationConfig.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testLazyValidatorForMethodValidationWithProxyTargetClass() {
|
||||
void lazyValidatorForMethodValidationWithProxyTargetClass() {
|
||||
doTestLazyValidatorForMethodValidation(LazyMethodValidationConfigWithProxyTargetClass.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testLazyValidatorForMethodValidationWithValidatorProvider() {
|
||||
void lazyValidatorForMethodValidationWithValidatorProvider() {
|
||||
doTestLazyValidatorForMethodValidation(LazyMethodValidationConfigWithValidatorProvider.class);
|
||||
}
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user