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.

PR691.java 1.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. import org.aspectj.testing.*;
  2. /** @testcase PR#691 around AST type XXX */
  3. public class PR691 {
  4. public static void main (String[] args) {
  5. Tester.expectEvent("around");
  6. new MailerTest().run(new TestResult());
  7. Tester.checkAllEvents();
  8. }
  9. }
  10. class TestResult {}
  11. class Message {}
  12. class MailerTest {
  13. public void run(TestResult result) {
  14. new Mailer().sendTextMail();
  15. }
  16. }
  17. class Mailer {
  18. public void sendTextMail(){
  19. new Transport().send(new Message());
  20. }
  21. }
  22. class Transport { public void send(Message m){ } }
  23. aspect Mail {
  24. pointcut inThisTestCase(MailerTest testCase) :
  25. call(* MailerTest.run(TestResult))
  26. && target(testCase);
  27. pointcut flowOfTestCase(MailerTest testCase) :
  28. cflow(inThisTestCase(testCase));
  29. pointcut sendMailCall() : call(void Mailer.sendTextMail(..));
  30. pointcut transportSend(Message msg) :
  31. call(void Transport.send(Message)) && args(msg);
  32. // no bug if no testCase context
  33. //void around(Message msg) :
  34. // flowOfTestCase(MailerTest)
  35. void around(Message msg, final MailerTest testCase) :
  36. flowOfTestCase(testCase)
  37. && cflow(sendMailCall())
  38. && transportSend(msg) {
  39. Tester.event("around");
  40. proceed(msg,testCase);
  41. }
  42. }