Package org.codehaus.aspectwerkz.expression

Examples of org.codehaus.aspectwerkz.expression.ExpressionInfo


            new ExpressionContext(PointcutType.HANDLER, s_declaringType, s_declaringType)));
    }

    public void testClassTypeEarlyFiltering() throws Exception {
        ExpressionNamespace.getNamespace(NAMESPACE).addExpressionInfo(
                "pcWithinForCall", new ExpressionInfo("within(test.expression.Target)", NAMESPACE));
        ExpressionInfo referenceToWithin = new ExpressionInfo("pcWithinForCall AND execution(* modifiers1(..))", NAMESPACE);
        assertTrue(referenceToWithin.getAdvisedClassFilterExpression().match(
                new ExpressionContext(PointcutType.EXECUTION, modifiers1, s_declaringType)));
        ExpressionNamespace.getNamespace(NAMESPACE).addExpressionInfo(
                "pcWithinForCall2", new ExpressionInfo("within(test.expression.TargetNOMATCH)", NAMESPACE));
        ExpressionInfo referenceToWithin2 = new ExpressionInfo("pcWithinForCall2 AND execution(* modifiers1(..))", NAMESPACE);
        assertFalse(referenceToWithin2.getAdvisedClassFilterExpression().match(
                new ExpressionContext(PointcutType.EXECUTION, modifiers1, s_declaringType)));
    }
View Full Code Here


                new ExpressionContext(PointcutType.EXECUTION, modifiers1, s_declaringType)));
    }

    // ============ class attribute test =============
    public void testClassAttribute1() throws Exception {
        assertTrue(new ExpressionInfo("within(test.expression.Target)", NAMESPACE).getExpression().match(
            new ExpressionContext(PointcutType.HANDLER, s_declaringType, s_declaringType)));
        assertTrue(new ExpressionInfo("within(@Serializable test.expression.Target)", NAMESPACE).getExpression().match(
            new ExpressionContext(PointcutType.HANDLER, s_declaringType, s_declaringType)));
        assertTrue(new ExpressionInfo("within(@Serializable public final test.expression.Target)", NAMESPACE)
                .getExpression().match(new ExpressionContext(PointcutType.HANDLER, s_declaringType, s_declaringType)));
        assertFalse(new ExpressionInfo("within(@Serializable @Dummy test.expression.Target)", NAMESPACE)
                .getExpression().match(new ExpressionContext(PointcutType.HANDLER, s_declaringType, s_declaringType)));
    }
View Full Code Here

    }

    // Tests: http://jira.codehaus.org/browse/AW-223
    public void testClassAttribute2() throws Exception {
        MethodInfo method = JavaMethodInfo.getMethodInfo(Target.class.getDeclaredMethod("modifiers1", new Class[] {}));
        assertTrue(new ExpressionInfo("execution(void test.expression.*.*(..)) AND within(@Serializable *..*)", NAMESPACE).getExpression().match(
            new ExpressionContext(PointcutType.EXECUTION, method, s_declaringType)));
        assertFalse(new ExpressionInfo("execution(void test.expression.*.*(..)) AND within(@FakeAnnotation *..*)", NAMESPACE).getExpression().match(
            new ExpressionContext(PointcutType.EXECUTION, method, s_declaringType)));
    }
View Full Code Here

    // ============ pointcut type tests =============
    public void testPointcutTypes() throws Exception {
        MethodInfo method = JavaMethodInfo.getMethodInfo(Target.class.getDeclaredMethod("modifiers1", new Class[] {}));
        FieldInfo field = JavaFieldInfo.getFieldInfo(Target.class.getDeclaredField("modifier1"));
        assertTrue(new ExpressionInfo("execution(void test.expression.Target.modifiers1())", NAMESPACE).getExpression()
                .match(new ExpressionContext(PointcutType.EXECUTION, method, null)));
        assertFalse(new ExpressionInfo("execution(void test.expression.Target.modifiers1())", NAMESPACE)
                .getExpression().match(new ExpressionContext(PointcutType.CALL, method, null)));
        assertTrue(new ExpressionInfo("set(int test.expression.Target.modifier1)", NAMESPACE).getExpression().match(
            new ExpressionContext(PointcutType.SET, field, null)));
        assertFalse(new ExpressionInfo("get(int test.expression.Target.modifier1)", NAMESPACE).getExpression().match(
            new ExpressionContext(PointcutType.SET, field, null)));
        try {
            assertFalse(new ExpressionInfo("set(int test.expression.Target.modifier1())", NAMESPACE).getExpression()
                    .match(new ExpressionContext(PointcutType.SET, method, null)));
        } catch (Throwable e) {
            return;
        }
        fail("expected exception");
View Full Code Here

            AspectDefinition aspectDef = (AspectDefinition) it1.next();
            PointcutManager pointcutManager = aspectManager.getPointcutManager(aspectDef.getName());
            List cflowPointcuts = pointcutManager.getCflowPointcuts();
            for (Iterator it2 = cflowPointcuts.iterator(); it2.hasNext();) {
                Pointcut cflowPointcut = (Pointcut) it2.next();
                ExpressionInfo expressionInfo = cflowPointcut.getExpressionInfo();

                // register the cflow advices in the system and create the cflow system
                // pointcutManager
                // (if it does not already exist)
                if (!aspectManager.hasAspect(CFlowSystemAspect.NAME)) {
                    AspectDefinition cflowAspectDef = new AspectDefinition(
                        CFlowSystemAspect.NAME,
                        CFlowSystemAspect.CLASS_NAME,
                        aspectManager.getUuid());
                    PointcutDefinition pointcutDef = new PointcutDefinition(expressionInfo.getExpressionAsString());
                    cflowAspectDef.setDeploymentModel(CFlowSystemAspect.DEPLOYMENT_MODEL);
                    cflowAspectDef.addPointcut(pointcutDef);
                    try {
                        AdviceDefinition beforeAdviceDefinition = new AdviceDefinition(
                            CFlowSystemAspect.PRE_ADVICE,
View Full Code Here

    }

    // ============ advised class tests =============
    public void testAdvisedClassExpression() throws Exception {
        ClassInfo otherType = JavaClassInfo.getClassInfo(String.class);
        assertFalse(new ExpressionInfo("execution(void test.expression.Target.modifiers1())", NAMESPACE)
                .getAdvisedClassFilterExpression().match(new ExpressionContext(PointcutType.ANY, otherType, null)));
        assertTrue(new ExpressionInfo("execution(void test.expression.Target.modifiers1())", NAMESPACE)
                .getAdvisedClassFilterExpression()
                .match(new ExpressionContext(PointcutType.ANY, s_declaringType, null)));
        assertTrue(new ExpressionInfo("call(void test.expression.Target.modifiers1())", NAMESPACE)
                .getAdvisedClassFilterExpression()
                .match(new ExpressionContext(PointcutType.ANY, s_declaringType, null)));
        assertTrue(new ExpressionInfo("set(int test.expression.Target.modifier1)", NAMESPACE)
                .getAdvisedClassFilterExpression()
                .match(new ExpressionContext(PointcutType.ANY, s_declaringType, null)));
        assertTrue(new ExpressionInfo("get(int test.expression.Target.modifier1)", NAMESPACE)
                .getAdvisedClassFilterExpression()
                .match(new ExpressionContext(PointcutType.ANY, s_declaringType, null)));
        assertTrue(new ExpressionInfo("handler(java.lang.Exception) && within(test.expression.Target)", NAMESPACE)
                .getAdvisedClassFilterExpression()
                .match(new ExpressionContext(PointcutType.ANY, s_declaringType, null)));
        assertTrue(new ExpressionInfo("handler(java.lang.Exception) && within(test.expression.Target)", NAMESPACE)
                .getAdvisedClassFilterExpression()
                .match(new ExpressionContext(PointcutType.ANY, s_declaringType, null)));
        assertTrue(new ExpressionInfo(
            "handler(java.lang.Exception) && withincode(void test.expression.Target.modifiers1())",
            NAMESPACE).getAdvisedClassFilterExpression().match(
            new ExpressionContext(PointcutType.ANY, s_declaringType, null)));
        assertTrue(new ExpressionInfo(
            "handler(java.lang.Exception) && NOT withincode(void test.expression.Target.modifiers1())",
            NAMESPACE).getAdvisedClassFilterExpression()
                .match(new ExpressionContext(PointcutType.ANY, otherType, null)));
        assertFalse(new ExpressionInfo(
            "call(void test.expression.Dummy.modifiers1()) && within(test.expression.Target)",
            NAMESPACE).getAdvisedClassFilterExpression().match(
            new ExpressionContext(PointcutType.ANY, s_declaringType, null)));
        assertFalse(new ExpressionInfo(
            "call(void test.expression.Dummy.modifiers1()) && withincode(void test.expression.Target.modifiers1())",
            NAMESPACE).getAdvisedClassFilterExpression().match(
            new ExpressionContext(PointcutType.ANY, s_declaringType, null)));//fails on CALL
        assertFalse(new ExpressionInfo(
            "call(void test.expression.Target.modifiers1()) && withincode(void test.expression.TargetNOMATCH.modifiers1())",
            NAMESPACE).getAdvisedClassFilterExpression().match(
            new ExpressionContext(PointcutType.ANY, s_declaringType, s_declaringType)));//fails on WITHIN
        assertTrue(new ExpressionInfo(
            "execution(void test.expression.Target.modifiers1()) OR execution(* java.lang.String.*(..))",
            NAMESPACE).getAdvisedClassFilterExpression()
                .match(new ExpressionContext(PointcutType.ANY, otherType, null)));

        assertTrue(new ExpressionInfo(
            "execution(void test.expression.Target.modifiers1()) OR execution(* java.lang.String.*(..))",
            NAMESPACE).getAdvisedClassFilterExpression().match(
            new ExpressionContext(PointcutType.ANY, s_declaringType, null)));
        assertTrue(new ExpressionInfo(
            "execution(void test.expression.Target.modifiers1()) AND NOT execution(* java.lang.String.*(..))",
            NAMESPACE).getAdvisedClassFilterExpression().match(
            new ExpressionContext(PointcutType.ANY, s_declaringType, null)));

        // check that we ignore cflow
        assertTrue(new ExpressionInfo(
            "execution(void test.expression.Target.modifiers1()) AND cflow(execution(* *..*(..)))",
            NAMESPACE).getAdvisedClassFilterExpression().match(
            new ExpressionContext(PointcutType.ANY, s_declaringType, null)));
        assertTrue(new ExpressionInfo(
            "execution(void test.expression.Target.modifiers1()) AND NOT cflow(execution(* *..*(..)))",
            NAMESPACE).getAdvisedClassFilterExpression().match(
            new ExpressionContext(PointcutType.ANY, s_declaringType, null)));
        assertFalse(new ExpressionInfo(
            "execution(void test.expression.TargetNOMATCH.modifiers1()) AND cflow(execution(* *..*(..)))",
            NAMESPACE).getAdvisedClassFilterExpression().match(
            new ExpressionContext(PointcutType.ANY, s_declaringType, null)));
        assertFalse(new ExpressionInfo(
            "execution(void test.expression.TargetNOMATCH.modifiers1()) AND NOT cflow(execution(* *..*(..)))",
            NAMESPACE).getAdvisedClassFilterExpression().match(
            new ExpressionContext(PointcutType.ANY, s_declaringType, null)));

        // the following should return FALSE with a good early filtering
        // returning TRUE is not a problem for the early filtering but false will save time
        assertFalse(new ExpressionInfo(
            "execution(void test.expression.Target.modifiers1()) OR NOT execution(* java.lang.String.*(..))",
            NAMESPACE).getAdvisedClassFilterExpression().match(
            new ExpressionContext(PointcutType.ANY, otherType, null)));
        assertFalse(new ExpressionInfo(
            "execution(void test.expression.Target.modifiers1()) AND execution(* java.lang.String.*(..))",
            NAMESPACE).getAdvisedClassFilterExpression().match(
            new ExpressionContext(PointcutType.ANY, s_declaringType, null)));
        assertFalse(new ExpressionInfo(
            "execution(void test.expression.Target.modifiers1()) AND execution(* java.lang.String.*(..))",
            NAMESPACE).getAdvisedClassFilterExpression().match(
            new ExpressionContext(PointcutType.ANY, s_declaringType, null)));

        //FIXME: since Pointcut with signature in grammar, not/NOT must be separated by a <space>
        //        assertTrue(new ExpressionInfo(
        //            "NOT(execution(void test.expression.Target.modifiers1()) OR NOT execution(* java.lang.String.*(..)))",
        //            NAMESPACE).getAdvisedClassFilterExpression().match(
        //            new ExpressionContext(PointcutType.ANY, otherType, null)));
        assertTrue(new ExpressionInfo(
            "NOT (execution(void test.expression.Target.modifiers1()) OR NOT execution(* java.lang.String.*(..)))",
            NAMESPACE).getAdvisedClassFilterExpression()
                .match(new ExpressionContext(PointcutType.ANY, otherType, null)));

    }
View Full Code Here

    }

    public void testAdvisedCflowClassExpression() throws Exception {
        ClassInfo otherType = JavaClassInfo.getClassInfo(String.class);
        s_namespace
                .addExpressionInfo("string", new ExpressionInfo("execution(void java.lang.String.*(..))", NAMESPACE));
        s_namespace.addExpressionInfo("target", new ExpressionInfo(
            "execution(* test.expression.Target.*(..))",
            NAMESPACE));
        s_namespace.addExpressionInfo("cflowString", new ExpressionInfo(
            "cflow(execution(void java.lang.String.*(..)))",
            NAMESPACE));
        s_namespace.addExpressionInfo("cflowTarget", new ExpressionInfo(
            "cflow(call(void test.expression.Target.modifiers3()) && withincode(void test.expression.Target.*(..)))",
            NAMESPACE));
        assertFalse(new ExpressionInfo("string && cflowString", NAMESPACE).getAdvisedCflowClassFilterExpression()
                .match(new ExpressionContext(PointcutType.ANY, s_declaringType, null)));
                assertTrue(new ExpressionInfo("string && cflowString", NAMESPACE)
                        .getAdvisedCflowClassFilterExpression().match(
                            new ExpressionContext(PointcutType.ANY, otherType, null)));
        assertFalse(new ExpressionInfo("target && cflowString", NAMESPACE).getAdvisedCflowClassFilterExpression()
                .match(new ExpressionContext(PointcutType.ANY, s_declaringType, null)));
                assertTrue(new ExpressionInfo("target && cflowString", NAMESPACE)
                        .getAdvisedCflowClassFilterExpression().match(
                            new ExpressionContext(PointcutType.ANY, otherType, null)));
        assertTrue(new ExpressionInfo("! target && cflowString", NAMESPACE)
                .getAdvisedCflowClassFilterExpression().match(
                    new ExpressionContext(PointcutType.ANY, otherType, null)));
        // will match since NOT is ignored so that cflow aspect can be plugged
        assertTrue(new ExpressionInfo("target && ! cflowString", NAMESPACE)
                .getAdvisedCflowClassFilterExpression().match(
                    new ExpressionContext(PointcutType.ANY, otherType, null)));
        assertFalse(new ExpressionInfo("string && cflowTarget", NAMESPACE).getAdvisedCflowClassFilterExpression()
                .match(new ExpressionContext(PointcutType.ANY, otherType, null)));
        assertTrue(new ExpressionInfo("string && cflowTarget", NAMESPACE)
                .getAdvisedCflowClassFilterExpression().match(
                    new ExpressionContext(PointcutType.ANY, s_declaringType, null)));
        assertFalse(new ExpressionInfo("target && cflowTarget", NAMESPACE).getAdvisedCflowClassFilterExpression()
                .match(new ExpressionContext(PointcutType.ANY, otherType, null)));
        assertTrue(new ExpressionInfo("target && cflowTarget", NAMESPACE)
                .getAdvisedCflowClassFilterExpression().match(
                    new ExpressionContext(PointcutType.ANY, s_declaringType, null)));
        assertTrue(new ExpressionInfo(
            "execution(void test.expression.Dummy.modifiers1()) && cflow(execution(void test.expression.Target.modifiers1()))",
            NAMESPACE).getAdvisedCflowClassFilterExpression().match(
            new ExpressionContext(PointcutType.ANY, s_declaringType, null)));
        assertFalse(new ExpressionInfo(
            "execution(void test.expression.Dummy.modifiers1()) && cflow(execution(void test.expression.Target.modifiers1()))",
            NAMESPACE).getAdvisedCflowClassFilterExpression().match(
            new ExpressionContext(PointcutType.ANY, otherType, null)));
        assertFalse(new ExpressionInfo("cflow(execution(void test.expression.Target.modifiers1()))", NAMESPACE)
                .getAdvisedCflowClassFilterExpression().match(new ExpressionContext(PointcutType.ANY, otherType, null)));
        assertTrue(new ExpressionInfo("cflow(call(void test.expression.Target.modifiers1()))", NAMESPACE)
                .getAdvisedCflowClassFilterExpression().match(
                    new ExpressionContext(PointcutType.ANY, s_declaringType, null)));
        assertTrue(new ExpressionInfo(
            "cflow(execution(void test.expression.Target.modifiers1())) && within(test.expression.Target)",
            NAMESPACE).getAdvisedCflowClassFilterExpression().match(
            new ExpressionContext(PointcutType.ANY, s_declaringType, null)));
        assertTrue(new ExpressionInfo(
            "within(test.expression.Target) && cflow(call(void test.expression.Target.modifiers1()))",
            NAMESPACE).getAdvisedCflowClassFilterExpression().match(
            new ExpressionContext(PointcutType.ANY, s_declaringType, null)));
        assertFalse(new ExpressionInfo(
            "cflow(within(test.expression.T) && call(void test.expression.T.modifiers1()))",
            NAMESPACE).getAdvisedCflowClassFilterExpression().match(
            new ExpressionContext(PointcutType.ANY, s_declaringType, null)));
        assertTrue(new ExpressionInfo(
            "cflow(!within(test.expression.T) && call(void test.expression.Target.modifiers1()))",
            NAMESPACE).getAdvisedCflowClassFilterExpression().match(
            new ExpressionContext(PointcutType.ANY, s_declaringType, null)));
        assertFalse(new ExpressionInfo(
            "cflow(call(void test.expression.Target.modifiers1()) && NOT withincode(void test.expression.Target.modifiers1()))",
            NAMESPACE).getAdvisedCflowClassFilterExpression().match(
            new ExpressionContext(PointcutType.ANY, otherType, null)));

        assertTrue(new ExpressionInfo(
            "NOT execution(void test.expression.Target.modifiers1()) && cflow(call(void test.expression.Target.modifiers1()))",
            NAMESPACE).getAdvisedCflowClassFilterExpression().match(
            new ExpressionContext(PointcutType.ANY, s_declaringType, null)));

    }
View Full Code Here

    // ============ cflow type tests =============
    public void testFindCflowPointcut() throws Exception {
        MethodInfo method1 = JavaMethodInfo.getMethodInfo(Target.class.getDeclaredMethod("modifiers1", new Class[] {}));
        MethodInfo method2 = JavaMethodInfo.getMethodInfo(Target.class.getDeclaredMethod("modifiers2", new Class[] {}));
        MethodInfo method3 = JavaMethodInfo.getMethodInfo(Target.class.getDeclaredMethod("modifiers3", new Class[] {}));
        s_namespace.addExpressionInfo("pc1", new ExpressionInfo(
            "execution(void test.expression.Target.modifiers2())",
            NAMESPACE));
        s_namespace.addExpressionInfo("pc2", new ExpressionInfo(
            "execution(void test.expression.Target.modifiers3())",
            NAMESPACE));
        s_namespace.addExpressionInfo("cflowPC", new ExpressionInfo(
            "cflow(call(void test.expression.Target.modifiers3()) AND within(test.expression.*))",
            NAMESPACE));
        assertTrue(new ExpressionInfo("cflow(execution(void test.expression.Target.modifiers1()))", NAMESPACE)
                .getCflowExpression().match(new ExpressionContext(PointcutType.EXECUTION, method1, null)));
        assertTrue(new ExpressionInfo(
            "execution(void test.expression.Target.modifiers2()) && cflow(execution(void test.expression.Target.modifiers1()))",
            NAMESPACE).hasCflowPointcut());
        assertTrue(new ExpressionInfo(
            "execution(void test.expression.Target.modifiers2()) && cflow(execution(void test.expression.Target.modifiers1()))",
            NAMESPACE).hasCflowPointcut());
        assertTrue(new ExpressionInfo(
            "cflow(execution(void test.expression.Target.modifiers1())) && execution(void test.expression.Target.modifiers2())",
            NAMESPACE).hasCflowPointcut());
        assertTrue(new ExpressionInfo("cflowPC && pc1", NAMESPACE).hasCflowPointcut());
        assertTrue(new ExpressionInfo("pc1 && cflowPC", NAMESPACE).hasCflowPointcut());
        assertTrue(new ExpressionInfo("cflow(pc2) && pc1", NAMESPACE).hasCflowPointcut());
        assertTrue(new ExpressionInfo("pc1 && cflow(pc2)", NAMESPACE).hasCflowPointcut());
        assertTrue(new ExpressionInfo(
            "pc2 && cflow(pc1 || pc2 || call(void test.expression.Target.modifiers1()))",
            NAMESPACE).hasCflowPointcut());
        assertTrue(new ExpressionInfo(
            "cflow(pc1 || pc2 || call(void test.expression.Target.modifiers1())) AND pc1",
            NAMESPACE).hasCflowPointcut());
        assertTrue(new ExpressionInfo(
            "cflow(pc1 || call(void test.expression.Target.modifiers1())) && (execution(void test.expression.Target.modifiers3()) || pc1)",
            NAMESPACE).hasCflowPointcut());
        assertTrue(new ExpressionInfo(
            "cflow(execution(void test.expression.Target.modifiers1())) && execution(void test.expression.Target.modifiers2())",
            NAMESPACE).hasCflowPointcut());
        assertTrue(new ExpressionInfo("cflow(pc1) && execution(void test.expression.Target.modifiers3())", NAMESPACE)
                .hasCflowPointcut());
        assertTrue(new ExpressionInfo(
            "cflow(call(void test.expression.Target.modifiers1())) && execution(void test.expression.Target.modifiers1())",
            NAMESPACE).hasCflowPointcut());
        assertTrue(new ExpressionInfo(
            "cflow(call(void test.expression.Target.modifiers1())) || execution(void test.expression.Target.modifiers1())",
            NAMESPACE).hasCflowPointcut());
        assertFalse(new ExpressionInfo(
            "call(void test.expression.Target.modifiers1()) || execution(void test.expression.Target.modifiers1())",
            NAMESPACE).hasCflowPointcut());
        assertFalse(new ExpressionInfo(
            "call(void test.expression.Target.modifiers1()) && execution(void test.expression.Target.modifiers1())",
            NAMESPACE).hasCflowPointcut());
    }
View Full Code Here

    public void testCflowTypes() throws Exception {
        MethodInfo method1 = JavaMethodInfo.getMethodInfo(Target.class.getDeclaredMethod("modifiers1", new Class[] {}));
        MethodInfo method2 = JavaMethodInfo.getMethodInfo(Target.class.getDeclaredMethod("modifiers2", new Class[] {}));
        MethodInfo method3 = JavaMethodInfo.getMethodInfo(Target.class.getDeclaredMethod("modifiers3", new Class[] {}));
        s_namespace.addExpressionInfo("pc1", new ExpressionInfo(
            "execution(void test.expression.Target.modifiers2())",
            NAMESPACE));
        s_namespace.addExpressionInfo("pc2", new ExpressionInfo(
            "execution(void test.expression.Target.modifiers3())",
            NAMESPACE));
        s_namespace.addExpressionInfo("cflowPC", new ExpressionInfo(
            "cflow(call(void test.expression.Target.modifiers3()) AND within(test.expression.*))",
            NAMESPACE));
        assertTrue(new ExpressionInfo("cflow(execution(void test.expression.Target.modifiers1()))", NAMESPACE)
                .getCflowExpression().match(new ExpressionContext(PointcutType.EXECUTION, method1, null)));
        assertTrue(new ExpressionInfo(
            "execution(void test.expression.Target.modifiers2()) && cflow(execution(void test.expression.Target.modifiers1()))",
            NAMESPACE).getCflowExpression().match(new ExpressionContext(PointcutType.EXECUTION, method1, null)));
        assertTrue(new ExpressionInfo(
            "execution(void test.expression.Target.modifiers2()) && cflow(execution(void test.expression.Target.modifiers1()))",
            NAMESPACE).getCflowExpression().match(new ExpressionContext(PointcutType.EXECUTION, method1, null)));
        assertTrue(new ExpressionInfo(
            "cflow(execution(void test.expression.Target.modifiers1())) && execution(void test.expression.Target.modifiers2())",
            NAMESPACE).getCflowExpression().match(new ExpressionContext(PointcutType.EXECUTION, method1, null)));
        assertTrue(new ExpressionInfo("cflowPC && pc1", NAMESPACE).getCflowExpression().match(
            new ExpressionContext(PointcutType.CALL, method3, s_declaringType)));
        assertTrue(new ExpressionInfo("pc1 && cflowPC", NAMESPACE).getCflowExpression().match(
            new ExpressionContext(PointcutType.CALL, method3, s_declaringType)));
        assertTrue(new ExpressionInfo("cflow(pc2) && pc1", NAMESPACE).getCflowExpression().match(
            new ExpressionContext(PointcutType.EXECUTION, method3, s_declaringType)));
        assertFalse(new ExpressionInfo("pc1 && cflow(pc2)", NAMESPACE).getCflowExpression().match(
            new ExpressionContext(PointcutType.EXECUTION, method2, s_declaringType)));
        assertTrue(new ExpressionInfo(
            "pc2 && cflow(pc1 || pc2 || call(void test.expression.Target.modifiers1()))",
            NAMESPACE).getCflowExpression().match(new ExpressionContext(PointcutType.CALL, method1, null)));
        assertTrue(new ExpressionInfo(
            "cflow(pc1 || pc2 || call(void test.expression.Target.modifiers1())) AND pc1",
            NAMESPACE).getCflowExpression().match(new ExpressionContext(PointcutType.EXECUTION, method3, null)));
        assertTrue(new ExpressionInfo(
            "cflow(pc1 || call(void test.expression.Target.modifiers1())) && (execution(void test.expression.Target.modifiers3()) || pc1)",
            NAMESPACE).getCflowExpression().match(new ExpressionContext(PointcutType.EXECUTION, method2, null)));
        assertFalse(new ExpressionInfo(
            "cflow(execution(void test.expression.Target.modifiers1())) && execution(void test.expression.Target.modifiers2())",
            NAMESPACE).getCflowExpression().match(new ExpressionContext(PointcutType.EXECUTION, method2, null)));
        assertFalse(new ExpressionInfo("cflow(pc1) && execution(void test.expression.Target.modifiers3())", NAMESPACE)
                .getCflowExpression().match(new ExpressionContext(PointcutType.EXECUTION, method3, null)));
        assertFalse(new ExpressionInfo(
            "cflow(call(void test.expression.Target.modifiers1())) && execution(void test.expression.Target.modifiers1())",
            NAMESPACE).getCflowExpression().match(new ExpressionContext(PointcutType.EXECUTION, method1, null)));
        assertFalse(new ExpressionInfo(
            "cflow(call(void test.expression.Target.modifiers1())) || execution(void test.expression.Target.modifiers1())",
            NAMESPACE).getCflowExpression().match(new ExpressionContext(PointcutType.EXECUTION, method1, null)));
        assertTrue(new ExpressionInfo(
            "execution(void test.expression.Target.modifiers2()) AND NOT cflow(call(void test.expression.Target.modifiers1()))",
            NAMESPACE).getExpression().match(new ExpressionContext(PointcutType.EXECUTION, method2, null)));
        assertTrue(new ExpressionInfo(
            "execution(void test.expression.Target.modifiers2()) AND NOT cflow(call(void test.expression.Target.modifiers1()))",
            NAMESPACE).getCflowExpression().match(new ExpressionContext(PointcutType.CALL, method1, null)));
    }
View Full Code Here

    public void testCflowBelowTypes() throws Exception {
        MethodInfo method1 = JavaMethodInfo.getMethodInfo(Target.class.getDeclaredMethod("modifiers1", new Class[] {}));
        MethodInfo method2 = JavaMethodInfo.getMethodInfo(Target.class.getDeclaredMethod("modifiers2", new Class[] {}));
        MethodInfo method3 = JavaMethodInfo.getMethodInfo(Target.class.getDeclaredMethod("modifiers3", new Class[] {}));
        s_namespace.addExpressionInfo("pc1", new ExpressionInfo(
            "execution(void test.expression.Target.modifiers2())",
            NAMESPACE));
        s_namespace.addExpressionInfo("pc2", new ExpressionInfo(
            "execution(void test.expression.Target.modifiers3())",
            NAMESPACE));
        assertTrue(new ExpressionInfo("cflowbelow(execution(void test.expression.Target.modifiers1()))", NAMESPACE)
                .getCflowExpression().match(new ExpressionContext(PointcutType.EXECUTION, method1, null)));
        assertTrue(new ExpressionInfo(
            "cflowbelow(pc1 || pc2 || call(void test.expression.Target.modifiers1()))",
            NAMESPACE).getCflowExpression().match(new ExpressionContext(PointcutType.CALL, method1, null)));
        assertTrue(new ExpressionInfo(
            "cflowbelow(pc1 || pc2 || call(void test.expression.Target.modifiers1()))",
            NAMESPACE).getCflowExpression().match(new ExpressionContext(PointcutType.EXECUTION, method2, null)));
        assertTrue(new ExpressionInfo(
            "cflowbelow(pc1 || pc2 || call(void test.expression.Target.modifiers1()))",
            NAMESPACE).getCflowExpression().match(new ExpressionContext(PointcutType.EXECUTION, method3, null)));
    }
View Full Code Here

TOP

Related Classes of org.codehaus.aspectwerkz.expression.ExpressionInfo

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.