Polish
This commit is contained in:
@@ -51,7 +51,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
|
||||
* @author Chris Beams
|
||||
* @author Yanming Zhou
|
||||
*/
|
||||
public class AspectJExpressionPointcutTests {
|
||||
class AspectJExpressionPointcutTests {
|
||||
|
||||
public static final String MATCH_ALL_METHODS = "execution(* *(..))";
|
||||
|
||||
@@ -78,7 +78,7 @@ public class AspectJExpressionPointcutTests {
|
||||
|
||||
|
||||
@Test
|
||||
public void testMatchExplicit() {
|
||||
void testMatchExplicit() {
|
||||
String expression = "execution(int org.springframework.beans.testfixture.beans.TestBean.getAge())";
|
||||
|
||||
Pointcut pointcut = getPointcut(expression);
|
||||
@@ -96,7 +96,7 @@ public class AspectJExpressionPointcutTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMatchWithTypePattern() throws Exception {
|
||||
void testMatchWithTypePattern() {
|
||||
String expression = "execution(* *..TestBean.*Age(..))";
|
||||
|
||||
Pointcut pointcut = getPointcut(expression);
|
||||
@@ -115,12 +115,12 @@ public class AspectJExpressionPointcutTests {
|
||||
|
||||
|
||||
@Test
|
||||
public void testThis() throws SecurityException, NoSuchMethodException{
|
||||
void testThis() throws SecurityException, NoSuchMethodException{
|
||||
testThisOrTarget("this");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTarget() throws SecurityException, NoSuchMethodException {
|
||||
void testTarget() throws SecurityException, NoSuchMethodException {
|
||||
testThisOrTarget("target");
|
||||
}
|
||||
|
||||
@@ -144,12 +144,12 @@ public class AspectJExpressionPointcutTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWithinRootPackage() throws SecurityException, NoSuchMethodException {
|
||||
void testWithinRootPackage() throws SecurityException, NoSuchMethodException {
|
||||
testWithinPackage(false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWithinRootAndSubpackages() throws SecurityException, NoSuchMethodException {
|
||||
void testWithinRootAndSubpackages() throws SecurityException, NoSuchMethodException {
|
||||
testWithinPackage(true);
|
||||
}
|
||||
|
||||
@@ -173,7 +173,7 @@ public class AspectJExpressionPointcutTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFriendlyErrorOnNoLocationClassMatching() {
|
||||
void testFriendlyErrorOnNoLocationClassMatching() {
|
||||
AspectJExpressionPointcut pc = new AspectJExpressionPointcut();
|
||||
assertThatIllegalStateException().isThrownBy(() ->
|
||||
pc.matches(ITestBean.class))
|
||||
@@ -181,7 +181,7 @@ public class AspectJExpressionPointcutTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFriendlyErrorOnNoLocation2ArgMatching() {
|
||||
void testFriendlyErrorOnNoLocation2ArgMatching() {
|
||||
AspectJExpressionPointcut pc = new AspectJExpressionPointcut();
|
||||
assertThatIllegalStateException().isThrownBy(() ->
|
||||
pc.matches(getAge, ITestBean.class))
|
||||
@@ -189,7 +189,7 @@ public class AspectJExpressionPointcutTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFriendlyErrorOnNoLocation3ArgMatching() {
|
||||
void testFriendlyErrorOnNoLocation3ArgMatching() {
|
||||
AspectJExpressionPointcut pc = new AspectJExpressionPointcut();
|
||||
assertThatIllegalStateException().isThrownBy(() ->
|
||||
pc.matches(getAge, ITestBean.class, (Object[]) null))
|
||||
@@ -198,7 +198,7 @@ public class AspectJExpressionPointcutTests {
|
||||
|
||||
|
||||
@Test
|
||||
public void testMatchWithArgs() throws Exception {
|
||||
void testMatchWithArgs() throws Exception {
|
||||
String expression = "execution(void org.springframework.beans.testfixture.beans.TestBean.setSomeNumber(Number)) && args(Double)";
|
||||
|
||||
Pointcut pointcut = getPointcut(expression);
|
||||
@@ -217,7 +217,7 @@ public class AspectJExpressionPointcutTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSimpleAdvice() {
|
||||
void testSimpleAdvice() {
|
||||
String expression = "execution(int org.springframework.beans.testfixture.beans.TestBean.getAge())";
|
||||
CallCountingInterceptor interceptor = new CallCountingInterceptor();
|
||||
TestBean testBean = getAdvisedProxy(expression, interceptor);
|
||||
@@ -230,7 +230,7 @@ public class AspectJExpressionPointcutTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDynamicMatchingProxy() {
|
||||
void testDynamicMatchingProxy() {
|
||||
String expression = "execution(void org.springframework.beans.testfixture.beans.TestBean.setSomeNumber(Number)) && args(Double)";
|
||||
CallCountingInterceptor interceptor = new CallCountingInterceptor();
|
||||
TestBean testBean = getAdvisedProxy(expression, interceptor);
|
||||
@@ -244,7 +244,7 @@ public class AspectJExpressionPointcutTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInvalidExpression() {
|
||||
void testInvalidExpression() {
|
||||
String expression = "execution(void org.springframework.beans.testfixture.beans.TestBean.setSomeNumber(Number) && args(Double)";
|
||||
assertThatIllegalArgumentException().isThrownBy(getPointcut(expression)::getClassFilter); // call to getClassFilter forces resolution
|
||||
}
|
||||
@@ -274,7 +274,7 @@ public class AspectJExpressionPointcutTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWithUnsupportedPointcutPrimitive() {
|
||||
void testWithUnsupportedPointcutPrimitive() {
|
||||
String expression = "call(int org.springframework.beans.testfixture.beans.TestBean.getAge())";
|
||||
assertThatExceptionOfType(UnsupportedPointcutPrimitiveException.class)
|
||||
.isThrownBy(() -> getPointcut(expression).getClassFilter()) // call to getClassFilter forces resolution...
|
||||
@@ -282,14 +282,14 @@ public class AspectJExpressionPointcutTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAndSubstitution() {
|
||||
void testAndSubstitution() {
|
||||
AspectJExpressionPointcut pc = getPointcut("execution(* *(..)) and args(String)");
|
||||
String expr = pc.getPointcutExpression().getPointcutExpression();
|
||||
assertThat(expr).isEqualTo("execution(* *(..)) && args(String)");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMultipleAndSubstitutions() {
|
||||
void testMultipleAndSubstitutions() {
|
||||
AspectJExpressionPointcut pc = getPointcut("execution(* *(..)) and args(String) and this(Object)");
|
||||
String expr = pc.getPointcutExpression().getPointcutExpression();
|
||||
assertThat(expr).isEqualTo("execution(* *(..)) && args(String) && this(Object)");
|
||||
@@ -302,7 +302,7 @@ public class AspectJExpressionPointcutTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMatchGenericArgument() {
|
||||
void testMatchGenericArgument() {
|
||||
String expression = "execution(* set*(java.util.List<org.springframework.beans.testfixture.beans.TestBean>) )";
|
||||
AspectJExpressionPointcut ajexp = new AspectJExpressionPointcut();
|
||||
ajexp.setExpression(expression);
|
||||
@@ -321,7 +321,7 @@ public class AspectJExpressionPointcutTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMatchVarargs() throws Exception {
|
||||
void testMatchVarargs() throws Exception {
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
class MyTemplate {
|
||||
@@ -347,19 +347,19 @@ public class AspectJExpressionPointcutTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMatchAnnotationOnClassWithAtWithin() throws Exception {
|
||||
void testMatchAnnotationOnClassWithAtWithin() throws Exception {
|
||||
String expression = "@within(test.annotation.transaction.Tx)";
|
||||
testMatchAnnotationOnClass(expression);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMatchAnnotationOnClassWithoutBinding() throws Exception {
|
||||
void testMatchAnnotationOnClassWithoutBinding() throws Exception {
|
||||
String expression = "within(@test.annotation.transaction.Tx *)";
|
||||
testMatchAnnotationOnClass(expression);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMatchAnnotationOnClassWithSubpackageWildcard() throws Exception {
|
||||
void testMatchAnnotationOnClassWithSubpackageWildcard() throws Exception {
|
||||
String expression = "within(@(test.annotation..*) *)";
|
||||
AspectJExpressionPointcut springAnnotatedPc = testMatchAnnotationOnClass(expression);
|
||||
assertThat(springAnnotatedPc.matches(TestBean.class.getMethod("setName", String.class), TestBean.class)).isFalse();
|
||||
@@ -371,7 +371,7 @@ public class AspectJExpressionPointcutTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMatchAnnotationOnClassWithExactPackageWildcard() throws Exception {
|
||||
void testMatchAnnotationOnClassWithExactPackageWildcard() throws Exception {
|
||||
String expression = "within(@(test.annotation.transaction.*) *)";
|
||||
testMatchAnnotationOnClass(expression);
|
||||
}
|
||||
@@ -389,7 +389,7 @@ public class AspectJExpressionPointcutTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAnnotationOnMethodWithFQN() throws Exception {
|
||||
void testAnnotationOnMethodWithFQN() throws Exception {
|
||||
String expression = "@annotation(test.annotation.transaction.Tx)";
|
||||
AspectJExpressionPointcut ajexp = new AspectJExpressionPointcut();
|
||||
ajexp.setExpression(expression);
|
||||
@@ -403,7 +403,7 @@ public class AspectJExpressionPointcutTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAnnotationOnCglibProxyMethod() throws Exception {
|
||||
void testAnnotationOnCglibProxyMethod() throws Exception {
|
||||
String expression = "@annotation(test.annotation.transaction.Tx)";
|
||||
AspectJExpressionPointcut ajexp = new AspectJExpressionPointcut();
|
||||
ajexp.setExpression(expression);
|
||||
@@ -416,7 +416,7 @@ public class AspectJExpressionPointcutTests {
|
||||
|
||||
|
||||
@Test
|
||||
public void testNotAnnotationOnCglibProxyMethod() throws Exception {
|
||||
void testNotAnnotationOnCglibProxyMethod() throws Exception {
|
||||
String expression = "!@annotation(test.annotation.transaction.Tx)";
|
||||
AspectJExpressionPointcut ajexp = new AspectJExpressionPointcut();
|
||||
ajexp.setExpression(expression);
|
||||
@@ -428,7 +428,7 @@ public class AspectJExpressionPointcutTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAnnotationOnDynamicProxyMethod() throws Exception {
|
||||
void testAnnotationOnDynamicProxyMethod() throws Exception {
|
||||
String expression = "@annotation(test.annotation.transaction.Tx)";
|
||||
AspectJExpressionPointcut ajexp = new AspectJExpressionPointcut();
|
||||
ajexp.setExpression(expression);
|
||||
@@ -440,7 +440,7 @@ public class AspectJExpressionPointcutTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNotAnnotationOnDynamicProxyMethod() throws Exception {
|
||||
void testNotAnnotationOnDynamicProxyMethod() throws Exception {
|
||||
String expression = "!@annotation(test.annotation.transaction.Tx)";
|
||||
AspectJExpressionPointcut ajexp = new AspectJExpressionPointcut();
|
||||
ajexp.setExpression(expression);
|
||||
@@ -452,7 +452,7 @@ public class AspectJExpressionPointcutTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAnnotationOnMethodWithWildcard() throws Exception {
|
||||
void testAnnotationOnMethodWithWildcard() throws Exception {
|
||||
String expression = "execution(@(test.annotation..*) * *(..))";
|
||||
AspectJExpressionPointcut anySpringMethodAnnotation = new AspectJExpressionPointcut();
|
||||
anySpringMethodAnnotation.setExpression(expression);
|
||||
@@ -468,7 +468,7 @@ public class AspectJExpressionPointcutTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAnnotationOnMethodArgumentsWithFQN() throws Exception {
|
||||
void testAnnotationOnMethodArgumentsWithFQN() throws Exception {
|
||||
String expression = "@args(*, test.annotation.EmptySpringAnnotation))";
|
||||
AspectJExpressionPointcut takesSpringAnnotatedArgument2 = new AspectJExpressionPointcut();
|
||||
takesSpringAnnotatedArgument2.setExpression(expression);
|
||||
@@ -497,7 +497,7 @@ public class AspectJExpressionPointcutTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAnnotationOnMethodArgumentsWithWildcards() throws Exception {
|
||||
void testAnnotationOnMethodArgumentsWithWildcards() throws Exception {
|
||||
String expression = "execution(* *(*, @(test..*) *))";
|
||||
AspectJExpressionPointcut takesSpringAnnotatedArgument2 = new AspectJExpressionPointcut();
|
||||
takesSpringAnnotatedArgument2.setExpression(expression);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -28,10 +28,10 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
* @author Ramnivas Laddad
|
||||
* @author Chris Beams
|
||||
*/
|
||||
public class BeanNamePointcutMatchingTests {
|
||||
class BeanNamePointcutMatchingTests {
|
||||
|
||||
@Test
|
||||
public void testMatchingPointcuts() {
|
||||
void testMatchingPointcuts() {
|
||||
assertMatch("someName", "bean(someName)");
|
||||
|
||||
// Spring bean names are less restrictive compared to AspectJ names (methods, types etc.)
|
||||
@@ -66,7 +66,7 @@ public class BeanNamePointcutMatchingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNonMatchingPointcuts() {
|
||||
void testNonMatchingPointcuts() {
|
||||
assertMisMatch("someName", "bean(someNamex)");
|
||||
assertMisMatch("someName", "bean(someX*Name)");
|
||||
|
||||
@@ -87,7 +87,6 @@ public class BeanNamePointcutMatchingTests {
|
||||
}
|
||||
|
||||
private static boolean matches(final String beanName, String pcExpression) {
|
||||
@SuppressWarnings("serial")
|
||||
AspectJExpressionPointcut pointcut = new AspectJExpressionPointcut() {
|
||||
@Override
|
||||
protected String getCurrentProxiedBeanName() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -46,20 +46,20 @@ import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
|
||||
* @author Ramnivas Laddad
|
||||
* @since 2.0
|
||||
*/
|
||||
public class MethodInvocationProceedingJoinPointTests {
|
||||
class MethodInvocationProceedingJoinPointTests {
|
||||
|
||||
@Test
|
||||
public void testingBindingWithJoinPoint() {
|
||||
void testingBindingWithJoinPoint() {
|
||||
assertThatIllegalStateException().isThrownBy(AbstractAspectJAdvice::currentJoinPoint);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testingBindingWithProceedingJoinPoint() {
|
||||
void testingBindingWithProceedingJoinPoint() {
|
||||
assertThatIllegalStateException().isThrownBy(AbstractAspectJAdvice::currentJoinPoint);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCanGetMethodSignatureFromJoinPoint() {
|
||||
void testCanGetMethodSignatureFromJoinPoint() {
|
||||
final Object raw = new TestBean();
|
||||
// Will be set by advice during a method call
|
||||
final int newAge = 23;
|
||||
@@ -118,7 +118,7 @@ public class MethodInvocationProceedingJoinPointTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCanGetSourceLocationFromJoinPoint() {
|
||||
void testCanGetSourceLocationFromJoinPoint() {
|
||||
final Object raw = new TestBean();
|
||||
ProxyFactory pf = new ProxyFactory(raw);
|
||||
pf.addAdvisor(ExposeInvocationInterceptor.ADVISOR);
|
||||
@@ -135,7 +135,7 @@ public class MethodInvocationProceedingJoinPointTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCanGetStaticPartFromJoinPoint() {
|
||||
void testCanGetStaticPartFromJoinPoint() {
|
||||
final Object raw = new TestBean();
|
||||
ProxyFactory pf = new ProxyFactory(raw);
|
||||
pf.addAdvisor(ExposeInvocationInterceptor.ADVISOR);
|
||||
@@ -152,7 +152,7 @@ public class MethodInvocationProceedingJoinPointTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void toShortAndLongStringFormedCorrectly() throws Exception {
|
||||
void toShortAndLongStringFormedCorrectly() {
|
||||
final Object raw = new TestBean();
|
||||
ProxyFactory pf = new ProxyFactory(raw);
|
||||
pf.addAdvisor(ExposeInvocationInterceptor.ADVISOR);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -40,17 +40,17 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
/**
|
||||
* @author Dave Syer
|
||||
*/
|
||||
public class TrickyAspectJPointcutExpressionTests {
|
||||
class TrickyAspectJPointcutExpressionTests {
|
||||
|
||||
@Test
|
||||
public void testManualProxyJavaWithUnconditionalPointcut() throws Exception {
|
||||
void testManualProxyJavaWithUnconditionalPointcut() {
|
||||
TestService target = new TestServiceImpl();
|
||||
LogUserAdvice logAdvice = new LogUserAdvice();
|
||||
testAdvice(new DefaultPointcutAdvisor(logAdvice), logAdvice, target, "TestServiceImpl");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testManualProxyJavaWithStaticPointcut() throws Exception {
|
||||
void testManualProxyJavaWithStaticPointcut() {
|
||||
TestService target = new TestServiceImpl();
|
||||
LogUserAdvice logAdvice = new LogUserAdvice();
|
||||
AspectJExpressionPointcut pointcut = new AspectJExpressionPointcut();
|
||||
@@ -59,7 +59,7 @@ public class TrickyAspectJPointcutExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testManualProxyJavaWithDynamicPointcut() throws Exception {
|
||||
void testManualProxyJavaWithDynamicPointcut() {
|
||||
TestService target = new TestServiceImpl();
|
||||
LogUserAdvice logAdvice = new LogUserAdvice();
|
||||
AspectJExpressionPointcut pointcut = new AspectJExpressionPointcut();
|
||||
@@ -68,7 +68,7 @@ public class TrickyAspectJPointcutExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testManualProxyJavaWithDynamicPointcutAndProxyTargetClass() throws Exception {
|
||||
void testManualProxyJavaWithDynamicPointcutAndProxyTargetClass() {
|
||||
TestService target = new TestServiceImpl();
|
||||
LogUserAdvice logAdvice = new LogUserAdvice();
|
||||
AspectJExpressionPointcut pointcut = new AspectJExpressionPointcut();
|
||||
@@ -77,7 +77,7 @@ public class TrickyAspectJPointcutExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testManualProxyJavaWithStaticPointcutAndTwoClassLoaders() throws Exception {
|
||||
void testManualProxyJavaWithStaticPointcutAndTwoClassLoaders() throws Exception {
|
||||
|
||||
LogUserAdvice logAdvice = new LogUserAdvice();
|
||||
AspectJExpressionPointcut pointcut = new AspectJExpressionPointcut();
|
||||
@@ -95,13 +95,12 @@ public class TrickyAspectJPointcutExpressionTests {
|
||||
testAdvice(new DefaultPointcutAdvisor(pointcut, logAdvice), logAdvice, other, "TestServiceImpl");
|
||||
}
|
||||
|
||||
private void testAdvice(Advisor advisor, LogUserAdvice logAdvice, TestService target, String message)
|
||||
throws Exception {
|
||||
private void testAdvice(Advisor advisor, LogUserAdvice logAdvice, TestService target, String message) {
|
||||
testAdvice(advisor, logAdvice, target, message, false);
|
||||
}
|
||||
|
||||
private void testAdvice(Advisor advisor, LogUserAdvice logAdvice, TestService target, String message,
|
||||
boolean proxyTargetClass) throws Exception {
|
||||
boolean proxyTargetClass) {
|
||||
|
||||
logAdvice.reset();
|
||||
|
||||
@@ -148,7 +147,7 @@ public class TrickyAspectJPointcutExpressionTests {
|
||||
|
||||
public interface TestService {
|
||||
|
||||
public String sayHello();
|
||||
String sayHello();
|
||||
}
|
||||
|
||||
|
||||
@@ -162,14 +161,14 @@ public class TrickyAspectJPointcutExpressionTests {
|
||||
}
|
||||
|
||||
|
||||
public class LogUserAdvice implements MethodBeforeAdvice, ThrowsAdvice {
|
||||
public static class LogUserAdvice implements MethodBeforeAdvice, ThrowsAdvice {
|
||||
|
||||
private int countBefore = 0;
|
||||
|
||||
private int countThrows = 0;
|
||||
|
||||
@Override
|
||||
public void before(Method method, Object[] objects, @Nullable Object o) throws Throwable {
|
||||
public void before(Method method, Object[] objects, @Nullable Object o) {
|
||||
countBefore++;
|
||||
}
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ class TypePatternClassFilterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void invocationOfMatchesMethodBlowsUpWhenNoTypePatternHasBeenSet() throws Exception {
|
||||
void invocationOfMatchesMethodBlowsUpWhenNoTypePatternHasBeenSet() {
|
||||
assertThatIllegalStateException().isThrownBy(() -> new TypePatternClassFilter().matches(String.class));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -362,7 +362,7 @@ abstract class AbstractAspectJAdvisorFactoryTests {
|
||||
assertThat(lockable.locked()).as("Already locked").isTrue();
|
||||
lockable.lock();
|
||||
assertThat(lockable.locked()).as("Real target ignores locking").isTrue();
|
||||
assertThatExceptionOfType(UnsupportedOperationException.class).isThrownBy(() -> lockable.unlock());
|
||||
assertThatExceptionOfType(UnsupportedOperationException.class).isThrownBy(lockable::unlock);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -645,7 +645,7 @@ abstract class AbstractAspectJAdvisorFactoryTests {
|
||||
static class NamedPointcutAspectWithFQN {
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private ITestBean fieldThatShouldBeIgnoredBySpringAtAspectJProcessing = new TestBean();
|
||||
private final ITestBean fieldThatShouldBeIgnoredBySpringAtAspectJProcessing = new TestBean();
|
||||
|
||||
@Around("org.springframework.aop.aspectj.annotation.AbstractAspectJAdvisorFactoryTests.CommonPointcuts.getAge()()")
|
||||
int changeReturnValue(ProceedingJoinPoint pjp) {
|
||||
@@ -762,7 +762,7 @@ abstract class AbstractAspectJAdvisorFactoryTests {
|
||||
|
||||
|
||||
@Aspect
|
||||
class DoublingAspect {
|
||||
static class DoublingAspect {
|
||||
|
||||
@Around("execution(* getAge())")
|
||||
public Object doubleAge(ProceedingJoinPoint pjp) throws Throwable {
|
||||
@@ -771,7 +771,7 @@ abstract class AbstractAspectJAdvisorFactoryTests {
|
||||
}
|
||||
|
||||
@Aspect
|
||||
class IncrementingAspect extends DoublingAspect {
|
||||
static class IncrementingAspect extends DoublingAspect {
|
||||
|
||||
@Around("execution(* getAge())")
|
||||
public int incrementAge(ProceedingJoinPoint pjp) throws Throwable {
|
||||
@@ -1080,7 +1080,7 @@ class PerThisAspect {
|
||||
|
||||
// Just to check that this doesn't cause problems with introduction processing
|
||||
@SuppressWarnings("unused")
|
||||
private ITestBean fieldThatShouldBeIgnoredBySpringAtAspectJProcessing = new TestBean();
|
||||
private final ITestBean fieldThatShouldBeIgnoredBySpringAtAspectJProcessing = new TestBean();
|
||||
|
||||
@Around("execution(int *.getAge())")
|
||||
int returnCountAsAge() {
|
||||
|
||||
@@ -119,7 +119,7 @@ class ArgumentBindingTests {
|
||||
static class PointcutWithAnnotationArgument {
|
||||
|
||||
@Around("execution(* org.springframework..*.*(..)) && @annotation(transactional)")
|
||||
public Object around(ProceedingJoinPoint pjp, Transactional transactional) throws Throwable {
|
||||
public Object around(ProceedingJoinPoint pjp, Transactional transactional) {
|
||||
throw new IllegalStateException("Invoked with @Transactional");
|
||||
}
|
||||
}
|
||||
@@ -132,7 +132,7 @@ class ArgumentBindingTests {
|
||||
public void pointcutWithArgs(String s) {}
|
||||
|
||||
@Around("pointcutWithArgs(aString)")
|
||||
public Object doAround(ProceedingJoinPoint pjp, String aString) throws Throwable {
|
||||
public Object doAround(ProceedingJoinPoint pjp, String aString) {
|
||||
throw new IllegalArgumentException(aString);
|
||||
}
|
||||
}
|
||||
@@ -142,7 +142,7 @@ class ArgumentBindingTests {
|
||||
static class DynamicPointcutWithArgs {
|
||||
|
||||
@Around("execution(* *(..)) && args(java.lang.String)")
|
||||
public Object doAround(ProceedingJoinPoint pjp) throws Throwable {
|
||||
public Object doAround(ProceedingJoinPoint pjp) {
|
||||
throw new IllegalArgumentException(String.valueOf(pjp.getArgs()[0]));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -20,9 +20,9 @@ import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.aop.Pointcut;
|
||||
import org.springframework.aop.aspectj.AspectJExpressionPointcut;
|
||||
import org.springframework.aop.aspectj.AspectJExpressionPointcutTests;
|
||||
import org.springframework.aop.aspectj.annotation.AbstractAspectJAdvisorFactoryTests.ExceptionThrowingAspect;
|
||||
import org.springframework.aop.framework.AopConfigException;
|
||||
import org.springframework.aop.testfixture.aspectj.CommonExpressions;
|
||||
import org.springframework.aop.testfixture.aspectj.PerTargetAspect;
|
||||
import org.springframework.beans.testfixture.beans.TestBean;
|
||||
|
||||
@@ -33,15 +33,15 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
* @author Rod Johnson
|
||||
* @author Chris Beams
|
||||
*/
|
||||
public class AspectJPointcutAdvisorTests {
|
||||
class AspectJPointcutAdvisorTests {
|
||||
|
||||
private final AspectJAdvisorFactory af = new ReflectiveAspectJAdvisorFactory();
|
||||
|
||||
|
||||
@Test
|
||||
public void testSingleton() throws SecurityException, NoSuchMethodException {
|
||||
void testSingleton() throws SecurityException, NoSuchMethodException {
|
||||
AspectJExpressionPointcut ajexp = new AspectJExpressionPointcut();
|
||||
ajexp.setExpression(AspectJExpressionPointcutTests.MATCH_ALL_METHODS);
|
||||
ajexp.setExpression(CommonExpressions.MATCH_ALL_METHODS);
|
||||
|
||||
InstantiationModelAwarePointcutAdvisorImpl ajpa = new InstantiationModelAwarePointcutAdvisorImpl(
|
||||
ajexp, TestBean.class.getMethod("getAge"), af,
|
||||
@@ -53,9 +53,9 @@ public class AspectJPointcutAdvisorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPerTarget() throws SecurityException, NoSuchMethodException {
|
||||
void testPerTarget() throws SecurityException, NoSuchMethodException {
|
||||
AspectJExpressionPointcut ajexp = new AspectJExpressionPointcut();
|
||||
ajexp.setExpression(AspectJExpressionPointcutTests.MATCH_ALL_METHODS);
|
||||
ajexp.setExpression(CommonExpressions.MATCH_ALL_METHODS);
|
||||
|
||||
InstantiationModelAwarePointcutAdvisorImpl ajpa = new InstantiationModelAwarePointcutAdvisorImpl(
|
||||
ajexp, TestBean.class.getMethod("getAge"), af,
|
||||
@@ -76,13 +76,13 @@ public class AspectJPointcutAdvisorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPerCflowTarget() {
|
||||
void testPerCflowTarget() {
|
||||
assertThatExceptionOfType(AopConfigException.class).isThrownBy(() ->
|
||||
testIllegalInstantiationModel(AbstractAspectJAdvisorFactoryTests.PerCflowAspect.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPerCflowBelowTarget() {
|
||||
void testPerCflowBelowTarget() {
|
||||
assertThatExceptionOfType(AopConfigException.class).isThrownBy(() ->
|
||||
testIllegalInstantiationModel(AbstractAspectJAdvisorFactoryTests.PerCflowBelowAspect.class));
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -36,17 +36,17 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
|
||||
* @author Juergen Hoeller
|
||||
* @author Chris Beams
|
||||
*/
|
||||
public class AspectProxyFactoryTests {
|
||||
class AspectProxyFactoryTests {
|
||||
|
||||
@Test
|
||||
public void testWithNonAspect() {
|
||||
void testWithNonAspect() {
|
||||
AspectJProxyFactory proxyFactory = new AspectJProxyFactory(new TestBean());
|
||||
assertThatIllegalArgumentException().isThrownBy(() ->
|
||||
proxyFactory.addAspect(TestBean.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWithSimpleAspect() throws Exception {
|
||||
void testWithSimpleAspect() {
|
||||
TestBean bean = new TestBean();
|
||||
bean.setAge(2);
|
||||
AspectJProxyFactory proxyFactory = new AspectJProxyFactory(bean);
|
||||
@@ -56,7 +56,7 @@ public class AspectProxyFactoryTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWithPerThisAspect() throws Exception {
|
||||
void testWithPerThisAspect() {
|
||||
TestBean bean1 = new TestBean();
|
||||
TestBean bean2 = new TestBean();
|
||||
|
||||
@@ -76,15 +76,14 @@ public class AspectProxyFactoryTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWithInstanceWithNonAspect() throws Exception {
|
||||
void testWithInstanceWithNonAspect() {
|
||||
AspectJProxyFactory pf = new AspectJProxyFactory();
|
||||
assertThatIllegalArgumentException().isThrownBy(() ->
|
||||
pf.addAspect(new TestBean()));
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void testSerializable() throws Exception {
|
||||
void testSerializable() throws Exception {
|
||||
AspectJProxyFactory proxyFactory = new AspectJProxyFactory(new TestBean());
|
||||
proxyFactory.addAspect(LoggingAspectOnVarargs.class);
|
||||
ITestBean proxy = proxyFactory.getProxy();
|
||||
@@ -94,7 +93,7 @@ public class AspectProxyFactoryTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWithInstance() throws Exception {
|
||||
void testWithInstance() throws Exception {
|
||||
MultiplyReturnValue aspect = new MultiplyReturnValue();
|
||||
int multiple = 3;
|
||||
aspect.setMultiple(multiple);
|
||||
@@ -113,14 +112,13 @@ public class AspectProxyFactoryTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWithNonSingletonAspectInstance() throws Exception {
|
||||
void testWithNonSingletonAspectInstance() {
|
||||
AspectJProxyFactory pf = new AspectJProxyFactory();
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> pf.addAspect(new PerThisAspect()));
|
||||
}
|
||||
|
||||
@Test // SPR-13328
|
||||
@SuppressWarnings("unchecked")
|
||||
public void testProxiedVarargsWithEnumArray() throws Exception {
|
||||
public void testProxiedVarargsWithEnumArray() {
|
||||
AspectJProxyFactory proxyFactory = new AspectJProxyFactory(new TestBean());
|
||||
proxyFactory.addAspect(LoggingAspectOnVarargs.class);
|
||||
ITestBean proxy = proxyFactory.getProxy();
|
||||
@@ -128,8 +126,7 @@ public class AspectProxyFactoryTests {
|
||||
}
|
||||
|
||||
@Test // SPR-13328
|
||||
@SuppressWarnings("unchecked")
|
||||
public void testUnproxiedVarargsWithEnumArray() throws Exception {
|
||||
public void testUnproxiedVarargsWithEnumArray() {
|
||||
AspectJProxyFactory proxyFactory = new AspectJProxyFactory(new TestBean());
|
||||
proxyFactory.addAspect(LoggingAspectOnSetter.class);
|
||||
ITestBean proxy = proxyFactory.getProxy();
|
||||
@@ -174,13 +171,13 @@ public class AspectProxyFactoryTests {
|
||||
|
||||
public enum MyEnum implements MyInterface {
|
||||
|
||||
A, B;
|
||||
A, B
|
||||
}
|
||||
|
||||
|
||||
public enum MyOtherEnum implements MyInterface {
|
||||
|
||||
C, D;
|
||||
C, D
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -37,7 +37,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
* @author Rob Harrop
|
||||
* @author Chris Beams
|
||||
*/
|
||||
public class AspectJNamespaceHandlerTests {
|
||||
class AspectJNamespaceHandlerTests {
|
||||
|
||||
private ParserContext parserContext;
|
||||
|
||||
@@ -47,7 +47,7 @@ public class AspectJNamespaceHandlerTests {
|
||||
|
||||
|
||||
@BeforeEach
|
||||
public void setUp() throws Exception {
|
||||
public void setUp() {
|
||||
SourceExtractor sourceExtractor = new PassThroughSourceExtractor();
|
||||
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(this.registry);
|
||||
XmlReaderContext readerContext =
|
||||
@@ -56,7 +56,7 @@ public class AspectJNamespaceHandlerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRegisterAutoProxyCreator() throws Exception {
|
||||
void testRegisterAutoProxyCreator() {
|
||||
AopNamespaceUtils.registerAutoProxyCreatorIfNecessary(this.parserContext, null);
|
||||
assertThat(registry.getBeanDefinitionCount()).as("Incorrect number of definitions registered").isEqualTo(1);
|
||||
|
||||
@@ -65,7 +65,7 @@ public class AspectJNamespaceHandlerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRegisterAspectJAutoProxyCreator() throws Exception {
|
||||
void testRegisterAspectJAutoProxyCreator() {
|
||||
AopNamespaceUtils.registerAspectJAutoProxyCreatorIfNecessary(this.parserContext, null);
|
||||
assertThat(registry.getBeanDefinitionCount()).as("Incorrect number of definitions registered").isEqualTo(1);
|
||||
|
||||
@@ -77,7 +77,7 @@ public class AspectJNamespaceHandlerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRegisterAspectJAutoProxyCreatorWithExistingAutoProxyCreator() throws Exception {
|
||||
void testRegisterAspectJAutoProxyCreatorWithExistingAutoProxyCreator() {
|
||||
AopNamespaceUtils.registerAutoProxyCreatorIfNecessary(this.parserContext, null);
|
||||
assertThat(registry.getBeanDefinitionCount()).isEqualTo(1);
|
||||
|
||||
@@ -89,7 +89,7 @@ public class AspectJNamespaceHandlerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRegisterAutoProxyCreatorWhenAspectJAutoProxyCreatorAlreadyExists() throws Exception {
|
||||
void testRegisterAutoProxyCreatorWhenAspectJAutoProxyCreatorAlreadyExists() {
|
||||
AopNamespaceUtils.registerAspectJAutoProxyCreatorIfNecessary(this.parserContext, null);
|
||||
assertThat(registry.getBeanDefinitionCount()).isEqualTo(1);
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -40,7 +40,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
* @author Adrian Colyer
|
||||
* @author Chris Beams
|
||||
*/
|
||||
public class AspectJPrecedenceComparatorTests {
|
||||
class AspectJPrecedenceComparatorTests {
|
||||
|
||||
private static final int HIGH_PRECEDENCE_ADVISOR_ORDER = 100;
|
||||
private static final int LOW_PRECEDENCE_ADVISOR_ORDER = 200;
|
||||
@@ -56,7 +56,7 @@ public class AspectJPrecedenceComparatorTests {
|
||||
|
||||
|
||||
@BeforeEach
|
||||
public void setUp() throws Exception {
|
||||
public void setUp() {
|
||||
this.comparator = new AspectJPrecedenceComparator();
|
||||
this.anyOldMethod = getClass().getMethods()[0];
|
||||
this.anyOldPointcut = new AspectJExpressionPointcut();
|
||||
@@ -65,7 +65,7 @@ public class AspectJPrecedenceComparatorTests {
|
||||
|
||||
|
||||
@Test
|
||||
public void testSameAspectNoAfterAdvice() {
|
||||
void testSameAspectNoAfterAdvice() {
|
||||
Advisor advisor1 = createAspectJBeforeAdvice(HIGH_PRECEDENCE_ADVISOR_ORDER, EARLY_ADVICE_DECLARATION_ORDER, "someAspect");
|
||||
Advisor advisor2 = createAspectJBeforeAdvice(HIGH_PRECEDENCE_ADVISOR_ORDER, LATE_ADVICE_DECLARATION_ORDER, "someAspect");
|
||||
assertThat(this.comparator.compare(advisor1, advisor2)).as("advisor1 sorted before advisor2").isEqualTo(-1);
|
||||
@@ -76,7 +76,7 @@ public class AspectJPrecedenceComparatorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSameAspectAfterAdvice() {
|
||||
void testSameAspectAfterAdvice() {
|
||||
Advisor advisor1 = createAspectJAfterAdvice(HIGH_PRECEDENCE_ADVISOR_ORDER, EARLY_ADVICE_DECLARATION_ORDER, "someAspect");
|
||||
Advisor advisor2 = createAspectJAroundAdvice(HIGH_PRECEDENCE_ADVISOR_ORDER, LATE_ADVICE_DECLARATION_ORDER, "someAspect");
|
||||
assertThat(this.comparator.compare(advisor1, advisor2)).as("advisor2 sorted before advisor1").isEqualTo(1);
|
||||
@@ -87,14 +87,14 @@ public class AspectJPrecedenceComparatorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSameAspectOneOfEach() {
|
||||
void testSameAspectOneOfEach() {
|
||||
Advisor advisor1 = createAspectJAfterAdvice(HIGH_PRECEDENCE_ADVISOR_ORDER, EARLY_ADVICE_DECLARATION_ORDER, "someAspect");
|
||||
Advisor advisor2 = createAspectJBeforeAdvice(HIGH_PRECEDENCE_ADVISOR_ORDER, LATE_ADVICE_DECLARATION_ORDER, "someAspect");
|
||||
assertThat(this.comparator.compare(advisor1, advisor2)).as("advisor1 and advisor2 not comparable").isEqualTo(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSameAdvisorPrecedenceDifferentAspectNoAfterAdvice() {
|
||||
void testSameAdvisorPrecedenceDifferentAspectNoAfterAdvice() {
|
||||
Advisor advisor1 = createAspectJBeforeAdvice(HIGH_PRECEDENCE_ADVISOR_ORDER, EARLY_ADVICE_DECLARATION_ORDER, "someAspect");
|
||||
Advisor advisor2 = createAspectJBeforeAdvice(HIGH_PRECEDENCE_ADVISOR_ORDER, LATE_ADVICE_DECLARATION_ORDER, "someOtherAspect");
|
||||
assertThat(this.comparator.compare(advisor1, advisor2)).as("nothing to say about order here").isEqualTo(0);
|
||||
@@ -105,7 +105,7 @@ public class AspectJPrecedenceComparatorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSameAdvisorPrecedenceDifferentAspectAfterAdvice() {
|
||||
void testSameAdvisorPrecedenceDifferentAspectAfterAdvice() {
|
||||
Advisor advisor1 = createAspectJAfterAdvice(HIGH_PRECEDENCE_ADVISOR_ORDER, EARLY_ADVICE_DECLARATION_ORDER, "someAspect");
|
||||
Advisor advisor2 = createAspectJAroundAdvice(HIGH_PRECEDENCE_ADVISOR_ORDER, LATE_ADVICE_DECLARATION_ORDER, "someOtherAspect");
|
||||
assertThat(this.comparator.compare(advisor1, advisor2)).as("nothing to say about order here").isEqualTo(0);
|
||||
@@ -116,7 +116,7 @@ public class AspectJPrecedenceComparatorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHigherAdvisorPrecedenceNoAfterAdvice() {
|
||||
void testHigherAdvisorPrecedenceNoAfterAdvice() {
|
||||
Advisor advisor1 = createSpringAOPBeforeAdvice(HIGH_PRECEDENCE_ADVISOR_ORDER);
|
||||
Advisor advisor2 = createAspectJBeforeAdvice(LOW_PRECEDENCE_ADVISOR_ORDER, EARLY_ADVICE_DECLARATION_ORDER, "someOtherAspect");
|
||||
assertThat(this.comparator.compare(advisor1, advisor2)).as("advisor1 sorted before advisor2").isEqualTo(-1);
|
||||
@@ -127,7 +127,7 @@ public class AspectJPrecedenceComparatorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHigherAdvisorPrecedenceAfterAdvice() {
|
||||
void testHigherAdvisorPrecedenceAfterAdvice() {
|
||||
Advisor advisor1 = createAspectJAfterAdvice(HIGH_PRECEDENCE_ADVISOR_ORDER, EARLY_ADVICE_DECLARATION_ORDER, "someAspect");
|
||||
Advisor advisor2 = createAspectJAroundAdvice(LOW_PRECEDENCE_ADVISOR_ORDER, LATE_ADVICE_DECLARATION_ORDER, "someOtherAspect");
|
||||
assertThat(this.comparator.compare(advisor1, advisor2)).as("advisor1 sorted before advisor2").isEqualTo(-1);
|
||||
@@ -138,7 +138,7 @@ public class AspectJPrecedenceComparatorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLowerAdvisorPrecedenceNoAfterAdvice() {
|
||||
void testLowerAdvisorPrecedenceNoAfterAdvice() {
|
||||
Advisor advisor1 = createAspectJBeforeAdvice(LOW_PRECEDENCE_ADVISOR_ORDER, EARLY_ADVICE_DECLARATION_ORDER, "someAspect");
|
||||
Advisor advisor2 = createAspectJBeforeAdvice(HIGH_PRECEDENCE_ADVISOR_ORDER, EARLY_ADVICE_DECLARATION_ORDER, "someOtherAspect");
|
||||
assertThat(this.comparator.compare(advisor1, advisor2)).as("advisor1 sorted after advisor2").isEqualTo(1);
|
||||
@@ -149,7 +149,7 @@ public class AspectJPrecedenceComparatorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLowerAdvisorPrecedenceAfterAdvice() {
|
||||
void testLowerAdvisorPrecedenceAfterAdvice() {
|
||||
Advisor advisor1 = createAspectJAfterAdvice(LOW_PRECEDENCE_ADVISOR_ORDER, EARLY_ADVICE_DECLARATION_ORDER, "someAspect");
|
||||
Advisor advisor2 = createAspectJAroundAdvice(HIGH_PRECEDENCE_ADVISOR_ORDER, LATE_ADVICE_DECLARATION_ORDER, "someOtherAspect");
|
||||
assertThat(this.comparator.compare(advisor1, advisor2)).as("advisor1 sorted after advisor2").isEqualTo(1);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -25,14 +25,14 @@ import org.springframework.util.StopWatch;
|
||||
|
||||
/**
|
||||
* Benchmarks for introductions.
|
||||
*
|
||||
* <p>
|
||||
* NOTE: No assertions!
|
||||
*
|
||||
* @author Rod Johnson
|
||||
* @author Chris Beams
|
||||
* @since 2.0
|
||||
*/
|
||||
public class IntroductionBenchmarkTests {
|
||||
class IntroductionBenchmarkTests {
|
||||
|
||||
private static final int EXPECTED_COMPARE = 13;
|
||||
|
||||
@@ -53,7 +53,7 @@ public class IntroductionBenchmarkTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void timeManyInvocations() {
|
||||
void timeManyInvocations() {
|
||||
StopWatch sw = new StopWatch();
|
||||
|
||||
TestBean target = new TestBean();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -29,14 +29,14 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
*
|
||||
* @author Dave Syer
|
||||
*/
|
||||
public class NullPrimitiveTests {
|
||||
class NullPrimitiveTests {
|
||||
|
||||
interface Foo {
|
||||
int getValue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNullPrimitiveWithJdkProxy() {
|
||||
void testNullPrimitiveWithJdkProxy() {
|
||||
|
||||
class SimpleFoo implements Foo {
|
||||
@Override
|
||||
@@ -51,8 +51,7 @@ public class NullPrimitiveTests {
|
||||
|
||||
Foo foo = (Foo) factory.getProxy();
|
||||
|
||||
assertThatExceptionOfType(AopInvocationException.class).isThrownBy(() ->
|
||||
foo.getValue())
|
||||
assertThatExceptionOfType(AopInvocationException.class).isThrownBy(foo::getValue)
|
||||
.withMessageContaining("Foo.getValue()");
|
||||
}
|
||||
|
||||
@@ -63,7 +62,7 @@ public class NullPrimitiveTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNullPrimitiveWithCglibProxy() {
|
||||
void testNullPrimitiveWithCglibProxy() {
|
||||
|
||||
Bar target = new Bar();
|
||||
ProxyFactory factory = new ProxyFactory(target);
|
||||
@@ -71,8 +70,7 @@ public class NullPrimitiveTests {
|
||||
|
||||
Bar bar = (Bar) factory.getProxy();
|
||||
|
||||
assertThatExceptionOfType(AopInvocationException.class).isThrownBy(() ->
|
||||
bar.getValue())
|
||||
assertThatExceptionOfType(AopInvocationException.class).isThrownBy(bar::getValue)
|
||||
.withMessageContaining("Bar.getValue()");
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -32,13 +32,13 @@ import static org.springframework.core.testfixture.io.ResourceTestUtils.qualifie
|
||||
* @author Chris Beams
|
||||
* @since 03.09.2004
|
||||
*/
|
||||
public class PrototypeTargetTests {
|
||||
class PrototypeTargetTests {
|
||||
|
||||
private static final Resource CONTEXT = qualifiedResource(PrototypeTargetTests.class, "context.xml");
|
||||
|
||||
|
||||
@Test
|
||||
public void testPrototypeProxyWithPrototypeTarget() {
|
||||
void testPrototypeProxyWithPrototypeTarget() {
|
||||
TestBeanImpl.constructionCount = 0;
|
||||
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
|
||||
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(CONTEXT);
|
||||
@@ -52,7 +52,7 @@ public class PrototypeTargetTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSingletonProxyWithPrototypeTarget() {
|
||||
void testSingletonProxyWithPrototypeTarget() {
|
||||
TestBeanImpl.constructionCount = 0;
|
||||
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
|
||||
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(CONTEXT);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -57,10 +57,10 @@ import static org.assertj.core.api.Assertions.assertThatRuntimeException;
|
||||
* @author Chris Beams
|
||||
* @since 14.05.2003
|
||||
*/
|
||||
public class ProxyFactoryTests {
|
||||
class ProxyFactoryTests {
|
||||
|
||||
@Test
|
||||
public void testIndexOfMethods() {
|
||||
void testIndexOfMethods() {
|
||||
TestBean target = new TestBean();
|
||||
ProxyFactory pf = new ProxyFactory(target);
|
||||
NopInterceptor nop = new NopInterceptor();
|
||||
@@ -76,7 +76,7 @@ public class ProxyFactoryTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRemoveAdvisorByReference() {
|
||||
void testRemoveAdvisorByReference() {
|
||||
TestBean target = new TestBean();
|
||||
ProxyFactory pf = new ProxyFactory(target);
|
||||
NopInterceptor nop = new NopInterceptor();
|
||||
@@ -96,7 +96,7 @@ public class ProxyFactoryTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRemoveAdvisorByIndex() {
|
||||
void testRemoveAdvisorByIndex() {
|
||||
TestBean target = new TestBean();
|
||||
ProxyFactory pf = new ProxyFactory(target);
|
||||
NopInterceptor nop = new NopInterceptor();
|
||||
@@ -144,7 +144,7 @@ public class ProxyFactoryTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReplaceAdvisor() {
|
||||
void testReplaceAdvisor() {
|
||||
TestBean target = new TestBean();
|
||||
ProxyFactory pf = new ProxyFactory(target);
|
||||
NopInterceptor nop = new NopInterceptor();
|
||||
@@ -173,7 +173,7 @@ public class ProxyFactoryTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddRepeatedInterface() {
|
||||
void testAddRepeatedInterface() {
|
||||
TimeStamped tst = () -> {
|
||||
throw new UnsupportedOperationException("getTimeStamp");
|
||||
};
|
||||
@@ -186,7 +186,7 @@ public class ProxyFactoryTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetsAllInterfaces() {
|
||||
void testGetsAllInterfaces() {
|
||||
// Extend to get new interface
|
||||
class TestBeanSubclass extends TestBean implements Comparable<Object> {
|
||||
@Override
|
||||
@@ -220,10 +220,10 @@ public class ProxyFactoryTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInterceptorInclusionMethods() {
|
||||
void testInterceptorInclusionMethods() {
|
||||
class MyInterceptor implements MethodInterceptor {
|
||||
@Override
|
||||
public Object invoke(MethodInvocation invocation) throws Throwable {
|
||||
public Object invoke(MethodInvocation invocation) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
||||
@@ -244,9 +244,9 @@ public class ProxyFactoryTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSealedInterfaceExclusion() {
|
||||
void testSealedInterfaceExclusion() {
|
||||
// String implements ConstantDesc on JDK 12+, sealed as of JDK 17
|
||||
ProxyFactory factory = new ProxyFactory(new String());
|
||||
ProxyFactory factory = new ProxyFactory("");
|
||||
NopInterceptor di = new NopInterceptor();
|
||||
factory.addAdvice(0, di);
|
||||
Object proxy = factory.getProxy();
|
||||
@@ -257,7 +257,7 @@ public class ProxyFactoryTests {
|
||||
* Should see effect immediately on behavior.
|
||||
*/
|
||||
@Test
|
||||
public void testCanAddAndRemoveAspectInterfacesOnSingleton() {
|
||||
void testCanAddAndRemoveAspectInterfacesOnSingleton() {
|
||||
ProxyFactory config = new ProxyFactory(new TestBean());
|
||||
|
||||
assertThat(config.getProxy()).as("Shouldn't implement TimeStamped before manipulation")
|
||||
@@ -304,7 +304,7 @@ public class ProxyFactoryTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testProxyTargetClassWithInterfaceAsTarget() {
|
||||
void testProxyTargetClassWithInterfaceAsTarget() {
|
||||
ProxyFactory pf = new ProxyFactory();
|
||||
pf.setTargetClass(ITestBean.class);
|
||||
Object proxy = pf.getProxy();
|
||||
@@ -320,7 +320,7 @@ public class ProxyFactoryTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testProxyTargetClassWithConcreteClassAsTarget() {
|
||||
void testProxyTargetClassWithConcreteClassAsTarget() {
|
||||
ProxyFactory pf = new ProxyFactory();
|
||||
pf.setTargetClass(TestBean.class);
|
||||
Object proxy = pf.getProxy();
|
||||
@@ -347,7 +347,7 @@ public class ProxyFactoryTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInterfaceProxiesCanBeOrderedThroughAnnotations() {
|
||||
void testInterfaceProxiesCanBeOrderedThroughAnnotations() {
|
||||
Object proxy1 = new ProxyFactory(new A()).getProxy();
|
||||
Object proxy2 = new ProxyFactory(new B()).getProxy();
|
||||
List<Object> list = new ArrayList<>(2);
|
||||
@@ -359,7 +359,7 @@ public class ProxyFactoryTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTargetClassProxiesCanBeOrderedThroughAnnotations() {
|
||||
void testTargetClassProxiesCanBeOrderedThroughAnnotations() {
|
||||
ProxyFactory pf1 = new ProxyFactory(new A());
|
||||
pf1.setProxyTargetClass(true);
|
||||
ProxyFactory pf2 = new ProxyFactory(new B());
|
||||
@@ -375,7 +375,7 @@ public class ProxyFactoryTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInterceptorWithoutJoinpoint() {
|
||||
void testInterceptorWithoutJoinpoint() {
|
||||
final TestBean target = new TestBean("tb");
|
||||
ITestBean proxy = ProxyFactory.getProxy(ITestBean.class, (MethodInterceptor) invocation -> {
|
||||
assertThat(invocation.getThis()).isNull();
|
||||
@@ -385,7 +385,7 @@ public class ProxyFactoryTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCharSequenceProxy() {
|
||||
void testCharSequenceProxy() {
|
||||
CharSequence target = "test";
|
||||
ProxyFactory pf = new ProxyFactory(target);
|
||||
ClassLoader cl = target.getClass().getClassLoader();
|
||||
@@ -395,7 +395,7 @@ public class ProxyFactoryTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDateProxy() {
|
||||
void testDateProxy() {
|
||||
Date target = new Date();
|
||||
ProxyFactory pf = new ProxyFactory(target);
|
||||
pf.setProxyTargetClass(true);
|
||||
@@ -406,14 +406,14 @@ public class ProxyFactoryTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testJdbcSavepointProxy() throws SQLException {
|
||||
void testJdbcSavepointProxy() throws SQLException {
|
||||
Savepoint target = new Savepoint() {
|
||||
@Override
|
||||
public int getSavepointId() throws SQLException {
|
||||
public int getSavepointId() {
|
||||
return 1;
|
||||
}
|
||||
@Override
|
||||
public String getSavepointName() throws SQLException {
|
||||
public String getSavepointName() {
|
||||
return "sp";
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -37,17 +37,17 @@ import static org.mockito.Mockito.mock;
|
||||
* @author Chris Beams
|
||||
* @author Juergen Hoeller
|
||||
*/
|
||||
public class ThrowsAdviceInterceptorTests {
|
||||
class ThrowsAdviceInterceptorTests {
|
||||
|
||||
@Test
|
||||
public void testNoHandlerMethods() {
|
||||
void testNoHandlerMethods() {
|
||||
// should require one handler method at least
|
||||
assertThatExceptionOfType(AopConfigException.class).isThrownBy(() ->
|
||||
new ThrowsAdviceInterceptor(new Object()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNotInvoked() throws Throwable {
|
||||
void testNotInvoked() throws Throwable {
|
||||
MyThrowsHandler th = new MyThrowsHandler();
|
||||
ThrowsAdviceInterceptor ti = new ThrowsAdviceInterceptor(th);
|
||||
Object ret = new Object();
|
||||
@@ -58,7 +58,7 @@ public class ThrowsAdviceInterceptorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNoHandlerMethodForThrowable() throws Throwable {
|
||||
void testNoHandlerMethodForThrowable() throws Throwable {
|
||||
MyThrowsHandler th = new MyThrowsHandler();
|
||||
ThrowsAdviceInterceptor ti = new ThrowsAdviceInterceptor(th);
|
||||
assertThat(ti.getHandlerMethodCount()).isEqualTo(2);
|
||||
@@ -70,7 +70,7 @@ public class ThrowsAdviceInterceptorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCorrectHandlerUsed() throws Throwable {
|
||||
void testCorrectHandlerUsed() throws Throwable {
|
||||
MyThrowsHandler th = new MyThrowsHandler();
|
||||
ThrowsAdviceInterceptor ti = new ThrowsAdviceInterceptor(th);
|
||||
FileNotFoundException ex = new FileNotFoundException();
|
||||
@@ -84,7 +84,7 @@ public class ThrowsAdviceInterceptorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCorrectHandlerUsedForSubclass() throws Throwable {
|
||||
void testCorrectHandlerUsedForSubclass() throws Throwable {
|
||||
MyThrowsHandler th = new MyThrowsHandler();
|
||||
ThrowsAdviceInterceptor ti = new ThrowsAdviceInterceptor(th);
|
||||
// Extends RemoteException
|
||||
@@ -97,10 +97,9 @@ public class ThrowsAdviceInterceptorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHandlerMethodThrowsException() throws Throwable {
|
||||
void testHandlerMethodThrowsException() throws Throwable {
|
||||
final Throwable t = new Throwable();
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
MyThrowsHandler th = new MyThrowsHandler() {
|
||||
@Override
|
||||
public void afterThrowing(RemoteException ex) throws Throwable {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -34,7 +34,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
* @author Chris Beams
|
||||
* @since 06.04.2004
|
||||
*/
|
||||
public class ConcurrencyThrottleInterceptorTests {
|
||||
class ConcurrencyThrottleInterceptorTests {
|
||||
|
||||
protected static final Log logger = LogFactory.getLog(ConcurrencyThrottleInterceptorTests.class);
|
||||
|
||||
@@ -44,7 +44,7 @@ public class ConcurrencyThrottleInterceptorTests {
|
||||
|
||||
|
||||
@Test
|
||||
public void testSerializable() throws Exception {
|
||||
void testSerializable() throws Exception {
|
||||
DerivedTestBean tb = new DerivedTestBean();
|
||||
ProxyFactory proxyFactory = new ProxyFactory();
|
||||
proxyFactory.setInterfaces(ITestBean.class);
|
||||
@@ -63,12 +63,12 @@ public class ConcurrencyThrottleInterceptorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMultipleThreadsWithLimit1() {
|
||||
void testMultipleThreadsWithLimit1() {
|
||||
testMultipleThreads(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMultipleThreadsWithLimit10() {
|
||||
void testMultipleThreadsWithLimit10() {
|
||||
testMultipleThreads(10);
|
||||
}
|
||||
|
||||
@@ -111,8 +111,8 @@ public class ConcurrencyThrottleInterceptorTests {
|
||||
|
||||
private static class ConcurrencyThread extends Thread {
|
||||
|
||||
private ITestBean proxy;
|
||||
private Throwable ex;
|
||||
private final ITestBean proxy;
|
||||
private final Throwable ex;
|
||||
|
||||
public ConcurrencyThread(ITestBean proxy, Throwable ex) {
|
||||
this.proxy = proxy;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -144,7 +144,7 @@ class CustomizableTraceInterceptorTests {
|
||||
void sunnyDayPathLogsCorrectlyWithPrettyMuchAllPlaceholdersMatching() throws Throwable {
|
||||
MethodInvocation methodInvocation = mock();
|
||||
|
||||
given(methodInvocation.getMethod()).willReturn(String.class.getMethod("toString", new Class[0]));
|
||||
given(methodInvocation.getMethod()).willReturn(String.class.getMethod("toString"));
|
||||
given(methodInvocation.getThis()).willReturn(this);
|
||||
given(methodInvocation.getArguments()).willReturn(new Object[]{"$ One \\$", 2L});
|
||||
given(methodInvocation.proceed()).willReturn("Hello!");
|
||||
@@ -177,7 +177,6 @@ class CustomizableTraceInterceptorTests {
|
||||
* is properly configured in {@link CustomizableTraceInterceptor}.
|
||||
*/
|
||||
@Test
|
||||
@SuppressWarnings("deprecation")
|
||||
void supportedPlaceholderValues() {
|
||||
assertThat(ALLOWED_PLACEHOLDERS).containsExactlyInAnyOrderElementsOf(getPlaceholderConstantValues());
|
||||
}
|
||||
|
||||
@@ -35,10 +35,10 @@ import static org.mockito.Mockito.verify;
|
||||
* @author Rick Evans
|
||||
* @author Chris Beams
|
||||
*/
|
||||
public class DebugInterceptorTests {
|
||||
class DebugInterceptorTests {
|
||||
|
||||
@Test
|
||||
public void testSunnyDayPathLogsCorrectly() throws Throwable {
|
||||
void testSunnyDayPathLogsCorrectly() throws Throwable {
|
||||
MethodInvocation methodInvocation = mock();
|
||||
|
||||
Log log = mock();
|
||||
@@ -52,7 +52,7 @@ public class DebugInterceptorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExceptionPathStillLogsCorrectly() throws Throwable {
|
||||
void testExceptionPathStillLogsCorrectly() throws Throwable {
|
||||
MethodInvocation methodInvocation = mock();
|
||||
|
||||
IllegalArgumentException exception = new IllegalArgumentException();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -29,9 +29,9 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
* @author Rod Johnson
|
||||
* @author Chris Beams
|
||||
*/
|
||||
public class ExposeBeanNameAdvisorsTests {
|
||||
class ExposeBeanNameAdvisorsTests {
|
||||
|
||||
private class RequiresBeanNameBoundTestBean extends TestBean {
|
||||
private static class RequiresBeanNameBoundTestBean extends TestBean {
|
||||
private final String beanName;
|
||||
|
||||
public RequiresBeanNameBoundTestBean(String beanName) {
|
||||
@@ -46,7 +46,7 @@ public class ExposeBeanNameAdvisorsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNoIntroduction() {
|
||||
void testNoIntroduction() {
|
||||
String beanName = "foo";
|
||||
TestBean target = new RequiresBeanNameBoundTestBean(beanName);
|
||||
ProxyFactory pf = new ProxyFactory(target);
|
||||
@@ -61,7 +61,7 @@ public class ExposeBeanNameAdvisorsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWithIntroduction() {
|
||||
void testWithIntroduction() {
|
||||
String beanName = "foo";
|
||||
TestBean target = new RequiresBeanNameBoundTestBean(beanName);
|
||||
ProxyFactory pf = new ProxyFactory(target);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -31,10 +31,10 @@ import static org.springframework.core.testfixture.io.ResourceTestUtils.qualifie
|
||||
* @author Rod Johnson
|
||||
* @author Chris Beams
|
||||
*/
|
||||
public class ExposeInvocationInterceptorTests {
|
||||
class ExposeInvocationInterceptorTests {
|
||||
|
||||
@Test
|
||||
public void testXmlConfig() {
|
||||
void testXmlConfig() {
|
||||
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
|
||||
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(
|
||||
qualifiedResource(ExposeInvocationInterceptorTests.class, "context.xml"));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -32,10 +32,10 @@ import static org.mockito.Mockito.verify;
|
||||
* @author Rick Evans
|
||||
* @author Chris Beams
|
||||
*/
|
||||
public class PerformanceMonitorInterceptorTests {
|
||||
class PerformanceMonitorInterceptorTests {
|
||||
|
||||
@Test
|
||||
public void testSuffixAndPrefixAssignment() {
|
||||
void testSuffixAndPrefixAssignment() {
|
||||
PerformanceMonitorInterceptor interceptor = new PerformanceMonitorInterceptor();
|
||||
|
||||
assertThat(interceptor.getPrefix()).isNotNull();
|
||||
@@ -49,9 +49,9 @@ public class PerformanceMonitorInterceptorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSunnyDayPathLogsPerformanceMetricsCorrectly() throws Throwable {
|
||||
void testSunnyDayPathLogsPerformanceMetricsCorrectly() throws Throwable {
|
||||
MethodInvocation mi = mock();
|
||||
given(mi.getMethod()).willReturn(String.class.getMethod("toString", new Class[0]));
|
||||
given(mi.getMethod()).willReturn(String.class.getMethod("toString"));
|
||||
|
||||
Log log = mock();
|
||||
|
||||
@@ -62,10 +62,10 @@ public class PerformanceMonitorInterceptorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExceptionPathStillLogsPerformanceMetricsCorrectly() throws Throwable {
|
||||
void testExceptionPathStillLogsPerformanceMetricsCorrectly() throws Throwable {
|
||||
MethodInvocation mi = mock();
|
||||
|
||||
given(mi.getMethod()).willReturn(String.class.getMethod("toString", new Class[0]));
|
||||
given(mi.getMethod()).willReturn(String.class.getMethod("toString"));
|
||||
given(mi.proceed()).willThrow(new IllegalArgumentException());
|
||||
Log log = mock();
|
||||
|
||||
|
||||
@@ -34,10 +34,10 @@ import static org.mockito.Mockito.verify;
|
||||
* @author Rick Evans
|
||||
* @author Chris Beams
|
||||
*/
|
||||
public class SimpleTraceInterceptorTests {
|
||||
class SimpleTraceInterceptorTests {
|
||||
|
||||
@Test
|
||||
public void testSunnyDayPathLogsCorrectly() throws Throwable {
|
||||
void testSunnyDayPathLogsCorrectly() throws Throwable {
|
||||
MethodInvocation mi = mock();
|
||||
given(mi.getMethod()).willReturn(String.class.getMethod("toString"));
|
||||
given(mi.getThis()).willReturn(this);
|
||||
@@ -51,7 +51,7 @@ public class SimpleTraceInterceptorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExceptionPathStillLogsCorrectly() throws Throwable {
|
||||
void testExceptionPathStillLogsCorrectly() throws Throwable {
|
||||
MethodInvocation mi = mock();
|
||||
given(mi.getMethod()).willReturn(String.class.getMethod("toString"));
|
||||
given(mi.getThis()).willReturn(this);
|
||||
|
||||
@@ -29,31 +29,31 @@ import static org.mockito.Mockito.mock;
|
||||
* @author Rick Evans
|
||||
* @author Chris Beams
|
||||
*/
|
||||
public class DefaultScopedObjectTests {
|
||||
class DefaultScopedObjectTests {
|
||||
|
||||
private static final String GOOD_BEAN_NAME = "foo";
|
||||
|
||||
|
||||
@Test
|
||||
public void testCtorWithNullBeanFactory() throws Exception {
|
||||
void testCtorWithNullBeanFactory() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() ->
|
||||
new DefaultScopedObject(null, GOOD_BEAN_NAME));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCtorWithNullTargetBeanName() throws Exception {
|
||||
void testCtorWithNullTargetBeanName() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() ->
|
||||
testBadTargetBeanName(null));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCtorWithEmptyTargetBeanName() throws Exception {
|
||||
void testCtorWithEmptyTargetBeanName() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() ->
|
||||
testBadTargetBeanName(""));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCtorWithJustWhitespacedTargetBeanName() throws Exception {
|
||||
void testCtorWithJustWhitespacedTargetBeanName() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() ->
|
||||
testBadTargetBeanName(" "));
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -31,10 +31,10 @@ import static org.springframework.core.testfixture.io.ResourceTestUtils.qualifie
|
||||
* @author Juergen Hoeller
|
||||
* @author Chris Beams
|
||||
*/
|
||||
public class ScopedProxyAutowireTests {
|
||||
class ScopedProxyAutowireTests {
|
||||
|
||||
@Test
|
||||
public void testScopedProxyInheritsAutowireCandidateFalse() {
|
||||
void testScopedProxyInheritsAutowireCandidateFalse() {
|
||||
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
|
||||
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(
|
||||
qualifiedResource(ScopedProxyAutowireTests.class, "scopedAutowireFalse.xml"));
|
||||
@@ -48,7 +48,7 @@ public class ScopedProxyAutowireTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testScopedProxyReplacesAutowireCandidateTrue() {
|
||||
void testScopedProxyReplacesAutowireCandidateTrue() {
|
||||
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
|
||||
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(
|
||||
qualifiedResource(ScopedProxyAutowireTests.class, "scopedAutowireTrue.xml"));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -38,10 +38,10 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
* @author Chris Beams
|
||||
* @author Sebastien Deleuze
|
||||
*/
|
||||
public class AopUtilsTests {
|
||||
class AopUtilsTests {
|
||||
|
||||
@Test
|
||||
public void testPointcutCanNeverApply() {
|
||||
void testPointcutCanNeverApply() {
|
||||
class TestPointcut extends StaticMethodMatcherPointcut {
|
||||
@Override
|
||||
public boolean matches(Method method, @Nullable Class<?> clazzy) {
|
||||
@@ -54,13 +54,13 @@ public class AopUtilsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPointcutAlwaysApplies() {
|
||||
void testPointcutAlwaysApplies() {
|
||||
assertThat(AopUtils.canApply(new DefaultPointcutAdvisor(new NopInterceptor()), Object.class)).isTrue();
|
||||
assertThat(AopUtils.canApply(new DefaultPointcutAdvisor(new NopInterceptor()), TestBean.class)).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPointcutAppliesToOneMethodOnObject() {
|
||||
void testPointcutAppliesToOneMethodOnObject() {
|
||||
class TestPointcut extends StaticMethodMatcherPointcut {
|
||||
@Override
|
||||
public boolean matches(Method method, @Nullable Class<?> clazz) {
|
||||
@@ -80,7 +80,7 @@ public class AopUtilsTests {
|
||||
* that's subverted the singleton construction limitation.
|
||||
*/
|
||||
@Test
|
||||
public void testCanonicalFrameworkClassesStillCanonicalOnDeserialization() throws Exception {
|
||||
void testCanonicalFrameworkClassesStillCanonicalOnDeserialization() throws Exception {
|
||||
assertThat(SerializationTestUtils.serializeAndDeserialize(MethodMatcher.TRUE)).isSameAs(MethodMatcher.TRUE);
|
||||
assertThat(SerializationTestUtils.serializeAndDeserialize(ClassFilter.TRUE)).isSameAs(ClassFilter.TRUE);
|
||||
assertThat(SerializationTestUtils.serializeAndDeserialize(Pointcut.TRUE)).isSameAs(Pointcut.TRUE);
|
||||
@@ -91,7 +91,7 @@ public class AopUtilsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInvokeJoinpointUsingReflection() throws Throwable {
|
||||
void testInvokeJoinpointUsingReflection() throws Throwable {
|
||||
String name = "foo";
|
||||
TestBean testBean = new TestBean(name);
|
||||
Method method = ReflectionUtils.findMethod(TestBean.class, "getName");
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -33,7 +33,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
* @author Rod Johnson
|
||||
* @author Chris Beams
|
||||
*/
|
||||
public class ComposablePointcutTests {
|
||||
class ComposablePointcutTests {
|
||||
|
||||
public static MethodMatcher GETTER_METHOD_MATCHER = new StaticMethodMatcher() {
|
||||
@Override
|
||||
@@ -56,23 +56,16 @@ public class ComposablePointcutTests {
|
||||
}
|
||||
};
|
||||
|
||||
public static MethodMatcher SETTER_METHOD_MATCHER = new StaticMethodMatcher() {
|
||||
@Override
|
||||
public boolean matches(Method m, @Nullable Class<?> targetClass) {
|
||||
return m.getName().startsWith("set");
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@Test
|
||||
public void testMatchAll() throws NoSuchMethodException {
|
||||
void testMatchAll() throws NoSuchMethodException {
|
||||
Pointcut pc = new ComposablePointcut();
|
||||
assertThat(pc.getClassFilter().matches(Object.class)).isTrue();
|
||||
assertThat(pc.getMethodMatcher().matches(Object.class.getMethod("hashCode"), Exception.class)).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFilterByClass() throws NoSuchMethodException {
|
||||
void testFilterByClass() {
|
||||
ComposablePointcut pc = new ComposablePointcut();
|
||||
|
||||
assertThat(pc.getClassFilter().matches(Object.class)).isTrue();
|
||||
@@ -92,7 +85,7 @@ public class ComposablePointcutTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUnionMethodMatcher() {
|
||||
void testUnionMethodMatcher() {
|
||||
// Matches the getAge() method in any class
|
||||
ComposablePointcut pc = new ComposablePointcut(ClassFilter.TRUE, GET_AGE_METHOD_MATCHER);
|
||||
assertThat(Pointcuts.matches(pc, PointcutsTests.TEST_BEAN_ABSQUATULATE, TestBean.class)).isFalse();
|
||||
@@ -115,7 +108,7 @@ public class ComposablePointcutTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIntersectionMethodMatcher() {
|
||||
void testIntersectionMethodMatcher() {
|
||||
ComposablePointcut pc = new ComposablePointcut();
|
||||
assertThat(pc.getMethodMatcher().matches(PointcutsTests.TEST_BEAN_ABSQUATULATE, TestBean.class)).isTrue();
|
||||
assertThat(pc.getMethodMatcher().matches(PointcutsTests.TEST_BEAN_GET_AGE, TestBean.class)).isTrue();
|
||||
@@ -132,7 +125,7 @@ public class ComposablePointcutTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEqualsAndHashCode() throws Exception {
|
||||
void testEqualsAndHashCode() {
|
||||
ComposablePointcut pc1 = new ComposablePointcut();
|
||||
ComposablePointcut pc2 = new ComposablePointcut();
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -203,7 +203,7 @@ class ControlFlowPointcutTests {
|
||||
|
||||
// Will not be advised: not under MyComponent
|
||||
assertThat(proxy.getAge()).isEqualTo(target.getAge());
|
||||
assertThat(cflow.getEvaluations()).isEqualTo(1 * evaluationFactor);
|
||||
assertThat(cflow.getEvaluations()).isEqualTo(evaluationFactor);
|
||||
assertThat(nop.getCount()).isEqualTo(0);
|
||||
|
||||
// Will be advised: the proxy is invoked under MyComponent#getAge
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -47,14 +47,14 @@ import static org.mockito.Mockito.mock;
|
||||
class DelegatingIntroductionInterceptorTests {
|
||||
|
||||
@Test
|
||||
void testNullTarget() throws Exception {
|
||||
void testNullTarget() {
|
||||
// Shouldn't accept null target
|
||||
assertThatIllegalArgumentException().isThrownBy(() ->
|
||||
new DelegatingIntroductionInterceptor(null));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testIntroductionInterceptorWithDelegation() throws Exception {
|
||||
void testIntroductionInterceptorWithDelegation() {
|
||||
TestBean raw = new TestBean();
|
||||
assertThat(raw).isNotInstanceOf(TimeStamped.class);
|
||||
ProxyFactory factory = new ProxyFactory(raw);
|
||||
@@ -70,7 +70,7 @@ class DelegatingIntroductionInterceptorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testIntroductionInterceptorWithInterfaceHierarchy() throws Exception {
|
||||
void testIntroductionInterceptorWithInterfaceHierarchy() {
|
||||
TestBean raw = new TestBean();
|
||||
assertThat(raw).isNotInstanceOf(SubTimeStamped.class);
|
||||
ProxyFactory factory = new ProxyFactory(raw);
|
||||
@@ -86,7 +86,7 @@ class DelegatingIntroductionInterceptorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testIntroductionInterceptorWithSuperInterface() throws Exception {
|
||||
void testIntroductionInterceptorWithSuperInterface() {
|
||||
TestBean raw = new TestBean();
|
||||
assertThat(raw).isNotInstanceOf(TimeStamped.class);
|
||||
ProxyFactory factory = new ProxyFactory(raw);
|
||||
@@ -107,7 +107,7 @@ class DelegatingIntroductionInterceptorTests {
|
||||
final long t = 1001L;
|
||||
class Tester implements TimeStamped, ITester {
|
||||
@Override
|
||||
public void foo() throws Exception {
|
||||
public void foo() {
|
||||
}
|
||||
@Override
|
||||
public long getTimeStamp() {
|
||||
@@ -138,7 +138,7 @@ class DelegatingIntroductionInterceptorTests {
|
||||
@SuppressWarnings("serial")
|
||||
class TestII extends DelegatingIntroductionInterceptor implements TimeStamped, ITester {
|
||||
@Override
|
||||
public void foo() throws Exception {
|
||||
public void foo() {
|
||||
}
|
||||
@Override
|
||||
public long getTimeStamp() {
|
||||
@@ -177,9 +177,8 @@ class DelegatingIntroductionInterceptorTests {
|
||||
assertThat(o).isNotInstanceOf(TimeStamped.class);
|
||||
}
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
@Test
|
||||
void testIntroductionInterceptorDoesntReplaceToString() throws Exception {
|
||||
void testIntroductionInterceptorDoesNotReplaceToString() {
|
||||
TestBean raw = new TestBean();
|
||||
assertThat(raw).isNotInstanceOf(TimeStamped.class);
|
||||
ProxyFactory factory = new ProxyFactory(raw);
|
||||
@@ -246,7 +245,7 @@ class DelegatingIntroductionInterceptorTests {
|
||||
|
||||
// Test when target implements the interface: should get interceptor by preference.
|
||||
@Test
|
||||
void testIntroductionMasksTargetImplementation() throws Exception {
|
||||
void testIntroductionMasksTargetImplementation() {
|
||||
final long t = 1001L;
|
||||
@SuppressWarnings("serial")
|
||||
class TestII extends DelegatingIntroductionInterceptor implements TimeStamped {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -34,7 +34,7 @@ import static org.mockito.Mockito.mock;
|
||||
* @author Juergen Hoeller
|
||||
* @author Chris Beams
|
||||
*/
|
||||
public class MethodMatchersTests {
|
||||
class MethodMatchersTests {
|
||||
|
||||
private static final Method TEST_METHOD = mock(Method.class);
|
||||
|
||||
@@ -56,19 +56,19 @@ public class MethodMatchersTests {
|
||||
|
||||
|
||||
@Test
|
||||
public void testDefaultMatchesAll() throws Exception {
|
||||
void testDefaultMatchesAll() {
|
||||
MethodMatcher defaultMm = MethodMatcher.TRUE;
|
||||
assertThat(defaultMm.matches(EXCEPTION_GETMESSAGE, Exception.class)).isTrue();
|
||||
assertThat(defaultMm.matches(ITESTBEAN_SETAGE, TestBean.class)).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMethodMatcherTrueSerializable() throws Exception {
|
||||
void testMethodMatcherTrueSerializable() throws Exception {
|
||||
assertThat(MethodMatcher.TRUE).isSameAs(SerializationTestUtils.serializeAndDeserialize(MethodMatcher.TRUE));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSingle() throws Exception {
|
||||
void testSingle() {
|
||||
MethodMatcher defaultMm = MethodMatcher.TRUE;
|
||||
assertThat(defaultMm.matches(EXCEPTION_GETMESSAGE, Exception.class)).isTrue();
|
||||
assertThat(defaultMm.matches(ITESTBEAN_SETAGE, TestBean.class)).isTrue();
|
||||
@@ -80,7 +80,7 @@ public class MethodMatchersTests {
|
||||
|
||||
|
||||
@Test
|
||||
public void testDynamicAndStaticMethodMatcherIntersection() throws Exception {
|
||||
void testDynamicAndStaticMethodMatcherIntersection() {
|
||||
MethodMatcher mm1 = MethodMatcher.TRUE;
|
||||
MethodMatcher mm2 = new TestDynamicMethodMatcherWhichMatches();
|
||||
MethodMatcher intersection = MethodMatchers.intersection(mm1, mm2);
|
||||
@@ -95,7 +95,7 @@ public class MethodMatchersTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStaticMethodMatcherUnion() throws Exception {
|
||||
void testStaticMethodMatcherUnion() {
|
||||
MethodMatcher getterMatcher = new StartsWithMatcher("get");
|
||||
MethodMatcher setterMatcher = new StartsWithMatcher("set");
|
||||
MethodMatcher union = MethodMatchers.union(getterMatcher, setterMatcher);
|
||||
@@ -107,7 +107,7 @@ public class MethodMatchersTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUnionEquals() {
|
||||
void testUnionEquals() {
|
||||
MethodMatcher first = MethodMatchers.union(MethodMatcher.TRUE, MethodMatcher.TRUE);
|
||||
MethodMatcher second = new ComposablePointcut(MethodMatcher.TRUE).union(new ComposablePointcut(MethodMatcher.TRUE)).getMethodMatcher();
|
||||
assertThat(first).isEqualTo(second);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -31,7 +31,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
* @author Rod Johnson
|
||||
* @author Chris Beams
|
||||
*/
|
||||
public class PointcutsTests {
|
||||
class PointcutsTests {
|
||||
|
||||
public static Method TEST_BEAN_SET_AGE;
|
||||
public static Method TEST_BEAN_GET_AGE;
|
||||
@@ -120,7 +120,7 @@ public class PointcutsTests {
|
||||
|
||||
|
||||
@Test
|
||||
public void testTrue() {
|
||||
void testTrue() {
|
||||
assertThat(Pointcuts.matches(Pointcut.TRUE, TEST_BEAN_SET_AGE, TestBean.class, 6)).isTrue();
|
||||
assertThat(Pointcuts.matches(Pointcut.TRUE, TEST_BEAN_GET_AGE, TestBean.class)).isTrue();
|
||||
assertThat(Pointcuts.matches(Pointcut.TRUE, TEST_BEAN_ABSQUATULATE, TestBean.class)).isTrue();
|
||||
@@ -130,7 +130,7 @@ public class PointcutsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMatches() {
|
||||
void testMatches() {
|
||||
assertThat(Pointcuts.matches(allClassSetterPointcut, TEST_BEAN_SET_AGE, TestBean.class, 6)).isTrue();
|
||||
assertThat(Pointcuts.matches(allClassSetterPointcut, TEST_BEAN_GET_AGE, TestBean.class)).isFalse();
|
||||
assertThat(Pointcuts.matches(allClassSetterPointcut, TEST_BEAN_ABSQUATULATE, TestBean.class)).isFalse();
|
||||
@@ -143,7 +143,7 @@ public class PointcutsTests {
|
||||
* Should match all setters and getters on any class
|
||||
*/
|
||||
@Test
|
||||
public void testUnionOfSettersAndGetters() {
|
||||
void testUnionOfSettersAndGetters() {
|
||||
Pointcut union = Pointcuts.union(allClassGetterPointcut, allClassSetterPointcut);
|
||||
assertThat(Pointcuts.matches(union, TEST_BEAN_SET_AGE, TestBean.class, 6)).isTrue();
|
||||
assertThat(Pointcuts.matches(union, TEST_BEAN_GET_AGE, TestBean.class)).isTrue();
|
||||
@@ -151,7 +151,7 @@ public class PointcutsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUnionOfSpecificGetters() {
|
||||
void testUnionOfSpecificGetters() {
|
||||
Pointcut union = Pointcuts.union(allClassGetAgePointcut, allClassGetNamePointcut);
|
||||
assertThat(Pointcuts.matches(union, TEST_BEAN_SET_AGE, TestBean.class, 6)).isFalse();
|
||||
assertThat(Pointcuts.matches(union, TEST_BEAN_GET_AGE, TestBean.class)).isTrue();
|
||||
@@ -175,7 +175,7 @@ public class PointcutsTests {
|
||||
* Second one matches all getters in the MyTestBean class. TestBean getters shouldn't pass.
|
||||
*/
|
||||
@Test
|
||||
public void testUnionOfAllSettersAndSubclassSetters() {
|
||||
void testUnionOfAllSettersAndSubclassSetters() {
|
||||
assertThat(Pointcuts.matches(myTestBeanSetterPointcut, TEST_BEAN_SET_AGE, TestBean.class, 6)).isFalse();
|
||||
assertThat(Pointcuts.matches(myTestBeanSetterPointcut, TEST_BEAN_SET_AGE, MyTestBean.class, 6)).isTrue();
|
||||
assertThat(Pointcuts.matches(myTestBeanSetterPointcut, TEST_BEAN_GET_AGE, TestBean.class)).isFalse();
|
||||
@@ -193,7 +193,7 @@ public class PointcutsTests {
|
||||
* it's the union of allClassGetAge and subclass getters
|
||||
*/
|
||||
@Test
|
||||
public void testIntersectionOfSpecificGettersAndSubclassGetters() {
|
||||
void testIntersectionOfSpecificGettersAndSubclassGetters() {
|
||||
assertThat(Pointcuts.matches(allClassGetAgePointcut, TEST_BEAN_GET_AGE, TestBean.class)).isTrue();
|
||||
assertThat(Pointcuts.matches(allClassGetAgePointcut, TEST_BEAN_GET_AGE, MyTestBean.class)).isTrue();
|
||||
assertThat(Pointcuts.matches(myTestBeanGetterPointcut, TEST_BEAN_GET_NAME, TestBean.class)).isFalse();
|
||||
@@ -239,7 +239,7 @@ public class PointcutsTests {
|
||||
* The intersection of these two pointcuts leaves nothing.
|
||||
*/
|
||||
@Test
|
||||
public void testSimpleIntersection() {
|
||||
void testSimpleIntersection() {
|
||||
Pointcut intersection = Pointcuts.intersection(allClassGetterPointcut, allClassSetterPointcut);
|
||||
assertThat(Pointcuts.matches(intersection, TEST_BEAN_SET_AGE, TestBean.class, 6)).isFalse();
|
||||
assertThat(Pointcuts.matches(intersection, TEST_BEAN_GET_AGE, TestBean.class)).isFalse();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -36,14 +36,14 @@ import static org.springframework.core.testfixture.io.ResourceTestUtils.qualifie
|
||||
* @author Rod Johnson
|
||||
* @author Chris Beams
|
||||
*/
|
||||
public class RegexpMethodPointcutAdvisorIntegrationTests {
|
||||
class RegexpMethodPointcutAdvisorIntegrationTests {
|
||||
|
||||
private static final Resource CONTEXT =
|
||||
qualifiedResource(RegexpMethodPointcutAdvisorIntegrationTests.class, "context.xml");
|
||||
|
||||
|
||||
@Test
|
||||
public void testSinglePattern() throws Throwable {
|
||||
void testSinglePattern() throws Throwable {
|
||||
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
|
||||
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(CONTEXT);
|
||||
ITestBean advised = (ITestBean) bf.getBean("settersAdvised");
|
||||
@@ -62,7 +62,7 @@ public class RegexpMethodPointcutAdvisorIntegrationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMultiplePatterns() throws Throwable {
|
||||
void testMultiplePatterns() throws Throwable {
|
||||
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
|
||||
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(CONTEXT);
|
||||
// This is a CGLIB proxy, so we can proxy it to the target class
|
||||
@@ -86,7 +86,7 @@ public class RegexpMethodPointcutAdvisorIntegrationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSerialization() throws Throwable {
|
||||
void testSerialization() throws Throwable {
|
||||
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
|
||||
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(CONTEXT);
|
||||
// This is a CGLIB proxy, so we can proxy it to the target class
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -30,13 +30,13 @@ import static org.springframework.core.testfixture.io.ResourceTestUtils.qualifie
|
||||
/**
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
public class CommonsPool2TargetSourceProxyTests {
|
||||
class CommonsPool2TargetSourceProxyTests {
|
||||
|
||||
private static final Resource CONTEXT =
|
||||
qualifiedResource(CommonsPool2TargetSourceProxyTests.class, "context.xml");
|
||||
|
||||
@Test
|
||||
public void testProxy() throws Exception {
|
||||
void testProxy() {
|
||||
DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
|
||||
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(beanFactory);
|
||||
reader.loadBeanDefinitions(CONTEXT);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -39,7 +39,7 @@ import static org.springframework.core.testfixture.io.ResourceTestUtils.qualifie
|
||||
* @author Rod Johnson
|
||||
* @author Chris Beams
|
||||
*/
|
||||
public class HotSwappableTargetSourceTests {
|
||||
class HotSwappableTargetSourceTests {
|
||||
|
||||
/** Initial count value set in bean factory XML */
|
||||
private static final int INITIAL_COUNT = 10;
|
||||
@@ -68,7 +68,7 @@ public class HotSwappableTargetSourceTests {
|
||||
* Check it works like a normal invoker
|
||||
*/
|
||||
@Test
|
||||
public void testBasicFunctionality() {
|
||||
void testBasicFunctionality() {
|
||||
SideEffectBean proxied = (SideEffectBean) beanFactory.getBean("swappable");
|
||||
assertThat(proxied.getCount()).isEqualTo(INITIAL_COUNT);
|
||||
proxied.doWork();
|
||||
@@ -80,7 +80,7 @@ public class HotSwappableTargetSourceTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValidSwaps() {
|
||||
void testValidSwaps() {
|
||||
SideEffectBean target1 = (SideEffectBean) beanFactory.getBean("target1");
|
||||
SideEffectBean target2 = (SideEffectBean) beanFactory.getBean("target2");
|
||||
|
||||
@@ -107,7 +107,7 @@ public class HotSwappableTargetSourceTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRejectsSwapToNull() {
|
||||
void testRejectsSwapToNull() {
|
||||
HotSwappableTargetSource swapper = (HotSwappableTargetSource) beanFactory.getBean("swapper");
|
||||
assertThatIllegalArgumentException().as("Shouldn't be able to swap to invalid value").isThrownBy(() ->
|
||||
swapper.swap(null))
|
||||
@@ -117,7 +117,7 @@ public class HotSwappableTargetSourceTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSerialization() throws Exception {
|
||||
void testSerialization() throws Exception {
|
||||
SerializablePerson sp1 = new SerializablePerson();
|
||||
sp1.setName("Tony");
|
||||
SerializablePerson sp2 = new SerializablePerson();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -28,10 +28,10 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
* @author Juergen Hoeller
|
||||
* @author Chris Beams
|
||||
*/
|
||||
public class LazyCreationTargetSourceTests {
|
||||
class LazyCreationTargetSourceTests {
|
||||
|
||||
@Test
|
||||
public void testCreateLazy() {
|
||||
void testCreateLazy() {
|
||||
TargetSource targetSource = new AbstractLazyCreationTargetSource() {
|
||||
@Override
|
||||
protected Object createObject() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -36,10 +36,10 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
* @author Rod Johnson
|
||||
* @author Chris Beams
|
||||
*/
|
||||
public class PrototypeBasedTargetSourceTests {
|
||||
class PrototypeBasedTargetSourceTests {
|
||||
|
||||
@Test
|
||||
public void testSerializability() throws Exception {
|
||||
void testSerializability() throws Exception {
|
||||
MutablePropertyValues tsPvs = new MutablePropertyValues();
|
||||
tsPvs.add("targetBeanName", "person");
|
||||
RootBeanDefinition tsBd = new RootBeanDefinition(TestTargetSource.class);
|
||||
@@ -56,10 +56,8 @@ public class PrototypeBasedTargetSourceTests {
|
||||
|
||||
TestTargetSource cpts = (TestTargetSource) bf.getBean("ts");
|
||||
TargetSource serialized = SerializationTestUtils.serializeAndDeserialize(cpts);
|
||||
boolean condition = serialized instanceof SingletonTargetSource;
|
||||
assertThat(condition).as("Changed to SingletonTargetSource on deserialization").isTrue();
|
||||
SingletonTargetSource sts = (SingletonTargetSource) serialized;
|
||||
assertThat(sts.getTarget()).isNotNull();
|
||||
assertThat(serialized).isInstanceOfSatisfying(SingletonTargetSource.class,
|
||||
sts -> assertThat(sts.getTarget()).isNotNull());
|
||||
}
|
||||
|
||||
|
||||
@@ -72,7 +70,7 @@ public class PrototypeBasedTargetSourceTests {
|
||||
* state can't prevent serialization from working
|
||||
*/
|
||||
@SuppressWarnings({"unused", "serial"})
|
||||
private TestBean thisFieldIsNotSerializable = new TestBean();
|
||||
private final TestBean thisFieldIsNotSerializable = new TestBean();
|
||||
|
||||
@Override
|
||||
public Object getTarget() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -30,7 +30,7 @@ import static org.springframework.core.testfixture.io.ResourceTestUtils.qualifie
|
||||
* @author Rod Johnson
|
||||
* @author Chris Beams
|
||||
*/
|
||||
public class PrototypeTargetSourceTests {
|
||||
class PrototypeTargetSourceTests {
|
||||
|
||||
/** Initial count value set in bean factory XML */
|
||||
private static final int INITIAL_COUNT = 10;
|
||||
@@ -52,7 +52,7 @@ public class PrototypeTargetSourceTests {
|
||||
* With the singleton, there will be change.
|
||||
*/
|
||||
@Test
|
||||
public void testPrototypeAndSingletonBehaveDifferently() {
|
||||
void testPrototypeAndSingletonBehaveDifferently() {
|
||||
SideEffectBean singleton = (SideEffectBean) beanFactory.getBean("singleton");
|
||||
assertThat(singleton.getCount()).isEqualTo(INITIAL_COUNT);
|
||||
singleton.doWork();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -31,7 +31,7 @@ import static org.springframework.core.testfixture.io.ResourceTestUtils.qualifie
|
||||
* @author Rod Johnson
|
||||
* @author Chris Beams
|
||||
*/
|
||||
public class ThreadLocalTargetSourceTests {
|
||||
class ThreadLocalTargetSourceTests {
|
||||
|
||||
/** Initial count value set in bean factory XML */
|
||||
private static final int INITIAL_COUNT = 10;
|
||||
@@ -60,7 +60,7 @@ public class ThreadLocalTargetSourceTests {
|
||||
* with one another.
|
||||
*/
|
||||
@Test
|
||||
public void testUseDifferentManagedInstancesInSameThread() {
|
||||
void testUseDifferentManagedInstancesInSameThread() {
|
||||
SideEffectBean apartment = (SideEffectBean) beanFactory.getBean("apartment");
|
||||
assertThat(apartment.getCount()).isEqualTo(INITIAL_COUNT);
|
||||
apartment.doWork();
|
||||
@@ -72,7 +72,7 @@ public class ThreadLocalTargetSourceTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReuseInSameThread() {
|
||||
void testReuseInSameThread() {
|
||||
SideEffectBean apartment = (SideEffectBean) beanFactory.getBean("apartment");
|
||||
assertThat(apartment.getCount()).isEqualTo(INITIAL_COUNT);
|
||||
apartment.doWork();
|
||||
@@ -86,7 +86,7 @@ public class ThreadLocalTargetSourceTests {
|
||||
* Relies on introduction.
|
||||
*/
|
||||
@Test
|
||||
public void testCanGetStatsViaMixin() {
|
||||
void testCanGetStatsViaMixin() {
|
||||
ThreadLocalTargetSourceStats stats = (ThreadLocalTargetSourceStats) beanFactory.getBean("apartment");
|
||||
// +1 because creating target for stats call counts
|
||||
assertThat(stats.getInvocationCount()).isEqualTo(1);
|
||||
@@ -104,7 +104,7 @@ public class ThreadLocalTargetSourceTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNewThreadHasOwnInstance() throws InterruptedException {
|
||||
void testNewThreadHasOwnInstance() throws InterruptedException {
|
||||
SideEffectBean apartment = (SideEffectBean) beanFactory.getBean("apartment");
|
||||
assertThat(apartment.getCount()).isEqualTo(INITIAL_COUNT);
|
||||
apartment.doWork();
|
||||
@@ -144,7 +144,7 @@ public class ThreadLocalTargetSourceTests {
|
||||
* Test for SPR-1442. Destroyed target should re-associated with thread and not throw NPE.
|
||||
*/
|
||||
@Test
|
||||
public void testReuseDestroyedTarget() {
|
||||
void testReuseDestroyedTarget() {
|
||||
ThreadLocalTargetSource source = (ThreadLocalTargetSource)this.beanFactory.getBean("threadLocalTs");
|
||||
|
||||
// try first time
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -27,13 +27,13 @@ import static org.springframework.core.testfixture.TestGroup.LONG_RUNNING;
|
||||
* @author Rob Harrop
|
||||
* @author Chris Beams
|
||||
*/
|
||||
public class RefreshableTargetSourceTests {
|
||||
class RefreshableTargetSourceTests {
|
||||
|
||||
/**
|
||||
* Test what happens when checking for refresh but not refreshing object.
|
||||
*/
|
||||
@Test
|
||||
public void testRefreshCheckWithNonRefresh() throws Exception {
|
||||
void testRefreshCheckWithNonRefresh() throws Exception {
|
||||
CountingRefreshableTargetSource ts = new CountingRefreshableTargetSource();
|
||||
ts.setRefreshCheckDelay(0);
|
||||
|
||||
@@ -49,7 +49,7 @@ public class RefreshableTargetSourceTests {
|
||||
* Test what happens when checking for refresh and refresh occurs.
|
||||
*/
|
||||
@Test
|
||||
public void testRefreshCheckWithRefresh() throws Exception {
|
||||
void testRefreshCheckWithRefresh() throws Exception {
|
||||
CountingRefreshableTargetSource ts = new CountingRefreshableTargetSource(true);
|
||||
ts.setRefreshCheckDelay(0);
|
||||
|
||||
@@ -65,7 +65,7 @@ public class RefreshableTargetSourceTests {
|
||||
* Test what happens when no refresh occurs.
|
||||
*/
|
||||
@Test
|
||||
public void testWithNoRefreshCheck() throws Exception {
|
||||
void testWithNoRefreshCheck() {
|
||||
CountingRefreshableTargetSource ts = new CountingRefreshableTargetSource(true);
|
||||
ts.setRefreshCheckDelay(-1);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user