summaryrefslogtreecommitdiffstats
path: root/tests/bugs163/pr255856/Bug.java
blob: 65b8aeab5f42628c912946364005f2414003afc0 (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
package example;

import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

import junit.framework.TestCase;

import org.aspectj.lang.Aspects;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;

public class Bug extends TestCase {

        public void testAdviceMatch() {
                TestImpl impl = new TestImpl();
                impl.method();

                assertEquals(0, Aspects.aspectOf(TestAtAspect.class).count);
//                assertEquals(0, TestAspect.aspectOf().count);
        }


        @Retention(RetentionPolicy.RUNTIME)
        @Target(ElementType.TYPE)
        @Inherited
        static @interface TestAnnotation {
        }

        @TestAnnotation
        static interface TestInterface {
                void method();
        }

        static class TestImpl implements TestInterface {
//                @Override
                public void method() {
                }
        }

//        static aspect TestAspect {
//                int count = 0;
//
//                before() : @target(example.Bug.TestAnnotation)+ && execution(* *(..)) {
//                        count++;
//                }
//        }

        @Aspect
        static class TestAtAspect {
                int count = 0;

                @Before("@target(example.Bug.TestAnnotation)+ && execution(* *(..))") 
                public void increment() {
                        count++;
                }
        }
}