1   /***************************************************************************************
2    * Copyright (c) Jonas BonŽr, Alexandre Vasseur. All rights reserved.                 *
3    * http://aspectwerkz.codehaus.org                                                    *
4    * ---------------------------------------------------------------------------------- *
5    * The software in this package is published under the terms of the LGPL license      *
6    * a copy of which has been included with this distribution in the license.txt file.  *
7    **************************************************************************************/
8   package test.expression;
9   
10  import junit.framework.TestCase;
11  import org.codehaus.aspectwerkz.expression.ExpressionContext;
12  import org.codehaus.aspectwerkz.expression.ExpressionInfo;
13  import org.codehaus.aspectwerkz.expression.ExpressionNamespace;
14  import org.codehaus.aspectwerkz.expression.ExpressionVisitor;
15  import org.codehaus.aspectwerkz.expression.PointcutType;
16  import org.codehaus.aspectwerkz.reflect.ClassInfo;
17  import org.codehaus.aspectwerkz.reflect.ConstructorInfo;
18  import org.codehaus.aspectwerkz.reflect.FieldInfo;
19  import org.codehaus.aspectwerkz.reflect.MethodInfo;
20  import org.codehaus.aspectwerkz.reflect.impl.java.JavaClassInfo;
21  import org.codehaus.aspectwerkz.reflect.impl.java.JavaFieldInfo;
22  import org.codehaus.aspectwerkz.reflect.impl.java.JavaMethodInfo;
23  import org.codehaus.aspectwerkz.exception.DefinitionException;
24  import org.codehaus.aspectwerkz.cflow.CflowBinding;
25  
26  /***
27   * @author <a href="mailto:jboner@codehaus.org">Jonas BonŽr </a>
28   * @author <a href="mailto:alex@gnilux.com">Alexandre Vasseur </a>
29   */
30  public class ExpressionTest extends TestCase {
31      private static final String NAMESPACE = "TESTING";
32  
33      private static ExpressionNamespace s_namespace = ExpressionNamespace.getNamespace(NAMESPACE);
34  
35      private static ClassInfo s_declaringType = JavaClassInfo.getClassInfo(Target.class);
36  
37      private static MethodInfo modifiers1;
38  
39      private static MethodInfo modifiers2;
40  
41      private static MethodInfo modifiers3;
42  
43      private static MethodInfo modifiers4;
44  
45      private static MethodInfo parameters1;
46  
47      private static MethodInfo parameters2;
48  
49      private static MethodInfo parameters2bis;
50  
51      private static MethodInfo parameters3;
52  
53      private static MethodInfo parameters4;
54  
55      private static MethodInfo parameters5;
56  
57      private static MethodInfo returnType1;
58  
59      private static MethodInfo returnType2;
60  
61      private static MethodInfo returnType3;
62  
63      private static MethodInfo returnType4;
64  
65      private static MethodInfo returnType5;
66  
67      private static MethodInfo _method$Name1;
68  
69      private static MethodInfo attributes1;
70  
71      private static ConstructorInfo constructorNoArgPublic;
72  
73      private static ConstructorInfo constructorIntArgPrivate;
74  
75      private static FieldInfo modifier1;
76  
77      private static FieldInfo modifier2;
78  
79      private static FieldInfo modifier3;
80  
81      private static FieldInfo type1;
82  
83      private static FieldInfo type2;
84  
85      private static FieldInfo type3;
86  
87      private static FieldInfo type4;
88  
89      private static FieldInfo _field$Name1;
90  
91      private static FieldInfo attribute1;
92  
93      // ============ setup =============
94      static {
95          ConstructorInfo[] constructors = s_declaringType.getConstructors();
96          for (int i = 0; i < constructors.length; i++) {
97              ConstructorInfo constructor = constructors[i];
98              if (constructor.getParameterTypes().length == 0) {
99                  constructorNoArgPublic = constructor;
100             } else {
101                 constructorIntArgPrivate = constructor;
102             }
103         }
104 
105         MethodInfo[] methods = s_declaringType.getMethods();
106         for (int i = 0; i < methods.length; i++) {
107             MethodInfo method = methods[i];
108             if (method.getName().equals("modifiers1")) {
109                 modifiers1 = method;
110             }
111             if (method.getName().equals("modifiers2")) {
112                 modifiers2 = method;
113             }
114             if (method.getName().equals("modifiers3")) {
115                 modifiers3 = method;
116             }
117             if (method.getName().equals("modifiers4")) {
118                 modifiers4 = method;
119             }
120             if (method.getName().equals("parameters1")) {
121                 parameters1 = method;
122             }
123             if (method.getName().equals("parameters2")) {
124                 parameters2 = method;
125             }
126             if (method.getName().equals("parameters2bis")) {
127                 parameters2bis = method;
128             }
129             if (method.getName().equals("parameters3")) {
130                 parameters3 = method;
131             }
132             if (method.getName().equals("parameters4")) {
133                 parameters4 = method;
134             }
135             if (method.getName().equals("parameters5")) {
136                 parameters5 = method;
137             }
138             if (method.getName().equals("returnType1")) {
139                 returnType1 = method;
140             }
141             if (method.getName().equals("returnType1")) {
142                 returnType1 = method;
143             }
144             if (method.getName().equals("returnType2")) {
145                 returnType2 = method;
146             }
147             if (method.getName().equals("returnType3")) {
148                 returnType3 = method;
149             }
150             if (method.getName().equals("returnType4")) {
151                 returnType4 = method;
152             }
153             if (method.getName().equals("returnType5")) {
154                 returnType5 = method;
155             }
156             if (method.getName().equals("__method$Name1")) {
157                 _method$Name1 = method;
158             }
159             if (method.getName().equals("attributes1")) {
160                 attributes1 = method;
161             }
162         }
163         FieldInfo[] fields = s_declaringType.getFields();
164         for (int f = 0; f < fields.length; f++) {
165             FieldInfo field = fields[f];
166             if (field.getName().equals("modifier1")) {
167                 modifier1 = field;
168             }
169             if (field.getName().equals("modifier2")) {
170                 modifier2 = field;
171             }
172             if (field.getName().equals("modifier3")) {
173                 modifier3 = field;
174             }
175             if (field.getName().equals("type1")) {
176                 type1 = field;
177             }
178             if (field.getName().equals("type2")) {
179                 type2 = field;
180             }
181             if (field.getName().equals("type3")) {
182                 type3 = field;
183             }
184             if (field.getName().equals("type4")) {
185                 type4 = field;
186             }
187             if (field.getName().equals("__field$Name1")) {
188                 _field$Name1 = field;
189             }
190             if (field.getName().equals("attribute1")) {
191                 attribute1 = field;
192             }
193         }
194     }
195 
196     public ExpressionTest(String name) {
197         super(name);
198     }
199 
200     // ============ constructor signature test =============
201     public void testConstructor() throws Exception {
202         assertTrue(
203                 new ExpressionInfo("call(test.expression.Target.new())", NAMESPACE).getExpression().match(
204                         new ExpressionContext(PointcutType.CALL, constructorNoArgPublic, null)
205                 )
206         );
207         assertFalse(
208                 new ExpressionInfo("call(test.expression.Target.new(String))", NAMESPACE).getExpression().match(
209                         new ExpressionContext(PointcutType.CALL, constructorNoArgPublic, null)
210                 )
211         );
212         assertTrue(
213                 new ExpressionInfo("call(test.expression.Target.new())", NAMESPACE).getExpression().match(
214                         new ExpressionContext(PointcutType.CALL, constructorNoArgPublic, null)
215                 )
216         );
217         assertFalse(
218                 new ExpressionInfo("call(test.expression.Target.new(String))", NAMESPACE).getExpression().match(
219                         new ExpressionContext(PointcutType.CALL, constructorNoArgPublic, null)
220                 )
221         );
222         //AW-112 below
223         assertTrue(
224                 new ExpressionInfo("within(test.expression.Target) && execution(new())", NAMESPACE).getExpression()
225                 .match(new ExpressionContext(PointcutType.EXECUTION, constructorNoArgPublic, null))
226         );
227         assertTrue(
228                 new ExpressionInfo("within(test..*) && execution(*.expression.Target.new())", NAMESPACE).getExpression()
229                 .match(
230                         new ExpressionContext(
231                                 PointcutType.EXECUTION,
232                                 constructorNoArgPublic,
233                                 constructorNoArgPublic.getDeclaringType()
234                         )
235                 )
236         );
237         assertTrue(
238                 new ExpressionInfo("within(test..*.*) && execution(*.expression.Target.new())", NAMESPACE).getExpression()
239                 .match(
240                         new ExpressionContext(
241                                 PointcutType.EXECUTION,
242                                 constructorNoArgPublic,
243                                 constructorNoArgPublic.getDeclaringType()
244                         )
245                 )
246         );
247     }
248 
249     // ============ constructor modifiers test =============
250     public void testConstructorModifiers1() throws Exception {
251         assertTrue(
252                 new ExpressionInfo("call(public test.expression.Target.new())", NAMESPACE).getExpression().match(
253                         new ExpressionContext(PointcutType.CALL, constructorNoArgPublic, null)
254                 )
255         );
256         assertFalse(
257                 new ExpressionInfo("call(private test.expression.Target.new())", NAMESPACE).getExpression().match(
258                         new ExpressionContext(PointcutType.CALL, constructorNoArgPublic, null)
259                 )
260         );
261     }
262 
263     //  ============ constructor annotations test =============
264     public void testConstructorAnnotations1() throws Exception {
265         assertTrue(
266                 new ExpressionInfo("call(@Requires test.expression.Target.new())", NAMESPACE).getExpression().match(
267                         new ExpressionContext(PointcutType.CALL, constructorNoArgPublic, null)
268                 )
269         );
270         assertFalse(
271                 new ExpressionInfo("call(@RequiresNew test.expression.Target.new())", NAMESPACE).getExpression()
272                 .match(new ExpressionContext(PointcutType.CALL, constructorNoArgPublic, null))
273         );
274         assertTrue(
275                 new ExpressionInfo("execution(@Requires test.expression.Target.new())", NAMESPACE).getExpression()
276                 .match(new ExpressionContext(PointcutType.EXECUTION, constructorNoArgPublic, null))
277         );
278         assertFalse(
279                 new ExpressionInfo("execution(@RequiresNew test.expression.Target.new())", NAMESPACE).getExpression()
280                 .match(new ExpressionContext(PointcutType.EXECUTION, constructorNoArgPublic, null))
281         );
282     }
283 
284     public void testConstructorAnnotations2() throws Exception {
285         assertTrue(
286                 new ExpressionInfo("execution(@Requires *..*.new(..))", NAMESPACE).getExpression().match(
287                         new ExpressionContext(PointcutType.EXECUTION, constructorNoArgPublic, null)
288                 )
289         );
290         try {
291             // should fail - we are specifying a return type for ctor
292             assertTrue(
293                     new ExpressionInfo("execution(@Requires * new(..))", NAMESPACE).getExpression().match(
294                             new ExpressionContext(PointcutType.EXECUTION, constructorNoArgPublic, null)
295                     )
296             );
297             fail("Should fail - specified return type for ctor");
298         } catch (DefinitionException e) {
299             ;//test ok
300         }
301 
302         assertFalse(
303                 new ExpressionInfo("execution(@RequiresNew *..*.new(..))", NAMESPACE).getExpression().match(
304                         new ExpressionContext(PointcutType.EXECUTION, constructorNoArgPublic, null)
305                 )
306         );
307         assertTrue(
308                 new ExpressionInfo("call(@Requires *..*.new(..))", NAMESPACE).getExpression().match(
309                         new ExpressionContext(PointcutType.CALL, constructorNoArgPublic, null)
310                 )
311         );
312         assertFalse(
313                 new ExpressionInfo("call(@RequiresNew *..*.new(..))", NAMESPACE).getExpression().match(
314                         new ExpressionContext(PointcutType.CALL, constructorNoArgPublic, null)
315                 )
316         );
317     }
318 
319     // ============ method modifiers test =============
320     public void testMethodModifiers1() throws Exception {
321         assertFalse(
322                 new ExpressionInfo("call(public void test.expression.Target.modifiers1())", NAMESPACE)
323                 .getExpression().match(new ExpressionContext(PointcutType.CALL, modifiers1, null))
324         );
325         assertTrue(
326                 new ExpressionInfo("call(void test.expression.Target.modifiers1())", NAMESPACE).getExpression()
327                 .match(new ExpressionContext(PointcutType.CALL, modifiers1, null))
328         );
329         assertFalse(
330                 new ExpressionInfo("call(static final void test.expression.Target.modifiers1())", NAMESPACE)
331                 .getExpression().match(new ExpressionContext(PointcutType.CALL, modifiers1, null))
332         );
333     }
334 
335     public void testMethodModifiers2() throws Exception {
336         assertTrue(
337                 new ExpressionInfo("call(public void test.expression.Target.modifiers2())", NAMESPACE)
338                 .getExpression().match(new ExpressionContext(PointcutType.CALL, modifiers2, null))
339         );
340         assertTrue(
341                 new ExpressionInfo("call(void test.expression.Target.modifiers2())", NAMESPACE).getExpression()
342                 .match(new ExpressionContext(PointcutType.CALL, modifiers2, null))
343         );
344         assertFalse(
345                 new ExpressionInfo("call(static final void test.expression.Target.modifiers2())", NAMESPACE)
346                 .getExpression().match(new ExpressionContext(PointcutType.CALL, modifiers2, null))
347         );
348         assertFalse(
349                 new ExpressionInfo("call(public static final void test.expression.Target.modifiers2())", NAMESPACE)
350                 .getExpression().match(new ExpressionContext(PointcutType.CALL, modifiers2, null))
351         );
352         assertTrue(
353                 new ExpressionInfo("call(public static void test.expression.Target.modifiers2())", NAMESPACE)
354                 .getExpression().match(new ExpressionContext(PointcutType.CALL, modifiers2, null))
355         );
356     }
357 
358     public void testMethodModifiers3() throws Exception {
359         assertFalse(
360                 new ExpressionInfo("call(public void test.expression.Target.modifiers3())", NAMESPACE)
361                 .getExpression().match(new ExpressionContext(PointcutType.CALL, modifiers3, null))
362         );
363         assertTrue(
364                 new ExpressionInfo("call(void test.expression.Target.modifiers3())", NAMESPACE).getExpression()
365                 .match(new ExpressionContext(PointcutType.CALL, modifiers3, null))
366         );
367         assertTrue(
368                 new ExpressionInfo("call(static final void test.expression.Target.modifiers3())", NAMESPACE)
369                 .getExpression().match(new ExpressionContext(PointcutType.CALL, modifiers3, null))
370         );
371         assertFalse(
372                 new ExpressionInfo("call(public static native void test.expression.Target.modifiers3())", NAMESPACE)
373                 .getExpression().match(new ExpressionContext(PointcutType.CALL, modifiers3, null))
374         );
375         assertFalse(
376                 new ExpressionInfo("call(public static void test.expression.Target.modifiers3())", NAMESPACE)
377                 .getExpression().match(new ExpressionContext(PointcutType.CALL, modifiers3, null))
378         );
379         assertTrue(
380                 new ExpressionInfo("call(synchronized void test.expression.Target.modifiers3())", NAMESPACE)
381                 .getExpression().match(new ExpressionContext(PointcutType.CALL, modifiers3, null))
382         );
383         assertTrue(
384                 new ExpressionInfo(
385                         "call(protected native synchronized void test.expression.Target.modifiers3())",
386                         NAMESPACE
387                 ).getExpression().match(new ExpressionContext(PointcutType.CALL, modifiers3, null))
388         );
389         assertTrue(
390                 new ExpressionInfo("call(native protected void test.expression.Target.modifiers3())", NAMESPACE)
391                 .getExpression().match(new ExpressionContext(PointcutType.CALL, modifiers3, null))
392         );
393     }
394 
395     public void testMethodModifiers4() throws Exception {
396         ClassInfo otherType = JavaClassInfo.getClassInfo(String.class);
397         assertFalse(
398                 new ExpressionInfo("call(public * test.expression.*.*(..)) && within(test.expression.*)", NAMESPACE)
399                 .getExpression().match(new ExpressionContext(PointcutType.CALL, modifiers4, s_declaringType))
400         );
401         assertTrue(
402                 new ExpressionInfo("call(private * test.expression.*.*(..)) && within(test.expression.*)", NAMESPACE)
403                 .getExpression().match(new ExpressionContext(PointcutType.CALL, modifiers4, s_declaringType))
404         );
405         assertFalse(
406                 new ExpressionInfo(
407                         "call(protected * test.expression.*.*(..)) && within(test.expression.*)",
408                         NAMESPACE
409                 ).getExpression().match(new ExpressionContext(PointcutType.CALL, modifiers4, s_declaringType))
410         );
411         assertFalse(
412                 new ExpressionInfo(
413                         "call(protected * test.expression.*.*(..)) && within(test.expression.*)",
414                         NAMESPACE
415                 ).getExpression().match(new ExpressionContext(PointcutType.CALL, modifiers4, otherType))
416         );
417         assertTrue(
418                 new ExpressionInfo(
419                         "call(private * test.expression.*.*(..)) && within(java.lang.String)",
420                         NAMESPACE
421                 ).getExpression().match(new ExpressionContext(PointcutType.CALL, modifiers4, otherType))
422         );
423     }
424 
425     public void testMethodModifiers5() throws Exception {
426         assertFalse(
427                 new ExpressionInfo("call(!public void test.expression.Target.modifiers2())", NAMESPACE)
428                 .getExpression().match(new ExpressionContext(PointcutType.CALL, modifiers2, null))
429         );
430         assertFalse(
431                 new ExpressionInfo("call(!public void test.expression.Target.modifiers2())", NAMESPACE)
432                 .getExpression().match(new ExpressionContext(PointcutType.CALL, modifiers2, null))
433         );
434         assertTrue(
435                 new ExpressionInfo("call(!private void test.expression.Target.modifiers2())", NAMESPACE)
436                 .getExpression().match(new ExpressionContext(PointcutType.CALL, modifiers2, null))
437         );
438         assertTrue(
439                 new ExpressionInfo("call(!private static void test.expression.Target.modifiers2())", NAMESPACE)
440                 .getExpression().match(new ExpressionContext(PointcutType.CALL, modifiers2, null))
441         );
442         assertFalse(
443                 new ExpressionInfo("call(public !static void test.expression.Target.modifiers2())", NAMESPACE)
444                 .getExpression().match(new ExpressionContext(PointcutType.CALL, modifiers2, null))
445         );
446         assertFalse(
447                 new ExpressionInfo("call(public !static void test.expression.Target.modifiers2())", NAMESPACE)
448                 .getExpression().match(new ExpressionContext(PointcutType.CALL, modifiers2, null))
449         );
450     }
451 
452     // ============ method parameters test =============
453     public void testMethodParameters1() throws Exception {
454         assertTrue(
455                 new ExpressionInfo("call(void test.expression.Target.parameters1())", NAMESPACE).getExpression()
456                 .match(new ExpressionContext(PointcutType.CALL, parameters1, null))
457         );
458         assertTrue(
459                 new ExpressionInfo("call(void test.expression.Target.parameters1(..))", NAMESPACE).getExpression()
460                 .match(new ExpressionContext(PointcutType.CALL, parameters1, null))
461         );
462         assertFalse(
463                 new ExpressionInfo("call(void test.expression.Target.parameters1(*))", NAMESPACE).getExpression()
464                 .match(new ExpressionContext(PointcutType.CALL, parameters1, null))
465         );
466         assertFalse(
467                 new ExpressionInfo("call(void test.expression.Target.parameters1(int))", NAMESPACE).getExpression()
468                 .match(new ExpressionContext(PointcutType.CALL, parameters1, null))
469         );
470     }
471 
472     public void testMethodParameters2() throws Exception {
473         assertFalse(
474                 new ExpressionInfo("call(void test.expression.Target.parameters2())", NAMESPACE).getExpression()
475                 .match(new ExpressionContext(PointcutType.CALL, parameters2, null))
476         );
477         assertTrue(
478                 new ExpressionInfo("call(void test.expression.Target.parameters2(..))", NAMESPACE).getExpression()
479                 .match(new ExpressionContext(PointcutType.CALL, parameters2, null))
480         );
481         assertTrue(
482                 new ExpressionInfo("call(void test.expression.Target.parameters2(int, ..))", NAMESPACE)
483                 .getExpression().match(new ExpressionContext(PointcutType.CALL, parameters2, null))
484         );
485         //AW-263
486         assertTrue(
487                 new ExpressionInfo("call(void test.expression.Target.parameters2(int, float, byte, ..))", NAMESPACE)
488                 .getExpression().match(new ExpressionContext(PointcutType.CALL, parameters2, null))
489         );
490         assertTrue(
491                 new ExpressionInfo(
492                         "call(void test.expression.Target.parameters2(.., int, float, byte, ..))", NAMESPACE
493                 )
494                 .getExpression().match(new ExpressionContext(PointcutType.CALL, parameters2, null))
495         );
496         assertTrue(
497                 new ExpressionInfo("call(void test.expression.Target.parameters2(.., int, float, byte))", NAMESPACE)
498                 .getExpression().match(new ExpressionContext(PointcutType.CALL, parameters2, null))
499         );
500         assertTrue(
501                 new ExpressionInfo("call(void test.expression.Target.parameters2(.., int, float, ..))", NAMESPACE)
502                 .getExpression().match(new ExpressionContext(PointcutType.CALL, parameters2, null))
503         );
504         assertTrue(
505                 new ExpressionInfo(
506                         "call(void test.expression.Target.parameters2bis(.., int, float, byte, ..))", NAMESPACE
507                 )
508                 .getExpression().match(new ExpressionContext(PointcutType.CALL, parameters2bis, null))
509         );
510 
511 
512         assertTrue(
513                 new ExpressionInfo("call(void test.expression.Target.parameters2(int, float, byte))", NAMESPACE)
514                 .getExpression().match(new ExpressionContext(PointcutType.CALL, parameters2, null))
515         );
516         assertTrue(
517                 new ExpressionInfo("call(void test.expression.Target.parameters2(int, *, *))", NAMESPACE)
518                 .getExpression().match(new ExpressionContext(PointcutType.CALL, parameters2, null))
519         );
520         assertFalse(
521                 new ExpressionInfo("call(void test.expression.Target.parameters2(int, int, byte))", NAMESPACE)
522                 .getExpression().match(new ExpressionContext(PointcutType.CALL, parameters2, null))
523         );
524         assertTrue(
525                 new ExpressionInfo("call(void test.expression.Target.parameters2(*, *, byte))", NAMESPACE)
526                 .getExpression().match(new ExpressionContext(PointcutType.CALL, parameters2, null))
527         );
528     }
529 
530     public void testMethodParameters3() throws Exception {
531         assertFalse(
532                 new ExpressionInfo("call(void test.expression.Target.parameters3())", NAMESPACE).getExpression()
533                 .match(new ExpressionContext(PointcutType.CALL, parameters3, null))
534         );
535         assertTrue(
536                 new ExpressionInfo("call(void test.expression.Target.parameters3(..))", NAMESPACE).getExpression()
537                 .match(new ExpressionContext(PointcutType.CALL, parameters3, null))
538         );
539         assertFalse(
540                 new ExpressionInfo("call(void test.expression.Target.parameters3(int, ..))", NAMESPACE)
541                 .getExpression().match(new ExpressionContext(PointcutType.CALL, parameters3, null))
542         );
543         assertTrue(
544                 new ExpressionInfo("call(void test.expression.Target.parameters3(String, ..))", NAMESPACE)
545                 .getExpression().match(new ExpressionContext(PointcutType.CALL, parameters3, null))
546         );
547         assertFalse(
548                 new ExpressionInfo(
549                         "call(void test.expression.Target.parameters3(String, String, String))",
550                         NAMESPACE
551                 ).getExpression().match(new ExpressionContext(PointcutType.CALL, parameters3, null))
552         );
553         assertTrue(
554                 new ExpressionInfo(
555                         "call(void test.expression.Target.parameters3(String, StringBuffer, String))",
556                         NAMESPACE
557                 ).getExpression().match(new ExpressionContext(PointcutType.CALL, parameters3, null))
558         );
559         assertFalse(
560                 new ExpressionInfo(
561                         "call(void test.expression.Target.parameters3(String, StringBuffer, String, *))",
562                         NAMESPACE
563                 ).getExpression().match(new ExpressionContext(PointcutType.CALL, parameters3, null))
564         );
565     }
566 
567     public void testMethodParameters4() throws Exception {
568         assertFalse(
569                 new ExpressionInfo("call(void test.expression.Target.parameters4())", NAMESPACE).getExpression()
570                 .match(new ExpressionContext(PointcutType.CALL, parameters4, null))
571         );
572         assertTrue(
573                 new ExpressionInfo("call(void test.expression.Target.parameters4(..))", NAMESPACE).getExpression()
574                 .match(new ExpressionContext(PointcutType.CALL, parameters4, null))
575         );
576         assertFalse(
577                 new ExpressionInfo("call(void test.expression.Target.parameters4(Object))", NAMESPACE)
578                 .getExpression().match(new ExpressionContext(PointcutType.CALL, parameters4, null))
579         );
580         assertTrue(
581                 new ExpressionInfo("call(void test.expression.Target.parameters4(Object[]))", NAMESPACE)
582                 .getExpression().match(new ExpressionContext(PointcutType.CALL, parameters4, null))
583         );
584         assertFalse(
585                 new ExpressionInfo("call(void test.expression.Target.parameters4(Object[][]))", NAMESPACE)
586                 .getExpression().match(new ExpressionContext(PointcutType.CALL, parameters4, null))
587         );
588     }
589 
590     public void testMethodParameters5() throws Exception {
591         assertFalse(
592                 new ExpressionInfo("call(void test.expression.Target.parameters5())", NAMESPACE).getExpression()
593                 .match(new ExpressionContext(PointcutType.CALL, parameters5, null))
594         );
595         assertTrue(
596                 new ExpressionInfo("call(void test.expression.Target.parameters5(..))", NAMESPACE).getExpression()
597                 .match(new ExpressionContext(PointcutType.CALL, parameters5, null))
598         );
599         assertFalse(
600                 new ExpressionInfo("call(void test.expression.Target.parameters5(int))", NAMESPACE).getExpression()
601                 .match(new ExpressionContext(PointcutType.CALL, parameters5, null))
602         );
603         assertFalse(
604                 new ExpressionInfo("call(void test.expression.Target.parameters5(int[]))", NAMESPACE)
605                 .getExpression().match(new ExpressionContext(PointcutType.CALL, parameters5, null))
606         );
607         assertTrue(
608                 new ExpressionInfo("call(void test.expression.Target.parameters5(int[][]))", NAMESPACE)
609                 .getExpression().match(new ExpressionContext(PointcutType.CALL, parameters5, null))
610         );
611         assertFalse(
612                 new ExpressionInfo("call(void test.expression.Target.parameters5(int[][][]))", NAMESPACE)
613                 .getExpression().match(new ExpressionContext(PointcutType.CALL, parameters5, null))
614         );
615     }
616 
617     // ============ method return type test =============
618     public void testMethodReturnType1() throws Exception {
619         assertTrue(
620                 new ExpressionInfo("call(void test.expression.Target.returnType1())", NAMESPACE).getExpression()
621                 .match(new ExpressionContext(PointcutType.CALL, returnType1, null))
622         );
623         assertFalse(
624                 new ExpressionInfo("call(String test.expression.Target.returnType1())", NAMESPACE).getExpression()
625                 .match(new ExpressionContext(PointcutType.CALL, returnType1, null))
626         );
627         assertTrue(
628                 new ExpressionInfo("call(* test.expression.Target.returnType1())", NAMESPACE).getExpression().match(
629                         new ExpressionContext(PointcutType.CALL, returnType1, null)
630                 )
631         );
632     }
633 
634     public void testMethodReturnType2() throws Exception {
635         assertFalse(
636                 new ExpressionInfo("call(void test.expression.Target.returnType2())", NAMESPACE).getExpression()
637                 .match(new ExpressionContext(PointcutType.CALL, returnType2, null))
638         );
639         assertFalse(
640                 new ExpressionInfo("call(String test.expression.Target.returnType2())", NAMESPACE).getExpression()
641                 .match(new ExpressionContext(PointcutType.CALL, returnType2, null))
642         );
643         assertTrue(
644                 new ExpressionInfo("call(* test.expression.Target.returnType2())", NAMESPACE).getExpression().match(
645                         new ExpressionContext(PointcutType.CALL, returnType2, null)
646                 )
647         );
648         assertTrue(
649                 new ExpressionInfo("call(int test.expression.Target.returnType2())", NAMESPACE).getExpression()
650                 .match(new ExpressionContext(PointcutType.CALL, returnType2, null))
651         );
652         assertFalse(
653                 new ExpressionInfo("call(int[] test.expression.Target.returnType2())", NAMESPACE).getExpression()
654                 .match(new ExpressionContext(PointcutType.CALL, returnType2, null))
655         );
656     }
657 
658     public void testMethodReturnType3() throws Exception {
659         assertFalse(
660                 new ExpressionInfo("call(void test.expression.Target.returnType3())", NAMESPACE).getExpression()
661                 .match(new ExpressionContext(PointcutType.CALL, returnType3, null))
662         );
663         assertTrue(
664                 new ExpressionInfo("call(String test.expression.Target.returnType3())", NAMESPACE).getExpression()
665                 .match(new ExpressionContext(PointcutType.CALL, returnType3, null))
666         );
667         assertTrue(
668                 new ExpressionInfo("call(* test.expression.Target.returnType3())", NAMESPACE).getExpression().match(
669                         new ExpressionContext(PointcutType.CALL, returnType3, null)
670                 )
671         );
672         assertTrue(
673                 new ExpressionInfo("call(java.lang.String* test.expression.Target.returnType3())", NAMESPACE)
674                 .getExpression().match(new ExpressionContext(PointcutType.CALL, returnType3, null))
675         );
676         assertFalse(
677                 new ExpressionInfo("call(java.lang.StringBuffer test.expression.Target.returnType3())", NAMESPACE)
678                 .getExpression().match(new ExpressionContext(PointcutType.CALL, returnType3, null))
679         );
680     }
681 
682     public void testMethodReturnType4() throws Exception {
683         assertFalse(
684                 new ExpressionInfo("call(void test.expression.Target.returnType4())", NAMESPACE).getExpression()
685                 .match(new ExpressionContext(PointcutType.CALL, returnType4, null))
686         );
687         assertTrue(
688                 new ExpressionInfo("call(Process test.expression.Target.returnType4())", NAMESPACE).getExpression()
689                 .match(new ExpressionContext(PointcutType.CALL, returnType4, null))
690         );
691         assertTrue(
692                 new ExpressionInfo("call(* test.expression.Target.returnType4())", NAMESPACE).getExpression().match(
693                         new ExpressionContext(PointcutType.CALL, returnType4, null)
694                 )
695         );
696         assertTrue(
697                 new ExpressionInfo("call(java.lang.Process test.expression.Target.returnType4())", NAMESPACE)
698                 .getExpression().match(new ExpressionContext(PointcutType.CALL, returnType4, null))
699         );
700         assertTrue(
701                 new ExpressionInfo("call(java.lang.* test.expression.Target.returnType4())", NAMESPACE)
702                 .getExpression().match(new ExpressionContext(PointcutType.CALL, returnType4, null))
703         );
704         assertTrue(
705                 new ExpressionInfo("call(java..* test.expression.Target.returnType4())", NAMESPACE).getExpression()
706                 .match(new ExpressionContext(PointcutType.CALL, returnType4, null))
707         );
708         assertTrue(
709                 new ExpressionInfo("call(java.*.Process test.expression.Target.returnType4())", NAMESPACE)
710                 .getExpression().match(new ExpressionContext(PointcutType.CALL, returnType4, null))
711         );
712     }
713 
714     public void testMethodReturnType5() throws Exception {
715         assertFalse(
716                 new ExpressionInfo("call(void test.expression.Target.returnType5())", NAMESPACE).getExpression()
717                 .match(new ExpressionContext(PointcutType.CALL, returnType5, null))
718         );
719         assertFalse(
720                 new ExpressionInfo("call(float test.expression.Target.returnType5())", NAMESPACE).getExpression()
721                 .match(new ExpressionContext(PointcutType.CALL, returnType5, null))
722         );
723         assertFalse(
724                 new ExpressionInfo("call(float[] test.expression.Target.returnType5())", NAMESPACE).getExpression()
725                 .match(new ExpressionContext(PointcutType.CALL, returnType5, null))
726         );
727         assertTrue(
728                 new ExpressionInfo("call(float[][] test.expression.Target.returnType5())", NAMESPACE)
729                 .getExpression().match(new ExpressionContext(PointcutType.CALL, returnType5, null))
730         );
731         assertTrue(
732                 new ExpressionInfo("call(* test.expression.Target.returnType5())", NAMESPACE).getExpression().match(
733                         new ExpressionContext(PointcutType.CALL, returnType5, null)
734                 )
735         );
736     }
737 
738     // ============ method name test =============
739     public void testMethodName() throws Exception {
740         assertTrue(
741                 new ExpressionInfo("call(void test.expression.Target.__method$Name1())", NAMESPACE).getExpression()
742                 .match(new ExpressionContext(PointcutType.CALL, _method$Name1, null))
743         );
744         assertTrue(
745                 new ExpressionInfo("call(void test.expression.Target.__method$*())", NAMESPACE).getExpression()
746                 .match(new ExpressionContext(PointcutType.CALL, _method$Name1, null))
747         );
748         assertTrue(
749                 new ExpressionInfo("call(void test.expression.Target.*Name1())", NAMESPACE).getExpression().match(
750                         new ExpressionContext(PointcutType.CALL, _method$Name1, null)
751                 )
752         );
753         assertTrue(
754                 new ExpressionInfo("call(void test.expression.Target.*$*())", NAMESPACE).getExpression().match(
755                         new ExpressionContext(PointcutType.CALL, _method$Name1, null)
756                 )
757         );
758         assertTrue(
759                 new ExpressionInfo("call(void test.expression.*.__method$Name1())", NAMESPACE).getExpression()
760                 .match(new ExpressionContext(PointcutType.CALL, _method$Name1, null))
761         );
762         assertTrue(
763                 new ExpressionInfo("call(void test..*.__method$Name1())", NAMESPACE).getExpression().match(
764                         new ExpressionContext(PointcutType.CALL, _method$Name1, null)
765                 )
766         );
767         assertTrue(
768                 new ExpressionInfo("call(void test..*.*())", NAMESPACE).getExpression().match(
769                         new ExpressionContext(PointcutType.CALL, _method$Name1, null)
770                 )
771         );
772         assertFalse(
773                 new ExpressionInfo("call(void test.expression.Target.__Method$Name1())", NAMESPACE).getExpression()
774                 .match(new ExpressionContext(PointcutType.CALL, _method$Name1, null))
775         );
776         assertFalse(
777                 new ExpressionInfo("call(void test.expression.Target.__method$Name())", NAMESPACE).getExpression()
778                 .match(new ExpressionContext(PointcutType.CALL, _method$Name1, null))
779         );
780         assertFalse(
781                 new ExpressionInfo("call(void test.expression.Target._methodName1())", NAMESPACE).getExpression()
782                 .match(new ExpressionContext(PointcutType.CALL, _method$Name1, null))
783         );
784         assertTrue(
785                 new ExpressionInfo("execution(* __method$Name1())", NAMESPACE).getExpression()
786                 .match(new ExpressionContext(PointcutType.EXECUTION, _method$Name1, null))
787         );
788         assertTrue(
789                 new ExpressionInfo("within(test.expression.Target) && execution(* __method$Name1())", NAMESPACE).getExpression()
790                 .match(new ExpressionContext(PointcutType.EXECUTION, _method$Name1, _method$Name1.getDeclaringType()))
791         );
792         //AW-112 below
793         assertTrue(
794                 new ExpressionInfo("within(test.expression.Target) && execution(* __method$Name1())", NAMESPACE).getExpression()
795                 .match(new ExpressionContext(PointcutType.EXECUTION, _method$Name1, _method$Name1.getDeclaringType()))
796         );
797         assertTrue(
798                 new ExpressionInfo(
799                         "execution(* test.expression..*(..)) && execution(* *..Target.__method$Name1())", NAMESPACE
800                 ).getExpression()
801                 .match(new ExpressionContext(PointcutType.EXECUTION, _method$Name1, _method$Name1.getDeclaringType()))
802         );
803         assertTrue(
804                 new ExpressionInfo(
805                         "execution(* test.expression..*.*(..)) && execution(* *..Target.__method$Name1())", NAMESPACE
806                 ).getExpression()
807                 .match(new ExpressionContext(PointcutType.EXECUTION, _method$Name1, _method$Name1.getDeclaringType()))
808         );
809         assertTrue(
810                 new ExpressionInfo(
811                         "execution(* test..*(..)) && execution(* *.expression.Target.__method$Name1())", NAMESPACE
812                 ).getExpression()
813                 .match(new ExpressionContext(PointcutType.EXECUTION, _method$Name1, _method$Name1.getDeclaringType()))
814         );
815         assertTrue(
816                 new ExpressionInfo(
817                         "execution(* test..*.*(..)) && execution(* *.expression.Target.__method$Name1())", NAMESPACE
818                 ).getExpression()
819                 .match(new ExpressionContext(PointcutType.EXECUTION, _method$Name1, _method$Name1.getDeclaringType()))
820         );
821 
822         assertTrue(
823                 new ExpressionInfo(
824                         "execution(* test.expression.Target+.*(..)) && !execution(* returnType*(..))", NAMESPACE
825                 ).getExpression()
826                 .match(new ExpressionContext(PointcutType.EXECUTION, _method$Name1, _method$Name1.getDeclaringType()))
827         );
828         assertTrue(
829                 new ExpressionInfo(
830                         "execution(* test.expression.Target+.*(..)) && !execution(* returnType*(..))", NAMESPACE
831                 ).getAdvisedClassFilterExpression()
832                 .match(new ExpressionContext(PointcutType.EXECUTION, _method$Name1, _method$Name1.getDeclaringType()))
833         );
834         assertFalse(
835                 new ExpressionInfo(
836                         "execution(* test.expression.Target+.*(..)) && !execution(* returnType*(..))", NAMESPACE
837                 ).getExpression()
838                 .match(new ExpressionContext(PointcutType.EXECUTION, returnType1, returnType1.getDeclaringType()))
839         );
840     }
841 
842     // ============ method attribute test =============
843     public void testMethodAttributes1() throws Exception {
844         assertTrue(
845                 new ExpressionInfo("call(void test.expression.Target.attributes1())", NAMESPACE).getExpression()
846                 .match(new ExpressionContext(PointcutType.CALL, attributes1, null))
847         );
848         assertTrue(
849                 new ExpressionInfo("call(@Requires void test.expression.Target.attributes1())", NAMESPACE)
850                 .getExpression().match(new ExpressionContext(PointcutType.CALL, attributes1, null))
851         );
852         assertFalse(
853                 new ExpressionInfo("call(@RequiresNew void test.expression.Target.attributes1())", NAMESPACE)
854                 .getExpression().match(new ExpressionContext(PointcutType.CALL, attributes1, null))
855         );
856         assertFalse(
857                 new ExpressionInfo(
858                         "call(@Requires @RequiresNew void test.expression.Target.attributes1())",
859                         NAMESPACE
860                 ).getExpression().match(new ExpressionContext(PointcutType.CALL, attributes1, null))
861         );
862     }
863 
864     // ============ field modifier test =============
865     public void testFieldModifiers1() throws Exception {
866         assertTrue(
867                 new ExpressionInfo("set(int test.expression.Target.modifier1)", NAMESPACE).getExpression().match(
868                         new ExpressionContext(PointcutType.SET, modifier1, null)
869                 )
870         );
871         assertFalse(
872                 new ExpressionInfo("set(public int test.expression.Target.modifier1)", NAMESPACE).getExpression()
873                 .match(new ExpressionContext(PointcutType.SET, modifier1, null))
874         );
875         assertFalse(
876                 new ExpressionInfo("set(public int test.expression.Target.modifier1)", NAMESPACE).getExpression()
877                 .match(new ExpressionContext(PointcutType.SET, modifier1, null))
878         );
879     }
880 
881     public void testFieldModifiers2() throws Exception {
882         assertTrue(
883                 new ExpressionInfo("set(int test.expression.Target.modifier2)", NAMESPACE).getExpression().match(
884                         new ExpressionContext(PointcutType.SET, modifier2, null)
885                 )
886         );
887         assertTrue(
888                 new ExpressionInfo("set(public int test.expression.Target.modifier2)", NAMESPACE).getExpression()
889                 .match(new ExpressionContext(PointcutType.SET, modifier2, null))
890         );
891         assertTrue(
892                 new ExpressionInfo("set(static public int test.expression.Target.modifier2)", NAMESPACE)
893                 .getExpression().match(new ExpressionContext(PointcutType.SET, modifier2, null))
894         );
895         assertTrue(
896                 new ExpressionInfo("set(static int test.expression.Target.modifier2)", NAMESPACE).getExpression()
897                 .match(new ExpressionContext(PointcutType.SET, modifier2, null))
898         );
899         assertFalse(
900                 new ExpressionInfo("set(protected int test.expression.Target.modifier2)", NAMESPACE)
901                 .getExpression().match(new ExpressionContext(PointcutType.SET, modifier2, null))
902         );
903     }
904 
905     public void testFieldModifiers3() throws Exception {
906         assertTrue(
907                 new ExpressionInfo("set(int test.expression.Target.modifier3)", NAMESPACE).getExpression().match(
908                         new ExpressionContext(PointcutType.SET, modifier3, null)
909                 )
910         );
911         assertTrue(
912                 new ExpressionInfo("set(protected int test.expression.Target.modifier3)", NAMESPACE).getExpression()
913                 .match(new ExpressionContext(PointcutType.SET, modifier3, null))
914         );
915         assertTrue(
916                 new ExpressionInfo("set(static protected int test.expression.Target.modifier3)", NAMESPACE)
917                 .getExpression().match(new ExpressionContext(PointcutType.SET, modifier3, null))
918         );
919         assertTrue(
920                 new ExpressionInfo("set(static int test.expression.Target.modifier3)", NAMESPACE).getExpression()
921                 .match(new ExpressionContext(PointcutType.SET, modifier3, null))
922         );
923         assertTrue(
924                 new ExpressionInfo("set(transient int test.expression.Target.modifier3)", NAMESPACE).getExpression()
925                 .match(new ExpressionContext(PointcutType.SET, modifier3, null))
926         );
927         assertTrue(
928                 new ExpressionInfo(
929                         "set(static transient protected final int test.expression.Target.modifier3)",
930                         NAMESPACE
931                 ).getExpression().match(new ExpressionContext(PointcutType.SET, modifier3, null))
932         );
933         assertFalse(
934                 new ExpressionInfo("set(public int test.expression.Target.modifier3)", NAMESPACE).getExpression()
935                 .match(new ExpressionContext(PointcutType.SET, modifier3, null))
936         );
937     }
938 
939     //    public void testFieldModifiers4() throws Exception {
940     //        assertTrue(new ExpressionInfo("set(!private int test.expression.Target.modifier2)",
941     // NAMESPACE).getExpression().parse(new ExpressionContext(PointcutType.SET,
942     //                                                                                                                                          modifier2,
943     //                                                                                                                                          null)));
944     //        assertFalse(new ExpressionInfo("set(!public int test.expression.Target.modifier2)",
945     // NAMESPACE).getExpression()
946     //                                                                                                     .parse(new ExpressionContext(PointcutType.SET,
947     //                                                                                                                                  modifier2,
948     //                                                                                                                                  null)));
949     //        assertFalse(new ExpressionInfo("set(public !static int test.expression.Target.modifier2)",
950     // NAMESPACE).getExpression()
951     //                                                                                                     .parse(new ExpressionContext(PointcutType.SET,
952     //                                                                                                                                  modifier2,
953     //                                                                                                                                  null)));
954     //    }
955     // ============ field type test =============
956     public void testFieldType1() throws Exception {
957         assertTrue(
958                 new ExpressionInfo("set(int test.expression.Target.type1)", NAMESPACE).getExpression().match(
959                         new ExpressionContext(PointcutType.SET, type1, null)
960                 )
961         );
962         assertTrue(
963                 new ExpressionInfo("set(* test.expression.Target.type1)", NAMESPACE).getExpression().match(
964                         new ExpressionContext(PointcutType.SET, type1, null)
965                 )
966         );
967         assertFalse(
968                 new ExpressionInfo("set(Integer test.expression.Target.type1)", NAMESPACE).getExpression().match(
969                         new ExpressionContext(PointcutType.SET, type1, null)
970                 )
971         );
972         assertFalse(
973                 new ExpressionInfo("set(int[] test.expression.Target.type1)", NAMESPACE).getExpression().match(
974                         new ExpressionContext(PointcutType.SET, type1, null)
975                 )
976         );
977     }
978 
979     public void testFieldType2() throws Exception {
980         assertFalse(
981                 new ExpressionInfo("set(int test.expression.Target.type2)", NAMESPACE).getExpression().match(
982                         new ExpressionContext(PointcutType.SET, type2, null)
983                 )
984         );
985         assertTrue(
986                 new ExpressionInfo("set(* test.expression.Target.type2)", NAMESPACE).getExpression().match(
987                         new ExpressionContext(PointcutType.SET, type2, null)
988                 )
989         );
990         assertFalse(
991                 new ExpressionInfo("set(Integer test.expression.Target.type2)", NAMESPACE).getExpression().match(
992                         new ExpressionContext(PointcutType.SET, type2, null)
993                 )
994         );
995         assertFalse(
996                 new ExpressionInfo("set(int[] test.expression.Target.type2)", NAMESPACE).getExpression().match(
997                         new ExpressionContext(PointcutType.SET, type2, null)
998                 )
999         );
1000         assertTrue(
1001                 new ExpressionInfo("set(int[][] test.expression.Target.type2)", NAMESPACE).getExpression().match(
1002                         new ExpressionContext(PointcutType.SET, type2, null)
1003                 )
1004         );
1005     }
1006 
1007     public void testFieldType3() throws Exception {
1008         assertTrue(
1009                 new ExpressionInfo("set(String test.expression.Target.type3)", NAMESPACE).getExpression().match(
1010                         new ExpressionContext(PointcutType.SET, type3, null)
1011                 )
1012         );
1013         assertTrue(
1014                 new ExpressionInfo("set(java.lang.String test.expression.Target.type3)", NAMESPACE).getExpression()
1015                 .match(new ExpressionContext(PointcutType.SET, type3, null))
1016         );
1017         assertFalse(
1018                 new ExpressionInfo("set(java.lang.string test.expression.Target.type3)", NAMESPACE).getExpression()
1019                 .match(new ExpressionContext(PointcutType.SET, type3, null))
1020         );
1021         assertTrue(
1022                 new ExpressionInfo("set(java..* test.expression.Target.type3)", NAMESPACE).getExpression().match(
1023                         new ExpressionContext(PointcutType.SET, type3, null)
1024                 )
1025         );
1026         assertTrue(
1027                 new ExpressionInfo("set(java.*.String test.expression.Target.type3)", NAMESPACE).getExpression()
1028                 .match(new ExpressionContext(PointcutType.SET, type3, null))
1029         );
1030         assertTrue(
1031                 new ExpressionInfo("set(java.lang.String* test.expression.Target.type3)", NAMESPACE).getExpression()
1032                 .match(new ExpressionContext(PointcutType.SET, type3, null))
1033         );
1034         assertTrue(
1035                 new ExpressionInfo("set(* test.expression.Target.type3)", NAMESPACE).getExpression().match(
1036                         new ExpressionContext(PointcutType.SET, type3, null)
1037                 )
1038         );
1039         assertFalse(
1040                 new ExpressionInfo("set(StringBuffer test.expression.Target.type3)", NAMESPACE).getExpression()
1041                 .match(new ExpressionContext(PointcutType.SET, type3, null))
1042         );
1043         assertFalse(
1044                 new ExpressionInfo("set(java.lang.StringBuffer test.expression.Target.type3)", NAMESPACE)
1045                 .getExpression().match(new ExpressionContext(PointcutType.SET, type3, null))
1046         );
1047         assertFalse(
1048                 new ExpressionInfo("set(String[] test.expression.Target.type3)", NAMESPACE).getExpression().match(
1049                         new ExpressionContext(PointcutType.SET, type3, null)
1050                 )
1051         );
1052         assertFalse(
1053                 new ExpressionInfo("set(java.lang.String[] test.expression.Target.type3)", NAMESPACE)
1054                 .getExpression().match(new ExpressionContext(PointcutType.SET, type3, null))
1055         );
1056     }
1057 
1058     public void testFieldType4() throws Exception {
1059         assertFalse(
1060                 new ExpressionInfo("set(String test.expression.Target.type4)", NAMESPACE).getExpression().match(
1061                         new ExpressionContext(PointcutType.SET, type4, null)
1062                 )
1063         );
1064         assertFalse(
1065                 new ExpressionInfo("set(java.lang.String test.expression.Target.type4)", NAMESPACE).getExpression()
1066                 .match(new ExpressionContext(PointcutType.SET, type4, null))
1067         );
1068         assertTrue(
1069                 new ExpressionInfo("set(String[] test.expression.Target.type4)", NAMESPACE).getExpression().match(
1070                         new ExpressionContext(PointcutType.SET, type4, null)
1071                 )
1072         );
1073         assertTrue(
1074                 new ExpressionInfo("set(java.lang.String[] test.expression.Target.type4)", NAMESPACE)
1075                 .getExpression().match(new ExpressionContext(PointcutType.SET, type4, null))
1076         );
1077         assertTrue(
1078                 new ExpressionInfo("set(* test.expression.Target.type4)", NAMESPACE).getExpression().match(
1079                         new ExpressionContext(PointcutType.SET, type4, null)
1080                 )
1081         );
1082         assertFalse(
1083                 new ExpressionInfo("set(String[][] test.expression.Target.type4)", NAMESPACE).getExpression()
1084                 .match(new ExpressionContext(PointcutType.SET, type4, null))
1085         );
1086         assertFalse(
1087                 new ExpressionInfo("set(int[] test.expression.Target.type4)", NAMESPACE).getExpression().match(
1088                         new ExpressionContext(PointcutType.SET, type4, null)
1089                 )
1090         );
1091     }
1092 
1093     // ============ field name test =============
1094     public void testFieldName() throws Exception {
1095         assertTrue(
1096                 new ExpressionInfo("set(int test.expression.Target.__field$Name1)", NAMESPACE).getExpression()
1097                 .match(new ExpressionContext(PointcutType.SET, _field$Name1, null))
1098         );
1099         assertFalse(
1100                 new ExpressionInfo("set(int test.expression.Target.field$Name1)", NAMESPACE).getExpression().match(
1101                         new ExpressionContext(PointcutType.SET, _field$Name1, null)
1102                 )
1103         );
1104         assertTrue(
1105                 new ExpressionInfo("set(int test.expression.Target.__*$Name*)", NAMESPACE).getExpression().match(
1106                         new ExpressionContext(PointcutType.SET, _field$Name1, null)
1107                 )
1108         );
1109         assertTrue(
1110                 new ExpressionInfo("set(int test.expression.Target.__field*)", NAMESPACE).getExpression().match(
1111                         new ExpressionContext(PointcutType.SET, _field$Name1, null)
1112                 )
1113         );
1114         assertTrue(
1115                 new ExpressionInfo("set(int test.expression.*.__field$Name1)", NAMESPACE).getExpression().match(
1116                         new ExpressionContext(PointcutType.SET, _field$Name1, null)
1117                 )
1118         );
1119         assertTrue(
1120                 new ExpressionInfo("set(int test..Target.__field$Name1)", NAMESPACE).getExpression().match(
1121                         new ExpressionContext(PointcutType.SET, _field$Name1, null)
1122                 )
1123         );
1124         assertTrue(
1125                 new ExpressionInfo("set(int test..*.__field$Name1)", NAMESPACE).getExpression().match(
1126                         new ExpressionContext(PointcutType.SET, _field$Name1, null)
1127                 )
1128         );
1129         assertFalse(
1130                 new ExpressionInfo("set(int test..*.__fieldName1)", NAMESPACE).getExpression().match(
1131                         new ExpressionContext(PointcutType.SET, _field$Name1, null)
1132                 )
1133         );
1134         // AW-112 below
1135         assertTrue(
1136                 new ExpressionInfo("within(test.expression.Target) && set(int __field$Name1)", NAMESPACE).getExpression()
1137                 .match(new ExpressionContext(PointcutType.SET, _field$Name1, null))
1138         );
1139         assertTrue(
1140                 new ExpressionInfo("within(*.expression.Target) && set(int test..__field$Name1)", NAMESPACE).getExpression()
1141                 .match(new ExpressionContext(PointcutType.SET, _field$Name1, null))
1142         );
1143 
1144     }
1145 
1146     // ============ field attribute test =============
1147     public void testFieldAttributes1() throws Exception {
1148         assertTrue(
1149                 new ExpressionInfo("set(int test.expression.Target.attribute1)", NAMESPACE).getExpression().match(
1150                         new ExpressionContext(PointcutType.SET, attribute1, null)
1151                 )
1152         );
1153         assertTrue(
1154                 new ExpressionInfo("set(@ReadOnly int test.expression.Target.attribute1)", NAMESPACE)
1155                 .getExpression().match(new ExpressionContext(PointcutType.SET, attribute1, null))
1156         );
1157         assertFalse(
1158                 new ExpressionInfo("set(@Read int test.expression.Target.attribute1)", NAMESPACE).getExpression()
1159                 .match(new ExpressionContext(PointcutType.SET, attribute1, null))
1160         );
1161         assertFalse(
1162                 new ExpressionInfo("set(@ReadOnly @ReadWrite int test.expression.Target.attribute1)", NAMESPACE)
1163                 .getExpression().match(new ExpressionContext(PointcutType.SET, attribute1, null))
1164         );
1165     }
1166 
1167     // ============ class modifier test =============
1168     public void testClassModifier() throws Exception {
1169         assertTrue(
1170                 new ExpressionInfo("within(test.expression.Target)", NAMESPACE).getExpression().match(
1171                         new ExpressionContext(PointcutType.HANDLER, s_declaringType, s_declaringType)
1172                 )
1173         );
1174         assertTrue(
1175                 new ExpressionInfo("within(public test.expression.Target)", NAMESPACE).getExpression().match(
1176                         new ExpressionContext(PointcutType.HANDLER, s_declaringType, s_declaringType)
1177                 )
1178         );
1179         assertFalse(
1180                 new ExpressionInfo("within(protected test.expression.Target)", NAMESPACE).getExpression().match(
1181                         new ExpressionContext(PointcutType.HANDLER, s_declaringType, s_declaringType)
1182                 )
1183         );
1184         assertTrue(
1185                 new ExpressionInfo("within(final public test.expression.Target)", NAMESPACE).getExpression().match(
1186                         new ExpressionContext(PointcutType.HANDLER, s_declaringType, s_declaringType)
1187                 )
1188         );
1189 
1190         //        assertFalse(
1191         //                new ExpressionInfo( "within(abstract test.expression.Target)", NAMESPACE).
1192         //                getExpression().parse(new ExpressionContext( PointcutType.HANDLER, klass, klass))
1193         //
1194         //        );
1195     }
1196 
1197     // ============ class type test =============
1198     public void testClassType() throws Exception {
1199         assertTrue(
1200                 new ExpressionInfo("within(test.expression.Target)", NAMESPACE).getExpression().match(
1201                         new ExpressionContext(PointcutType.WITHIN, s_declaringType, s_declaringType)
1202                 )
1203         );
1204         assertTrue(
1205                 new ExpressionInfo("within(*)", NAMESPACE).getExpression().match(
1206                         new ExpressionContext(PointcutType.HANDLER, s_declaringType, s_declaringType)
1207                 )
1208         );
1209         assertTrue(
1210                 new ExpressionInfo("within(..)", NAMESPACE).getExpression().match(
1211                         new ExpressionContext(PointcutType.HANDLER, s_declaringType, s_declaringType)
1212                 )
1213         );
1214         assertTrue(
1215                 new ExpressionInfo("within(public *)", NAMESPACE).getExpression().match(
1216                         new ExpressionContext(PointcutType.HANDLER, s_declaringType, s_declaringType)
1217                 )
1218         );
1219         assertTrue(
1220                 new ExpressionInfo("within(test.*.Target)", NAMESPACE).getExpression().match(
1221                         new ExpressionContext(PointcutType.HANDLER, s_declaringType, s_declaringType)
1222                 )
1223         );
1224         assertTrue(
1225                 new ExpressionInfo("within(test.expression.*)", NAMESPACE).getExpression().match(
1226                         new ExpressionContext(PointcutType.HANDLER, s_declaringType, s_declaringType)
1227                 )
1228         );
1229         assertTrue(
1230                 new ExpressionInfo("within(test.expression.Tar*)", NAMESPACE).getExpression().match(
1231                         new ExpressionContext(PointcutType.HANDLER, s_declaringType, s_declaringType)
1232                 )
1233         );
1234         assertTrue(
1235                 new ExpressionInfo("within(test.expression.T*et)", NAMESPACE).getExpression().match(
1236                         new ExpressionContext(PointcutType.HANDLER, s_declaringType, s_declaringType)
1237                 )
1238         );
1239         assertTrue(
1240                 new ExpressionInfo("within(test..*)", NAMESPACE).getExpression().match(
1241                         new ExpressionContext(PointcutType.HANDLER, s_declaringType, s_declaringType)
1242                 )
1243         );
1244         assertTrue(
1245                 new ExpressionInfo("within(*.expression.*)", NAMESPACE).getExpression().match(
1246                         new ExpressionContext(PointcutType.HANDLER, s_declaringType, s_declaringType)
1247                 )
1248         );
1249         assertFalse(
1250                 new ExpressionInfo("within(test.expression.target)", NAMESPACE).getExpression().match(
1251                         new ExpressionContext(PointcutType.HANDLER, s_declaringType, s_declaringType)
1252                 )
1253         );
1254         assertFalse(
1255                 new ExpressionInfo("within(test.expression.Targett)", NAMESPACE).getExpression().match(
1256                         new ExpressionContext(PointcutType.HANDLER, s_declaringType, s_declaringType)
1257                 )
1258         );
1259         assertFalse(
1260                 new ExpressionInfo("within(test.*.*.Target)", NAMESPACE).getExpression().match(
1261                         new ExpressionContext(PointcutType.HANDLER, s_declaringType, s_declaringType)
1262                 )
1263         );
1264     }
1265 
1266     public void testClassTypeEarlyFiltering() throws Exception {
1267         ExpressionNamespace.getNamespace(NAMESPACE).addExpressionInfo(
1268                 "pcWithinForCall", new ExpressionInfo("within(test.expression.Target)", NAMESPACE)
1269         );
1270         ExpressionInfo referenceToWithin = new ExpressionInfo(
1271                 "pcWithinForCall AND execution(* modifiers1(..))", NAMESPACE
1272         );
1273         assertTrue(
1274                 referenceToWithin.getAdvisedClassFilterExpression().match(
1275                         new ExpressionContext(PointcutType.EXECUTION, modifiers1, s_declaringType)
1276                 )
1277         );
1278         ExpressionNamespace.getNamespace(NAMESPACE).addExpressionInfo(
1279                 "pcWithinForCall2", new ExpressionInfo("within(test.expression.TargetNOMATCH)", NAMESPACE)
1280         );
1281         ExpressionInfo referenceToWithin2 = new ExpressionInfo(
1282                 "pcWithinForCall2 AND execution(* modifiers1(..))", NAMESPACE
1283         );
1284         assertFalse(
1285                 referenceToWithin2.getAdvisedClassFilterExpression().match(
1286                         new ExpressionContext(PointcutType.EXECUTION, modifiers1, s_declaringType)
1287                 )
1288         );
1289     }
1290 
1291     // ============ class attribute test =============
1292     public void testClassAttribute1() throws Exception {
1293         assertTrue(
1294                 new ExpressionInfo("within(test.expression.Target)", NAMESPACE).getExpression().match(
1295                         new ExpressionContext(PointcutType.HANDLER, s_declaringType, s_declaringType)
1296                 )
1297         );
1298         assertTrue(
1299                 new ExpressionInfo("within(@Serializable test.expression.Target)", NAMESPACE).getExpression().match(
1300                         new ExpressionContext(PointcutType.HANDLER, s_declaringType, s_declaringType)
1301                 )
1302         );
1303         assertFalse(
1304                 new ExpressionInfo("within(!@Serializable test.expression.Target)", NAMESPACE).getExpression().match(
1305                         new ExpressionContext(PointcutType.HANDLER, s_declaringType, s_declaringType)
1306                 )
1307         );
1308         assertTrue(
1309                 new ExpressionInfo("within(!@NotHereSerializable test.expression.Target)", NAMESPACE).getExpression()
1310                 .match(new ExpressionContext(PointcutType.HANDLER, s_declaringType, s_declaringType))
1311         );
1312         assertTrue(
1313                 new ExpressionInfo("within(@Serializable public final test.expression.Target)", NAMESPACE)
1314                 .getExpression().match(new ExpressionContext(PointcutType.HANDLER, s_declaringType, s_declaringType))
1315         );
1316         assertFalse(
1317                 new ExpressionInfo("within(@Serializable @Dummy test.expression.Target)", NAMESPACE)
1318                 .getExpression().match(new ExpressionContext(PointcutType.HANDLER, s_declaringType, s_declaringType))
1319         );
1320     }
1321 
1322     // Tests: http://jira.codehaus.org/browse/AW-223
1323     public void testClassAttribute2() throws Exception {
1324         MethodInfo method = JavaMethodInfo.getMethodInfo(Target.class.getDeclaredMethod("modifiers1", new Class[]{}));
1325         assertTrue(
1326                 new ExpressionInfo(
1327                         "execution(void test.expression.*.*(..)) AND within(@Serializable *..*)", NAMESPACE
1328                 ).getExpression().match(new ExpressionContext(PointcutType.EXECUTION, method, s_declaringType))
1329         );
1330         assertFalse(
1331                 new ExpressionInfo(
1332                         "execution(void test.expression.*.*(..)) AND within(@FakeAnnotation *..*)", NAMESPACE
1333                 ).getExpression().match(new ExpressionContext(PointcutType.EXECUTION, method, s_declaringType))
1334         );
1335     }
1336 
1337     // ============ pointcut type tests =============
1338     public void testPointcutTypes() throws Exception {
1339         MethodInfo method = JavaMethodInfo.getMethodInfo(Target.class.getDeclaredMethod("modifiers1", new Class[]{}));
1340         FieldInfo field = JavaFieldInfo.getFieldInfo(Target.class.getDeclaredField("modifier1"));
1341         assertTrue(
1342                 new ExpressionInfo("execution(void test.expression.Target.modifiers1())", NAMESPACE).getExpression()
1343                 .match(new ExpressionContext(PointcutType.EXECUTION, method, null))
1344         );
1345         assertFalse(
1346                 new ExpressionInfo("execution(void test.expression.Target.modifiers1())", NAMESPACE)
1347                 .getExpression().match(new ExpressionContext(PointcutType.CALL, method, null))
1348         );
1349         assertTrue(
1350                 new ExpressionInfo("set(int test.expression.Target.modifier1)", NAMESPACE).getExpression().match(
1351                         new ExpressionContext(PointcutType.SET, field, null)
1352                 )
1353         );
1354         assertFalse(
1355                 new ExpressionInfo("get(int test.expression.Target.modifier1)", NAMESPACE).getExpression().match(
1356                         new ExpressionContext(PointcutType.SET, field, null)
1357                 )
1358         );
1359         try {
1360             assertFalse(
1361                     new ExpressionInfo("set(int test.expression.Target.modifier1())", NAMESPACE).getExpression()
1362                     .match(new ExpressionContext(PointcutType.SET, method, null))
1363             );
1364         } catch (Throwable e) {
1365             return;
1366         }
1367         fail("expected exception");
1368     }
1369 
1370     // ============ advised class tests =============
1371     public void testAdvisedClassExpression() throws Exception {
1372         ClassInfo otherType = JavaClassInfo.getClassInfo(String.class);
1373         assertFalse(
1374                 new ExpressionInfo("execution(void test.expression.Target.modifiers1())", NAMESPACE)
1375                 .getAdvisedClassFilterExpression().match(new ExpressionContext(PointcutType.WITHIN, otherType, null))
1376         );
1377         assertTrue(
1378                 new ExpressionInfo("execution(void test.expression.Target.modifiers1())", NAMESPACE)
1379                 .getAdvisedClassFilterExpression()
1380                 .match(new ExpressionContext(PointcutType.WITHIN, s_declaringType, null))
1381         );
1382         assertTrue(
1383                 new ExpressionInfo("call(void test.expression.Target.modifiers1())", NAMESPACE)
1384                 .getAdvisedClassFilterExpression()
1385                 .match(new ExpressionContext(PointcutType.WITHIN, s_declaringType, null))
1386         );
1387         assertTrue(
1388                 new ExpressionInfo("set(int test.expression.Target.modifier1)", NAMESPACE)
1389                 .getAdvisedClassFilterExpression()
1390                 .match(new ExpressionContext(PointcutType.WITHIN, s_declaringType, null))
1391         );
1392         assertTrue(
1393                 new ExpressionInfo("get(int test.expression.Target.modifier1)", NAMESPACE)
1394                 .getAdvisedClassFilterExpression()
1395                 .match(new ExpressionContext(PointcutType.WITHIN, s_declaringType, null))
1396         );
1397 
1398         //DIGME all hanlder stuff there
1399         assertTrue(
1400                 new ExpressionInfo("handler(java.lang.Exception) && within(test.expression.Target)", NAMESPACE)
1401                 .getAdvisedClassFilterExpression()
1402                 .match(new ExpressionContext(PointcutType.WITHIN, s_declaringType, null))
1403         );
1404         assertTrue(
1405                 new ExpressionInfo("handler(java.lang.Exception) && within(test.expression.Target)", NAMESPACE)
1406                 .getAdvisedClassFilterExpression()
1407                 .match(new ExpressionContext(PointcutType.WITHIN, s_declaringType, s_declaringType))
1408         );
1409         assertTrue(
1410                 new ExpressionInfo(
1411                         "handler(java.lang.Exception) && withincode(void test.expression.Target.modifiers1())",
1412                         NAMESPACE
1413                 ).getAdvisedClassFilterExpression().match(
1414                         new ExpressionContext(PointcutType.WITHIN, s_declaringType, null)
1415                 )
1416         );
1417         assertTrue(
1418                 new ExpressionInfo(
1419                         "handler(java.lang.Exception) && !withincode(void test.expression.Target.modifiers1())",
1420                         NAMESPACE
1421                 ).getAdvisedClassFilterExpression()
1422                 .match(new ExpressionContext(PointcutType.WITHIN, otherType, null))
1423         );
1424         assertFalse(
1425                 new ExpressionInfo(
1426                         "call(void test.expression.Dummy.modifiers1()) && within(test.expression.Target)",
1427                         NAMESPACE
1428                 ).getAdvisedClassFilterExpression().match(
1429                         new ExpressionContext(PointcutType.WITHIN, s_declaringType, null)
1430                 )
1431         );
1432         assertFalse(
1433                 new ExpressionInfo(
1434                         "call(void test.expression.Dummy.modifiers1()) && withincode(void test.expression.Target.modifiers1())",
1435                         NAMESPACE
1436                 ).getAdvisedClassFilterExpression().match(
1437                         new ExpressionContext(PointcutType.WITHIN, s_declaringType, null)
1438                 )
1439         );//fails on CALL
1440         assertFalse(
1441                 new ExpressionInfo(
1442                         "call(void test.expression.Target.modifiers1()) && withincode(void test.expression.TargetNOMATCH.modifiers1())",
1443                         NAMESPACE
1444                 ).getAdvisedClassFilterExpression().match(
1445                         new ExpressionContext(PointcutType.WITHIN, s_declaringType, s_declaringType)
1446                 )
1447         );//fails on WITHIN but withincode needs more info??
1448         assertTrue(
1449                 new ExpressionInfo(
1450                         "execution(void test.expression.Target.modifiers1()) OR execution(* java.lang.String.*(..))",
1451                         NAMESPACE
1452                 ).getAdvisedClassFilterExpression()
1453                 .match(new ExpressionContext(PointcutType.WITHIN, otherType, null))
1454         );
1455 
1456         assertTrue(
1457                 new ExpressionInfo(
1458                         "execution(void test.expression.Target.modifiers1()) OR execution(* java.lang.String.*(..))",
1459                         NAMESPACE
1460                 ).getAdvisedClassFilterExpression().match(
1461                         new ExpressionContext(PointcutType.WITHIN, s_declaringType, null)
1462                 )
1463         );
1464         assertTrue(
1465                 new ExpressionInfo(
1466                         "execution(void test.expression.Target.modifiers1()) AND !execution(* java.lang.String.*(..))",
1467                         NAMESPACE
1468                 ).getAdvisedClassFilterExpression().match(
1469                         new ExpressionContext(PointcutType.WITHIN, s_declaringType, null)
1470                 )
1471         );
1472 
1473         // check that we ignore cflow
1474         assertTrue(
1475                 new ExpressionInfo(
1476                         "execution(void test.expression.Target.modifiers1()) AND cflow(execution(* *..*(..)))",
1477                         NAMESPACE
1478                 ).getAdvisedClassFilterExpression().match(
1479                         new ExpressionContext(PointcutType.WITHIN, s_declaringType, null)
1480                 )
1481         );
1482         assertTrue(
1483                 new ExpressionInfo(
1484                         "execution(void test.expression.Target.modifiers1()) AND !cflow(execution(* *..*(..)))",
1485                         NAMESPACE
1486                 ).getAdvisedClassFilterExpression().match(
1487                         new ExpressionContext(PointcutType.WITHIN, s_declaringType, null)
1488                 )
1489         );
1490         assertFalse(
1491                 new ExpressionInfo(
1492                         "execution(void test.expression.TargetNOMATCH.modifiers1()) AND cflow(execution(* *..*(..)))",
1493                         NAMESPACE
1494                 ).getAdvisedClassFilterExpression().match(
1495                         new ExpressionContext(PointcutType.WITHIN, s_declaringType, null)
1496                 )
1497         );
1498         assertFalse(
1499                 new ExpressionInfo(
1500                         "execution(void test.expression.TargetNOMATCH.modifiers1()) AND !cflow(execution(* *..*(..)))",
1501                         NAMESPACE
1502                 ).getAdvisedClassFilterExpression().match(
1503                         new ExpressionContext(PointcutType.WITHIN, s_declaringType, null)
1504                 )
1505         );
1506 
1507         // the following should return FALSE with a good early filtering
1508         // returning TRUE is not a problem for the early filtering but false will save time
1509         assertFalse(
1510                 new ExpressionInfo(
1511                         "execution(void test.expression.Target.modifiers1()) OR !execution(* java.lang.String.*(..))",
1512                         NAMESPACE
1513                 ).getAdvisedClassFilterExpression().match(new ExpressionContext(PointcutType.WITHIN, otherType, null))
1514         );
1515         assertFalse(
1516                 new ExpressionInfo(
1517                         "execution(void test.expression.Target.modifiers1()) AND execution(* java.lang.String.*(..))",
1518                         NAMESPACE
1519                 ).getAdvisedClassFilterExpression().match(
1520                         new ExpressionContext(PointcutType.WITHIN, s_declaringType, null)
1521                 )
1522         );
1523         assertFalse(
1524                 new ExpressionInfo(
1525                         "execution(void test.expression.Target.modifiers1()) AND execution(* java.lang.String.*(..))",
1526                         NAMESPACE
1527                 ).getAdvisedClassFilterExpression().match(
1528                         new ExpressionContext(PointcutType.WITHIN, s_declaringType, null)
1529                 )
1530         );
1531 
1532         assertTrue(
1533                 new ExpressionInfo(
1534                         "!(execution(void test.expression.Target.modifiers1()) OR !execution(* java.lang.String.*(..)))",
1535                         NAMESPACE
1536                 ).getAdvisedClassFilterExpression()
1537                 .match(new ExpressionContext(PointcutType.WITHIN, otherType, null))
1538         );
1539 
1540     }
1541 
1542     public void testAdvisedCflowClassExpression() throws Exception {
1543         ClassInfo otherType = JavaClassInfo.getClassInfo(String.class);
1544         s_namespace.addExpressionInfo(
1545                 "string",
1546                 new ExpressionInfo("execution(void java.lang.String.*(..))", NAMESPACE)
1547         );
1548         s_namespace.addExpressionInfo(
1549                 "target",
1550                 new ExpressionInfo("execution(* test.expression.Target.*(..))", NAMESPACE)
1551         );
1552         s_namespace.addExpressionInfo(
1553                 "cflowString",
1554                 new ExpressionInfo("cflow(execution(void java.lang.String.*(..)))", NAMESPACE)
1555         );
1556         s_namespace.addExpressionInfo(
1557                 "cflowTarget",
1558                 new ExpressionInfo(
1559                         "cflow(call(void test.expression.Target.modifiers3()) && withincode(void test.expression.Target.*(..)))",
1560                         NAMESPACE
1561                 )
1562         );
1563         assertFalse(
1564                 singleCflowOf(new ExpressionInfo("string && cflowString", NAMESPACE))
1565                 .getAdvisedClassFilterExpression()
1566                 .match(new ExpressionContext(PointcutType.WITHIN, s_declaringType, null))
1567         );
1568         assertTrue(
1569                 singleCflowOf(new ExpressionInfo("string && cflowString", NAMESPACE))
1570                 .getAdvisedClassFilterExpression().match(new ExpressionContext(PointcutType.WITHIN, otherType, null))
1571         );
1572         assertFalse(
1573                 singleCflowOf(new ExpressionInfo("target && cflowString", NAMESPACE)).getAdvisedClassFilterExpression()
1574                 .match(new ExpressionContext(PointcutType.WITHIN, s_declaringType, null))
1575         );
1576         assertTrue(
1577                 singleCflowOf(new ExpressionInfo("target && cflowString", NAMESPACE))
1578                 .getAdvisedClassFilterExpression().match(new ExpressionContext(PointcutType.WITHIN, otherType, null))
1579         );
1580         assertTrue(
1581                 singleCflowOf(new ExpressionInfo("! target && cflowString", NAMESPACE))
1582                 .getAdvisedClassFilterExpression().match(new ExpressionContext(PointcutType.WITHIN, otherType, null))
1583         );
1584         // will match since NOT is ignored so that cflow aspect can be plugged
1585         assertTrue(
1586                 singleCflowOf(new ExpressionInfo("target && ! cflowString", NAMESPACE))
1587                 .getAdvisedClassFilterExpression().match(new ExpressionContext(PointcutType.WITHIN, otherType, null))
1588         );
1589         assertFalse(
1590                 singleCflowOf(new ExpressionInfo("string && cflowTarget", NAMESPACE)).getAdvisedClassFilterExpression()
1591                 .match(new ExpressionContext(PointcutType.WITHIN, otherType, null))
1592         );
1593         assertTrue(
1594                 singleCflowOf(new ExpressionInfo("string && cflowTarget", NAMESPACE))
1595                 .getAdvisedClassFilterExpression().match(
1596                         new ExpressionContext(PointcutType.WITHIN, s_declaringType, null)
1597                 )
1598         );
1599         assertFalse(
1600                 singleCflowOf(new ExpressionInfo("target && cflowTarget", NAMESPACE)).getAdvisedClassFilterExpression()
1601                 .match(new ExpressionContext(PointcutType.WITHIN, otherType, null))
1602         );
1603         assertTrue(
1604                 singleCflowOf(new ExpressionInfo("target && cflowTarget", NAMESPACE))
1605                 .getAdvisedClassFilterExpression().match(
1606                         new ExpressionContext(PointcutType.WITHIN, s_declaringType, null)
1607                 )
1608         );
1609         assertTrue(
1610                 singleCflowOf(
1611                         new ExpressionInfo(
1612                                 "execution(void test.expression.Dummy.modifiers1()) && cflow(execution(void test.expression.Target.modifiers1()))",
1613                                 NAMESPACE
1614                         )
1615                 ).getAdvisedClassFilterExpression().match(
1616                         new ExpressionContext(PointcutType.WITHIN, s_declaringType, null)
1617                 )
1618         );
1619         assertFalse(
1620                 singleCflowOf(
1621                         new ExpressionInfo(
1622                                 "execution(void test.expression.Dummy.modifiers1()) && cflow(execution(void test.expression.Target.modifiers1()))",
1623                                 NAMESPACE
1624                         )
1625                 ).getAdvisedClassFilterExpression().match(new ExpressionContext(PointcutType.WITHIN, otherType, null))
1626         );
1627         assertFalse(
1628                 singleCflowOf(
1629                         new ExpressionInfo("cflow(execution(void test.expression.Target.modifiers1()))", NAMESPACE)
1630                 )
1631                 .getAdvisedClassFilterExpression().match(new ExpressionContext(PointcutType.WITHIN, otherType, null))
1632         );
1633         assertTrue(
1634                 singleCflowOf(new ExpressionInfo("cflow(call(void test.expression.Target.modifiers1()))", NAMESPACE))
1635                 .getAdvisedClassFilterExpression().match(
1636                         new ExpressionContext(PointcutType.WITHIN, s_declaringType, null)
1637                 )
1638         );
1639         assertTrue(
1640                 singleCflowOf(
1641                         new ExpressionInfo(
1642                                 "cflow(execution(void test.expression.Target.modifiers1())) && within(test.expression.Target)",
1643                                 NAMESPACE
1644                         )
1645                 ).getAdvisedClassFilterExpression().match(
1646                         new ExpressionContext(PointcutType.WITHIN, s_declaringType, null)
1647                 )
1648         );
1649         assertTrue(
1650                 singleCflowOf(
1651                         new ExpressionInfo(
1652                                 "within(test.expression.Target) && cflow(call(void test.expression.Target.modifiers1()))",
1653                                 NAMESPACE
1654                         )
1655                 ).getAdvisedClassFilterExpression().match(
1656                         new ExpressionContext(PointcutType.WITHIN, s_declaringType, null)
1657                 )
1658         );
1659         assertFalse(
1660                 singleCflowOf(
1661                         new ExpressionInfo(
1662                                 "cflow(within(test.expression.T) && call(void test.expression.T.modifiers1()))",
1663                                 NAMESPACE
1664                         )
1665                 ).getAdvisedClassFilterExpression().match(
1666                         new ExpressionContext(PointcutType.WITHIN, s_declaringType, null)
1667                 )
1668         );
1669         assertTrue(
1670                 singleCflowOf(
1671                         new ExpressionInfo(
1672                                 "cflow(!within(test.expression.T) && call(void test.expression.Target.modifiers1()))",
1673                                 NAMESPACE
1674                         )
1675                 ).getAdvisedClassFilterExpression().match(
1676                         new ExpressionContext(PointcutType.WITHIN, s_declaringType, null)
1677                 )
1678         );
1679         assertFalse(
1680                 singleCflowOf(
1681                         new ExpressionInfo(
1682                                 "cflow(call(void test.expression.Target.modifiers1()) && !withincode(void test.expression.Target.modifiers1()))",
1683                                 NAMESPACE
1684                         )
1685                 ).getAdvisedClassFilterExpression().match(new ExpressionContext(PointcutType.WITHIN, otherType, null))
1686         );
1687 
1688         assertTrue(
1689                 singleCflowOf(
1690                         new ExpressionInfo(
1691                                 "!execution(void test.expression.Target.modifiers1()) && cflow(call(void test.expression.Target.modifiers1()))",
1692                                 NAMESPACE
1693                         )
1694                 ).getAdvisedClassFilterExpression().match(
1695                         new ExpressionContext(PointcutType.WITHIN, s_declaringType, null)
1696                 )
1697         );
1698 
1699     }
1700 
1701     // ============ cflow type tests =============
1702     public void testFindCflowPointcut() throws Exception {
1703         MethodInfo method1 = JavaMethodInfo.getMethodInfo(Target.class.getDeclaredMethod("modifiers1", new Class[]{}));
1704         MethodInfo method2 = JavaMethodInfo.getMethodInfo(Target.class.getDeclaredMethod("modifiers2", new Class[]{}));
1705         MethodInfo method3 = JavaMethodInfo.getMethodInfo(Target.class.getDeclaredMethod("modifiers3", new Class[]{}));
1706         s_namespace.addExpressionInfo(
1707                 "pc1", new ExpressionInfo(
1708                         "execution(void test.expression.Target.modifiers2())",
1709                         NAMESPACE
1710                 )
1711         );
1712         s_namespace.addExpressionInfo(
1713                 "pc2", new ExpressionInfo(
1714                         "execution(void test.expression.Target.modifiers3())",
1715                         NAMESPACE
1716                 )
1717         );
1718         s_namespace.addExpressionInfo(
1719                 "cflowPC", new ExpressionInfo(
1720                         "cflow(call(void test.expression.Target.modifiers3()) AND within(test.expression.*))",
1721                         NAMESPACE
1722                 )
1723         );
1724         assertTrue(
1725                 singleCflowOf(
1726                         new ExpressionInfo("cflow(execution(void test.expression.Target.modifiers1()))", NAMESPACE)
1727                 )
1728                 .getExpression().match(new ExpressionContext(PointcutType.EXECUTION, method1, null))
1729         );
1730 
1731         ExpressionInfo expression = null;
1732 
1733         expression = new ExpressionInfo(
1734                 "execution(void test.expression.Target.modifiers2()) && cflow(execution(void test.expression.Target.modifiers1()))",
1735                 NAMESPACE
1736         );
1737         assertTrue(CflowBinding.getCflowBindingsForCflowOf(expression).size() == 1);
1738 
1739         expression = new ExpressionInfo(
1740                 "execution(void test.expression.Target.modifiers2()) && cflow(execution(void test.expression.Target.modifiers1()))",
1741                 NAMESPACE
1742         );
1743         assertTrue(CflowBinding.getCflowBindingsForCflowOf(expression).size() == 1);
1744 
1745         expression = new ExpressionInfo(
1746                 "cflow(execution(void test.expression.Target.modifiers1())) && execution(void test.expression.Target.modifiers2())",
1747                 NAMESPACE
1748         );
1749         assertTrue(CflowBinding.getCflowBindingsForCflowOf(expression).size() == 1);
1750 
1751         expression = new ExpressionInfo("cflowPC && pc1", NAMESPACE);
1752         assertTrue(CflowBinding.getCflowBindingsForCflowOf(expression).size() == 1);
1753         expression = new ExpressionInfo("pc1 && cflowPC", NAMESPACE);
1754         assertTrue(CflowBinding.getCflowBindingsForCflowOf(expression).size() == 1);
1755         expression = new ExpressionInfo("cflow(pc2) && pc1", NAMESPACE);
1756         assertTrue(CflowBinding.getCflowBindingsForCflowOf(expression).size() == 1);
1757         expression = new ExpressionInfo("pc1 && cflow(pc2)", NAMESPACE);
1758         assertTrue(CflowBinding.getCflowBindingsForCflowOf(expression).size() == 1);
1759 
1760         expression = new ExpressionInfo(
1761                 "pc2 && cflow(pc1 || pc2 || call(void test.expression.Target.modifiers1()))",
1762                 NAMESPACE
1763         );
1764         assertTrue(CflowBinding.getCflowBindingsForCflowOf(expression).size() == 1);
1765 
1766         expression = new ExpressionInfo(
1767                 "cflow(pc1 || pc2 || call(void test.expression.Target.modifiers1())) AND pc1",
1768                 NAMESPACE
1769         );
1770         assertTrue(CflowBinding.getCflowBindingsForCflowOf(expression).size() == 1);
1771 
1772         expression = new ExpressionInfo(
1773                 "cflow(pc1 || call(void test.expression.Target.modifiers1())) && (execution(void test.expression.Target.modifiers3()) || pc1)",
1774                 NAMESPACE
1775         );
1776         assertTrue(CflowBinding.getCflowBindingsForCflowOf(expression).size() == 1);
1777 
1778         expression = new ExpressionInfo(
1779                 "cflow(execution(void test.expression.Target.modifiers1())) && execution(void test.expression.Target.modifiers2())",
1780                 NAMESPACE
1781         );
1782         assertTrue(CflowBinding.getCflowBindingsForCflowOf(expression).size() == 1);
1783 
1784         expression =
1785         new ExpressionInfo("cflow(pc1) && execution(void test.expression.Target.modifiers3())", NAMESPACE);
1786         assertTrue(CflowBinding.getCflowBindingsForCflowOf(expression).size() == 1);
1787 
1788         expression = new ExpressionInfo(
1789                 "cflow(call(void test.expression.Target.modifiers1())) && execution(void test.expression.Target.modifiers1())",
1790                 NAMESPACE
1791         );
1792         assertTrue(CflowBinding.getCflowBindingsForCflowOf(expression).size() == 1);
1793 
1794         expression = new ExpressionInfo(
1795                 "cflow(call(void test.expression.Target.modifiers1())) || execution(void test.expression.Target.modifiers1())",
1796                 NAMESPACE
1797         );
1798         assertTrue(CflowBinding.getCflowBindingsForCflowOf(expression).size() == 1);
1799 
1800         expression = new ExpressionInfo(
1801                 "cflow(call(void test.expression.Target.modifiers1())) && cflow(call(void test.expression.Target.modifiers2())) || execution(void test.expression.Target.modifiers1())",
1802                 NAMESPACE
1803         );
1804         assertTrue(CflowBinding.getCflowBindingsForCflowOf(expression).size() == 2);
1805 
1806         expression = new ExpressionInfo(
1807                 "call(void test.expression.Target.modifiers1()) || execution(void test.expression.Target.modifiers1())",
1808                 NAMESPACE
1809         );
1810         assertTrue(CflowBinding.getCflowBindingsForCflowOf(expression).size() == 0);
1811 
1812         expression = new ExpressionInfo(
1813                 "call(void test.expression.Target.modifiers1()) && execution(void test.expression.Target.modifiers1())",
1814                 NAMESPACE
1815         );
1816         assertTrue(CflowBinding.getCflowBindingsForCflowOf(expression).size() == 0);
1817     }
1818 
1819     public void testCflowTypes() throws Exception {
1820         MethodInfo method1 = JavaMethodInfo.getMethodInfo(Target.class.getDeclaredMethod("modifiers1", new Class[]{}));
1821         MethodInfo method2 = JavaMethodInfo.getMethodInfo(Target.class.getDeclaredMethod("modifiers2", new Class[]{}));
1822         MethodInfo method3 = JavaMethodInfo.getMethodInfo(Target.class.getDeclaredMethod("modifiers3", new Class[]{}));
1823         s_namespace.addExpressionInfo(
1824                 "pc1", new ExpressionInfo(
1825                         "execution(void test.expression.Target.modifiers2())",
1826                         NAMESPACE
1827                 )
1828         );
1829         s_namespace.addExpressionInfo(
1830                 "pc2", new ExpressionInfo(
1831                         "execution(void test.expression.Target.modifiers3())",
1832                         NAMESPACE
1833                 )
1834         );
1835         s_namespace.addExpressionInfo(
1836                 "cflowPC", new ExpressionInfo(
1837                         "cflow(call(void test.expression.Target.modifiers3()) AND within(test.expression.*))",
1838                         NAMESPACE
1839                 )
1840         );
1841         assertTrue(
1842                 singleCflowOf(
1843                         new ExpressionInfo("cflow(execution(void test.expression.Target.modifiers1()))", NAMESPACE)
1844                 ).getExpression().match(new ExpressionContext(PointcutType.EXECUTION, method1, null))
1845         );
1846         assertTrue(
1847                 singleCflowOf(
1848                         new ExpressionInfo(
1849                                 "execution(void test.expression.Target.modifiers2()) && cflow(execution(void test.expression.Target.modifiers1()))",
1850                                 NAMESPACE
1851                         )
1852                 ).getExpression().match(new ExpressionContext(PointcutType.EXECUTION, method1, null))
1853         );
1854         assertTrue(
1855                 singleCflowOf(
1856                         new ExpressionInfo(
1857                                 "execution(void test.expression.Target.modifiers2()) && cflow(execution(void test.expression.Target.modifiers1()))",
1858                                 NAMESPACE
1859                         )
1860                 ).getExpression().match(new ExpressionContext(PointcutType.EXECUTION, method1, null))
1861         );
1862         assertTrue(
1863                 singleCflowOf(
1864                         new ExpressionInfo(
1865                                 "cflow(execution(void test.expression.Target.modifiers1())) && execution(void test.expression.Target.modifiers2())",
1866                                 NAMESPACE
1867                         )
1868                 ).getExpression().match(new ExpressionContext(PointcutType.EXECUTION, method1, null))
1869         );
1870         assertTrue(
1871                 singleCflowOf(new ExpressionInfo("cflowPC && pc1", NAMESPACE)).getExpression().match(
1872                         new ExpressionContext(PointcutType.CALL, method3, s_declaringType)
1873                 )
1874         );
1875         assertTrue(
1876                 singleCflowOf(new ExpressionInfo("pc1 && cflowPC", NAMESPACE)).getExpression().match(
1877                         new ExpressionContext(PointcutType.CALL, method3, s_declaringType)
1878                 )
1879         );
1880         assertTrue(
1881                 singleCflowOf(new ExpressionInfo("cflow(pc2) && pc1", NAMESPACE)).getExpression().match(
1882                         new ExpressionContext(PointcutType.EXECUTION, method3, s_declaringType)
1883                 )
1884         );
1885         assertFalse(
1886                 singleCflowOf(new ExpressionInfo("pc1 && cflow(pc2)", NAMESPACE)).getExpression().match(
1887                         new ExpressionContext(PointcutType.EXECUTION, method2, s_declaringType)
1888                 )
1889         );
1890         assertTrue(
1891                 singleCflowOf(
1892                         new ExpressionInfo(
1893                                 "pc2 && cflow(pc1 || pc2 || call(void test.expression.Target.modifiers1()))",
1894                                 NAMESPACE
1895                         )
1896                 ).getExpression().match(new ExpressionContext(PointcutType.CALL, method1, null))
1897         );
1898         assertTrue(
1899                 singleCflowOf(
1900                         new ExpressionInfo(
1901                                 "cflow(pc1 || pc2 || call(void test.expression.Target.modifiers1())) AND pc1",
1902                                 NAMESPACE
1903                         )
1904                 ).getExpression().match(new ExpressionContext(PointcutType.EXECUTION, method3, null))
1905         );
1906         assertTrue(
1907                 singleCflowOf(
1908                         new ExpressionInfo(
1909                                 "cflow(pc1 || call(void test.expression.Target.modifiers1())) && (execution(void test.expression.Target.modifiers3()) || pc1)",
1910                                 NAMESPACE
1911                         )
1912                 ).getExpression().match(new ExpressionContext(PointcutType.EXECUTION, method2, null))
1913         );
1914         assertFalse(
1915                 singleCflowOf(
1916                         new ExpressionInfo(
1917                                 "cflow(execution(void test.expression.Target.modifiers1())) && execution(void test.expression.Target.modifiers2())",
1918                                 NAMESPACE
1919                         )
1920                 ).getExpression().match(new ExpressionContext(PointcutType.EXECUTION, method2, null))
1921         );
1922         assertTrue(
1923                 new ExpressionInfo("cflow(pc1) && execution(void test.expression.Target.modifiers3())", NAMESPACE)
1924                 .getExpression().match(new ExpressionContext(PointcutType.EXECUTION, method3, null))
1925         );
1926         assertFalse(
1927                 singleCflowOf(
1928                         new ExpressionInfo(
1929                                 "cflow(call(void test.expression.Target.modifiers1())) && execution(void test.expression.Target.modifiers1())",
1930                                 NAMESPACE
1931                         )
1932                 ).getExpression().match(new ExpressionContext(PointcutType.EXECUTION, method1, null))
1933         );
1934         assertFalse(
1935                 singleCflowOf(
1936                         new ExpressionInfo(
1937                                 "cflow(call(void test.expression.Target.modifiers1())) || execution(void test.expression.Target.modifiers1())",
1938                                 NAMESPACE
1939                         )
1940                 ).getExpression().match(new ExpressionContext(PointcutType.EXECUTION, method1, null))
1941         );
1942         assertTrue(
1943                 new ExpressionInfo(
1944                         "execution(void test.expression.Target.modifiers2()) AND !cflow(call(void test.expression.Target.modifiers1()))",
1945                         NAMESPACE
1946                 ).getExpression().match(new ExpressionContext(PointcutType.EXECUTION, method2, null))
1947         );
1948         assertTrue(
1949                 singleCflowOf(
1950                         new ExpressionInfo(
1951                                 "execution(void test.expression.Target.modifiers2()) AND !cflow(call(void test.expression.Target.modifiers1()))",
1952                                 NAMESPACE
1953                         )
1954                 ).getExpression().match(new ExpressionContext(PointcutType.CALL, method1, null))
1955         );
1956     }
1957 
1958     public void testCflowBelowTypes() throws Exception {
1959         MethodInfo method1 = JavaMethodInfo.getMethodInfo(Target.class.getDeclaredMethod("modifiers1", new Class[]{}));
1960         MethodInfo method2 = JavaMethodInfo.getMethodInfo(Target.class.getDeclaredMethod("modifiers2", new Class[]{}));
1961         MethodInfo method3 = JavaMethodInfo.getMethodInfo(Target.class.getDeclaredMethod("modifiers3", new Class[]{}));
1962         s_namespace.addExpressionInfo(
1963                 "pc1", new ExpressionInfo(
1964                         "execution(void test.expression.Target.modifiers2())",
1965                         NAMESPACE
1966                 )
1967         );
1968         s_namespace.addExpressionInfo(
1969                 "pc2", new ExpressionInfo(
1970                         "execution(void test.expression.Target.modifiers3())",
1971                         NAMESPACE
1972                 )
1973         );
1974         assertTrue(
1975                 singleCflowOf(
1976                         new ExpressionInfo(
1977                                 "cflowbelow(execution(void test.expression.Target.modifiers1()))", NAMESPACE
1978                         )
1979                 ).getExpression().match(new ExpressionContext(PointcutType.EXECUTION, method1, null))
1980         );
1981         assertTrue(
1982                 singleCflowOf(
1983                         new ExpressionInfo(
1984                                 "cflowbelow(pc1 || pc2 || call(void test.expression.Target.modifiers1()))",
1985                                 NAMESPACE
1986                         )
1987                 ).getExpression().match(new ExpressionContext(PointcutType.CALL, method1, null))
1988         );
1989         assertTrue(
1990                 singleCflowOf(
1991                         new ExpressionInfo(
1992                                 "cflowbelow(pc1 || pc2 || call(void test.expression.Target.modifiers1()))",
1993                                 NAMESPACE
1994                         )
1995                 ).getExpression().match(new ExpressionContext(PointcutType.EXECUTION, method2, null))
1996         );
1997         assertTrue(
1998                 singleCflowOf(
1999                         new ExpressionInfo(
2000                                 "cflowbelow(pc1 || pc2 || call(void test.expression.Target.modifiers1()))",
2001                                 NAMESPACE
2002                         )
2003                 ).getExpression().match(new ExpressionContext(PointcutType.EXECUTION, method3, null))
2004         );
2005     }
2006 
2007     // ============ hasmethod/hasfield =============
2008     public void testHasMethod() throws Exception {
2009         ClassInfo klass = JavaClassInfo.getClassInfo(Target.class);
2010         ClassInfo string = JavaClassInfo.getClassInfo(String.class);
2011         assertTrue(
2012                 new ExpressionInfo(
2013                         "hasmethod(void modifiers1())",
2014                         NAMESPACE
2015                 ).getExpression().match(new ExpressionContext(PointcutType.EXECUTION, klass, klass))
2016         );
2017         assertFalse(
2018                 new ExpressionInfo(
2019                         "hasmethod(void modifiers1())",
2020                         NAMESPACE
2021                 ).getExpression().match(new ExpressionContext(PointcutType.CALL, klass, string))
2022         );
2023         // will match at the AdvisedClassFilterExpression level
2024         assertTrue(
2025                 new ExpressionInfo(
2026                         "hasmethod(* getClass())",//since has not declaring type there !
2027                         NAMESPACE
2028                 ).getAdvisedClassFilterExpression().match(new ExpressionContext(PointcutType.EXECUTION, klass, klass))
2029         );
2030         // but not at the Expression level
2031         assertFalse(
2032                 new ExpressionInfo(
2033                         "hasmethod(* getClass())",
2034                         NAMESPACE
2035                 ).getExpression().match(new ExpressionContext(PointcutType.EXECUTION, klass, klass))
2036         );
2037         // unless method is in class hierarchy
2038         assertFalse(
2039                 new ExpressionInfo(
2040                         "hasmethod(* java.lang.Object+.getClass())",
2041                         NAMESPACE
2042                 ).getExpression().match(new ExpressionContext(PointcutType.EXECUTION, klass, klass))
2043         );
2044         // even a fake method will match
2045         assertTrue(
2046                 new ExpressionInfo(
2047                         "hasmethod(* java.lang.Object+.DOESNOTEXIST())",
2048                         NAMESPACE
2049                 ).getAdvisedClassFilterExpression().match(new ExpressionContext(PointcutType.EXECUTION, klass, klass))
2050         );
2051         // but not at Expression level
2052         assertFalse(
2053                 new ExpressionInfo(
2054                         "hasmethod(* java.lang.Object+.DOESNOTEXIST())",
2055                         NAMESPACE
2056                 ).getExpression().match(new ExpressionContext(PointcutType.EXECUTION, klass, klass))
2057         );
2058     }
2059 
2060     public void testHasField() throws Exception {
2061         ClassInfo klass = JavaClassInfo.getClassInfo(Target.class);
2062         ClassInfo string = JavaClassInfo.getClassInfo(String.class);
2063         assertTrue(
2064                 new ExpressionInfo(
2065                         "hasfield(int modifier1)",
2066                         NAMESPACE
2067                 ).getExpression().match(new ExpressionContext(PointcutType.EXECUTION, klass, klass))
2068         );
2069         assertFalse(
2070                 new ExpressionInfo(
2071                         "hasfield(* modifier1)",
2072                         NAMESPACE
2073                 ).getExpression().match(new ExpressionContext(PointcutType.CALL, klass, string))
2074         );
2075         // will match here
2076         assertTrue(
2077                 new ExpressionInfo(
2078                         "hasfield(* value)",//since no declaring class here !
2079                         NAMESPACE
2080                 ).getAdvisedClassFilterExpression().match(new ExpressionContext(PointcutType.EXECUTION, klass, klass))
2081         );
2082         // and not at the Expression level
2083         assertFalse(
2084                 new ExpressionInfo(
2085                         "hasfield(* value)",
2086                         NAMESPACE
2087                 ).getExpression().match(new ExpressionContext(PointcutType.EXECUTION, klass, klass))
2088         );
2089         //value field exists in String.class
2090         assertTrue(
2091                 new ExpressionInfo(
2092                         "hasfield(* value)",
2093                         NAMESPACE
2094                 ).getExpression().match(new ExpressionContext(PointcutType.CALL, klass, string))
2095         );
2096     }
2097 
2098     // ============ within type tests =============
2099     public void testWithinType1() throws Exception {
2100         ClassInfo otherType = JavaClassInfo.getClassInfo(String.class);
2101         MethodInfo method = JavaMethodInfo.getMethodInfo(Target.class.getDeclaredMethod("modifiers1", new Class[]{}));
2102         assertTrue(
2103                 new ExpressionInfo(
2104                         "execution(void test.expression.Target.modifiers1()) AND within(test.expression.Target)",
2105                         NAMESPACE
2106                 ).getExpression().match(new ExpressionContext(PointcutType.EXECUTION, method, s_declaringType))
2107         );
2108         assertTrue(
2109                 new ExpressionInfo(
2110                         "call(void test.expression.Target.modifiers1()) AND within(test.expression.Target)",
2111                         NAMESPACE
2112                 ).getExpression().match(new ExpressionContext(PointcutType.CALL, method, s_declaringType))
2113         );
2114         assertFalse(
2115                 new ExpressionInfo(
2116                         "call(void test.expression.Target.modifiers1()) AND !within(test.expression.Target)",
2117                         NAMESPACE
2118                 ).getExpression().match(new ExpressionContext(PointcutType.CALL, method, s_declaringType))
2119         );
2120         assertTrue(
2121                 new ExpressionInfo(
2122                         "call(void test.expression.Target.modifiers1()) AND within(java.lang.String)",
2123                         NAMESPACE
2124                 ).getExpression().match(new ExpressionContext(PointcutType.CALL, method, otherType))
2125         );
2126         assertFalse(
2127                 new ExpressionInfo(
2128                         "call(void test.expression.Target.modifiers1()) AND within(java.lang.String)",
2129                         NAMESPACE
2130                 ).getExpression().match(new ExpressionContext(PointcutType.CALL, method, s_declaringType))
2131         );
2132         assertTrue(
2133                 new ExpressionInfo(
2134                         "call(void test.expression.Target.modifiers1()) AND !within(java.lang.String)",
2135                         NAMESPACE
2136                 ).getExpression().match(new ExpressionContext(PointcutType.CALL, method, s_declaringType))
2137         );
2138         //-- test early evaluation
2139         assertTrue(
2140                 new ExpressionInfo(
2141                         "call(void test.expression.Target.NOMATCH()) AND within(java.lang.String)",
2142                         NAMESPACE
2143                 ).getAdvisedClassFilterExpression().match(new ExpressionContext(PointcutType.CALL, method, otherType))
2144         );
2145         assertFalse(
2146                 new ExpressionInfo(
2147                         "call(void test.expression.Target.NOMATCH()) AND within(java.lang.String)",
2148                         NAMESPACE
2149                 ).getAdvisedClassFilterExpression().match(
2150                         new ExpressionContext(PointcutType.CALL, method, s_declaringType)
2151                 )
2152         );
2153         assertTrue(
2154                 new ExpressionInfo(
2155                         "call(void test.expression.Target.NOMATCH()) AND !within(java.lang.String)",
2156                         NAMESPACE
2157                 ).getAdvisedClassFilterExpression().match(
2158                         new ExpressionContext(PointcutType.CALL, method, s_declaringType)
2159                 )
2160         );
2161         assertFalse(
2162                 new ExpressionInfo(
2163                         "call(void test.expression.NOMATCHTarget.NOMATCH()) AND within(java.lang.String)",
2164                         NAMESPACE
2165                 ).getAdvisedClassFilterExpression().match(new ExpressionContext(PointcutType.CALL, method, otherType))
2166         );
2167     }
2168 
2169     public void testWithinType2() throws Exception {
2170         ClassInfo klass = JavaClassInfo.getClassInfo(Target.class);
2171         MethodInfo method = JavaMethodInfo.getMethodInfo(Target.class.getDeclaredMethod("modifiers1", new Class[]{}));
2172         assertTrue(
2173                 new ExpressionInfo("execution(void *..*.modifiers1()) AND within(test.expression.Target)", NAMESPACE)
2174                 .getAdvisedClassFilterExpression().match(
2175                         new ExpressionContext(PointcutType.EXECUTION, method, s_declaringType)
2176                 )
2177         );
2178         assertTrue(
2179                 new ExpressionInfo("execution(void *..*.modifiers1()) AND within(@Serializable *..*)", NAMESPACE)
2180                 .getAdvisedClassFilterExpression().match(
2181                         new ExpressionContext(PointcutType.EXECUTION, method, s_declaringType)
2182                 )
2183         );
2184         assertFalse(
2185                 new ExpressionInfo(
2186                         "execution(void *..*.modifiers1()) AND !within(@Serializable *..*)",
2187                         NAMESPACE
2188                 ).getAdvisedClassFilterExpression().match(
2189                         new ExpressionContext(PointcutType.EXECUTION, method, s_declaringType)
2190                 )
2191         );
2192     }
2193 
2194     public void testWithinCodeType() throws Exception {
2195         MethodInfo stringtoStringMethod = JavaMethodInfo.getMethodInfo(
2196                 String.class.getDeclaredMethod("toString", new Class[]{})
2197         );
2198         MethodInfo method = JavaMethodInfo.getMethodInfo(Target.class.getDeclaredMethod("modifiers1", new Class[]{}));
2199         assertTrue(
2200                 new ExpressionInfo(
2201                         "execution(void test.expression.Target.modifiers1()) AND withincode(void test.expression.Target.modifiers1())",
2202                         NAMESPACE
2203                 ).getExpression().match(new ExpressionContext(PointcutType.EXECUTION, method, method))
2204         );
2205         assertTrue(
2206                 new ExpressionInfo(
2207                         "call(void test.expression.Target.modifiers1()) AND withincode(void test.expression.Target.modifiers1())",
2208                         NAMESPACE
2209                 ).getExpression().match(new ExpressionContext(PointcutType.CALL, method, method))
2210         );
2211         assertFalse(
2212                 new ExpressionInfo(
2213                         "call(void test.expression.Target.modifiers1()) AND !withincode(void test.expression.Target.modifiers1())",
2214                         NAMESPACE
2215                 ).getExpression().match(new ExpressionContext(PointcutType.CALL, method, method))
2216         );
2217         assertTrue(
2218                 new ExpressionInfo(
2219                         "execution(void test.expression.Target.modifiers1()) AND withincode(* java.lang.String.toString())",
2220                         NAMESPACE
2221                 ).getExpression().match(new ExpressionContext(PointcutType.EXECUTION, method, stringtoStringMethod))
2222         );
2223         assertFalse(
2224                 new ExpressionInfo(
2225                         "execution(void test.expression.Target.modifiers1()) AND withincode(* java.lang.String.toString())",
2226                         NAMESPACE
2227                 ).getExpression().match(new ExpressionContext(PointcutType.EXECUTION, method, method))
2228         );
2229         //-- test early evaluation
2230         assertTrue(
2231                 new ExpressionInfo(
2232                         "call(void test.expression.Target.modifiers1()) AND withincode(* java.lang.String.NOMATCHtoString())",
2233                         NAMESPACE
2234                 ).getAdvisedClassFilterExpression().match(
2235                         new ExpressionContext(PointcutType.CALL, method, stringtoStringMethod)
2236                 )
2237         );
2238         assertFalse(
2239                 new ExpressionInfo(
2240                         "call(void test.expression.Target.modifiers1()) AND withincode(* java.lang.String.NOMATCHtoString())",
2241                         NAMESPACE
2242                 ).getAdvisedClassFilterExpression().match(new ExpressionContext(PointcutType.CALL, method, method))
2243         );
2244         assertFalse(
2245                 new ExpressionInfo(
2246                         "call(void test.expression.Target.modifiers1()) AND withincode(* java.lang.StringNOMATCH.*())",
2247                         NAMESPACE
2248                 ).getAdvisedClassFilterExpression().match(new ExpressionContext(PointcutType.CALL, method, method))
2249         );
2250 
2251     }
2252 
2253     // ============ pointcut ref tests =============
2254     public void testPointcutReference() throws Exception {
2255         s_namespace.addExpressionInfo(
2256                 "pc1", new ExpressionInfo(
2257                         "execution(void test.expression.Target.modifiers2())",
2258                         NAMESPACE
2259                 )
2260         );
2261         s_namespace.addExpressionInfo(
2262                 "pc2", new ExpressionInfo(
2263                         "execution(void test.expression.Target.modifiers3())",
2264                         NAMESPACE
2265                 )
2266         );
2267         assertTrue(
2268                 new ExpressionInfo("execution(void test.expression.Target.modifiers1()) || pc1", NAMESPACE)
2269                 .getExpression().match(new ExpressionContext(PointcutType.EXECUTION, modifiers1, null))
2270         );
2271         assertTrue(
2272                 new ExpressionInfo("execution(void test.expression.Target.modifiers1()) || pc1", NAMESPACE)
2273                 .getExpression().match(new ExpressionContext(PointcutType.EXECUTION, modifiers2, null))
2274         );
2275         assertTrue(
2276                 new ExpressionInfo("execution(void test.expression.Target.modifiers1()) || pc2", NAMESPACE)
2277                 .getExpression().match(new ExpressionContext(PointcutType.EXECUTION, modifiers3, null))
2278         );
2279         assertTrue(
2280                 new ExpressionInfo("execution(void test.expression.Target.modifiers1()) || pc1 || pc2", NAMESPACE)
2281                 .getExpression().match(new ExpressionContext(PointcutType.EXECUTION, modifiers1, null))
2282         );
2283         assertTrue(
2284                 new ExpressionInfo("execution(void test.expression.Target.modifiers1()) || pc1 || pc2", NAMESPACE)
2285                 .getExpression().match(new ExpressionContext(PointcutType.EXECUTION, modifiers2, null))
2286         );
2287         assertTrue(
2288                 new ExpressionInfo("execution(void test.expression.Target.modifiers1()) || pc1 || pc2 ", NAMESPACE)
2289                 .getExpression().match(new ExpressionContext(PointcutType.EXECUTION, modifiers3, null))
2290         );
2291         assertTrue(
2292                 new ExpressionInfo("execution(void test.expression.Target.modifiers1()) || pc2 || pc1", NAMESPACE)
2293                 .getExpression().match(new ExpressionContext(PointcutType.EXECUTION, modifiers1, null))
2294         );
2295         assertTrue(
2296                 new ExpressionInfo("execution(void test.expression.Target.modifiers1()) || pc2 || pc1", NAMESPACE)
2297                 .getExpression().match(new ExpressionContext(PointcutType.EXECUTION, modifiers2, null))
2298         );
2299         assertTrue(
2300                 new ExpressionInfo("execution(void test.expression.Target.modifiers1()) || pc2 || pc1 ", NAMESPACE)
2301                 .getExpression().match(new ExpressionContext(PointcutType.EXECUTION, modifiers3, null))
2302         );
2303         assertTrue(
2304                 new ExpressionInfo("pc1 || pc2 || execution(void test.expression.Target.modifiers1())", NAMESPACE)
2305                 .getExpression().match(new ExpressionContext(PointcutType.EXECUTION, modifiers1, null))
2306         );
2307         assertTrue(
2308                 new ExpressionInfo("pc1 || pc2 || execution(void test.expression.Target.modifiers1())", NAMESPACE)
2309                 .getExpression().match(new ExpressionContext(PointcutType.EXECUTION, modifiers2, null))
2310         );
2311         assertTrue(
2312                 new ExpressionInfo("pc1 || pc2 || execution(void test.expression.Target.modifiers1())", NAMESPACE)
2313                 .getExpression().match(new ExpressionContext(PointcutType.EXECUTION, modifiers3, null))
2314         );
2315         assertTrue(
2316                 new ExpressionInfo(
2317                         "(execution(void test.expression.Target.modifiers1()) || pc1 || pc2) AND within(test.expression.Target)",
2318                         NAMESPACE
2319                 ).getExpression()
2320                 .match(new ExpressionContext(PointcutType.EXECUTION, modifiers1, s_declaringType))
2321         );
2322         assertTrue(
2323                 new ExpressionInfo(
2324                         "(execution(void test.expression.Target.modifiers1()) || pc1 || pc2) AND within(test.expression.Target)",
2325                         NAMESPACE
2326                 ).getExpression()
2327                 .match(new ExpressionContext(PointcutType.EXECUTION, modifiers2, s_declaringType))
2328         );
2329         assertTrue(
2330                 new ExpressionInfo(
2331                         "(execution(void test.expression.Target.modifiers1()) || pc1 || pc2) AND within(test.expression.Target)",
2332                         NAMESPACE
2333                 ).getExpression()
2334                 .match(new ExpressionContext(PointcutType.EXECUTION, modifiers3, s_declaringType))
2335         );
2336         assertTrue(
2337                 new ExpressionInfo(
2338                         "within(test.expression.Target) && (pc1 || pc2 || execution(void test.expression.Target.modifiers1()))",
2339                         NAMESPACE
2340                 ).getExpression()
2341                 .match(new ExpressionContext(PointcutType.EXECUTION, modifiers1, s_declaringType))
2342         );
2343         assertTrue(
2344                 new ExpressionInfo(
2345                         "within(test.expression.Target) && (pc2 || pc1 || execution(void test.expression.Target.modifiers1()))",
2346                         NAMESPACE
2347                 ).getExpression()
2348                 .match(new ExpressionContext(PointcutType.EXECUTION, modifiers2, s_declaringType))
2349         );
2350         assertTrue(
2351                 new ExpressionInfo(
2352                         "within(test.expression.Target) && (pc1 || execution(void test.expression.Target.modifiers1()) || pc2)",
2353                         NAMESPACE
2354                 ).getExpression()
2355                 .match(new ExpressionContext(PointcutType.EXECUTION, modifiers3, s_declaringType))
2356         );
2357     }
2358 
2359     // ============ pointcut ref tests =============
2360     public void testPointcutReferenceOutsideScope() throws Exception {
2361         String namespace1 = "Lib";
2362         String namespace2 = "org.moneymaker.Util";
2363         ExpressionNamespace.getNamespace(namespace1).addExpressionInfo(
2364                 "pc1",
2365                 new ExpressionInfo("execution(void test.expression.Target.modifiers1())", namespace1)
2366         );
2367         ExpressionNamespace.getNamespace(namespace2).addExpressionInfo(
2368                 "pc2",
2369                 new ExpressionInfo("execution(void test.expression.Target.modifiers2())", namespace2)
2370         );
2371         assertTrue(
2372                 new ExpressionInfo("execution(* foo.bar.*()) || Lib.pc1", NAMESPACE).getExpression().match(
2373                         new ExpressionContext(PointcutType.EXECUTION, modifiers1, null)
2374                 )
2375         );
2376         assertTrue(
2377                 new ExpressionInfo("Lib.pc1 || execution(* foo.bar.*())", NAMESPACE).getExpression().match(
2378                         new ExpressionContext(PointcutType.EXECUTION, modifiers1, null)
2379                 )
2380         );
2381         assertTrue(
2382                 new ExpressionInfo("org.moneymaker.Util.pc2 || Lib.pc1", NAMESPACE).getExpression().match(
2383                         new ExpressionContext(PointcutType.EXECUTION, modifiers2, null)
2384                 )
2385         );
2386         assertTrue(
2387                 new ExpressionInfo("Lib.pc1 || org.moneymaker.Util.pc2", NAMESPACE).getExpression().match(
2388                         new ExpressionContext(PointcutType.EXECUTION, modifiers2, null)
2389                 )
2390         );
2391         assertFalse(
2392                 new ExpressionInfo("execution(void test.expression.Target.modifiers1()) || Lib.pc1", NAMESPACE)
2393                 .getExpression().match(new ExpressionContext(PointcutType.EXECUTION, modifiers2, null))
2394         );
2395     }
2396 
2397     // ============ and tests =============
2398     public void testAnd() throws Exception {
2399         assertTrue(
2400                 new ExpressionInfo(
2401                         "execution(void test.expression.Target.modifiers1()) AND within(test.expression.Target)",
2402                         NAMESPACE
2403                 ).getExpression()
2404                 .match(new ExpressionContext(PointcutType.EXECUTION, modifiers1, s_declaringType))
2405         );
2406         assertFalse(
2407                 new ExpressionInfo(
2408                         "execution(void test.expression.Target.modifiers1()) AND call(void test.expression.Target.modifiers1())",
2409                         NAMESPACE
2410                 ).getExpression()
2411                 .match(new ExpressionContext(PointcutType.EXECUTION, modifiers1, s_declaringType))
2412         );
2413         assertFalse(
2414                 new ExpressionInfo(
2415                         "call(void test.expression.Target.modifiers1()) AND set(int test.expression.Target.modifier1)",
2416                         NAMESPACE
2417                 ).getExpression().match(new ExpressionContext(PointcutType.CALL, modifier1, null))
2418         );
2419         assertTrue(
2420                 new ExpressionInfo(
2421                         "execution(void test.expression.Target.modifiers1()) && within(test.expression.Target)",
2422                         NAMESPACE
2423                 ).getExpression()
2424                 .match(new ExpressionContext(PointcutType.EXECUTION, modifiers1, s_declaringType))
2425         );
2426         assertFalse(
2427                 new ExpressionInfo(
2428                         "execution(void test.expression.Target.modifiers1()) && call(void test.expression.Target.modifiers1())",
2429                         NAMESPACE
2430                 ).getExpression()
2431                 .match(new ExpressionContext(PointcutType.EXECUTION, modifiers1, s_declaringType))
2432         );
2433         assertFalse(
2434                 new ExpressionInfo(
2435                         "call(void test.expression.Target.modifiers1()) && set(int test.expression.Target.modifier1)",
2436                         NAMESPACE
2437                 ).getExpression().match(new ExpressionContext(PointcutType.CALL, modifier1, null))
2438         );
2439     }
2440 
2441     // ============ or tests =============
2442     public void testOr() throws Exception {
2443         assertTrue(
2444                 new ExpressionInfo(
2445                         "execution(void test.expression.Target.modifiers1()) OR call(void test.expression.Target.modifiers1())",
2446                         NAMESPACE
2447                 ).getExpression().match(new ExpressionContext(PointcutType.EXECUTION, modifiers1, null))
2448         );
2449         assertTrue(
2450                 new ExpressionInfo(
2451                         "execution(void test.expression.Target.modifiers1()) OR call(void test.expression.Target.modifiers1())",
2452                         NAMESPACE
2453                 ).getExpression().match(new ExpressionContext(PointcutType.CALL, modifiers1, null))
2454         );
2455         assertTrue(
2456                 new ExpressionInfo(
2457                         "call(void test.expression.Target.modifiers1()) OR set(int test.expression.Target.modifiers)",
2458                         NAMESPACE
2459                 ).getExpression().match(new ExpressionContext(PointcutType.CALL, modifiers1, null))
2460         );
2461         assertTrue(
2462                 new ExpressionInfo(
2463                         "set(int test.expression.Target.modifier1) OR call(void test.expression.Target.modifiers1())",
2464                         NAMESPACE
2465                 ).getExpression().match(new ExpressionContext(PointcutType.SET, modifier1, null))
2466         );
2467         assertTrue(
2468                 new ExpressionInfo(
2469                         "call(void test.expression.Target.modifiers1()) OR set(int test.expression.Target.modifier1)",
2470                         NAMESPACE
2471                 ).getExpression().match(new ExpressionContext(PointcutType.SET, modifier1, null))
2472         );
2473         assertTrue(
2474                 new ExpressionInfo(
2475                         "execution(void test.expression.Target.modifiers1()) || call(void test.expression.Target.modifiers1())",
2476                         NAMESPACE
2477                 ).getExpression().match(new ExpressionContext(PointcutType.EXECUTION, modifiers1, null))
2478         );
2479         assertTrue(
2480                 new ExpressionInfo(
2481                         "execution(void test.expression.Target.modifiers1()) || call(void test.expression.Target.modifiers1())",
2482                         NAMESPACE
2483                 ).getExpression().match(new ExpressionContext(PointcutType.CALL, modifiers1, null))
2484         );
2485         assertTrue(
2486                 new ExpressionInfo(
2487                         "call(void test.expression.Target.modifiers1()) || set(int test.expression.Target.modifier1)",
2488                         NAMESPACE
2489                 ).getExpression().match(new ExpressionContext(PointcutType.CALL, modifiers1, null))
2490         );
2491         assertTrue(
2492                 new ExpressionInfo(
2493                         "call(void test.expression.Target.modifiers1()) || set(int test.expression.Target.modifier1)",
2494                         NAMESPACE
2495                 ).getExpression().match(new ExpressionContext(PointcutType.SET, modifier1, null))
2496         );
2497     }
2498 
2499     // ============ not tests =============
2500     public void testNot() throws Exception {
2501         assertFalse(
2502                 new ExpressionInfo(
2503                         "execution(void test.expression.Target.modifiers1()) AND !within(test.expression.Target)",
2504                         NAMESPACE
2505                 ).getExpression()
2506                 .match(new ExpressionContext(PointcutType.EXECUTION, modifiers1, s_declaringType))
2507         );
2508         assertTrue(
2509                 new ExpressionInfo(
2510                         "execution(void test.expression.Target.modifiers1()) AND !call(void test.expression.Target.modifiers1())",
2511                         NAMESPACE
2512                 ).getExpression()
2513                 .match(new ExpressionContext(PointcutType.EXECUTION, modifiers1, s_declaringType))
2514         );
2515         assertFalse(
2516                 new ExpressionInfo(
2517                         "call(void test.expression.Target.modifiers1()) AND !set(int test.expression.Target.modifier1)",
2518                         NAMESPACE
2519                 ).getExpression().match(new ExpressionContext(PointcutType.CALL, modifier1, null))
2520         );
2521         assertFalse(
2522                 new ExpressionInfo(
2523                         "execution(void test.expression.Target.modifiers1()) && !within(test.expression.Target)",
2524                         NAMESPACE
2525                 ).getExpression()
2526                 .match(new ExpressionContext(PointcutType.EXECUTION, modifiers1, s_declaringType))
2527         );
2528         assertTrue(
2529                 new ExpressionInfo(
2530                         "execution(void test.expression.Target.modifiers1()) && !call(void test.expression.Target.modifiers1())",
2531                         NAMESPACE
2532                 ).getExpression()
2533                 .match(new ExpressionContext(PointcutType.EXECUTION, modifiers1, s_declaringType))
2534         );
2535         ExpressionVisitor expression = new ExpressionInfo(
2536                 "execution(void test.expression.Target.modifiers1()) && !call(void test.expression.Target.modifiers3()) && !(call(void test.expression.Target.modifiers1()) || call(void test.expression.Target.modifiers2()))",
2537                 NAMESPACE
2538         ).getExpression();
2539         assertTrue(expression.match(new ExpressionContext(PointcutType.EXECUTION, modifiers1, s_declaringType)));
2540         assertFalse(expression.match(new ExpressionContext(PointcutType.CALL, modifiers1, s_declaringType)));
2541         assertFalse(expression.match(new ExpressionContext(PointcutType.SET, modifier1, s_declaringType)));
2542         assertFalse(
2543                 new ExpressionInfo(
2544                         "call(void test.expression.Target.modifiers1()) && !set(int test.expression.Target.modifier1)",
2545                         NAMESPACE
2546                 ).getExpression().match(new ExpressionContext(PointcutType.CALL, modifier1, null))
2547         );
2548     }
2549 
2550     public void testGrammar() throws Throwable {
2551         // test parsing
2552         new ExpressionInfo("args(..)", NAMESPACE);
2553         new ExpressionInfo("args(foo, java, String[], foo, ..)", NAMESPACE);
2554         new ExpressionInfo("args(foo, String+)", NAMESPACE);
2555         new ExpressionInfo("args(.., String+)", NAMESPACE);
2556         new ExpressionInfo("args(java.lang.String, ..)", NAMESPACE);
2557         new ExpressionInfo("args(.., String+, ..)", NAMESPACE); // TODO this syntax is a bit dangerous
2558     }
2559 
2560     // ============ args() test =============
2561     public void testMethodArgs1() throws Exception {
2562         assertTrue(
2563                 new ExpressionInfo("call(void test.expression.Target.parameters1(..)) && args(..)", NAMESPACE)
2564                 .getExpression().match(new ExpressionContext(PointcutType.CALL, parameters1, null))
2565         );
2566         assertTrue(
2567                 new ExpressionInfo("call(void test.expression.Target.parameters1(..)) && args()", NAMESPACE)
2568                 .getExpression().match(new ExpressionContext(PointcutType.CALL, parameters1, null))
2569         );
2570         assertFalse(
2571                 new ExpressionInfo("call(void test.expression.Target.parameters1(..)) && args(int)", NAMESPACE)
2572                 .getExpression().match(new ExpressionContext(PointcutType.CALL, parameters1, null))
2573         );
2574         assertFalse(
2575                 new ExpressionInfo(
2576                         "execution(void test.expression.Target.parameters1(..)) && args(.., int)",
2577                         NAMESPACE
2578                 ).getExpression().match(new ExpressionContext(PointcutType.CALL, parameters1, null))
2579         );
2580         assertFalse(
2581                 new ExpressionInfo(
2582                         "execution(void test.expression.Target.parameters1(..)) && args(.., int)",
2583                         NAMESPACE
2584                 ).getExpression().match(new ExpressionContext(PointcutType.CALL, parameters1, null))
2585         );
2586     }
2587 
2588     public void testMethodArgs2() throws Exception {
2589         assertTrue(
2590                 new ExpressionInfo("call(void test.expression.Target.parameters2(..)) && args(..)", NAMESPACE)
2591                 .getExpression().match(new ExpressionContext(PointcutType.CALL, parameters2, null))
2592         );
2593         assertFalse(
2594                 new ExpressionInfo("call(void test.expression.Target.parameters2(..)) && args()", NAMESPACE)
2595                 .getExpression().match(new ExpressionContext(PointcutType.CALL, parameters2, null))
2596         );
2597         assertFalse(
2598                 new ExpressionInfo("call(void test.expression.Target.parameters2(..)) && args(int)", NAMESPACE)
2599                 .getExpression().match(new ExpressionContext(PointcutType.CALL, parameters2, null))
2600         );
2601         assertTrue(
2602                 new ExpressionInfo(
2603                         "call(void test.expression.Target.parameters2(..)) && args(int, float, byte)",
2604                         NAMESPACE
2605                 ).getExpression().match(new ExpressionContext(PointcutType.CALL, parameters2, null))
2606         );
2607         assertTrue(
2608                 new ExpressionInfo(
2609                         "call(void test.expression.Target.parameters2(..)) && args(.., float, byte)",
2610                         NAMESPACE
2611                 ).getExpression().match(new ExpressionContext(PointcutType.CALL, parameters2, null))
2612         );
2613         assertTrue(
2614                 new ExpressionInfo("call(void test.expression.Target.parameters2(..)) && args(.., byte)", NAMESPACE)
2615                 .getExpression().match(new ExpressionContext(PointcutType.CALL, parameters2, null))
2616         );
2617         assertTrue(
2618                 new ExpressionInfo(
2619                         "call(void test.expression.Target.parameters2(..)) && args(int, float, ..)",
2620                         NAMESPACE
2621                 ).getExpression().match(new ExpressionContext(PointcutType.CALL, parameters2, null))
2622         );
2623         assertTrue(
2624                 new ExpressionInfo("call(void test.expression.Target.parameters2(..)) && args(int, ..)", NAMESPACE)
2625                 .getExpression().match(new ExpressionContext(PointcutType.CALL, parameters2, null))
2626         );
2627 
2628         // AW-263
2629         assertTrue(
2630                 new ExpressionInfo(
2631                         "call(void test.expression.Target.parameters2(..)) && args(int, float, byte, ..)", NAMESPACE
2632                 )
2633                 .getExpression().match(new ExpressionContext(PointcutType.CALL, parameters2, null))
2634         );
2635         assertTrue(
2636                 new ExpressionInfo(
2637                         "call(void test.expression.Target.parameters2(..)) && args(.., int, float, byte, ..)",
2638                         NAMESPACE
2639                 )
2640                 .getExpression().match(new ExpressionContext(PointcutType.CALL, parameters2, null))
2641         );
2642         assertTrue(
2643                 new ExpressionInfo(
2644                         "call(void test.expression.Target.parameters2(..)) && args(.., int, float, byte)", NAMESPACE
2645                 )
2646                 .getExpression().match(new ExpressionContext(PointcutType.CALL, parameters2, null))
2647         );
2648 
2649         // target method is parameters2bis(int i, short s, byte b, int ibis, float fbis, byte bbis)
2650         assertFalse(
2651                 new ExpressionInfo(
2652                         "call(void test.expression.Target.parameters2bis(..)) && args(int, float, byte, ..)",
2653                         NAMESPACE
2654                 )
2655                 .getExpression().match(new ExpressionContext(PointcutType.CALL, parameters2bis, null))
2656         );
2657         assertTrue(
2658                 new ExpressionInfo(
2659                         "call(void test.expression.Target.parameters2bis(..)) && args(.., int, float, byte, ..)",
2660                         NAMESPACE
2661                 )
2662                 .getExpression().match(new ExpressionContext(PointcutType.CALL, parameters2bis, null))
2663         );
2664         assertTrue(
2665                 new ExpressionInfo(
2666                         "call(void test.expression.Target.parameters2bis(..)) && args(.., int, float, byte)",
2667                         NAMESPACE
2668                 )
2669                 .getExpression().match(new ExpressionContext(PointcutType.CALL, parameters2bis, null))
2670         );
2671         assertTrue(
2672                 new ExpressionInfo(
2673                         "call(void test.expression.Target.parameters2bis(..)) && args(.., int, float, ..)", NAMESPACE
2674                 )
2675                 .getExpression().match(new ExpressionContext(PointcutType.CALL, parameters2bis, null))
2676         );
2677         assertFalse(
2678                 new ExpressionInfo(
2679                         "call(void test.expression.Target.parameters2bis(..)) && args(.., int, float, a, b, c, d, e, f, g, h, i,..)",
2680                         NAMESPACE
2681                 )
2682                 .getExpression().match(new ExpressionContext(PointcutType.CALL, parameters2bis, null))
2683         );
2684 
2685         assertFalse(
2686                 new ExpressionInfo(
2687                         "call(void test.expression.Target.parameters2(..)) && args(WRONG, ..)",
2688                         NAMESPACE
2689                 ).getExpression().match(new ExpressionContext(PointcutType.CALL, parameters2, null))
2690         );
2691         assertFalse(
2692                 new ExpressionInfo(
2693                         "call(void test.expression.Target.parameters2(..)) && args(.., WRONG)",
2694                         NAMESPACE
2695                 ).getExpression().match(new ExpressionContext(PointcutType.CALL, parameters2, null))
2696         );
2697         assertFalse(
2698                 new ExpressionInfo(
2699                         "call(void test.expression.Target.parameters2(..)) && args(int, float, WRONG)",
2700                         NAMESPACE
2701                 ).getExpression().match(new ExpressionContext(PointcutType.CALL, parameters2, null))
2702         );
2703         assertFalse(
2704                 new ExpressionInfo(
2705                         "call(void test.expression.Target.parameters2(..)) && args(int, float, byte, WRONG)",
2706                         NAMESPACE
2707                 ).getExpression().match(new ExpressionContext(PointcutType.CALL, parameters2, null))
2708         );
2709     }
2710 
2711     public void testMethodArgs3() throws Exception {
2712         assertFalse(
2713                 new ExpressionInfo("call(void test.expression.Target.parameters3())", NAMESPACE).getExpression()
2714                 .match(new ExpressionContext(PointcutType.CALL, parameters3, null))
2715         );
2716         assertTrue(
2717                 new ExpressionInfo("call(void test.expression.Target.parameters3(..))", NAMESPACE).getExpression()
2718                 .match(new ExpressionContext(PointcutType.CALL, parameters3, null))
2719         );
2720         assertFalse(
2721                 new ExpressionInfo("call(void test.expression.Target.parameters3(int, ..))", NAMESPACE)
2722                 .getExpression().match(new ExpressionContext(PointcutType.CALL, parameters3, null))
2723         );
2724         assertTrue(
2725                 new ExpressionInfo("call(void test.expression.Target.parameters3(String, ..))", NAMESPACE)
2726                 .getExpression().match(new ExpressionContext(PointcutType.CALL, parameters3, null))
2727         );
2728         assertFalse(
2729                 new ExpressionInfo(
2730                         "call(void test.expression.Target.parameters3(String, String, String))",
2731                         NAMESPACE
2732                 ).getExpression().match(new ExpressionContext(PointcutType.CALL, parameters3, null))
2733         );
2734         assertTrue(
2735                 new ExpressionInfo(
2736                         "call(void test.expression.Target.parameters3(String, StringBuffer, String))",
2737                         NAMESPACE
2738                 ).getExpression().match(new ExpressionContext(PointcutType.CALL, parameters3, null))
2739         );
2740         assertTrue(
2741                 new ExpressionInfo(
2742                         "call(void test.expression.Target.parameters3(String, java.io.Serializable+, String))",
2743                         NAMESPACE
2744                 ).getExpression().match(new ExpressionContext(PointcutType.CALL, parameters3, null))
2745         );
2746         assertFalse(
2747                 new ExpressionInfo(
2748                         "call(void test.expression.Target.parameters3(String, StringBuffer, String, *))",
2749                         NAMESPACE
2750                 ).getExpression().match(new ExpressionContext(PointcutType.CALL, parameters3, null))
2751         );
2752     }
2753 
2754     public void testMethodArgs4() throws Exception {
2755         assertTrue(
2756                 new ExpressionInfo("call(void test.expression.Target.parameters4(..)) && args(..)", NAMESPACE)
2757                 .getExpression().match(new ExpressionContext(PointcutType.CALL, parameters4, null))
2758         );
2759         assertTrue(
2760                 new ExpressionInfo(
2761                         "call(void test.expression.Target.parameters4(..)) && args(java.lang.Object[])",
2762                         NAMESPACE
2763                 ).getExpression().match(new ExpressionContext(PointcutType.CALL, parameters4, null))
2764         );
2765         //use of abbreviation on java.lang.*, up to 2 dimension array, see regexp.Pattern
2766         assertTrue(
2767                 new ExpressionInfo("call(void test.expression.Target.parameters4(..)) && args(Object[])", NAMESPACE)
2768                 .getExpression().match(new ExpressionContext(PointcutType.CALL, parameters4, null))
2769         );
2770         assertFalse(
2771                 new ExpressionInfo(
2772                         "call(void test.expression.Target.parameters4(..)) && args(java.lang.Object[][])",
2773                         NAMESPACE
2774                 ).getExpression().match(new ExpressionContext(PointcutType.CALL, parameters4, null))
2775         );
2776     }
2777 
2778     public void testMethodArgs5() throws Exception {
2779         assertTrue(
2780                 new ExpressionInfo("call(void test.expression.Target.parameters5(..)) && args(..)", NAMESPACE)
2781                 .getExpression().match(new ExpressionContext(PointcutType.CALL, parameters5, null))
2782         );
2783         assertTrue(
2784                 new ExpressionInfo("call(void test.expression.Target.parameters5(..)) && args(int[][])", NAMESPACE)
2785                 .getExpression().match(new ExpressionContext(PointcutType.CALL, parameters5, null))
2786         );
2787         assertFalse(
2788                 new ExpressionInfo("call(void test.expression.Target.parameters5(..)) && args(int[])", NAMESPACE)
2789                 .getExpression().match(new ExpressionContext(PointcutType.CALL, parameters5, null))
2790         );
2791     }
2792 
2793     public void testMethodArgsBinding() throws Exception {
2794         ExpressionInfo info = null;
2795 
2796         info = new ExpressionInfo("call(void test.expression.Target.parameters2(..)) && args(i, f, b)", NAMESPACE);
2797         info.addArgument("i", "int", this.getClass().getClassLoader());
2798         info.addArgument("f", "float", this.getClass().getClassLoader());
2799         info.addArgument("b", "byte", this.getClass().getClassLoader());
2800         assertTrue(info.getExpression().match(new ExpressionContext(PointcutType.CALL, parameters2, null)));
2801 
2802         info = new ExpressionInfo("call(void test.expression.Target.parameters2(..)) && args(i, f, byte)", NAMESPACE);
2803         info.addArgument("i", "int", this.getClass().getClassLoader());
2804         info.addArgument("f", "float", this.getClass().getClassLoader());
2805         assertTrue(info.getExpression().match(new ExpressionContext(PointcutType.CALL, parameters2, null)));
2806 
2807 //        info = new ExpressionInfo("call(void test.expression.Target.parameters2(..)) && args(i, f, b)", NAMESPACE);
2808 //        info.addArgument("i", "int", this.getClass().getClassLoader());
2809 //        info.addArgument("f", "WRONG", this.getClass().getClassLoader());
2810 //        // b will be considered as a type
2811 //        assertFalse(info.getExpression().match(new ExpressionContext(PointcutType.CALL, parameters2, null)));
2812     }
2813 
2814     public void testAnnotationFQN() {
2815         //class @
2816         ExpressionInfo info = new ExpressionInfo("within(@examples.annotation.AnnotationA *)", NAMESPACE);
2817         info = new ExpressionInfo("within(@examples.annotation.Annotation$A *)", NAMESPACE);
2818         info = new ExpressionInfo("within(@examples.annotation.Annotation$A @bar.Baz *)", NAMESPACE);
2819         info = new ExpressionInfo("within(@examples.annotation.Annotation$A !@bar.Baz *)", NAMESPACE);
2820 
2821 
2822         // method @
2823         info = new ExpressionInfo(
2824                 "execution(@examples.annotation.AnnotationA * examples.annotation.Target.*(..))", NAMESPACE
2825         );
2826         info = new ExpressionInfo(
2827                 "execution(@examples.annotation.Annotation$A * examples.annotation.Target.*(..))", NAMESPACE
2828         );
2829         info = new ExpressionInfo(
2830                 "execution(@examples.annotation.Annotation$A @bar.Baz * examples.annotation.Target.*(..))", NAMESPACE
2831         );
2832 
2833         // field @
2834         info = new ExpressionInfo("set(@examples.annotation.AnnotationA * Class.field)", NAMESPACE);
2835         info = new ExpressionInfo("set(@examples.annotation.AnnotationA @bar.Baz * Class.field)", NAMESPACE);
2836     }
2837 
2838     public void testWithinCtor() {
2839         ExpressionInfo info = null;
2840 
2841         info = new ExpressionInfo(
2842                 "withincode(test.expression.Target.new())",
2843                 NAMESPACE
2844         );
2845 
2846         info = new ExpressionInfo(
2847                 "execution(* test.expression.Target.*(..)) && withincode(test.expression.Target.new())",
2848                 NAMESPACE
2849         );
2850         assertTrue(
2851                 info.getAdvisedClassFilterExpression().match(
2852                         new ExpressionContext(PointcutType.EXECUTION, modifiers1, constructorNoArgPublic)
2853                 )
2854         );
2855         assertTrue(
2856                 info.getExpression().match(
2857                         new ExpressionContext(PointcutType.EXECUTION, modifiers1, constructorNoArgPublic)
2858                 )
2859         );
2860         // will match since we limit early match to declaring type:
2861         assertTrue(
2862                 info.getAdvisedClassFilterExpression().match(
2863                         new ExpressionContext(PointcutType.EXECUTION, modifiers1, constructorIntArgPrivate)
2864                 )
2865         );
2866         assertFalse(
2867                 info.getExpression().match(
2868                         new ExpressionContext(PointcutType.EXECUTION, modifiers1, constructorIntArgPrivate)
2869                 )
2870         );
2871 
2872         info = new ExpressionInfo(
2873                 "execution(* test.expression.Target.*(..)) && withincode(test.expression.Target.new(int))",
2874                 NAMESPACE
2875         );
2876         assertTrue(
2877                 info.getAdvisedClassFilterExpression().match(
2878                         new ExpressionContext(PointcutType.EXECUTION, modifiers1, constructorIntArgPrivate)
2879                 )
2880         );
2881         assertTrue(
2882                 info.getExpression().match(
2883                         new ExpressionContext(PointcutType.EXECUTION, modifiers1, constructorIntArgPrivate)
2884                 )
2885         );
2886         // will match since we limit early match to declaring type:
2887         assertTrue(
2888                 info.getAdvisedClassFilterExpression().match(
2889                         new ExpressionContext(PointcutType.EXECUTION, modifiers1, constructorNoArgPublic)
2890                 )
2891         );
2892         assertFalse(
2893                 info.getExpression().match(
2894                         new ExpressionContext(PointcutType.EXECUTION, modifiers1, constructorNoArgPublic)
2895                 )
2896         );
2897 
2898         info = new ExpressionInfo(
2899                 "execution(* test.expression.Target.*(..)) && withincode(private test.expression.Target.new())",
2900                 NAMESPACE
2901         );
2902         assertTrue(
2903                 info.getAdvisedClassFilterExpression().match(
2904                         new ExpressionContext(PointcutType.EXECUTION, modifiers1, constructorIntArgPrivate)
2905                 )
2906         );
2907         assertFalse(
2908                 info.getExpression().match(
2909                         new ExpressionContext(PointcutType.EXECUTION, modifiers1, constructorIntArgPrivate)
2910                 )
2911         );
2912         assertTrue(
2913                 info.getAdvisedClassFilterExpression().match(
2914                         new ExpressionContext(PointcutType.EXECUTION, modifiers1, constructorNoArgPublic)
2915                 )
2916         );
2917         assertFalse(
2918                 info.getExpression().match(
2919                         new ExpressionContext(PointcutType.EXECUTION, modifiers1, constructorNoArgPublic)
2920                 )
2921         );
2922 
2923         // test early filtering
2924         info = new ExpressionInfo(
2925                 "execution(* test.expression.Target.*(..)) && withincode(test.expressionWRONG.Target.new())",
2926                 NAMESPACE
2927         );
2928         assertFalse(
2929                 info.getAdvisedClassFilterExpression().match(
2930                         new ExpressionContext(PointcutType.EXECUTION, modifier1, constructorNoArgPublic)
2931                 )
2932         );
2933     }
2934 
2935     public void testThis() {
2936         ClassInfo otherType = JavaClassInfo.getClassInfo(String.class);
2937         ExpressionInfo info = null;
2938 
2939         info = new ExpressionInfo(
2940                 "execution(* parameters1(..)) && this(test.expression.Target)",
2941                 NAMESPACE
2942         );
2943         assertTrue(
2944                 info.getAdvisedClassFilterExpression().match(
2945                         new ExpressionContext(PointcutType.EXECUTION, s_declaringType, s_declaringType)
2946                 )
2947         );
2948         assertTrue(
2949                 info.getAdvisedClassFilterExpression().match(
2950                         new ExpressionContext(PointcutType.EXECUTION, parameters1, s_declaringType)
2951                 )
2952         );
2953         assertTrue(
2954                 info.getAdvisedClassFilterExpression().match(
2955                         new ExpressionContext(PointcutType.EXECUTION, parameters2, s_declaringType)
2956                 )
2957         );
2958         assertFalse(
2959                 info.getAdvisedClassFilterExpression().match(
2960                         new ExpressionContext(PointcutType.EXECUTION, parameters2, otherType)
2961                 )
2962         );
2963         assertFalse(
2964                 info.getExpression().match(
2965                         new ExpressionContext(PointcutType.EXECUTION, s_declaringType, s_declaringType)
2966                 )
2967         );
2968         assertTrue(
2969                 info.getExpression().match(
2970                         new ExpressionContext(PointcutType.EXECUTION, parameters1, s_declaringType)
2971                 )
2972         );
2973         assertFalse(
2974                 info.getExpression().match(
2975                         new ExpressionContext(PointcutType.EXECUTION, parameters2, s_declaringType)
2976                 )
2977         );
2978         assertFalse(info.getExpression().match(new ExpressionContext(PointcutType.EXECUTION, parameters2, otherType)));
2979 
2980         info = new ExpressionInfo(
2981                 "call(* parameters1(..)) && this(test.expression.Target)",
2982                 NAMESPACE
2983         );
2984         assertTrue(
2985                 info.getAdvisedClassFilterExpression().match(
2986                         new ExpressionContext(PointcutType.CALL, s_declaringType, s_declaringType)
2987                 )
2988         );
2989         assertTrue(
2990                 info.getAdvisedClassFilterExpression().match(
2991                         new ExpressionContext(PointcutType.CALL, parameters1, s_declaringType)
2992                 )
2993         );
2994         assertTrue(
2995                 info.getAdvisedClassFilterExpression().match(
2996                         new ExpressionContext(PointcutType.CALL, parameters2, s_declaringType)
2997                 )
2998         );
2999         assertFalse(
3000                 info.getAdvisedClassFilterExpression().match(
3001                         new ExpressionContext(PointcutType.CALL, parameters2, otherType)
3002                 )
3003         );
3004         assertFalse(
3005                 info.getExpression().match(new ExpressionContext(PointcutType.CALL, s_declaringType, s_declaringType))
3006         );
3007         assertTrue(info.getExpression().match(new ExpressionContext(PointcutType.CALL, parameters1, s_declaringType)));
3008         assertFalse(
3009                 info.getExpression().match(new ExpressionContext(PointcutType.CALL, parameters2, s_declaringType))
3010         );
3011         assertFalse(info.getExpression().match(new ExpressionContext(PointcutType.CALL, parameters2, otherType)));
3012 
3013         info = new ExpressionInfo(
3014                 "call(* parameters1(..)) && this(java.lang.String)",
3015                 NAMESPACE
3016         );
3017         assertTrue(
3018                 info.getAdvisedClassFilterExpression().match(
3019                         new ExpressionContext(PointcutType.CALL, parameters1, otherType)
3020                 )
3021         );
3022         assertTrue(info.getExpression().match(new ExpressionContext(PointcutType.CALL, parameters1, otherType)));
3023         assertTrue(
3024                 info.getAdvisedClassFilterExpression().match(
3025                         new ExpressionContext(PointcutType.CALL, parameters2, otherType)
3026                 )
3027         );
3028         assertFalse(info.getExpression().match(new ExpressionContext(PointcutType.CALL, parameters2, otherType)));
3029 
3030         //TODO test when withinInfo is a static method (should not match)
3031         //same with field get / set
3032     }
3033 
3034     public void testTarget() {
3035         ClassInfo otherType = JavaClassInfo.getClassInfo(String.class);
3036         ExpressionInfo info = null;
3037 
3038         info = new ExpressionInfo(
3039                 "execution(* parameters1(..)) && target(test.expression.Target)",
3040                 NAMESPACE
3041         );
3042         assertTrue(
3043                 info.getAdvisedClassFilterExpression().match(
3044                         new ExpressionContext(PointcutType.EXECUTION, s_declaringType, s_declaringType)
3045                 )
3046         );
3047         assertTrue(
3048                 info.getAdvisedClassFilterExpression().match(
3049                         new ExpressionContext(PointcutType.EXECUTION, parameters1, s_declaringType)
3050                 )
3051         );
3052         assertTrue(
3053                 info.getAdvisedClassFilterExpression().match(
3054                         new ExpressionContext(PointcutType.EXECUTION, parameters2, s_declaringType)
3055                 )
3056         );
3057         assertTrue(
3058                 info.getAdvisedClassFilterExpression().match(
3059                         new ExpressionContext(PointcutType.EXECUTION, parameters2, otherType)//otherType ignored
3060                 )
3061         );
3062         assertFalse(
3063                 info.getExpression().match(
3064                         new ExpressionContext(PointcutType.EXECUTION, s_declaringType, s_declaringType)
3065                 )
3066         );
3067         assertTrue(
3068                 info.getExpression().match(
3069                         new ExpressionContext(PointcutType.EXECUTION, parameters1, s_declaringType)
3070                 )
3071         );
3072         assertFalse(
3073                 info.getExpression().match(
3074                         new ExpressionContext(PointcutType.EXECUTION, parameters2, s_declaringType)
3075                 )
3076         );
3077         assertFalse(info.getExpression().match(new ExpressionContext(PointcutType.EXECUTION, parameters2, otherType)));
3078 
3079         info = new ExpressionInfo(
3080                 "call(* parameters1(..)) && target(test.expression.Target)",
3081                 NAMESPACE
3082         );
3083         assertTrue(
3084                 info.getAdvisedClassFilterExpression().match(
3085                         new ExpressionContext(PointcutType.CALL, s_declaringType, s_declaringType)
3086                 )
3087         );
3088         assertTrue(
3089                 info.getAdvisedClassFilterExpression().match(
3090                         new ExpressionContext(PointcutType.CALL, parameters1, s_declaringType)
3091                 )
3092         );
3093         assertTrue(
3094                 info.getAdvisedClassFilterExpression().match(
3095                         new ExpressionContext(PointcutType.CALL, parameters2, s_declaringType)
3096                 )
3097         );
3098         assertTrue(
3099                 info.getAdvisedClassFilterExpression().match(
3100                         new ExpressionContext(PointcutType.CALL, parameters2, otherType)//otherType ignored
3101                 )
3102         );
3103         assertFalse(
3104                 info.getExpression().match(new ExpressionContext(PointcutType.CALL, s_declaringType, s_declaringType))
3105         );
3106         assertTrue(info.getExpression().match(new ExpressionContext(PointcutType.CALL, parameters1, s_declaringType)));
3107         assertFalse(
3108                 info.getExpression().match(new ExpressionContext(PointcutType.CALL, parameters2, s_declaringType))
3109         );
3110         assertFalse(info.getExpression().match(new ExpressionContext(PointcutType.CALL, parameters2, otherType)));
3111 
3112         info = new ExpressionInfo(
3113                 "call(* parameters1(..)) && target(java.lang.String)",
3114                 NAMESPACE
3115         );
3116         assertTrue(
3117                 info.getAdvisedClassFilterExpression().match(
3118                         new ExpressionContext(PointcutType.CALL, parameters1, otherType)
3119                 )
3120         );
3121         assertFalse(info.getExpression().match(new ExpressionContext(PointcutType.CALL, parameters1, otherType)));
3122         assertTrue(
3123                 info.getAdvisedClassFilterExpression().match(
3124                         new ExpressionContext(PointcutType.CALL, parameters2, otherType)
3125                 )
3126         );
3127         assertFalse(info.getExpression().match(new ExpressionContext(PointcutType.CALL, parameters2, otherType)));
3128 
3129         //TODO test when withinInfo is a static method (should not match)
3130         //same with field get / set
3131     }
3132 
3133     public static void main(String[] args) {
3134         junit.textui.TestRunner.run(suite());
3135     }
3136 
3137     public static junit.framework.Test suite() {
3138         return new junit.framework.TestSuite(ExpressionTest.class);
3139     }
3140 
3141     private static ExpressionInfo singleCflowOf(ExpressionInfo singleCflowExpression) {
3142         CflowBinding cfb = (CflowBinding) CflowBinding.getCflowBindingsForCflowOf(singleCflowExpression).get(0);
3143         return cfb.getExpression();
3144     }
3145 
3146 }