1
1
/*
2
- * Copyright 2002-2014 the original author or authors.
2
+ * Copyright 2002-2015 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
@@ -85,25 +85,37 @@ public void findMethodAnnotationOnBridgeMethod() throws Exception {
85
85
assertNull (m .getAnnotation (Order .class ));
86
86
assertNull (getAnnotation (m , Order .class ));
87
87
assertNotNull (findAnnotation (m , Order .class ));
88
- // TODO: actually found on OpenJDK 8 b99! assertNull(m.getAnnotation(Transactional.class));
88
+ assertNull (m .getAnnotation (Transactional .class ));
89
89
assertNotNull (getAnnotation (m , Transactional .class ));
90
90
assertNotNull (findAnnotation (m , Transactional .class ));
91
91
}
92
92
93
- // TODO consider whether we want this to handle annotations on interfaces
94
- // public void findMethodAnnotationFromInterfaceImplementedByRoot()
95
- // throws Exception {
96
- // Method m = Leaf.class.getMethod("fromInterfaceImplementedByRoot",
97
- // (Class[]) null);
98
- // Order o = findAnnotation(Order.class, m, Leaf.class);
99
- // assertNotNull(o);
100
- // }
93
+ @ Test
94
+ public void findMethodAnnotationFromInterface () throws Exception {
95
+ Method method = ImplementsInterfaceWithAnnotatedMethod .class .getMethod ("foo" );
96
+ Order order = findAnnotation (method , Order .class );
97
+ assertNotNull (order );
98
+ }
99
+
100
+ @ Test
101
+ public void findMethodAnnotationFromInterfaceOnSuper () throws Exception {
102
+ Method method = SubOfImplementsInterfaceWithAnnotatedMethod .class .getMethod ("foo" );
103
+ Order order = findAnnotation (method , Order .class );
104
+ assertNotNull (order );
105
+ }
106
+
107
+ @ Test
108
+ public void findMethodAnnotationFromInterfaceWhenSuperDoesNotImplementMethod () throws Exception {
109
+ Method method = SubOfAbstractImplementsInterfaceWithAnnotatedMethod .class .getMethod ("foo" );
110
+ Order order = findAnnotation (method , Order .class );
111
+ assertNotNull (order );
112
+ }
101
113
102
114
/**
103
115
* @since 4.1.2
104
116
*/
105
117
@ Test
106
- public void findAnnotationFavorsLocalMetaAnnotationsOverInterfaces () {
118
+ public void findClassAnnotationFavorsLocalMetaAnnotationsOverInterfaces () {
107
119
Component component = AnnotationUtils .findAnnotation (
108
120
ClassWithLocalMetaAnnotationAndMetaAnnotatedInterface .class , Component .class );
109
121
assertNotNull (component );
@@ -114,7 +126,7 @@ public void findAnnotationFavorsLocalMetaAnnotationsOverInterfaces() {
114
126
* @since 4.0.3
115
127
*/
116
128
@ Test
117
- public void findAnnotationFavorsInheritedAnnotationsOverMoreLocallyDeclaredComposedAnnotations () {
129
+ public void findClassAnnotationFavorsInheritedAnnotationsOverMoreLocallyDeclaredComposedAnnotations () {
118
130
Transactional transactional = AnnotationUtils .findAnnotation (
119
131
SubSubClassWithInheritedAnnotation .class , Transactional .class );
120
132
assertNotNull (transactional );
@@ -125,42 +137,42 @@ public void findAnnotationFavorsInheritedAnnotationsOverMoreLocallyDeclaredCompo
125
137
* @since 4.0.3
126
138
*/
127
139
@ Test
128
- public void findAnnotationFavorsInheritedComposedAnnotationsOverMoreLocallyDeclaredComposedAnnotations () {
140
+ public void findClassAnnotationFavorsInheritedComposedAnnotationsOverMoreLocallyDeclaredComposedAnnotations () {
129
141
Component component = AnnotationUtils .findAnnotation (
130
142
SubSubClassWithInheritedMetaAnnotation .class , Component .class );
131
143
assertNotNull (component );
132
144
assertEquals ("meta2" , component .value ());
133
145
}
134
146
135
147
@ Test
136
- public void findAnnotationOnMetaMetaAnnotatedClass () {
148
+ public void findClassAnnotationOnMetaMetaAnnotatedClass () {
137
149
Component component = AnnotationUtils .findAnnotation (MetaMetaAnnotatedClass .class , Component .class );
138
150
assertNotNull ("Should find meta-annotation on composed annotation on class" , component );
139
151
assertEquals ("meta2" , component .value ());
140
152
}
141
153
142
154
@ Test
143
- public void findAnnotationOnMetaMetaMetaAnnotatedClass () {
155
+ public void findClassAnnotationOnMetaMetaMetaAnnotatedClass () {
144
156
Component component = AnnotationUtils .findAnnotation (MetaMetaMetaAnnotatedClass .class , Component .class );
145
157
assertNotNull ("Should find meta-annotation on meta-annotation on composed annotation on class" , component );
146
158
assertEquals ("meta2" , component .value ());
147
159
}
148
160
149
161
@ Test
150
- public void findAnnotationOnAnnotatedClassWithMissingTargetMetaAnnotation () {
162
+ public void findClassAnnotationOnAnnotatedClassWithMissingTargetMetaAnnotation () {
151
163
// TransactionalClass is NOT annotated or meta-annotated with @Component
152
164
Component component = AnnotationUtils .findAnnotation (TransactionalClass .class , Component .class );
153
165
assertNull ("Should not find @Component on TransactionalClass" , component );
154
166
}
155
167
156
168
@ Test
157
- public void findAnnotationOnMetaCycleAnnotatedClassWithMissingTargetMetaAnnotation () {
169
+ public void findClassAnnotationOnMetaCycleAnnotatedClassWithMissingTargetMetaAnnotation () {
158
170
Component component = AnnotationUtils .findAnnotation (MetaCycleAnnotatedClass .class , Component .class );
159
171
assertNull ("Should not find @Component on MetaCycleAnnotatedClass" , component );
160
172
}
161
173
162
174
@ Test
163
- public void testFindAnnotationDeclaringClass () throws Exception {
175
+ public void findAnnotationDeclaringClassForAllScenarios () throws Exception {
164
176
// no class-level annotation
165
177
assertNull (findAnnotationDeclaringClass (Transactional .class , NonAnnotatedInterface .class ));
166
178
assertNull (findAnnotationDeclaringClass (Transactional .class , NonAnnotatedClass .class ));
@@ -250,7 +262,7 @@ public void findAnnotationDeclaringClassForTypesWithMultipleCandidateTypes() {
250
262
}
251
263
252
264
@ Test
253
- public void testIsAnnotationDeclaredLocally () throws Exception {
265
+ public void isAnnotationDeclaredLocallyForAllScenarios () throws Exception {
254
266
// no class-level annotation
255
267
assertFalse (isAnnotationDeclaredLocally (Transactional .class , NonAnnotatedInterface .class ));
256
268
assertFalse (isAnnotationDeclaredLocally (Transactional .class , NonAnnotatedClass .class ));
@@ -269,7 +281,7 @@ public void testIsAnnotationDeclaredLocally() throws Exception {
269
281
}
270
282
271
283
@ Test
272
- public void testIsAnnotationInherited () throws Exception {
284
+ public void isAnnotationInheritedForAllScenarios () throws Exception {
273
285
// no class-level annotation
274
286
assertFalse (isAnnotationInherited (Transactional .class , NonAnnotatedInterface .class ));
275
287
assertFalse (isAnnotationInherited (Transactional .class , NonAnnotatedClass .class ));
@@ -336,27 +348,6 @@ public void getDefaultValueFromAnnotationType() throws Exception {
336
348
assertEquals (Ordered .LOWEST_PRECEDENCE , AnnotationUtils .getDefaultValue (Order .class ));
337
349
}
338
350
339
- @ Test
340
- public void findAnnotationFromInterface () throws Exception {
341
- Method method = ImplementsInterfaceWithAnnotatedMethod .class .getMethod ("foo" );
342
- Order order = findAnnotation (method , Order .class );
343
- assertNotNull (order );
344
- }
345
-
346
- @ Test
347
- public void findAnnotationFromInterfaceOnSuper () throws Exception {
348
- Method method = SubOfImplementsInterfaceWithAnnotatedMethod .class .getMethod ("foo" );
349
- Order order = findAnnotation (method , Order .class );
350
- assertNotNull (order );
351
- }
352
-
353
- @ Test
354
- public void findAnnotationFromInterfaceWhenSuperDoesNotImplementMethod () throws Exception {
355
- Method method = SubOfAbstractImplementsInterfaceWithAnnotatedMethod .class .getMethod ("foo" );
356
- Order order = findAnnotation (method , Order .class );
357
- assertNotNull (order );
358
- }
359
-
360
351
@ Test
361
352
public void findRepeatableAnnotationOnComposedAnnotation () {
362
353
Repeatable repeatable = findAnnotation (MyRepeatableMeta .class , Repeatable .class );
0 commit comments