View Javadoc

1   /*
2    * $Id: ClasspathAnnotationsScannerTestCase.java 20321 2010-11-24 15:21:24Z dfeist $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
5    *
6    * The software in this package is published under the terms of the CPAL v1.0
7    * license, a copy of which has been included with this distribution in the
8    * LICENSE.txt file.
9    */
10  package org.mule.util.scan.annotations;
11  
12  import junit.framework.TestCase;
13  import org.objectweb.asm.ClassReader;
14  
15  public class ClasspathAnnotationsScannerTestCase extends TestCase
16  {
17      public void testScanAnnotationsWithFilter() throws Exception
18      {
19          ClassReader r = new ClosableClassReader(SampleClassWithAnnotations.class.getName());
20          AnnotationsScanner scanner = new AnnotationsScanner(new AnnotationTypeFilter(MultiMarker.class));
21  
22          r.accept(scanner, 0);
23  
24          assertEquals(1, scanner.getAllAnnotations().size());
25      }
26  
27      public void testScanMetaAnnotations() throws Exception
28      {
29          ClassReader r = new ClosableClassReader(SampleBeanWithAnnotations.class.getName());
30          AnnotationsScanner scanner = new AnnotationsScanner(new MetaAnnotationTypeFilter(Meta.class));
31  
32          r.accept(scanner, 0);
33  
34          assertEquals(2, scanner.getMethodAnnotations().size());
35      }
36  }