1
2
3
4
5
6
7 package org.mule.util.scan.annotations;
8
9 import org.mule.tck.junit4.AbstractMuleTestCase;
10
11 import org.junit.Test;
12 import org.objectweb.asm.ClassReader;
13
14 import static org.junit.Assert.assertEquals;
15
16 public class ClasspathAnnotationsScannerTestCase extends AbstractMuleTestCase
17 {
18
19 @Test
20 public void testScanAnnotationsWithFilter() throws Exception
21 {
22 ClassReader r = new ClosableClassReader(SampleClassWithAnnotations.class.getName());
23 AnnotationsScanner scanner = new AnnotationsScanner(new AnnotationTypeFilter(MultiMarker.class));
24
25 r.accept(scanner, 0);
26
27 assertEquals(1, scanner.getAllAnnotations().size());
28 }
29
30 @Test
31 public void testScanMetaAnnotations() throws Exception
32 {
33 ClassReader r = new ClosableClassReader(SampleBeanWithAnnotations.class.getName());
34 AnnotationsScanner scanner = new AnnotationsScanner(new MetaAnnotationTypeFilter(Meta.class));
35
36 r.accept(scanner, 0);
37
38 assertEquals(2, scanner.getMethodAnnotations().size());
39 }
40 }