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 testExecutionWithClassFileRetentionAnnotation() {
   PointcutExpression pc1 =
       parser.parsePointcutExpression(
           "execution(@org.aspectj.weaver.tools.Java15PointcutExpressionTest.MyAnnotation * *(..))");
   PointcutExpression pc2 =
       parser.parsePointcutExpression(
           "execution(@org.aspectj.weaver.tools.Java15PointcutExpressionTest.MyClassFileRetentionAnnotation * *(..))");
   ShadowMatch sMatch = pc1.matchesMethodExecution(a);
   assertTrue("matches", sMatch.alwaysMatches());
   sMatch = pc2.matchesMethodExecution(a);
   assertTrue("no match", sMatch.neverMatches());
   sMatch = pc1.matchesMethodExecution(b);
   assertTrue("no match", sMatch.neverMatches());
   sMatch = pc2.matchesMethodExecution(b);
   assertTrue("matches", sMatch.alwaysMatches());
 }
  public void testReferencePointcutNoParams() {
    PointcutExpression pc =
        parser.parsePointcutExpression("foo()", C.class, new PointcutParameter[0]);
    ShadowMatch sMatch1 = pc.matchesMethodCall(a, b);
    ShadowMatch sMatch2 = pc.matchesMethodExecution(a);
    assertTrue("no match on call", sMatch1.neverMatches());
    assertTrue("match on execution", sMatch2.alwaysMatches());

    pc =
        parser.parsePointcutExpression(
            "org.aspectj.weaver.tools.Java15PointcutExpressionTest.C.foo()");
    sMatch1 = pc.matchesMethodCall(a, b);
    sMatch2 = pc.matchesMethodExecution(a);
    assertTrue("no match on call", sMatch1.neverMatches());
    assertTrue("match on execution", sMatch2.alwaysMatches());
  }
 public void testAtAnnotation() {
   PointcutExpression atAnnotation =
       parser.parsePointcutExpression(
           "@annotation(org.aspectj.weaver.tools.Java15PointcutExpressionTest.MyAnnotation)");
   ShadowMatch sMatch1 = atAnnotation.matchesMethodCall(b, a);
   ShadowMatch sMatch2 = atAnnotation.matchesMethodCall(a, a);
   assertTrue("does not match call to b", sMatch1.neverMatches());
   assertTrue("matches call to a", sMatch2.alwaysMatches());
 }
 public void testAtWithinCode() {
   PointcutExpression atWithinCode =
       parser.parsePointcutExpression(
           "@withincode(org.aspectj.weaver.tools.Java15PointcutExpressionTest.MyAnnotation)");
   ShadowMatch sMatch1 = atWithinCode.matchesMethodCall(a, b);
   ShadowMatch sMatch2 = atWithinCode.matchesMethodCall(a, a);
   assertTrue("does not match from b", sMatch1.neverMatches());
   assertTrue("matches from a", sMatch2.alwaysMatches());
 }
 public void testAtWithin() {
   PointcutExpression atWithin =
       parser.parsePointcutExpression(
           "@within(org.aspectj.weaver.tools.Java15PointcutExpressionTest.MyAnnotation)");
   ShadowMatch sMatch1 = atWithin.matchesMethodExecution(a);
   ShadowMatch sMatch2 = atWithin.matchesMethodExecution(b);
   assertTrue("does not match a", sMatch1.neverMatches());
   assertTrue("matches b", sMatch2.alwaysMatches());
 }
 public void testReferencePCsInOtherType() throws Exception {
   PointcutExpression ex =
       parser.parsePointcutExpression(
           "org.aspectj.weaver.tools.Java15PointcutExpressionTest.ExternalReferrer.d()",
           ExternalReferrer.class,
           new PointcutParameter[0]);
   ShadowMatch sm = ex.matchesMethodExecution(a);
   assertTrue("should match", sm.alwaysMatches());
   sm = ex.matchesMethodExecution(b);
   assertTrue("does not match", sm.neverMatches());
 }
  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 testAtWithinWithBinding() {
   PointcutParameter p1 = parser.createPointcutParameter("x", MyAnnotation.class);
   PointcutExpression atWithin =
       parser.parsePointcutExpression("@within(x)", B.class, new PointcutParameter[] {p1});
   ShadowMatch sMatch1 = atWithin.matchesMethodExecution(a);
   ShadowMatch sMatch2 = atWithin.matchesMethodExecution(b);
   assertTrue("does not match a", sMatch1.neverMatches());
   assertTrue("matches b", sMatch2.alwaysMatches());
   JoinPointMatch jpm = sMatch2.matchesJoinPoint(new B(), new B(), new Object[0]);
   assertTrue(jpm.matches());
   assertEquals(1, jpm.getParameterBindings().length);
   MyAnnotation bAnnotation = B.class.getAnnotation(MyAnnotation.class);
   assertEquals("annotation on B", bAnnotation, jpm.getParameterBindings()[0].getBinding());
 }