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