Browse Source

Polish

pull/31869/head
Stéphane Nicoll 2 years ago
parent
commit
1bd523f6b6
  1. 12
      spring-context/src/test/java/org/springframework/aop/aspectj/AroundAdviceBindingTests.java
  2. 6
      spring-context/src/test/java/org/springframework/aop/aspectj/AroundAdviceCircularTests.java
  3. 18
      spring-context/src/test/java/org/springframework/aop/aspectj/BeanNamePointcutTests.java
  4. 7
      spring-context/src/test/java/org/springframework/aop/aspectj/ImplicitJPArgumentMatchingAtAspectJTests.java
  5. 18
      spring-context/src/test/java/org/springframework/aop/aspectj/PropertyDependentAspectTests.java
  6. 12
      spring-context/src/test/java/org/springframework/aop/aspectj/autoproxy/AtAspectJAnnotationBindingTests.java
  7. 9
      spring-context/src/test/java/org/springframework/aop/config/AopNamespaceHandlerAdviceTypeTests.java
  8. 9
      spring-context/src/test/java/org/springframework/aop/config/AopNamespaceHandlerArgNamesTests.java
  9. 6
      spring-context/src/test/java/org/springframework/aop/config/AopNamespaceHandlerProxyTargetClassTests.java
  10. 9
      spring-context/src/test/java/org/springframework/aop/config/AopNamespaceHandlerReturningTests.java
  11. 14
      spring-context/src/test/java/org/springframework/aop/config/AopNamespaceHandlerTests.java
  12. 9
      spring-context/src/test/java/org/springframework/aop/config/AopNamespaceHandlerThrowingTests.java
  13. 20
      spring-context/src/test/java/org/springframework/aop/config/MethodLocatingFactoryBeanTests.java
  14. 43
      spring-context/src/test/java/org/springframework/aop/framework/CglibProxyTests.java
  15. 18
      spring-context/src/test/java/org/springframework/aop/framework/JdkDynamicProxyTests.java
  16. 7
      spring-context/src/test/java/org/springframework/aop/framework/ObjenesisProxyTests.java
  17. 76
      spring-context/src/test/java/org/springframework/aop/framework/ProxyFactoryBeanTests.java
  18. 15
      spring-context/src/test/java/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorTests.java
  19. 25
      spring-context/src/test/java/org/springframework/aop/framework/autoproxy/AutoProxyCreatorTests.java
  20. 12
      spring-context/src/test/java/org/springframework/aop/scope/ScopedProxyTests.java
  21. 2
      spring-core/src/test/java/org/springframework/aot/hint/annotation/RegisterReflectionForBindingProcessorTests.java
  22. 2
      spring-core/src/test/java/org/springframework/aot/nativex/ReflectionHintsWriterTests.java
  23. 2
      spring-core/src/test/java/org/springframework/aot/nativex/SerializationHintsWriterTests.java
  24. 4
      spring-core/src/test/java/org/springframework/core/io/buffer/LimitedDataBufferListTests.java
  25. 2
      spring-core/src/test/java/org/springframework/core/log/CompositeLogTests.java

12
spring-context/src/test/java/org/springframework/aop/aspectj/AroundAdviceBindingTests.java

@ -38,7 +38,7 @@ import static org.mockito.Mockito.verify; @@ -38,7 +38,7 @@ import static org.mockito.Mockito.verify;
* @author Adrian Colyer
* @author Chris Beams
*/
public class AroundAdviceBindingTests {
class AroundAdviceBindingTests {
private AroundAdviceBindingCollaborator mockCollaborator = mock();
@ -50,7 +50,7 @@ public class AroundAdviceBindingTests { @@ -50,7 +50,7 @@ public class AroundAdviceBindingTests {
@BeforeEach
public void onSetUp() throws Exception {
void onSetUp() throws Exception {
ctx = new ClassPathXmlApplicationContext(getClass().getSimpleName() + ".xml", getClass());
AroundAdviceBindingTestAspect aroundAdviceAspect = (AroundAdviceBindingTestAspect) ctx.getBean("testAspect");
@ -67,25 +67,25 @@ public class AroundAdviceBindingTests { @@ -67,25 +67,25 @@ public class AroundAdviceBindingTests {
}
@Test
public void testOneIntArg() {
void testOneIntArg() {
testBeanProxy.setAge(5);
verify(mockCollaborator).oneIntArg(5);
}
@Test
public void testOneObjectArgBoundToTarget() {
void testOneObjectArgBoundToTarget() {
testBeanProxy.getAge();
verify(mockCollaborator).oneObjectArg(this.testBeanTarget);
}
@Test
public void testOneIntAndOneObjectArgs() {
void testOneIntAndOneObjectArgs() {
testBeanProxy.setAge(5);
verify(mockCollaborator).oneIntAndOneObject(5, this.testBeanProxy);
}
@Test
public void testJustJoinPoint() {
void testJustJoinPoint() {
testBeanProxy.getAge();
verify(mockCollaborator).justJoinPoint("getAge");
}

6
spring-context/src/test/java/org/springframework/aop/aspectj/AroundAdviceCircularTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -26,10 +26,10 @@ import static org.assertj.core.api.Assertions.assertThat; @@ -26,10 +26,10 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Juergen Hoeller
* @author Chris Beams
*/
public class AroundAdviceCircularTests extends AroundAdviceBindingTests {
class AroundAdviceCircularTests extends AroundAdviceBindingTests {
@Test
public void testBothBeansAreProxies() {
void testBothBeansAreProxies() {
Object tb = ctx.getBean("testBean");
assertThat(AopUtils.isAopProxy(tb)).isTrue();
Object tb2 = ctx.getBean("testBean2");

18
spring-context/src/test/java/org/springframework/aop/aspectj/BeanNamePointcutTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -38,7 +38,7 @@ import static org.assertj.core.api.Assertions.assertThat; @@ -38,7 +38,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Juergen Hoeller
* @author Chris Beams
*/
public class BeanNamePointcutTests {
class BeanNamePointcutTests {
private ITestBean testBean1;
private ITestBean testBean2;
@ -55,7 +55,7 @@ public class BeanNamePointcutTests { @@ -55,7 +55,7 @@ public class BeanNamePointcutTests {
@BeforeEach
public void setup() {
void setup() {
ctx = new ClassPathXmlApplicationContext(getClass().getSimpleName() + ".xml", getClass());
testBean1 = (ITestBean) ctx.getBean("testBean1");
testBean2 = (ITestBean) ctx.getBean("testBean2");
@ -74,7 +74,7 @@ public class BeanNamePointcutTests { @@ -74,7 +74,7 @@ public class BeanNamePointcutTests {
// We don't need to test all combination of pointcuts due to BeanNamePointcutMatchingTests
@Test
public void testMatchingBeanName() {
void testMatchingBeanName() {
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 @@ public class BeanNamePointcutTests { @@ -84,7 +84,7 @@ public class BeanNamePointcutTests {
}
@Test
public void testNonMatchingBeanName() {
void testNonMatchingBeanName() {
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 @@ public class BeanNamePointcutTests { @@ -92,13 +92,13 @@ public class BeanNamePointcutTests {
}
@Test
public void testNonMatchingNestedBeanName() {
void testNonMatchingNestedBeanName() {
boolean condition = this.testBeanContainingNestedBean.getDoctor() instanceof Advised;
assertThat(condition).as("Non-matching bean must *not* be advised (proxied)").isFalse();
}
@Test
public void testMatchingFactoryBeanObject() {
void testMatchingFactoryBeanObject() {
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 @@ public class BeanNamePointcutTests { @@ -110,7 +110,7 @@ public class BeanNamePointcutTests {
}
@Test
public void testMatchingFactoryBeanItself() {
void testMatchingFactoryBeanItself() {
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 @@ public class BeanNamePointcutTests { @@ -122,7 +122,7 @@ public class BeanNamePointcutTests {
}
@Test
public void testPointcutAdvisorCombination() {
void testPointcutAdvisorCombination() {
boolean condition = this.interceptThis instanceof Advised;
assertThat(condition).as("Matching bean must be advised (proxied)").isTrue();
boolean condition1 = this.dontInterceptThis instanceof Advised;

7
spring-context/src/test/java/org/springframework/aop/aspectj/ImplicitJPArgumentMatchingAtAspectJTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -31,11 +31,10 @@ import org.springframework.context.support.ClassPathXmlApplicationContext; @@ -31,11 +31,10 @@ import org.springframework.context.support.ClassPathXmlApplicationContext;
* @author Ramnivas Laddad
* @author Chris Beams
*/
public class ImplicitJPArgumentMatchingAtAspectJTests {
class ImplicitJPArgumentMatchingAtAspectJTests {
@Test
@SuppressWarnings("resource")
public void testAspect() {
void testAspect() {
// nothing to really test; it is enough if we don't get error while creating the app context
new ClassPathXmlApplicationContext(getClass().getSimpleName() + ".xml", getClass());
}

18
spring-context/src/test/java/org/springframework/aop/aspectj/PropertyDependentAspectTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -36,29 +36,25 @@ import static org.assertj.core.api.Assertions.assertThat; @@ -36,29 +36,25 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Juergen Hoeller
* @author Chris Beams
*/
@SuppressWarnings("resource")
public class PropertyDependentAspectTests {
class PropertyDependentAspectTests {
@Test
public void propertyDependentAspectWithPropertyDeclaredBeforeAdvice()
throws Exception {
void propertyDependentAspectWithPropertyDeclaredBeforeAdvice() {
checkXmlAspect(getClass().getSimpleName() + "-before.xml");
}
@Test
public void propertyDependentAspectWithPropertyDeclaredAfterAdvice() throws Exception {
void propertyDependentAspectWithPropertyDeclaredAfterAdvice() {
checkXmlAspect(getClass().getSimpleName() + "-after.xml");
}
@Test
public void propertyDependentAtAspectJAspectWithPropertyDeclaredBeforeAdvice()
throws Exception {
void propertyDependentAtAspectJAspectWithPropertyDeclaredBeforeAdvice() {
checkAtAspectJAspect(getClass().getSimpleName() + "-atAspectJ-before.xml");
}
@Test
public void propertyDependentAtAspectJAspectWithPropertyDeclaredAfterAdvice()
throws Exception {
void propertyDependentAtAspectJAspectWithPropertyDeclaredAfterAdvice() {
checkAtAspectJAspect(getClass().getSimpleName() + "-atAspectJ-after.xml");
}
@ -133,7 +129,7 @@ class JoinPointMonitorAtAspectJAspect { @@ -133,7 +129,7 @@ class JoinPointMonitorAtAspectJAspect {
int aroundExecutions;
@Before("execution(* increment*())")
public void before() {
void before() {
beforeExecutions++;
}

12
spring-context/src/test/java/org/springframework/aop/aspectj/autoproxy/AtAspectJAnnotationBindingTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -33,7 +33,7 @@ import static org.assertj.core.api.Assertions.assertThat; @@ -33,7 +33,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Juergen Hoeller
* @author Chris Beams
*/
public class AtAspectJAnnotationBindingTests {
class AtAspectJAnnotationBindingTests {
private AnnotatedTestBean testBean;
@ -41,26 +41,26 @@ public class AtAspectJAnnotationBindingTests { @@ -41,26 +41,26 @@ public class AtAspectJAnnotationBindingTests {
@BeforeEach
public void setup() {
void setup() {
ctx = new ClassPathXmlApplicationContext(getClass().getSimpleName() + "-context.xml", getClass());
testBean = (AnnotatedTestBean) ctx.getBean("testBean");
}
@Test
public void testAnnotationBindingInAroundAdvice() {
void testAnnotationBindingInAroundAdvice() {
assertThat(testBean.doThis()).isEqualTo("this value doThis");
assertThat(testBean.doThat()).isEqualTo("that value doThat");
assertThat(testBean.doArray()).hasSize(2);
}
@Test
public void testNoMatchingWithoutAnnotationPresent() {
void testNoMatchingWithoutAnnotationPresent() {
assertThat(testBean.doTheOther()).isEqualTo("doTheOther");
}
@Test
public void testPointcutEvaluatedAgainstArray() {
void testPointcutEvaluatedAgainstArray() {
ctx.getBean("arrayFactoryBean");
}

9
spring-context/src/test/java/org/springframework/aop/config/AopNamespaceHandlerAdviceTypeTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -28,16 +28,15 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType; @@ -28,16 +28,15 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
* @author Adrian Colyer
* @author Chris Beams
*/
public class AopNamespaceHandlerAdviceTypeTests {
class AopNamespaceHandlerAdviceTypeTests {
@Test
@SuppressWarnings("resource")
public void testParsingOfAdviceTypes() {
void testParsingOfAdviceTypes() {
new ClassPathXmlApplicationContext(getClass().getSimpleName() + "-ok.xml", getClass());
}
@Test
public void testParsingOfAdviceTypesWithError() {
void testParsingOfAdviceTypesWithError() {
assertThatExceptionOfType(BeanDefinitionStoreException.class).isThrownBy(() ->
new ClassPathXmlApplicationContext(getClass().getSimpleName() + "-error.xml", getClass()))
.matches(ex -> ex.contains(SAXParseException.class));

9
spring-context/src/test/java/org/springframework/aop/config/AopNamespaceHandlerArgNamesTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -27,16 +27,15 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType; @@ -27,16 +27,15 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
* @author Adrian Colyer
* @author Chris Beams
*/
public class AopNamespaceHandlerArgNamesTests {
class AopNamespaceHandlerArgNamesTests {
@Test
@SuppressWarnings("resource")
public void testArgNamesOK() {
void testArgNamesOK() {
new ClassPathXmlApplicationContext(getClass().getSimpleName() + "-ok.xml", getClass());
}
@Test
public void testArgNamesError() {
void testArgNamesError() {
assertThatExceptionOfType(BeanCreationException.class).isThrownBy(() ->
new ClassPathXmlApplicationContext(getClass().getSimpleName() + "-error.xml", getClass()))
.matches(ex -> ex.contains(IllegalArgumentException.class));

6
spring-context/src/test/java/org/springframework/aop/config/AopNamespaceHandlerProxyTargetClassTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -28,10 +28,10 @@ import static org.assertj.core.api.Assertions.assertThat; @@ -28,10 +28,10 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Rob Harrop
* @author Chris Beams
*/
public class AopNamespaceHandlerProxyTargetClassTests extends AopNamespaceHandlerTests {
class AopNamespaceHandlerProxyTargetClassTests extends AopNamespaceHandlerTests {
@Test
public void testIsClassProxy() {
void testIsClassProxy() {
ITestBean bean = getTestBean();
assertThat(AopUtils.isCglibProxy(bean)).as("Should be a CGLIB proxy").isTrue();
assertThat(((Advised) bean).isExposeProxy()).as("Should expose proxy").isTrue();

9
spring-context/src/test/java/org/springframework/aop/config/AopNamespaceHandlerReturningTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -28,16 +28,15 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType; @@ -28,16 +28,15 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
* @author Adrian Colyer
* @author Chris Beams
*/
public class AopNamespaceHandlerReturningTests {
class AopNamespaceHandlerReturningTests {
@Test
@SuppressWarnings("resource")
public void testReturningOnReturningAdvice() {
void testReturningOnReturningAdvice() {
new ClassPathXmlApplicationContext(getClass().getSimpleName() + "-ok.xml", getClass());
}
@Test
public void testParseReturningOnOtherAdviceType() {
void testParseReturningOnOtherAdviceType() {
assertThatExceptionOfType(BeanDefinitionStoreException.class).isThrownBy(() ->
new ClassPathXmlApplicationContext(getClass().getSimpleName() + "-error.xml", getClass()))
.matches(ex -> ex.contains(SAXParseException.class));

14
spring-context/src/test/java/org/springframework/aop/config/AopNamespaceHandlerTests.java

@ -37,13 +37,13 @@ import static org.assertj.core.api.Assertions.assertThat; @@ -37,13 +37,13 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Rob Harrop
* @author Chris Beams
*/
public class AopNamespaceHandlerTests {
class AopNamespaceHandlerTests {
private ApplicationContext context;
@BeforeEach
public void setup() {
void setup() {
this.context = new ClassPathXmlApplicationContext(getClass().getSimpleName() + "-context.xml", getClass());
}
@ -53,7 +53,7 @@ public class AopNamespaceHandlerTests { @@ -53,7 +53,7 @@ public class AopNamespaceHandlerTests {
@Test
public void testIsProxy() throws Exception {
void testIsProxy() {
ITestBean bean = getTestBean();
assertThat(AopUtils.isAopProxy(bean)).as("Bean is not a proxy").isTrue();
@ -66,7 +66,7 @@ public class AopNamespaceHandlerTests { @@ -66,7 +66,7 @@ public class AopNamespaceHandlerTests {
}
@Test
public void testAdviceInvokedCorrectly() throws Exception {
void testAdviceInvokedCorrectly() {
CountingBeforeAdvice getAgeCounter = (CountingBeforeAdvice) this.context.getBean("getAgeCounter");
CountingBeforeAdvice getNameCounter = (CountingBeforeAdvice) this.context.getBean("getNameCounter");
@ -87,7 +87,7 @@ public class AopNamespaceHandlerTests { @@ -87,7 +87,7 @@ public class AopNamespaceHandlerTests {
}
@Test
public void testAspectApplied() throws Exception {
void testAspectApplied() {
ITestBean bean = getTestBean();
CountingAspectJAdvice advice = (CountingAspectJAdvice) this.context.getBean("countingAdvice");
@ -107,7 +107,7 @@ public class AopNamespaceHandlerTests { @@ -107,7 +107,7 @@ public class AopNamespaceHandlerTests {
}
@Test
public void testAspectAppliedForInitializeBeanWithEmptyName() {
void testAspectAppliedForInitializeBeanWithEmptyName() {
ITestBean bean = (ITestBean) this.context.getAutowireCapableBeanFactory().initializeBean(new TestBean(), "");
CountingAspectJAdvice advice = (CountingAspectJAdvice) this.context.getBean("countingAdvice");
@ -127,7 +127,7 @@ public class AopNamespaceHandlerTests { @@ -127,7 +127,7 @@ public class AopNamespaceHandlerTests {
}
@Test
public void testAspectAppliedForInitializeBeanWithNullName() {
void testAspectAppliedForInitializeBeanWithNullName() {
ITestBean bean = (ITestBean) this.context.getAutowireCapableBeanFactory().initializeBean(new TestBean(), null);
CountingAspectJAdvice advice = (CountingAspectJAdvice) this.context.getBean("countingAdvice");

9
spring-context/src/test/java/org/springframework/aop/config/AopNamespaceHandlerThrowingTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -28,16 +28,15 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType; @@ -28,16 +28,15 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
* @author Adrian Colyer
* @author Chris Beams
*/
public class AopNamespaceHandlerThrowingTests {
class AopNamespaceHandlerThrowingTests {
@Test
@SuppressWarnings("resource")
public void testThrowingOnThrowingAdvice() {
void testThrowingOnThrowingAdvice() {
new ClassPathXmlApplicationContext(getClass().getSimpleName() + "-ok.xml", getClass());
}
@Test
public void testParseThrowingOnOtherAdviceType() {
void testParseThrowingOnOtherAdviceType() {
assertThatExceptionOfType(BeanDefinitionStoreException.class).isThrownBy(() ->
new ClassPathXmlApplicationContext(getClass().getSimpleName() + "-error.xml", getClass()))
.matches(ex -> ex.contains(SAXParseException.class));

20
spring-context/src/test/java/org/springframework/aop/config/MethodLocatingFactoryBeanTests.java

@ -32,7 +32,7 @@ import static org.mockito.Mockito.verify; @@ -32,7 +32,7 @@ import static org.mockito.Mockito.verify;
* @author Rick Evans
* @author Chris Beams
*/
public class MethodLocatingFactoryBeanTests {
class MethodLocatingFactoryBeanTests {
private static final String BEAN_NAME = "string";
private MethodLocatingFactoryBean factory = new MethodLocatingFactoryBean();
@ -40,24 +40,24 @@ public class MethodLocatingFactoryBeanTests { @@ -40,24 +40,24 @@ public class MethodLocatingFactoryBeanTests {
@Test
public void testIsSingleton() {
void testIsSingleton() {
assertThat(factory.isSingleton()).isTrue();
}
@Test
public void testGetObjectType() {
void testGetObjectType() {
assertThat(factory.getObjectType()).isEqualTo(Method.class);
}
@Test
public void testWithNullTargetBeanName() {
void testWithNullTargetBeanName() {
factory.setMethodName("toString()");
assertThatIllegalArgumentException().isThrownBy(() ->
factory.setBeanFactory(beanFactory));
}
@Test
public void testWithEmptyTargetBeanName() {
void testWithEmptyTargetBeanName() {
factory.setTargetBeanName("");
factory.setMethodName("toString()");
assertThatIllegalArgumentException().isThrownBy(() ->
@ -65,14 +65,14 @@ public class MethodLocatingFactoryBeanTests { @@ -65,14 +65,14 @@ public class MethodLocatingFactoryBeanTests {
}
@Test
public void testWithNullTargetMethodName() {
void testWithNullTargetMethodName() {
factory.setTargetBeanName(BEAN_NAME);
assertThatIllegalArgumentException().isThrownBy(() ->
factory.setBeanFactory(beanFactory));
}
@Test
public void testWithEmptyTargetMethodName() {
void testWithEmptyTargetMethodName() {
factory.setTargetBeanName(BEAN_NAME);
factory.setMethodName("");
assertThatIllegalArgumentException().isThrownBy(() ->
@ -80,7 +80,7 @@ public class MethodLocatingFactoryBeanTests { @@ -80,7 +80,7 @@ public class MethodLocatingFactoryBeanTests {
}
@Test
public void testWhenTargetBeanClassCannotBeResolved() {
void testWhenTargetBeanClassCannotBeResolved() {
factory.setTargetBeanName(BEAN_NAME);
factory.setMethodName("toString()");
assertThatIllegalArgumentException().isThrownBy(() ->
@ -90,7 +90,7 @@ public class MethodLocatingFactoryBeanTests { @@ -90,7 +90,7 @@ public class MethodLocatingFactoryBeanTests {
@Test
@SuppressWarnings({ "unchecked", "rawtypes" })
public void testSunnyDayPath() throws Exception {
void testSunnyDayPath() throws Exception {
given(beanFactory.getType(BEAN_NAME)).willReturn((Class)String.class);
factory.setTargetBeanName(BEAN_NAME);
factory.setMethodName("toString()");
@ -105,7 +105,7 @@ public class MethodLocatingFactoryBeanTests { @@ -105,7 +105,7 @@ public class MethodLocatingFactoryBeanTests {
@Test
@SuppressWarnings({ "unchecked", "rawtypes" })
public void testWhereMethodCannotBeResolved() {
void testWhereMethodCannotBeResolved() {
given(beanFactory.getType(BEAN_NAME)).willReturn((Class)String.class);
factory.setTargetBeanName(BEAN_NAME);
factory.setMethodName("loadOfOld()");

43
spring-context/src/test/java/org/springframework/aop/framework/CglibProxyTests.java

@ -52,8 +52,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException @@ -52,8 +52,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
* @author Ramnivas Laddad
* @author Chris Beams
*/
@SuppressWarnings("serial")
public class CglibProxyTests extends AbstractAopProxyTests implements Serializable {
class CglibProxyTests extends AbstractAopProxyTests implements Serializable {
private static final String DEPENDENCY_CHECK_CONTEXT =
CglibProxyTests.class.getSimpleName() + "-with-dependency-checking.xml";
@ -80,13 +79,13 @@ public class CglibProxyTests extends AbstractAopProxyTests implements Serializab @@ -80,13 +79,13 @@ public class CglibProxyTests extends AbstractAopProxyTests implements Serializab
@Test
public void testNullConfig() {
void testNullConfig() {
assertThatIllegalArgumentException().isThrownBy(() ->
new CglibAopProxy(null));
}
@Test
public void testNoTarget() {
void testNoTarget() {
AdvisedSupport pc = new AdvisedSupport(ITestBean.class);
pc.addAdvice(new NopInterceptor());
AopProxy aop = createAopProxy(pc);
@ -94,7 +93,7 @@ public class CglibProxyTests extends AbstractAopProxyTests implements Serializab @@ -94,7 +93,7 @@ public class CglibProxyTests extends AbstractAopProxyTests implements Serializab
}
@Test
public void testProtectedMethodInvocation() {
void testProtectedMethodInvocation() {
ProtectedMethodTestBean bean = new ProtectedMethodTestBean();
bean.value = "foo";
mockTargetSource.setTarget(bean);
@ -111,7 +110,7 @@ public class CglibProxyTests extends AbstractAopProxyTests implements Serializab @@ -111,7 +110,7 @@ public class CglibProxyTests extends AbstractAopProxyTests implements Serializab
}
@Test
public void testPackageMethodInvocation() {
void testPackageMethodInvocation() {
PackageMethodTestBean bean = new PackageMethodTestBean();
bean.value = "foo";
mockTargetSource.setTarget(bean);
@ -128,7 +127,7 @@ public class CglibProxyTests extends AbstractAopProxyTests implements Serializab @@ -128,7 +127,7 @@ public class CglibProxyTests extends AbstractAopProxyTests implements Serializab
}
@Test
public void testProxyCanBeClassNotInterface() {
void testProxyCanBeClassNotInterface() {
TestBean raw = new TestBean();
raw.setAge(32);
mockTargetSource.setTarget(raw);
@ -146,7 +145,7 @@ public class CglibProxyTests extends AbstractAopProxyTests implements Serializab @@ -146,7 +145,7 @@ public class CglibProxyTests extends AbstractAopProxyTests implements Serializab
}
@Test
public void testMethodInvocationDuringConstructor() {
void testMethodInvocationDuringConstructor() {
CglibTestBean bean = new CglibTestBean();
bean.setName("Rob Harrop");
@ -160,7 +159,7 @@ public class CglibProxyTests extends AbstractAopProxyTests implements Serializab @@ -160,7 +159,7 @@ public class CglibProxyTests extends AbstractAopProxyTests implements Serializab
}
@Test
public void testToStringInvocation() {
void testToStringInvocation() {
PrivateCglibTestBean bean = new PrivateCglibTestBean();
bean.setName("Rob Harrop");
@ -174,7 +173,7 @@ public class CglibProxyTests extends AbstractAopProxyTests implements Serializab @@ -174,7 +173,7 @@ public class CglibProxyTests extends AbstractAopProxyTests implements Serializab
}
@Test
public void testUnadvisedProxyCreationWithCallDuringConstructor() {
void testUnadvisedProxyCreationWithCallDuringConstructor() {
CglibTestBean target = new CglibTestBean();
target.setName("Rob Harrop");
@ -189,7 +188,7 @@ public class CglibProxyTests extends AbstractAopProxyTests implements Serializab @@ -189,7 +188,7 @@ public class CglibProxyTests extends AbstractAopProxyTests implements Serializab
}
@Test
public void testMultipleProxies() {
void testMultipleProxies() {
TestBean target = new TestBean();
target.setAge(20);
TestBean target2 = new TestBean();
@ -235,7 +234,7 @@ public class CglibProxyTests extends AbstractAopProxyTests implements Serializab @@ -235,7 +234,7 @@ public class CglibProxyTests extends AbstractAopProxyTests implements Serializab
}
@Test
public void testMultipleProxiesForIntroductionAdvisor() {
void testMultipleProxiesForIntroductionAdvisor() {
TestBean target1 = new TestBean();
target1.setAge(20);
TestBean target2 = new TestBean();
@ -259,7 +258,7 @@ public class CglibProxyTests extends AbstractAopProxyTests implements Serializab @@ -259,7 +258,7 @@ public class CglibProxyTests extends AbstractAopProxyTests implements Serializab
}
@Test
public void testWithNoArgConstructor() {
void testWithNoArgConstructor() {
NoArgCtorTestBean target = new NoArgCtorTestBean("b", 1);
target.reset();
@ -274,7 +273,7 @@ public class CglibProxyTests extends AbstractAopProxyTests implements Serializab @@ -274,7 +273,7 @@ public class CglibProxyTests extends AbstractAopProxyTests implements Serializab
}
@Test
public void testProxyAProxy() {
void testProxyAProxy() {
ITestBean target = new TestBean();
mockTargetSource.setTarget(target);
@ -295,7 +294,7 @@ public class CglibProxyTests extends AbstractAopProxyTests implements Serializab @@ -295,7 +294,7 @@ public class CglibProxyTests extends AbstractAopProxyTests implements Serializab
}
@Test
public void testProxyAProxyWithAdditionalInterface() {
void testProxyAProxyWithAdditionalInterface() {
ITestBean target = new TestBean();
mockTargetSource.setTarget(target);
@ -353,7 +352,7 @@ public class CglibProxyTests extends AbstractAopProxyTests implements Serializab @@ -353,7 +352,7 @@ public class CglibProxyTests extends AbstractAopProxyTests implements Serializab
}
@Test
public void testExceptionHandling() {
void testExceptionHandling() {
ExceptionThrower bean = new ExceptionThrower();
mockTargetSource.setTarget(bean);
@ -376,14 +375,13 @@ public class CglibProxyTests extends AbstractAopProxyTests implements Serializab @@ -376,14 +375,13 @@ public class CglibProxyTests extends AbstractAopProxyTests implements Serializab
}
@Test
@SuppressWarnings("resource")
public void testWithDependencyChecking() {
void testWithDependencyChecking() {
ApplicationContext ctx = new ClassPathXmlApplicationContext(DEPENDENCY_CHECK_CONTEXT, getClass());
ctx.getBean("testBean");
}
@Test
public void testAddAdviceAtRuntime() {
void testAddAdviceAtRuntime() {
TestBean bean = new TestBean();
CountingBeforeAdvice cba = new CountingBeforeAdvice();
@ -405,7 +403,7 @@ public class CglibProxyTests extends AbstractAopProxyTests implements Serializab @@ -405,7 +403,7 @@ public class CglibProxyTests extends AbstractAopProxyTests implements Serializab
}
@Test
public void testProxyProtectedMethod() {
void testProxyProtectedMethod() {
CountingBeforeAdvice advice = new CountingBeforeAdvice();
ProxyFactory proxyFactory = new ProxyFactory(new MyBean());
proxyFactory.addAdvice(advice);
@ -417,15 +415,14 @@ public class CglibProxyTests extends AbstractAopProxyTests implements Serializab @@ -417,15 +415,14 @@ public class CglibProxyTests extends AbstractAopProxyTests implements Serializab
}
@Test
public void testProxyTargetClassInCaseOfNoInterfaces() {
void testProxyTargetClassInCaseOfNoInterfaces() {
ProxyFactory proxyFactory = new ProxyFactory(new MyBean());
MyBean proxy = (MyBean) proxyFactory.getProxy();
assertThat(proxy.add(1, 3)).isEqualTo(4);
}
@Test // SPR-13328
@SuppressWarnings("unchecked")
public void testVarargsWithEnumArray() {
void testVarargsWithEnumArray() {
ProxyFactory proxyFactory = new ProxyFactory(new MyBean());
MyBean proxy = (MyBean) proxyFactory.getProxy();
assertThat(proxy.doWithVarargs(MyEnum.A, MyOtherEnum.C)).isTrue();

18
spring-context/src/test/java/org/springframework/aop/framework/JdkDynamicProxyTests.java

@ -38,8 +38,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException @@ -38,8 +38,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
* @author Chris Beams
* @since 13.03.2003
*/
@SuppressWarnings("serial")
public class JdkDynamicProxyTests extends AbstractAopProxyTests implements Serializable {
class JdkDynamicProxyTests extends AbstractAopProxyTests implements Serializable {
@Override
protected Object createProxy(ProxyCreatorSupport as) {
@ -56,13 +55,13 @@ public class JdkDynamicProxyTests extends AbstractAopProxyTests implements Seria @@ -56,13 +55,13 @@ public class JdkDynamicProxyTests extends AbstractAopProxyTests implements Seria
@Test
public void testNullConfig() {
void testNullConfig() {
assertThatIllegalArgumentException().isThrownBy(() ->
new JdkDynamicAopProxy(null));
}
@Test
public void testProxyIsJustInterface() {
void testProxyIsJustInterface() {
TestBean raw = new TestBean();
raw.setAge(32);
AdvisedSupport pc = new AdvisedSupport(ITestBean.class);
@ -77,7 +76,7 @@ public class JdkDynamicProxyTests extends AbstractAopProxyTests implements Seria @@ -77,7 +76,7 @@ public class JdkDynamicProxyTests extends AbstractAopProxyTests implements Seria
}
@Test
public void testInterceptorIsInvokedWithNoTarget() {
void testInterceptorIsInvokedWithNoTarget() {
// Test return value
final int age = 25;
MethodInterceptor mi = (invocation -> age);
@ -91,7 +90,7 @@ public class JdkDynamicProxyTests extends AbstractAopProxyTests implements Seria @@ -91,7 +90,7 @@ public class JdkDynamicProxyTests extends AbstractAopProxyTests implements Seria
}
@Test
public void testTargetCanGetInvocationWithPrivateClass() {
void testTargetCanGetInvocationWithPrivateClass() {
final ExposedInvocationTestBean expectedTarget = new ExposedInvocationTestBean() {
@Override
protected void assertions(MethodInvocation invocation) {
@ -119,7 +118,7 @@ public class JdkDynamicProxyTests extends AbstractAopProxyTests implements Seria @@ -119,7 +118,7 @@ public class JdkDynamicProxyTests extends AbstractAopProxyTests implements Seria
}
@Test
public void testProxyNotWrappedIfIncompatible() {
void testProxyNotWrappedIfIncompatible() {
FooBar bean = new FooBar();
ProxyCreatorSupport as = new ProxyCreatorSupport();
as.setInterfaces(Foo.class);
@ -131,7 +130,7 @@ public class JdkDynamicProxyTests extends AbstractAopProxyTests implements Seria @@ -131,7 +130,7 @@ public class JdkDynamicProxyTests extends AbstractAopProxyTests implements Seria
}
@Test
public void testEqualsAndHashCodeDefined() {
void testEqualsAndHashCodeDefined() {
AdvisedSupport as = new AdvisedSupport(Named.class);
as.setTarget(new Person());
JdkDynamicAopProxy aopProxy = new JdkDynamicAopProxy(as);
@ -142,8 +141,7 @@ public class JdkDynamicProxyTests extends AbstractAopProxyTests implements Seria @@ -142,8 +141,7 @@ public class JdkDynamicProxyTests extends AbstractAopProxyTests implements Seria
}
@Test // SPR-13328
@SuppressWarnings("unchecked")
public void testVarargsWithEnumArray() {
void testVarargsWithEnumArray() {
ProxyFactory proxyFactory = new ProxyFactory(new VarargTestBean());
VarargTestInterface proxy = (VarargTestInterface) proxyFactory.getProxy();
assertThat(proxy.doWithVarargs(MyEnum.A, MyOtherEnum.C)).isTrue();

7
spring-context/src/test/java/org/springframework/aop/framework/ObjenesisProxyTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -30,11 +30,10 @@ import static org.assertj.core.api.Assertions.assertThat; @@ -30,11 +30,10 @@ import static org.assertj.core.api.Assertions.assertThat;
*
* @author Oliver Gierke
*/
public class ObjenesisProxyTests {
class ObjenesisProxyTests {
@Test
public void appliesAspectToClassWithComplexConstructor() {
@SuppressWarnings("resource")
void appliesAspectToClassWithComplexConstructor() {
ApplicationContext context = new ClassPathXmlApplicationContext("ObjenesisProxyTests-context.xml", getClass());
ClassWithComplexConstructor bean = context.getBean(ClassWithComplexConstructor.class);

76
spring-context/src/test/java/org/springframework/aop/framework/ProxyFactoryBeanTests.java

@ -71,7 +71,7 @@ import static org.assertj.core.api.Assertions.assertThatIOException; @@ -71,7 +71,7 @@ import static org.assertj.core.api.Assertions.assertThatIOException;
* @author Chris Beams
* @since 13.03.2003
*/
public class ProxyFactoryBeanTests {
class ProxyFactoryBeanTests {
private static final Class<?> CLASS = ProxyFactoryBeanTests.class;
private static final String CLASSNAME = CLASS.getSimpleName();
@ -92,7 +92,7 @@ public class ProxyFactoryBeanTests { @@ -92,7 +92,7 @@ public class ProxyFactoryBeanTests {
@BeforeEach
public void setup() throws Exception {
void setup() throws Exception {
DefaultListableBeanFactory parent = new DefaultListableBeanFactory();
parent.registerBeanDefinition("target2", new RootBeanDefinition(TestApplicationListener.class));
this.factory = new DefaultListableBeanFactory(parent);
@ -102,25 +102,25 @@ public class ProxyFactoryBeanTests { @@ -102,25 +102,25 @@ public class ProxyFactoryBeanTests {
@Test
public void testIsDynamicProxyWhenInterfaceSpecified() {
void testIsDynamicProxyWhenInterfaceSpecified() {
ITestBean test1 = (ITestBean) factory.getBean("test1");
assertThat(Proxy.isProxyClass(test1.getClass())).as("test1 is a dynamic proxy").isTrue();
}
@Test
public void testIsDynamicProxyWhenInterfaceSpecifiedForPrototype() {
void testIsDynamicProxyWhenInterfaceSpecifiedForPrototype() {
ITestBean test1 = (ITestBean) factory.getBean("test2");
assertThat(Proxy.isProxyClass(test1.getClass())).as("test2 is a dynamic proxy").isTrue();
}
@Test
public void testIsDynamicProxyWhenAutodetectingInterfaces() {
void testIsDynamicProxyWhenAutodetectingInterfaces() {
ITestBean test1 = (ITestBean) factory.getBean("test3");
assertThat(Proxy.isProxyClass(test1.getClass())).as("test3 is a dynamic proxy").isTrue();
}
@Test
public void testIsDynamicProxyWhenAutodetectingInterfacesForPrototype() {
void testIsDynamicProxyWhenAutodetectingInterfacesForPrototype() {
ITestBean test1 = (ITestBean) factory.getBean("test4");
assertThat(Proxy.isProxyClass(test1.getClass())).as("test4 is a dynamic proxy").isTrue();
}
@ -130,7 +130,7 @@ public class ProxyFactoryBeanTests { @@ -130,7 +130,7 @@ public class ProxyFactoryBeanTests {
* interceptor chain and targetSource property.
*/
@Test
public void testDoubleTargetSourcesAreRejected() {
void testDoubleTargetSourcesAreRejected() {
testDoubleTargetSourceIsRejected("doubleTarget");
// Now with conversion from arbitrary bean to a TargetSource
testDoubleTargetSourceIsRejected("arbitraryTarget");
@ -148,7 +148,7 @@ public class ProxyFactoryBeanTests { @@ -148,7 +148,7 @@ public class ProxyFactoryBeanTests {
}
@Test
public void testTargetSourceNotAtEndOfInterceptorNamesIsRejected() {
void testTargetSourceNotAtEndOfInterceptorNamesIsRejected() {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(new ClassPathResource(NOTLAST_TARGETSOURCE_CONTEXT, CLASS));
@ -160,7 +160,7 @@ public class ProxyFactoryBeanTests { @@ -160,7 +160,7 @@ public class ProxyFactoryBeanTests {
}
@Test
public void testGetObjectTypeWithDirectTarget() {
void testGetObjectTypeWithDirectTarget() {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(new ClassPathResource(TARGETSOURCE_CONTEXT, CLASS));
@ -177,7 +177,7 @@ public class ProxyFactoryBeanTests { @@ -177,7 +177,7 @@ public class ProxyFactoryBeanTests {
}
@Test
public void testGetObjectTypeWithTargetViaTargetSource() {
void testGetObjectTypeWithTargetViaTargetSource() {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(new ClassPathResource(TARGETSOURCE_CONTEXT, CLASS));
ITestBean tb = (ITestBean) bf.getBean("viaTargetSource");
@ -187,7 +187,7 @@ public class ProxyFactoryBeanTests { @@ -187,7 +187,7 @@ public class ProxyFactoryBeanTests {
}
@Test
public void testGetObjectTypeWithNoTargetOrTargetSource() {
void testGetObjectTypeWithNoTargetOrTargetSource() {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(new ClassPathResource(TARGETSOURCE_CONTEXT, CLASS));
@ -198,7 +198,7 @@ public class ProxyFactoryBeanTests { @@ -198,7 +198,7 @@ public class ProxyFactoryBeanTests {
}
@Test
public void testGetObjectTypeOnUninitializedFactoryBean() {
void testGetObjectTypeOnUninitializedFactoryBean() {
ProxyFactoryBean pfb = new ProxyFactoryBean();
assertThat(pfb.getObjectType()).isNull();
}
@ -208,7 +208,7 @@ public class ProxyFactoryBeanTests { @@ -208,7 +208,7 @@ public class ProxyFactoryBeanTests {
* Interceptors and interfaces and the target are the same.
*/
@Test
public void testSingletonInstancesAreEqual() {
void testSingletonInstancesAreEqual() {
ITestBean test1 = (ITestBean) factory.getBean("test1");
ITestBean test1_1 = (ITestBean) factory.getBean("test1");
//assertTrue("Singleton instances ==", test1 == test1_1);
@ -232,7 +232,7 @@ public class ProxyFactoryBeanTests { @@ -232,7 +232,7 @@ public class ProxyFactoryBeanTests {
}
@Test
public void testPrototypeInstancesAreNotEqual() {
void testPrototypeInstancesAreNotEqual() {
assertThat(factory.getType("prototype")).isAssignableTo(ITestBean.class);
ITestBean test2 = (ITestBean) factory.getBean("prototype");
ITestBean test2_1 = (ITestBean) factory.getBean("prototype");
@ -276,7 +276,7 @@ public class ProxyFactoryBeanTests { @@ -276,7 +276,7 @@ public class ProxyFactoryBeanTests {
}
@Test
public void testCglibPrototypeInstance() {
void testCglibPrototypeInstance() {
Object prototype = testPrototypeInstancesAreIndependent("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 +286,7 @@ public class ProxyFactoryBeanTests { @@ -286,7 +286,7 @@ public class ProxyFactoryBeanTests {
* Test invoker is automatically added to manipulate target.
*/
@Test
public void testAutoInvoker() {
void testAutoInvoker() {
String name = "Hieronymous";
TestBean target = (TestBean) factory.getBean("test");
target.setName(name);
@ -295,7 +295,7 @@ public class ProxyFactoryBeanTests { @@ -295,7 +295,7 @@ public class ProxyFactoryBeanTests {
}
@Test
public void testCanGetFactoryReferenceAndManipulate() {
void testCanGetFactoryReferenceAndManipulate() {
ProxyFactoryBean config = (ProxyFactoryBean) factory.getBean("&test1");
assertThat(config.getObjectType()).isAssignableTo(ITestBean.class);
assertThat(factory.getType("test1")).isAssignableTo(ITestBean.class);
@ -327,7 +327,7 @@ public class ProxyFactoryBeanTests { @@ -327,7 +327,7 @@ public class ProxyFactoryBeanTests {
* autowire without ambiguity from target and proxy
*/
@Test
public void testTargetAsInnerBean() {
void testTargetAsInnerBean() {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(new ClassPathResource(INNER_BEAN_TARGET_CONTEXT, CLASS));
ITestBean itb = (ITestBean) bf.getBean("testBean");
@ -343,7 +343,7 @@ public class ProxyFactoryBeanTests { @@ -343,7 +343,7 @@ public class ProxyFactoryBeanTests {
* Each instance will be independent.
*/
@Test
public void testCanAddAndRemoveAspectInterfacesOnPrototype() {
void testCanAddAndRemoveAspectInterfacesOnPrototype() {
assertThat(factory.getBean("test2")).as("Shouldn't implement TimeStamped before manipulation")
.isNotInstanceOf(TimeStamped.class);
@ -402,7 +402,7 @@ public class ProxyFactoryBeanTests { @@ -402,7 +402,7 @@ public class ProxyFactoryBeanTests {
* singleton.
*/
@Test
public void testCanAddAndRemoveAdvicesOnSingleton() {
void testCanAddAndRemoveAdvicesOnSingleton() {
ITestBean it = (ITestBean) factory.getBean("test1");
Advised pc = (Advised) it;
it.getAge();
@ -415,7 +415,7 @@ public class ProxyFactoryBeanTests { @@ -415,7 +415,7 @@ public class ProxyFactoryBeanTests {
}
@Test
public void testMethodPointcuts() {
void testMethodPointcuts() {
ITestBean tb = (ITestBean) factory.getBean("pointcuts");
PointcutForVoid.reset();
assertThat(PointcutForVoid.methodNames).as("No methods intercepted").isEmpty();
@ -431,7 +431,7 @@ public class ProxyFactoryBeanTests { @@ -431,7 +431,7 @@ public class ProxyFactoryBeanTests {
}
@Test
public void testCanAddThrowsAdviceWithoutAdvisor() throws Throwable {
void testCanAddThrowsAdviceWithoutAdvisor() throws Throwable {
DefaultListableBeanFactory f = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(f).loadBeanDefinitions(new ClassPathResource(THROWS_ADVICE_CONTEXT, CLASS));
MyThrowsHandler th = (MyThrowsHandler) f.getBean("throwsAdvice");
@ -464,19 +464,19 @@ public class ProxyFactoryBeanTests { @@ -464,19 +464,19 @@ public class ProxyFactoryBeanTests {
// TODO put in sep file to check quality of error message
/*
@Test
public void testNoInterceptorNamesWithoutTarget() {
void testNoInterceptorNamesWithoutTarget() {
assertThatExceptionOfType(AopConfigurationException.class).as("Should require interceptor names").isThrownBy(() ->
ITestBean tb = (ITestBean) factory.getBean("noInterceptorNamesWithoutTarget"));
}
@Test
public void testNoInterceptorNamesWithTarget() {
void testNoInterceptorNamesWithTarget() {
ITestBean tb = (ITestBean) factory.getBean("noInterceptorNamesWithoutTarget");
}
*/
@Test
public void testEmptyInterceptorNames() {
void testEmptyInterceptorNames() {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(new ClassPathResource(INVALID_CONTEXT, CLASS));
assertThat(bf.getBean("emptyInterceptorNames")).isInstanceOf(ITestBean.class);
@ -487,7 +487,7 @@ public class ProxyFactoryBeanTests { @@ -487,7 +487,7 @@ public class ProxyFactoryBeanTests {
* Globals must be followed by a target.
*/
@Test
public void testGlobalsWithoutTarget() {
void testGlobalsWithoutTarget() {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(new ClassPathResource(INVALID_CONTEXT, CLASS));
assertThatExceptionOfType(BeanCreationException.class).as("Should require target name").isThrownBy(() ->
@ -502,7 +502,7 @@ public class ProxyFactoryBeanTests { @@ -502,7 +502,7 @@ public class ProxyFactoryBeanTests {
* to be included in proxiedInterface [].
*/
@Test
public void testGlobalsCanAddAspectInterfaces() {
void testGlobalsCanAddAspectInterfaces() {
AddedGlobalInterface agi = (AddedGlobalInterface) factory.getBean("autoInvoker");
assertThat(agi.globalsAdded()).isEqualTo(-1);
@ -521,7 +521,7 @@ public class ProxyFactoryBeanTests { @@ -521,7 +521,7 @@ public class ProxyFactoryBeanTests {
}
@Test
public void testSerializableSingletonProxy() throws Exception {
void testSerializableSingletonProxy() throws Exception {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(new ClassPathResource(SERIALIZATION_CONTEXT, CLASS));
Person p = (Person) bf.getBean("serializableSingleton");
@ -544,7 +544,7 @@ public class ProxyFactoryBeanTests { @@ -544,7 +544,7 @@ public class ProxyFactoryBeanTests {
}
@Test
public void testSerializablePrototypeProxy() throws Exception {
void testSerializablePrototypeProxy() throws Exception {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(new ClassPathResource(SERIALIZATION_CONTEXT, CLASS));
Person p = (Person) bf.getBean("serializablePrototype");
@ -556,7 +556,7 @@ public class ProxyFactoryBeanTests { @@ -556,7 +556,7 @@ public class ProxyFactoryBeanTests {
}
@Test
public void testSerializableSingletonProxyFactoryBean() throws Exception {
void testSerializableSingletonProxyFactoryBean() throws Exception {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(new ClassPathResource(SERIALIZATION_CONTEXT, CLASS));
Person p = (Person) bf.getBean("serializableSingleton");
@ -569,7 +569,7 @@ public class ProxyFactoryBeanTests { @@ -569,7 +569,7 @@ public class ProxyFactoryBeanTests {
}
@Test
public void testProxyNotSerializableBecauseOfAdvice() throws Exception {
void testProxyNotSerializableBecauseOfAdvice() throws Exception {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(new ClassPathResource(SERIALIZATION_CONTEXT, CLASS));
Person p = (Person) bf.getBean("interceptorNotSerializableSingleton");
@ -577,7 +577,7 @@ public class ProxyFactoryBeanTests { @@ -577,7 +577,7 @@ public class ProxyFactoryBeanTests {
}
@Test
public void testPrototypeAdvisor() {
void testPrototypeAdvisor() {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(new ClassPathResource(CONTEXT, CLASS));
@ -598,7 +598,7 @@ public class ProxyFactoryBeanTests { @@ -598,7 +598,7 @@ public class ProxyFactoryBeanTests {
}
@Test
public void testPrototypeInterceptorSingletonTarget() {
void testPrototypeInterceptorSingletonTarget() {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(new ClassPathResource(CONTEXT, CLASS));
@ -623,14 +623,14 @@ public class ProxyFactoryBeanTests { @@ -623,14 +623,14 @@ public class ProxyFactoryBeanTests {
* Checks for correct use of getType() by bean factory.
*/
@Test
public void testInnerBeanTargetUsingAutowiring() {
void testInnerBeanTargetUsingAutowiring() {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(new ClassPathResource(AUTOWIRING_CONTEXT, CLASS));
bf.getBean("testBean");
}
@Test
public void testFrozenFactoryBean() {
void testFrozenFactoryBean() {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(new ClassPathResource(FROZEN_CONTEXT, CLASS));
@ -639,7 +639,7 @@ public class ProxyFactoryBeanTests { @@ -639,7 +639,7 @@ public class ProxyFactoryBeanTests {
}
@Test
public void testDetectsInterfaces() {
void testDetectsInterfaces() {
ProxyFactoryBean fb = new ProxyFactoryBean();
fb.setTarget(new TestBean());
fb.addAdvice(new DebugInterceptor());
@ -650,7 +650,7 @@ public class ProxyFactoryBeanTests { @@ -650,7 +650,7 @@ public class ProxyFactoryBeanTests {
}
@Test
public void testWithInterceptorNames() {
void testWithInterceptorNames() {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
bf.registerSingleton("debug", new DebugInterceptor());
@ -664,7 +664,7 @@ public class ProxyFactoryBeanTests { @@ -664,7 +664,7 @@ public class ProxyFactoryBeanTests {
}
@Test
public void testWithLateInterceptorNames() {
void testWithLateInterceptorNames() {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
bf.registerSingleton("debug", new DebugInterceptor());

15
spring-context/src/test/java/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorTests.java

@ -48,8 +48,7 @@ import static org.assertj.core.api.Assertions.assertThat; @@ -48,8 +48,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Dave Syer
* @author Chris Beams
*/
@SuppressWarnings("resource")
public class AdvisorAutoProxyCreatorTests {
class AdvisorAutoProxyCreatorTests {
private static final Class<?> CLASS = AdvisorAutoProxyCreatorTests.class;
private static final String CLASSNAME = CLASS.getSimpleName();
@ -75,7 +74,7 @@ public class AdvisorAutoProxyCreatorTests { @@ -75,7 +74,7 @@ public class AdvisorAutoProxyCreatorTests {
* which are sourced from matching advisors
*/
@Test
public void testCommonInterceptorAndAdvisor() throws Exception {
void testCommonInterceptorAndAdvisor() {
BeanFactory bf = new ClassPathXmlApplicationContext(COMMON_INTERCEPTORS_CONTEXT, CLASS);
ITestBean test1 = (ITestBean) bf.getBean("test1");
assertThat(AopUtils.isAopProxy(test1)).isTrue();
@ -120,7 +119,7 @@ public class AdvisorAutoProxyCreatorTests { @@ -120,7 +119,7 @@ public class AdvisorAutoProxyCreatorTests {
* hence no proxying, for this bean
*/
@Test
public void testCustomTargetSourceNoMatch() throws Exception {
void testCustomTargetSourceNoMatch() {
BeanFactory bf = new ClassPathXmlApplicationContext(CUSTOM_TARGETSOURCE_CONTEXT, CLASS);
ITestBean test = (ITestBean) bf.getBean("test");
assertThat(AopUtils.isAopProxy(test)).isFalse();
@ -129,7 +128,7 @@ public class AdvisorAutoProxyCreatorTests { @@ -129,7 +128,7 @@ public class AdvisorAutoProxyCreatorTests {
}
@Test
public void testCustomPrototypeTargetSource() throws Exception {
void testCustomPrototypeTargetSource() {
CountingTestBean.count = 0;
BeanFactory bf = new ClassPathXmlApplicationContext(CUSTOM_TARGETSOURCE_CONTEXT, CLASS);
ITestBean test = (ITestBean) bf.getBean("prototypeTest");
@ -145,7 +144,7 @@ public class AdvisorAutoProxyCreatorTests { @@ -145,7 +144,7 @@ public class AdvisorAutoProxyCreatorTests {
}
@Test
public void testLazyInitTargetSource() throws Exception {
void testLazyInitTargetSource() {
CountingTestBean.count = 0;
BeanFactory bf = new ClassPathXmlApplicationContext(CUSTOM_TARGETSOURCE_CONTEXT, CLASS);
ITestBean test = (ITestBean) bf.getBean("lazyInitTest");
@ -161,7 +160,7 @@ public class AdvisorAutoProxyCreatorTests { @@ -161,7 +160,7 @@ public class AdvisorAutoProxyCreatorTests {
}
@Test
public void testQuickTargetSourceCreator() throws Exception {
void testQuickTargetSourceCreator() {
ClassPathXmlApplicationContext bf =
new ClassPathXmlApplicationContext(QUICK_TARGETSOURCE_CONTEXT, CLASS);
ITestBean test = (ITestBean) bf.getBean("test");
@ -209,7 +208,7 @@ public class AdvisorAutoProxyCreatorTests { @@ -209,7 +208,7 @@ public class AdvisorAutoProxyCreatorTests {
}
@Test
public void testWithOptimizedProxy() throws Exception {
void testWithOptimizedProxy() {
BeanFactory beanFactory = new ClassPathXmlApplicationContext(OPTIMIZED_CONTEXT, CLASS);
ITestBean testBean = (ITestBean) beanFactory.getBean("optimizedTestBean");

25
spring-context/src/test/java/org/springframework/aop/framework/autoproxy/AutoProxyCreatorTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -55,11 +55,10 @@ import static org.assertj.core.api.Assertions.assertThat; @@ -55,11 +55,10 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Chris Beams
* @since 09.12.2003
*/
@SuppressWarnings("resource")
public class AutoProxyCreatorTests {
class AutoProxyCreatorTests {
@Test
public void testBeanNameAutoProxyCreator() {
void testBeanNameAutoProxyCreator() {
StaticApplicationContext sac = new StaticApplicationContext();
sac.registerSingleton("testInterceptor", TestInterceptor.class);
@ -109,7 +108,7 @@ public class AutoProxyCreatorTests { @@ -109,7 +108,7 @@ public class AutoProxyCreatorTests {
}
@Test
public void testBeanNameAutoProxyCreatorWithFactoryBeanProxy() {
void testBeanNameAutoProxyCreatorWithFactoryBeanProxy() {
StaticApplicationContext sac = new StaticApplicationContext();
sac.registerSingleton("testInterceptor", TestInterceptor.class);
@ -143,7 +142,7 @@ public class AutoProxyCreatorTests { @@ -143,7 +142,7 @@ public class AutoProxyCreatorTests {
}
@Test
public void testCustomAutoProxyCreator() {
void testCustomAutoProxyCreator() {
StaticApplicationContext sac = new StaticApplicationContext();
sac.registerSingleton("testAutoProxyCreator", TestAutoProxyCreator.class);
sac.registerSingleton("noInterfaces", NoInterfaces.class);
@ -178,7 +177,7 @@ public class AutoProxyCreatorTests { @@ -178,7 +177,7 @@ public class AutoProxyCreatorTests {
}
@Test
public void testAutoProxyCreatorWithFallbackToTargetClass() {
void testAutoProxyCreatorWithFallbackToTargetClass() {
StaticApplicationContext sac = new StaticApplicationContext();
sac.registerSingleton("testAutoProxyCreator", FallbackTestAutoProxyCreator.class);
sac.registerSingleton("noInterfaces", NoInterfaces.class);
@ -213,7 +212,7 @@ public class AutoProxyCreatorTests { @@ -213,7 +212,7 @@ public class AutoProxyCreatorTests {
}
@Test
public void testAutoProxyCreatorWithFallbackToDynamicProxy() {
void testAutoProxyCreatorWithFallbackToDynamicProxy() {
StaticApplicationContext sac = new StaticApplicationContext();
MutablePropertyValues pvs = new MutablePropertyValues();
@ -253,7 +252,7 @@ public class AutoProxyCreatorTests { @@ -253,7 +252,7 @@ public class AutoProxyCreatorTests {
}
@Test
public void testAutoProxyCreatorWithPackageVisibleMethod() {
void testAutoProxyCreatorWithPackageVisibleMethod() {
StaticApplicationContext sac = new StaticApplicationContext();
sac.registerSingleton("testAutoProxyCreator", TestAutoProxyCreator.class);
sac.registerSingleton("packageVisibleMethodToBeProxied", PackageVisibleMethod.class);
@ -270,7 +269,7 @@ public class AutoProxyCreatorTests { @@ -270,7 +269,7 @@ public class AutoProxyCreatorTests {
}
@Test
public void testAutoProxyCreatorWithFactoryBean() {
void testAutoProxyCreatorWithFactoryBean() {
StaticApplicationContext sac = new StaticApplicationContext();
sac.registerSingleton("testAutoProxyCreator", TestAutoProxyCreator.class);
sac.registerSingleton("singletonFactoryToBeProxied", DummyFactory.class);
@ -290,7 +289,7 @@ public class AutoProxyCreatorTests { @@ -290,7 +289,7 @@ public class AutoProxyCreatorTests {
}
@Test
public void testAutoProxyCreatorWithFactoryBeanAndPrototype() {
void testAutoProxyCreatorWithFactoryBeanAndPrototype() {
StaticApplicationContext sac = new StaticApplicationContext();
sac.registerSingleton("testAutoProxyCreator", TestAutoProxyCreator.class);
@ -314,7 +313,7 @@ public class AutoProxyCreatorTests { @@ -314,7 +313,7 @@ public class AutoProxyCreatorTests {
}
@Test
public void testAutoProxyCreatorWithFactoryBeanAndProxyObjectOnly() {
void testAutoProxyCreatorWithFactoryBeanAndProxyObjectOnly() {
StaticApplicationContext sac = new StaticApplicationContext();
MutablePropertyValues pvs = new MutablePropertyValues();
@ -345,7 +344,7 @@ public class AutoProxyCreatorTests { @@ -345,7 +344,7 @@ public class AutoProxyCreatorTests {
}
@Test
public void testAutoProxyCreatorWithFactoryBeanAndProxyFactoryBeanOnly() {
void testAutoProxyCreatorWithFactoryBeanAndProxyFactoryBeanOnly() {
StaticApplicationContext sac = new StaticApplicationContext();
MutablePropertyValues pvs = new MutablePropertyValues();

12
spring-context/src/test/java/org/springframework/aop/scope/ScopedProxyTests.java

@ -39,7 +39,7 @@ import static org.assertj.core.api.Assertions.assertThat; @@ -39,7 +39,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Juergen Hoeller
* @author Chris Beams
*/
public class ScopedProxyTests {
class ScopedProxyTests {
private static final Class<?> CLASS = ScopedProxyTests.class;
private static final String CLASSNAME = CLASS.getSimpleName();
@ -51,7 +51,7 @@ public class ScopedProxyTests { @@ -51,7 +51,7 @@ public class ScopedProxyTests {
@Test // SPR-2108
public void testProxyAssignable() throws Exception {
void testProxyAssignable() {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(MAP_CONTEXT);
Object baseMap = bf.getBean("singletonMap");
@ -60,7 +60,7 @@ public class ScopedProxyTests { @@ -60,7 +60,7 @@ public class ScopedProxyTests {
}
@Test
public void testSimpleProxy() throws Exception {
void testSimpleProxy() {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(MAP_CONTEXT);
Object simpleMap = bf.getBean("simpleMap");
@ -71,7 +71,7 @@ public class ScopedProxyTests { @@ -71,7 +71,7 @@ public class ScopedProxyTests {
}
@Test
public void testScopedOverride() throws Exception {
void testScopedOverride() {
GenericApplicationContext ctx = new GenericApplicationContext();
new XmlBeanDefinitionReader(ctx).loadBeanDefinitions(OVERRIDE_CONTEXT);
SimpleMapScope scope = new SimpleMapScope();
@ -87,7 +87,7 @@ public class ScopedProxyTests { @@ -87,7 +87,7 @@ public class ScopedProxyTests {
}
@Test
public void testJdkScopedProxy() throws Exception {
void testJdkScopedProxy() throws Exception {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(TESTBEAN_CONTEXT);
bf.setSerializationId("X");
@ -119,7 +119,7 @@ public class ScopedProxyTests { @@ -119,7 +119,7 @@ public class ScopedProxyTests {
}
@Test
public void testCglibScopedProxy() throws Exception {
void testCglibScopedProxy() throws Exception {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(LIST_CONTEXT);
bf.setSerializationId("Y");

2
spring-core/src/test/java/org/springframework/aot/hint/annotation/RegisterReflectionForBindingProcessorTests.java

@ -29,7 +29,7 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy; @@ -29,7 +29,7 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy;
*
* @author Sebastien Deleuze
*/
public class RegisterReflectionForBindingProcessorTests {
class RegisterReflectionForBindingProcessorTests {
private final RegisterReflectionForBindingProcessor processor = new RegisterReflectionForBindingProcessor();

2
spring-core/src/test/java/org/springframework/aot/nativex/ReflectionHintsWriterTests.java

@ -41,7 +41,7 @@ import static org.assertj.core.api.Assertions.assertThat; @@ -41,7 +41,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Sebastien Deleuze
* @author Stephane Nicoll
*/
public class ReflectionHintsWriterTests {
class ReflectionHintsWriterTests {
@Test
void empty() throws JSONException {

2
spring-core/src/test/java/org/springframework/aot/nativex/SerializationHintsWriterTests.java

@ -32,7 +32,7 @@ import org.springframework.core.env.Environment; @@ -32,7 +32,7 @@ import org.springframework.core.env.Environment;
*
* @author Sebastien Deleuze
*/
public class SerializationHintsWriterTests {
class SerializationHintsWriterTests {
@Test
void shouldWriteEmptyHint() throws JSONException {

4
spring-core/src/test/java/org/springframework/core/io/buffer/LimitedDataBufferListTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2021 the original author or authors.
* Copyright 2002-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -28,7 +28,7 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy; @@ -28,7 +28,7 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy;
* @author Rossen Stoyanchev
* @since 5.1.11
*/
public class LimitedDataBufferListTests {
class LimitedDataBufferListTests {
@Test
void limitEnforced() {

2
spring-core/src/test/java/org/springframework/core/log/CompositeLogTests.java

@ -31,7 +31,7 @@ import static org.mockito.Mockito.verifyNoMoreInteractions; @@ -31,7 +31,7 @@ import static org.mockito.Mockito.verifyNoMoreInteractions;
* Unit tests for {@link CompositeLog}.
* @author Rossen Stoyanchev
*/
public class CompositeLogTests {
class CompositeLogTests {
private final Log logger1 = mock();

Loading…
Cancel
Save