aboutsummaryrefslogtreecommitdiffstats
path: root/tests/java5/ataspectj/ataspectj/IfPointcutTest.java
blob: 1073a730bfacd53edafb572e29078005bda840d5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/*******************************************************************************
 * Copyright (c) Jonas Bon�r, Alexandre Vasseur
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Common Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/cpl-v10.html
 *******************************************************************************/
package ataspectj;

import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import junit.framework.TestCase;
import org.aspectj.lang.annotation.Aspect;

/**
 * @author <a href="mailto:alex AT gnilux DOT com">Alexandre Vasseur</a>
 */
public class IfPointcutTest extends TestCase {

    static StringBuffer s_log = new StringBuffer();
    static void log(String s) {
        s_log.append(s).append(" ");
    }

    public void hello(int i) {
        System.out.println("IfPointcutTest.hello " + i);
    }

    public void testIf() {
        fail("FIXME AV: see below, TestAspect has its advice and pointcut commented out");
        IfPointcutTest me = new IfPointcutTest();
        me.hello(1);
        me.hello(-1);
    }

    public static void main(String[] args) {
        TestHelper.runAndThrowOnFailure(suite());
    }

    public static junit.framework.Test suite() {
        return new junit.framework.TestSuite(IfPointcutTest.class);
    }



    @Aspect
    public static class TestAspect {

        public boolean positive(int i) {
            return (i>=0);
        }

        //FIXME av if pcd support
        //@Pointcut("args(i) && if(i>0)")
        void ifPc(int i) {}

        //FIXME av if pcd support
        //@Before("execution(* ataspectj.IfPointcutTest.hello(int)) && ifPc(i)")
        void before(int i) {
            System.out.println("IfPointcutTest$TestAspect.before");
        }
    }
}