moving unit tests from .testsuite -> .aop

This commit is contained in:
Chris Beams 2008-12-11 23:35:15 +00:00
parent c373688c00
commit 7bba0b7a69
3 changed files with 26 additions and 8 deletions

View File

@ -16,17 +16,20 @@
package org.springframework.aop.aspectj; package org.springframework.aop.aspectj;
import junit.framework.TestCase; import static org.junit.Assert.*;
import org.junit.Test;
import org.springframework.beans.TestBean; import org.springframework.beans.TestBean;
/** /**
* Tests for matching of bean() pointcut designator. * Tests for matching of bean() pointcut designator.
* *
* @author Ramnivas Laddad * @author Ramnivas Laddad
* @author Chris Beams
*/ */
public class BeanNamePointcutMatchingTests extends TestCase { public class BeanNamePointcutMatchingTests {
@Test
public void testMatchingPointcuts() { public void testMatchingPointcuts() {
assertMatch("someName", "bean(someName)"); assertMatch("someName", "bean(someName)");
@ -61,6 +64,7 @@ public class BeanNamePointcutMatchingTests extends TestCase {
assertMatch("someName", "bean(someName) && !bean(someOtherName)"); assertMatch("someName", "bean(someName) && !bean(someOtherName)");
} }
@Test
public void testNonMatchingPointcuts() { public void testNonMatchingPointcuts() {
assertMisMatch("someName", "bean(someNamex)"); assertMisMatch("someName", "bean(someNamex)");
assertMisMatch("someName", "bean(someX*Name)"); assertMisMatch("someName", "bean(someX*Name)");
@ -83,6 +87,7 @@ public class BeanNamePointcutMatchingTests extends TestCase {
} }
private static boolean matches(final String beanName, String pcExpression) { private static boolean matches(final String beanName, String pcExpression) {
@SuppressWarnings("serial")
AspectJExpressionPointcut pointcut = new AspectJExpressionPointcut() { AspectJExpressionPointcut pointcut = new AspectJExpressionPointcut() {
protected String getCurrentProxiedBeanName() { protected String getCurrentProxiedBeanName() {
return beanName; return beanName;

View File

@ -16,7 +16,9 @@
package org.springframework.aop.aspectj.autoproxy; 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.beans.ITestBean;
import org.springframework.aop.support.AopUtils; import org.springframework.aop.support.AopUtils;
import org.springframework.context.support.ClassPathXmlApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext;
@ -27,8 +29,9 @@ import java.io.IOException;
* @author Rob Harrop * @author Rob Harrop
* @since 2.0 * @since 2.0
*/ */
public class AtAspectJAfterThrowingTests extends TestCase { public class AtAspectJAfterThrowingTests {
@Test
public void testAccessThrowable() throws Exception { public void testAccessThrowable() throws Exception {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("afterThrowingAdviceTests.xml", getClass()); ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("afterThrowingAdviceTests.xml", getClass());

View File

@ -16,8 +16,9 @@
package org.springframework.aop.aspectj.autoproxy.benchmark; 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.framework.Advised;
import org.springframework.aop.support.AopUtils; import org.springframework.aop.support.AopUtils;
import org.springframework.beans.ITestBean; import org.springframework.beans.ITestBean;
@ -25,12 +26,13 @@ import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.util.StopWatch; 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. * Advisors to demonstrate that existing autoproxying contract is honoured.
* *
* @author Rod Johnson * @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"; 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; return 10;
} }
@Test
public void testRepeatedAroundAdviceInvocationsWithAspectJ() { public void testRepeatedAroundAdviceInvocationsWithAspectJ() {
testRepeatedAroundAdviceInvocations(ASPECTJ_CONTEXT, getCount(), "AspectJ"); testRepeatedAroundAdviceInvocations(ASPECTJ_CONTEXT, getCount(), "AspectJ");
} }
@Test
public void testRepeatedAroundAdviceInvocationsWithSpringAop() { public void testRepeatedAroundAdviceInvocationsWithSpringAop() {
testRepeatedAroundAdviceInvocations(SPRING_AOP_CONTEXT, getCount(), "Spring AOP"); testRepeatedAroundAdviceInvocations(SPRING_AOP_CONTEXT, getCount(), "Spring AOP");
} }
@Test
public void testRepeatedBeforeAdviceInvocationsWithAspectJ() { public void testRepeatedBeforeAdviceInvocationsWithAspectJ() {
testBeforeAdviceWithoutJoinPoint(ASPECTJ_CONTEXT, getCount(), "AspectJ"); testBeforeAdviceWithoutJoinPoint(ASPECTJ_CONTEXT, getCount(), "AspectJ");
} }
@Test
public void testRepeatedBeforeAdviceInvocationsWithSpringAop() { public void testRepeatedBeforeAdviceInvocationsWithSpringAop() {
testBeforeAdviceWithoutJoinPoint(SPRING_AOP_CONTEXT, getCount(), "Spring AOP"); testBeforeAdviceWithoutJoinPoint(SPRING_AOP_CONTEXT, getCount(), "Spring AOP");
} }
@Test
public void testRepeatedAfterReturningAdviceInvocationsWithAspectJ() { public void testRepeatedAfterReturningAdviceInvocationsWithAspectJ() {
testAfterReturningAdviceWithoutJoinPoint(ASPECTJ_CONTEXT, getCount(), "AspectJ"); testAfterReturningAdviceWithoutJoinPoint(ASPECTJ_CONTEXT, getCount(), "AspectJ");
} }
@Test
public void testRepeatedAfterReturningAdviceInvocationsWithSpringAop() { public void testRepeatedAfterReturningAdviceInvocationsWithSpringAop() {
testAfterReturningAdviceWithoutJoinPoint(SPRING_AOP_CONTEXT, getCount(), "Spring AOP"); testAfterReturningAdviceWithoutJoinPoint(SPRING_AOP_CONTEXT, getCount(), "Spring AOP");
} }
@Test
public void testRepeatedMixWithAspectJ() { public void testRepeatedMixWithAspectJ() {
testMix(ASPECTJ_CONTEXT, getCount(), "AspectJ"); testMix(ASPECTJ_CONTEXT, getCount(), "AspectJ");
} }
@Test
public void testRepeatedMixWithSpringAop() { public void testRepeatedMixWithSpringAop() {
testMix(SPRING_AOP_CONTEXT, getCount(), "Spring AOP"); testMix(SPRING_AOP_CONTEXT, getCount(), "Spring AOP");
} }