You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

JoinPointClosureTest.java 1.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /*
  2. * Created on 07-May-2004
  3. *
  4. * TODO To change the template for this generated file go to
  5. * Window - Preferences - Java - Code Generation - Code and Comments
  6. */
  7. package org.aspectj.aopalliance.tests;
  8. import java.lang.reflect.AccessibleObject;
  9. import junit.framework.TestCase;
  10. import org.aspectj.aopalliance.JoinPointClosure;
  11. import org.aspectj.lang.JoinPoint;
  12. /**
  13. * @author colyer
  14. *
  15. * TODO To change the template for this generated type comment go to
  16. * Window - Preferences - Java - Code Generation - Code and Comments
  17. */
  18. public class JoinPointClosureTest extends TestCase {
  19. public void testGetThis() {
  20. JoinPoint jp = new MockJoinPoint(this,null,null);
  21. JoinPointClosure jpc = new JoinPointClosure(jp) {
  22. public Object execute() {return null;}
  23. public AccessibleObject getStaticPart() {return null;}};
  24. assertEquals("getThis returns join point 'this'",this,jpc.getThis());
  25. }
  26. public void testProceed() {
  27. JoinPoint jp = new MockJoinPoint(this,null,null);
  28. JoinPointClosure jpc = new JoinPointClosure(jp) {
  29. public Object execute() {return this;}
  30. public AccessibleObject getStaticPart() {return null;}};
  31. try {
  32. Object ret = jpc.proceed();
  33. assertTrue("should return value from execute",ret instanceof JoinPointClosure);
  34. } catch (Throwable e) {
  35. fail("Exception proceeding on join point : " + e);
  36. }
  37. }
  38. }