1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.bcel;
19
20 import static org.junit.jupiter.api.Assertions.assertEquals;
21
22 import org.apache.bcel.classfile.AnnotationDefault;
23 import org.apache.bcel.classfile.ElementValue;
24 import org.apache.bcel.classfile.JavaClass;
25 import org.apache.bcel.classfile.Method;
26 import org.apache.bcel.classfile.SimpleElementValue;
27 import org.junit.jupiter.api.Test;
28
29 public class AnnotationDefaultAttributeTestCase extends AbstractTestCase {
30
31
32
33
34 @Test
35 public void testMethodAnnotations() throws ClassNotFoundException {
36 final JavaClass clazz = getTestJavaClass(PACKAGE_BASE_NAME + ".data.SimpleAnnotation");
37 final Method m = getMethod(clazz, "fruit");
38 final AnnotationDefault a = (AnnotationDefault) findAttribute("AnnotationDefault", m.getAttributes());
39 final SimpleElementValue val = (SimpleElementValue) a.getDefaultValue();
40 assertEquals(ElementValue.STRING, val.getElementValueType(), "Wrong element value type");
41 assertEquals("bananas", val.getValueString(), "Wrong default");
42 }
43 }