From 7bba0b7a690a5e6d5625d3b5cc3c71d0eee4494e Mon Sep 17 00:00:00 2001 From: Chris Beams Date: Thu, 11 Dec 2008 23:35:15 +0000 Subject: [PATCH] moving unit tests from .testsuite -> .aop --- .../aspectj/BeanNamePointcutMatchingTests.java | 11 ++++++++--- .../autoproxy/AtAspectJAfterThrowingTests.java | 7 +++++-- .../autoproxy/benchmark/BenchmarkTests.java | 16 +++++++++++++--- 3 files changed, 26 insertions(+), 8 deletions(-) rename {org.springframework.testsuite => org.springframework.aop}/src/test/java/org/springframework/aop/aspectj/BeanNamePointcutMatchingTests.java (92%) diff --git a/org.springframework.testsuite/src/test/java/org/springframework/aop/aspectj/BeanNamePointcutMatchingTests.java b/org.springframework.aop/src/test/java/org/springframework/aop/aspectj/BeanNamePointcutMatchingTests.java similarity index 92% rename from org.springframework.testsuite/src/test/java/org/springframework/aop/aspectj/BeanNamePointcutMatchingTests.java rename to org.springframework.aop/src/test/java/org/springframework/aop/aspectj/BeanNamePointcutMatchingTests.java index df40ef37bdc..90f7b00d5d9 100644 --- a/org.springframework.testsuite/src/test/java/org/springframework/aop/aspectj/BeanNamePointcutMatchingTests.java +++ b/org.springframework.aop/src/test/java/org/springframework/aop/aspectj/BeanNamePointcutMatchingTests.java @@ -16,17 +16,20 @@ package org.springframework.aop.aspectj; -import junit.framework.TestCase; +import static org.junit.Assert.*; +import org.junit.Test; import org.springframework.beans.TestBean; /** * Tests for matching of bean() pointcut designator. * * @author Ramnivas Laddad + * @author Chris Beams */ -public class BeanNamePointcutMatchingTests extends TestCase { +public class BeanNamePointcutMatchingTests { + @Test public void testMatchingPointcuts() { assertMatch("someName", "bean(someName)"); @@ -61,6 +64,7 @@ public class BeanNamePointcutMatchingTests extends TestCase { assertMatch("someName", "bean(someName) && !bean(someOtherName)"); } + @Test public void testNonMatchingPointcuts() { assertMisMatch("someName", "bean(someNamex)"); assertMisMatch("someName", "bean(someX*Name)"); @@ -82,7 +86,8 @@ public class BeanNamePointcutMatchingTests extends TestCase { matches(beanName, pcExpression)); } - private static boolean matches(final String beanName, String pcExpression) { + private static boolean matches(final String beanName, String pcExpression) { + @SuppressWarnings("serial") AspectJExpressionPointcut pointcut = new AspectJExpressionPointcut() { protected String getCurrentProxiedBeanName() { return beanName; diff --git a/org.springframework.testsuite/src/test/java/org/springframework/aop/aspectj/autoproxy/AtAspectJAfterThrowingTests.java b/org.springframework.testsuite/src/test/java/org/springframework/aop/aspectj/autoproxy/AtAspectJAfterThrowingTests.java index 1952ea3d4a8..ba835346c52 100644 --- a/org.springframework.testsuite/src/test/java/org/springframework/aop/aspectj/autoproxy/AtAspectJAfterThrowingTests.java +++ b/org.springframework.testsuite/src/test/java/org/springframework/aop/aspectj/autoproxy/AtAspectJAfterThrowingTests.java @@ -16,7 +16,9 @@ package org.springframework.aop.aspectj.autoproxy; -import junit.framework.TestCase; +import static org.junit.Assert.*; + +import org.junit.Test; import org.springframework.beans.ITestBean; import org.springframework.aop.support.AopUtils; import org.springframework.context.support.ClassPathXmlApplicationContext; @@ -27,8 +29,9 @@ import java.io.IOException; * @author Rob Harrop * @since 2.0 */ -public class AtAspectJAfterThrowingTests extends TestCase { +public class AtAspectJAfterThrowingTests { + @Test public void testAccessThrowable() throws Exception { ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("afterThrowingAdviceTests.xml", getClass()); diff --git a/org.springframework.testsuite/src/test/java/org/springframework/aop/aspectj/autoproxy/benchmark/BenchmarkTests.java b/org.springframework.testsuite/src/test/java/org/springframework/aop/aspectj/autoproxy/benchmark/BenchmarkTests.java index 69a1219d5d9..9895e299195 100644 --- a/org.springframework.testsuite/src/test/java/org/springframework/aop/aspectj/autoproxy/benchmark/BenchmarkTests.java +++ b/org.springframework.testsuite/src/test/java/org/springframework/aop/aspectj/autoproxy/benchmark/BenchmarkTests.java @@ -16,8 +16,9 @@ package org.springframework.aop.aspectj.autoproxy.benchmark; -import junit.framework.TestCase; +import static org.junit.Assert.*; +import org.junit.Test; import org.springframework.aop.framework.Advised; import org.springframework.aop.support.AopUtils; import org.springframework.beans.ITestBean; @@ -25,12 +26,13 @@ import org.springframework.context.support.ClassPathXmlApplicationContext; import org.springframework.util.StopWatch; /** - * Tests for AspectJ auto proxying. Includes mixing with Spring AOP + * Integration tests for AspectJ auto proxying. Includes mixing with Spring AOP * Advisors to demonstrate that existing autoproxying contract is honoured. * * @author Rod Johnson + * @author Chris Beams */ -public class BenchmarkTests extends TestCase { +public class BenchmarkTests { private static final String ASPECTJ_CONTEXT = "/org/springframework/aop/aspectj/autoproxy/benchmark/aspectj.xml"; @@ -43,34 +45,42 @@ public class BenchmarkTests extends TestCase { return 10; } + @Test public void testRepeatedAroundAdviceInvocationsWithAspectJ() { testRepeatedAroundAdviceInvocations(ASPECTJ_CONTEXT, getCount(), "AspectJ"); } + @Test public void testRepeatedAroundAdviceInvocationsWithSpringAop() { testRepeatedAroundAdviceInvocations(SPRING_AOP_CONTEXT, getCount(), "Spring AOP"); } + @Test public void testRepeatedBeforeAdviceInvocationsWithAspectJ() { testBeforeAdviceWithoutJoinPoint(ASPECTJ_CONTEXT, getCount(), "AspectJ"); } + @Test public void testRepeatedBeforeAdviceInvocationsWithSpringAop() { testBeforeAdviceWithoutJoinPoint(SPRING_AOP_CONTEXT, getCount(), "Spring AOP"); } + @Test public void testRepeatedAfterReturningAdviceInvocationsWithAspectJ() { testAfterReturningAdviceWithoutJoinPoint(ASPECTJ_CONTEXT, getCount(), "AspectJ"); } + @Test public void testRepeatedAfterReturningAdviceInvocationsWithSpringAop() { testAfterReturningAdviceWithoutJoinPoint(SPRING_AOP_CONTEXT, getCount(), "Spring AOP"); } + @Test public void testRepeatedMixWithAspectJ() { testMix(ASPECTJ_CONTEXT, getCount(), "AspectJ"); } + @Test public void testRepeatedMixWithSpringAop() { testMix(SPRING_AOP_CONTEXT, getCount(), "Spring AOP"); }