diff --git a/org.springframework.testsuite/src/test/java/org/springframework/aop/aspectj/MethodInvocationProceedingJoinPointTests.java b/org.springframework.aop/src/test/java/org/springframework/aop/aspectj/MethodInvocationProceedingJoinPointTests.java similarity index 97% rename from org.springframework.testsuite/src/test/java/org/springframework/aop/aspectj/MethodInvocationProceedingJoinPointTests.java rename to org.springframework.aop/src/test/java/org/springframework/aop/aspectj/MethodInvocationProceedingJoinPointTests.java index 0238e8caeb..a32409dc58 100644 --- a/org.springframework.testsuite/src/test/java/org/springframework/aop/aspectj/MethodInvocationProceedingJoinPointTests.java +++ b/org.springframework.aop/src/test/java/org/springframework/aop/aspectj/MethodInvocationProceedingJoinPointTests.java @@ -16,15 +16,17 @@ package org.springframework.aop.aspectj; +import static org.junit.Assert.*; + import java.lang.reflect.Method; import java.util.Arrays; -import junit.framework.TestCase; import org.aspectj.lang.JoinPoint; import org.aspectj.lang.JoinPoint.StaticPart; import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.reflect.MethodSignature; import org.aspectj.lang.reflect.SourceLocation; +import org.junit.Test; import org.springframework.aop.MethodBeforeAdvice; import org.springframework.aop.framework.AopContext; @@ -36,10 +38,12 @@ import org.springframework.beans.TestBean; /** * @author Rod Johnson + * @author Chris Beams * @since 2.0 */ -public class MethodInvocationProceedingJoinPointTests extends TestCase { +public class MethodInvocationProceedingJoinPointTests { + @Test public void testingBindingWithJoinPoint() { try { AbstractAspectJAdvice.currentJoinPoint(); @@ -50,6 +54,7 @@ public class MethodInvocationProceedingJoinPointTests extends TestCase { } } + @Test public void testingBindingWithProceedingJoinPoint() { try { AbstractAspectJAdvice.currentJoinPoint(); @@ -60,6 +65,7 @@ public class MethodInvocationProceedingJoinPointTests extends TestCase { } } + @Test public void testCanGetMethodSignatureFromJoinPoint() { final Object raw = new TestBean(); // Will be set by advice during a method call @@ -128,6 +134,7 @@ public class MethodInvocationProceedingJoinPointTests extends TestCase { assertEquals("Advice reentrantly set age", newAge, itb.getAge()); } + @Test public void testCanGetSourceLocationFromJoinPoint() { final Object raw = new TestBean(); ProxyFactory pf = new ProxyFactory(raw); @@ -159,6 +166,7 @@ public class MethodInvocationProceedingJoinPointTests extends TestCase { itb.getAge(); } + @Test public void testCanGetStaticPartFromJoinPoint() { final Object raw = new TestBean(); ProxyFactory pf = new ProxyFactory(raw); diff --git a/org.springframework.testsuite/src/test/java/org/springframework/aop/aspectj/OverloadedAdviceTests.java b/org.springframework.testsuite/src/test/java/org/springframework/aop/aspectj/OverloadedAdviceTests.java index 42d60c89cf..4583fb0d21 100644 --- a/org.springframework.testsuite/src/test/java/org/springframework/aop/aspectj/OverloadedAdviceTests.java +++ b/org.springframework.testsuite/src/test/java/org/springframework/aop/aspectj/OverloadedAdviceTests.java @@ -16,18 +16,21 @@ package org.springframework.aop.aspectj; -import junit.framework.TestCase; +import static org.junit.Assert.*; +import org.junit.Test; import org.springframework.beans.factory.BeanCreationException; import org.springframework.context.support.ClassPathXmlApplicationContext; /** - * Tests for overloaded advice. + * Integration tests for overloaded advice. * * @author Adrian Colyer + * @author Chris Beams */ -public class OverloadedAdviceTests extends TestCase { +public class OverloadedAdviceTests { + @Test public void testExceptionOnConfigParsingWithMismatchedAdviceMethod() { try { new ClassPathXmlApplicationContext("org/springframework/aop/aspectj/overloaded-advice-tests.xml"); @@ -40,6 +43,7 @@ public class OverloadedAdviceTests extends TestCase { } } + @Test public void testExceptionOnConfigParsingWithAmbiguousAdviceMethod() { try { new ClassPathXmlApplicationContext("org/springframework/aop/aspectj/ambiguous-advice-tests.xml"); diff --git a/org.springframework.testsuite/src/test/java/org/springframework/aop/aspectj/PropertyDependentAspectTests.java b/org.springframework.testsuite/src/test/java/org/springframework/aop/aspectj/PropertyDependentAspectTests.java index 3fc5c6fa86..73b81a9ba1 100644 --- a/org.springframework.testsuite/src/test/java/org/springframework/aop/aspectj/PropertyDependentAspectTests.java +++ b/org.springframework.testsuite/src/test/java/org/springframework/aop/aspectj/PropertyDependentAspectTests.java @@ -16,8 +16,9 @@ package org.springframework.aop.aspectj; -import junit.framework.TestCase; +import static org.junit.Assert.*; +import org.junit.Test; import org.springframework.aop.framework.Advised; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; @@ -28,21 +29,26 @@ import org.springframework.context.support.ClassPathXmlApplicationContext; * * @author Ramnivas Laddad * @author Juergen Hoeller + * @author Chris Beams */ -public class PropertyDependentAspectTests extends TestCase { +public class PropertyDependentAspectTests { + @Test public void testPropertyDependentAspectWithPropertyDeclaredBeforeAdvice() throws Exception { checkXmlAspect("org/springframework/aop/aspectj/property-dependent-aspect-property-before-aspect-test.xml"); } + @Test public void testPropertyDependentAspectWithPropertyDeclaredAfterAdvice() throws Exception { checkXmlAspect("org/springframework/aop/aspectj/property-dependent-aspect-property-after-aspect-test.xml"); } + @Test public void testPropertyDependentAtAspectJAspectWithPropertyDeclaredBeforeAdvice() throws Exception { checkAtAspectJAspect("org/springframework/aop/aspectj/property-dependent-atAspectJ-aspect-property-before-aspect-test.xml"); } + @Test public void testPropertyDependentAtAspectJAspectWithPropertyDeclaredAfterAdvice() throws Exception { checkAtAspectJAspect("org/springframework/aop/aspectj/property-dependent-atAspectJ-aspect-property-after-aspect-test.xml"); } diff --git a/org.springframework.testsuite/src/test/java/org/springframework/aop/aspectj/TigerAspectJExpressionPointcutTests.java b/org.springframework.testsuite/src/test/java/org/springframework/aop/aspectj/TigerAspectJExpressionPointcutTests.java index b371fe2d3a..93a5470c3b 100644 --- a/org.springframework.testsuite/src/test/java/org/springframework/aop/aspectj/TigerAspectJExpressionPointcutTests.java +++ b/org.springframework.testsuite/src/test/java/org/springframework/aop/aspectj/TigerAspectJExpressionPointcutTests.java @@ -16,6 +16,8 @@ package org.springframework.aop.aspectj; +import static org.junit.Assert.*; + import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; @@ -25,8 +27,8 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import junit.framework.TestCase; - +import org.junit.Before; +import org.junit.Test; import org.springframework.beans.TestBean; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.simple.SimpleJdbcTemplate; @@ -39,8 +41,9 @@ import org.springframework.transaction.annotation.Transactional; * Java5-specific AspectJExpressionPointcutTests. * * @author Rod Johnson + * @author Chris Beams */ -public class TigerAspectJExpressionPointcutTests extends TestCase { +public class TigerAspectJExpressionPointcutTests { // TODO factor into static in AspectJExpressionPointcut private Method getAge; @@ -48,6 +51,7 @@ public class TigerAspectJExpressionPointcutTests extends TestCase { private Map methodsOnHasGeneric = new HashMap(); + @Before public void setUp() throws NoSuchMethodException { getAge = TestBean.class.getMethod("getAge", (Class[]) null); // Assumes no overloading @@ -69,6 +73,7 @@ public class TigerAspectJExpressionPointcutTests extends TestCase { } } + @Test public void testMatchGenericArgument() { String expression = "execution(* set*(java.util.List) )"; AspectJExpressionPointcut ajexp = new AspectJExpressionPointcut(); @@ -87,6 +92,7 @@ public class TigerAspectJExpressionPointcutTests extends TestCase { assertFalse(ajexp.matches(getAge, TestBean.class)); } + @Test public void testMatchVarargs() throws SecurityException, NoSuchMethodException { String expression = "execution(int *.*(String, Object...))"; AspectJExpressionPointcut jdbcVarArgs = new AspectJExpressionPointcut(); @@ -109,16 +115,19 @@ public class TigerAspectJExpressionPointcutTests extends TestCase { assertFalse(jdbcVarArgs.matches(getAge, TestBean.class)); } + @Test public void testMatchAnnotationOnClassWithAtWithin() throws SecurityException, NoSuchMethodException { String expression = "@within(org.springframework.transaction.annotation.Transactional)"; testMatchAnnotationOnClass(expression); } + @Test public void testMatchAnnotationOnClassWithoutBinding() throws SecurityException, NoSuchMethodException { String expression = "within(@org.springframework.transaction.annotation.Transactional *)"; testMatchAnnotationOnClass(expression); } + @Test public void testMatchAnnotationOnClassWithSubpackageWildcard() throws SecurityException, NoSuchMethodException { String expression = "within(@(org.springframework..*) *)"; AspectJExpressionPointcut springAnnotatedPc = testMatchAnnotationOnClass(expression); @@ -133,6 +142,7 @@ public class TigerAspectJExpressionPointcutTests extends TestCase { SpringAnnotated.class)); } + @Test public void testMatchAnnotationOnClassWithExactPackageWildcard() throws SecurityException, NoSuchMethodException { String expression = "within(@(org.springframework.transaction.annotation.*) *)"; testMatchAnnotationOnClass(expression); @@ -150,6 +160,7 @@ public class TigerAspectJExpressionPointcutTests extends TestCase { return ajexp; } + @Test public void testAnnotationOnMethodWithFQN() throws SecurityException, NoSuchMethodException { String expression = "@annotation(org.springframework.transaction.annotation.Transactional)"; AspectJExpressionPointcut ajexp = new AspectJExpressionPointcut(); @@ -163,6 +174,7 @@ public class TigerAspectJExpressionPointcutTests extends TestCase { assertFalse(ajexp.matches(AnnotationTransactionAttributeSourceTests.TestBean3.class.getMethod("setName", String.class), TestBean3.class)); } + @Test public void testAnnotationOnMethodWithWildcard() throws SecurityException, NoSuchMethodException { String expression = "execution(@(org.springframework..*) * *(..))"; AspectJExpressionPointcut anySpringMethodAnnotation = new AspectJExpressionPointcut(); @@ -176,6 +188,7 @@ public class TigerAspectJExpressionPointcutTests extends TestCase { assertFalse(anySpringMethodAnnotation.matches(AnnotationTransactionAttributeSourceTests.TestBean3.class.getMethod("setName", String.class), TestBean3.class)); } + @Test public void testAnnotationOnMethodArgumentsWithFQN() throws SecurityException, NoSuchMethodException { String expression = "@args(*, org.springframework.aop.aspectj.TigerAspectJExpressionPointcutTests.EmptySpringAnnotation))"; AspectJExpressionPointcut takesSpringAnnotatedArgument2 = new AspectJExpressionPointcut(); @@ -204,6 +217,7 @@ public class TigerAspectJExpressionPointcutTests extends TestCase { ); } + @Test public void testAnnotationOnMethodArgumentsWithWildcards() throws SecurityException, NoSuchMethodException { String expression = "execution(* *(*, @(org.springframework..*) *))"; AspectJExpressionPointcut takesSpringAnnotatedArgument2 = new AspectJExpressionPointcut();