Skip to content

Commit

Permalink
Polish
Browse files Browse the repository at this point in the history
  • Loading branch information
snicoll committed Dec 20, 2023
1 parent 4c0d0ba commit 1bd523f
Show file tree
Hide file tree
Showing 25 changed files with 170 additions and 187 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
* @author Adrian Colyer
* @author Chris Beams
*/
public class AroundAdviceBindingTests {
class AroundAdviceBindingTests {

private AroundAdviceBindingCollaborator mockCollaborator = mock();

Expand All @@ -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");
Expand All @@ -67,25 +67,25 @@ public void onSetUp() throws Exception {
}

@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");
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -26,10 +26,10 @@
* @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");
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -38,7 +38,7 @@
* @author Juergen Hoeller
* @author Chris Beams
*/
public class BeanNamePointcutTests {
class BeanNamePointcutTests {

private ITestBean testBean1;
private ITestBean testBean2;
Expand All @@ -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");
Expand All @@ -74,7 +74,7 @@ public void setup() {
// 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
Expand All @@ -84,21 +84,21 @@ public void testMatchingBeanName() {
}

@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);
assertThat(this.counterAspect.getCount()).as("Advice must *not* have been executed").isEqualTo(0);
}

@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");
Expand All @@ -110,7 +110,7 @@ public void testMatchingFactoryBeanObject() {
}

@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");
Expand All @@ -122,7 +122,7 @@ public void testMatchingFactoryBeanItself() {
}

@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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -31,11 +31,10 @@
* @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());
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -36,29 +36,25 @@
* @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");
}

Expand Down Expand Up @@ -133,7 +129,7 @@ class JoinPointMonitorAtAspectJAspect {
int aroundExecutions;

@Before("execution(* increment*())")
public void before() {
void before() {
beforeExecutions++;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -33,34 +33,34 @@
* @author Juergen Hoeller
* @author Chris Beams
*/
public class AtAspectJAnnotationBindingTests {
class AtAspectJAnnotationBindingTests {

private AnnotatedTestBean testBean;

private ClassPathXmlApplicationContext ctx;


@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");
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -28,16 +28,15 @@
* @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));
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -27,16 +27,15 @@
* @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));
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -28,10 +28,10 @@
* @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();
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -28,16 +28,15 @@
* @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));
Expand Down
Loading

0 comments on commit 1bd523f

Please sign in to comment.