public void testAtArgs() {
    PointcutExpression atArgs =
        parser.parsePointcutExpression(
            "@args(..,org.aspectj.weaver.tools.Java15PointcutExpressionTest.MyAnnotation)");
    ShadowMatch sMatch1 = atArgs.matchesMethodExecution(a);
    ShadowMatch sMatch2 = atArgs.matchesMethodExecution(c);
    assertTrue("never matches A", sMatch1.neverMatches());
    assertTrue("maybe matches C", sMatch2.maybeMatches());
    JoinPointMatch jp2 =
        sMatch2.matchesJoinPoint(new B(), new B(), new Object[] {new A(), new B()});
    assertTrue("matches", jp2.matches());

    atArgs =
        parser.parsePointcutExpression(
            "@args(org.aspectj.weaver.tools.Java15PointcutExpressionTest.MyAnnotation,org.aspectj.weaver.tools.Java15PointcutExpressionTest.MyAnnotation)");
    sMatch1 = atArgs.matchesMethodExecution(a);
    sMatch2 = atArgs.matchesMethodExecution(c);
    assertTrue("never matches A", sMatch1.neverMatches());
    assertTrue("maybe matches C", sMatch2.maybeMatches());
    JoinPointMatch jp1 =
        sMatch2.matchesJoinPoint(new A(), new A(), new Object[] {new A(), new B()});
    assertFalse("does not match", jp1.matches());
    jp2 = sMatch2.matchesJoinPoint(new B(), new B(), new Object[] {new B(), new B()});
    assertTrue("matches", jp2.matches());
  }
 public void testAtTarget() {
   PointcutExpression atTarget =
       parser.parsePointcutExpression(
           "@target(org.aspectj.weaver.tools.Java15PointcutExpressionTest.MyAnnotation)");
   ShadowMatch sMatch1 = atTarget.matchesMethodExecution(a);
   ShadowMatch sMatch2 = atTarget.matchesMethodExecution(b);
   assertTrue("maybe matches A", sMatch1.maybeMatches());
   assertTrue("maybe matches B", sMatch2.maybeMatches());
   JoinPointMatch jp1 = sMatch1.matchesJoinPoint(new A(), new A(), new Object[0]);
   assertFalse("does not match", jp1.matches());
   JoinPointMatch jp2 = sMatch2.matchesJoinPoint(new B(), new B(), new Object[0]);
   assertTrue("matches", jp2.matches());
 }
 public void testAtTargetWithBinding() {
   PointcutParameter param = parser.createPointcutParameter("a", MyAnnotation.class);
   B myB = new B();
   MyAnnotation bAnnotation = B.class.getAnnotation(MyAnnotation.class);
   PointcutExpression atThis =
       parser.parsePointcutExpression("@target(a)", A.class, new PointcutParameter[] {param});
   ShadowMatch sMatch1 = atThis.matchesMethodExecution(a);
   ShadowMatch sMatch2 = atThis.matchesMethodExecution(b);
   assertTrue("maybe matches A", sMatch1.maybeMatches());
   assertTrue("maybe matches B", sMatch2.maybeMatches());
   JoinPointMatch jp1 = sMatch1.matchesJoinPoint(new A(), new A(), new Object[0]);
   assertFalse("does not match", jp1.matches());
   JoinPointMatch jp2 = sMatch2.matchesJoinPoint(myB, myB, new Object[0]);
   assertTrue("matches", jp2.matches());
   assertEquals(1, jp2.getParameterBindings().length);
   assertEquals(
       "should be myB's annotation", bAnnotation, jp2.getParameterBindings()[0].getBinding());
 }
  public void testReferencePointcutParams() {
    PointcutParameter p1 = parser.createPointcutParameter("x", A.class);
    PointcutExpression pc =
        parser.parsePointcutExpression("goo(x)", C.class, new PointcutParameter[] {p1});

    ShadowMatch sMatch1 = pc.matchesMethodCall(a, b);
    ShadowMatch sMatch2 = pc.matchesMethodExecution(a);
    assertTrue("no match on call", sMatch1.neverMatches());
    assertTrue("match on execution", sMatch2.maybeMatches());
    A anA = new A();
    JoinPointMatch jpm = sMatch2.matchesJoinPoint(anA, new A(), new Object[0]);
    assertTrue(jpm.matches());
    assertEquals("should be bound to anA", anA, jpm.getParameterBindings()[0].getBinding());
  }
  public void testAtArgsWithBinding() {
    PointcutParameter p1 = parser.createPointcutParameter("a", MyAnnotation.class);
    PointcutParameter p2 = parser.createPointcutParameter("b", MyAnnotation.class);
    PointcutExpression atArgs =
        parser.parsePointcutExpression("@args(..,a)", A.class, new PointcutParameter[] {p1});
    ShadowMatch sMatch2 = atArgs.matchesMethodExecution(c);
    assertTrue("maybe matches C", sMatch2.maybeMatches());
    JoinPointMatch jp2 =
        sMatch2.matchesJoinPoint(new B(), new B(), new Object[] {new A(), new B()});
    assertTrue("matches", jp2.matches());
    assertEquals(1, jp2.getParameterBindings().length);
    MyAnnotation bAnnotation = B.class.getAnnotation(MyAnnotation.class);
    assertEquals("annotation on B", bAnnotation, jp2.getParameterBindings()[0].getBinding());

    atArgs =
        parser.parsePointcutExpression("@args(a,b)", A.class, new PointcutParameter[] {p1, p2});
    sMatch2 = atArgs.matchesMethodExecution(c);
    assertTrue("maybe matches C", sMatch2.maybeMatches());
    jp2 = sMatch2.matchesJoinPoint(new B(), new B(), new Object[] {new B(), new B()});
    assertTrue("matches", jp2.matches());
    assertEquals(2, jp2.getParameterBindings().length);
    assertEquals("annotation on B", bAnnotation, jp2.getParameterBindings()[0].getBinding());
    assertEquals("annotation on B", bAnnotation, jp2.getParameterBindings()[1].getBinding());
  }