Browse Source

moving unit tests from .testsuite -> .aop

conversation
Chris Beams 16 years ago
parent
commit
2b7bc1ea58
  1. 35
      org.springframework.aop/src/test/java/example/aspects/PerTargetAspect.java
  2. 2
      org.springframework.aop/src/test/java/example/aspects/PerThisAspect.java
  3. 24
      org.springframework.aop/src/test/java/example/aspects/TwoAdviceAspect.java
  4. 68
      org.springframework.aop/src/test/java/org/springframework/aop/aspectj/annotation/AbstractAspectJAdvisorFactoryTests.java
  5. 4
      org.springframework.aop/src/test/java/org/springframework/aop/aspectj/annotation/AspectJPointcutAdvisorTests.java
  6. 4
      org.springframework.aop/src/test/java/org/springframework/aop/aspectj/annotation/AspectMetadataTests.java
  7. 3
      org.springframework.aop/src/test/java/org/springframework/aop/aspectj/annotation/AspectProxyFactoryTests.java
  8. 31
      org.springframework.aop/src/test/java/org/springframework/aop/aspectj/annotation/PerThisAspect.java

35
org.springframework.aop/src/test/java/example/aspects/PerTargetAspect.java

@ -0,0 +1,35 @@ @@ -0,0 +1,35 @@
/**
*
*/
package example.aspects;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.springframework.core.Ordered;
@Aspect("pertarget(execution(* *.getSpouse()))")
public class PerTargetAspect implements Ordered {
public int count;
private int order = Ordered.LOWEST_PRECEDENCE;
@Around("execution(int *.getAge())")
public int returnCountAsAge() {
return count++;
}
@Before("execution(void *.set*(int))")
public void countSetter() {
++count;
}
public int getOrder() {
return this.order;
}
public void setOrder(int order) {
this.order = order;
}
}

2
org.springframework.aop/src/test/java/org/springframework/aop/aspectj/autoproxy/PerThisAspect.java → org.springframework.aop/src/test/java/example/aspects/PerThisAspect.java

@ -14,7 +14,7 @@ @@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.aop.aspectj.autoproxy;
package example.aspects;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;

24
org.springframework.aop/src/test/java/example/aspects/TwoAdviceAspect.java

@ -0,0 +1,24 @@ @@ -0,0 +1,24 @@
/**
*
*/
package example.aspects;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
@Aspect
public class TwoAdviceAspect {
private int totalCalls;
@Around("execution(* getAge())")
public int returnCallCount(ProceedingJoinPoint pjp) throws Exception {
return totalCalls;
}
@Before("execution(* setAge(int)) && args(newAge)")
public void countSet(int newAge) throws Exception {
++totalCalls;
}
}

68
org.springframework.aop/src/test/java/org/springframework/aop/aspectj/annotation/AbstractAspectJAdvisorFactoryTests.java

@ -49,6 +49,9 @@ import org.springframework.core.OrderComparator; @@ -49,6 +49,9 @@ import org.springframework.core.OrderComparator;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import example.aspects.PerTargetAspect;
import example.aspects.TwoAdviceAspect;
/**
* Abstract tests for AspectJAdvisorFactory.
* See subclasses for tests of concrete factories.
@ -593,33 +596,6 @@ public abstract class AbstractAspectJAdvisorFactoryTests { @@ -593,33 +596,6 @@ public abstract class AbstractAspectJAdvisorFactoryTests {
}
@Aspect("pertarget(execution(* *.getSpouse()))")
public static class PerTargetAspect implements Ordered {
public int count;
private int order = Ordered.LOWEST_PRECEDENCE;
@Around("execution(int *.getAge())")
public int returnCountAsAge() {
return count++;
}
@Before("execution(void *.set*(int))")
public void countSetter() {
++count;
}
public int getOrder() {
return this.order;
}
public void setOrder(int order) {
this.order = order;
}
}
@Aspect("pertarget(execution(* *.getSpouse()))")
@Order(10)
public static class PerTargetAspectWithOrderAnnotation10 {
@ -656,28 +632,6 @@ public abstract class AbstractAspectJAdvisorFactoryTests { @@ -656,28 +632,6 @@ public abstract class AbstractAspectJAdvisorFactoryTests {
}
@Aspect("perthis(execution(* *.getSpouse()))")
public static class PerThisAspect {
public int count;
/**
* Just to check that this doesn't cause problems with introduction processing
*/
private ITestBean fieldThatShouldBeIgnoredBySpringAtAspectJProcessing = new TestBean();
@Around("execution(int *.getAge())")
public int returnCountAsAge() {
return count++;
}
@Before("execution(void *.set*(int))")
public void countSetter() {
++count;
}
}
@Aspect("pertypewithin(org.springframework.beans.IOther+)")
public static class PerTypeWithinAspect {
@ -833,22 +787,6 @@ public abstract class AbstractAspectJAdvisorFactoryTests { @@ -833,22 +787,6 @@ public abstract class AbstractAspectJAdvisorFactoryTests {
}
@Aspect
public static class TwoAdviceAspect {
private int totalCalls;
@Around("execution(* getAge())")
public int returnCallCount(ProceedingJoinPoint pjp) throws Exception {
return totalCalls;
}
@Before("execution(* setAge(int)) && args(newAge)")
public void countSet(int newAge) throws Exception {
++totalCalls;
}
}
public static class Echo {
public Object echo(Object o) throws Exception {

4
org.springframework.aop/src/test/java/org/springframework/aop/aspectj/annotation/AspectJPointcutAdvisorTests.java

@ -25,6 +25,8 @@ import org.springframework.aop.aspectj.AspectJExpressionPointcutTests; @@ -25,6 +25,8 @@ import org.springframework.aop.aspectj.AspectJExpressionPointcutTests;
import org.springframework.aop.framework.AopConfigException;
import org.springframework.beans.TestBean;
import example.aspects.PerTargetAspect;
/**
* @author Rod Johnson
* @author Chris Beams
@ -51,7 +53,7 @@ public class AspectJPointcutAdvisorTests { @@ -51,7 +53,7 @@ public class AspectJPointcutAdvisorTests {
ajexp.setExpression(AspectJExpressionPointcutTests.MATCH_ALL_METHODS);
InstantiationModelAwarePointcutAdvisorImpl ajpa = new InstantiationModelAwarePointcutAdvisorImpl(af, ajexp,
new SingletonMetadataAwareAspectInstanceFactory(new AbstractAspectJAdvisorFactoryTests.PerTargetAspect(),"someBean"), null, 1, "someBean");
new SingletonMetadataAwareAspectInstanceFactory(new PerTargetAspect(),"someBean"), null, 1, "someBean");
assertNotSame(Pointcut.TRUE, ajpa.getAspectMetadata().getPerClausePointcut());
assertTrue(ajpa.getAspectMetadata().getPerClausePointcut() instanceof AspectJExpressionPointcut);
assertTrue(ajpa.isPerInstance());

4
org.springframework.aop/src/test/java/org/springframework/aop/aspectj/annotation/AspectMetadataTests.java

@ -22,8 +22,8 @@ import org.junit.Test; @@ -22,8 +22,8 @@ import org.junit.Test;
import org.springframework.aop.Pointcut;
import org.springframework.aop.aspectj.annotation.AbstractAspectJAdvisorFactoryTests.ExceptionAspect;
import org.springframework.aop.aspectj.annotation.AbstractAspectJAdvisorFactoryTests.PerTargetAspect;
import org.springframework.aop.aspectj.annotation.AbstractAspectJAdvisorFactoryTests.PerThisAspect;
import example.aspects.PerTargetAspect;
/**
* @since 2.0

3
org.springframework.aop/src/test/java/org/springframework/aop/aspectj/annotation/AspectProxyFactoryTests.java

@ -20,7 +20,8 @@ import static org.junit.Assert.*; @@ -20,7 +20,8 @@ import static org.junit.Assert.*;
import org.junit.Test;
import org.springframework.aop.aspectj.autoproxy.MultiplyReturnValue;
import org.springframework.aop.aspectj.autoproxy.PerThisAspect;
import example.aspects.PerThisAspect;
/**
* @author Rob Harrop

31
org.springframework.aop/src/test/java/org/springframework/aop/aspectj/annotation/PerThisAspect.java

@ -0,0 +1,31 @@ @@ -0,0 +1,31 @@
/**
*
*/
package org.springframework.aop.aspectj.annotation;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.springframework.beans.ITestBean;
import org.springframework.beans.TestBean;
@Aspect("perthis(execution(* *.getSpouse()))")
public class PerThisAspect {
public int count;
/**
* Just to check that this doesn't cause problems with introduction processing
*/
private ITestBean fieldThatShouldBeIgnoredBySpringAtAspectJProcessing = new TestBean();
@Around("execution(int *.getAge())")
public int returnCountAsAge() {
return count++;
}
@Before("execution(void *.set*(int))")
public void countSetter() {
++count;
}
}
Loading…
Cancel
Save