@@ -59,6 +59,7 @@ public class AnnotationUtilsTests {
59
59
@ Rule
60
60
public final ExpectedException exception = ExpectedException .none ();
61
61
62
+
62
63
@ Test
63
64
public void findMethodAnnotationOnLeaf () throws Exception {
64
65
Method m = Leaf .class .getMethod ("annotatedOnLeaf" );
@@ -264,22 +265,22 @@ public void findAnnotationDeclaringClassForAllScenarios() throws Exception {
264
265
265
266
// inherited class-level annotation; note: @Transactional is inherited
266
267
assertEquals (InheritedAnnotationInterface .class ,
267
- findAnnotationDeclaringClass (Transactional .class , InheritedAnnotationInterface .class ));
268
+ findAnnotationDeclaringClass (Transactional .class , InheritedAnnotationInterface .class ));
268
269
assertNull (findAnnotationDeclaringClass (Transactional .class , SubInheritedAnnotationInterface .class ));
269
270
assertEquals (InheritedAnnotationClass .class ,
270
- findAnnotationDeclaringClass (Transactional .class , InheritedAnnotationClass .class ));
271
+ findAnnotationDeclaringClass (Transactional .class , InheritedAnnotationClass .class ));
271
272
assertEquals (InheritedAnnotationClass .class ,
272
- findAnnotationDeclaringClass (Transactional .class , SubInheritedAnnotationClass .class ));
273
+ findAnnotationDeclaringClass (Transactional .class , SubInheritedAnnotationClass .class ));
273
274
274
275
// non-inherited class-level annotation; note: @Order is not inherited,
275
276
// but findAnnotationDeclaringClass() should still find it on classes.
276
277
assertEquals (NonInheritedAnnotationInterface .class ,
277
- findAnnotationDeclaringClass (Order .class , NonInheritedAnnotationInterface .class ));
278
+ findAnnotationDeclaringClass (Order .class , NonInheritedAnnotationInterface .class ));
278
279
assertNull (findAnnotationDeclaringClass (Order .class , SubNonInheritedAnnotationInterface .class ));
279
280
assertEquals (NonInheritedAnnotationClass .class ,
280
- findAnnotationDeclaringClass (Order .class , NonInheritedAnnotationClass .class ));
281
+ findAnnotationDeclaringClass (Order .class , NonInheritedAnnotationClass .class ));
281
282
assertEquals (NonInheritedAnnotationClass .class ,
282
- findAnnotationDeclaringClass (Order .class , SubNonInheritedAnnotationClass .class ));
283
+ findAnnotationDeclaringClass (Order .class , SubNonInheritedAnnotationClass .class ));
283
284
}
284
285
285
286
@ Test
@@ -291,23 +292,23 @@ public void findAnnotationDeclaringClassForTypesWithSingleCandidateType() {
291
292
292
293
// inherited class-level annotation; note: @Transactional is inherited
293
294
assertEquals (InheritedAnnotationInterface .class ,
294
- findAnnotationDeclaringClassForTypes (transactionalCandidateList , InheritedAnnotationInterface .class ));
295
+ findAnnotationDeclaringClassForTypes (transactionalCandidateList , InheritedAnnotationInterface .class ));
295
296
assertNull (findAnnotationDeclaringClassForTypes (transactionalCandidateList , SubInheritedAnnotationInterface .class ));
296
297
assertEquals (InheritedAnnotationClass .class ,
297
- findAnnotationDeclaringClassForTypes (transactionalCandidateList , InheritedAnnotationClass .class ));
298
+ findAnnotationDeclaringClassForTypes (transactionalCandidateList , InheritedAnnotationClass .class ));
298
299
assertEquals (InheritedAnnotationClass .class ,
299
- findAnnotationDeclaringClassForTypes (transactionalCandidateList , SubInheritedAnnotationClass .class ));
300
+ findAnnotationDeclaringClassForTypes (transactionalCandidateList , SubInheritedAnnotationClass .class ));
300
301
301
302
// non-inherited class-level annotation; note: @Order is not inherited,
302
303
// but findAnnotationDeclaringClassForTypes() should still find it on classes.
303
304
List <Class <? extends Annotation >> orderCandidateList = Arrays .<Class <? extends Annotation >> asList (Order .class );
304
305
assertEquals (NonInheritedAnnotationInterface .class ,
305
- findAnnotationDeclaringClassForTypes (orderCandidateList , NonInheritedAnnotationInterface .class ));
306
+ findAnnotationDeclaringClassForTypes (orderCandidateList , NonInheritedAnnotationInterface .class ));
306
307
assertNull (findAnnotationDeclaringClassForTypes (orderCandidateList , SubNonInheritedAnnotationInterface .class ));
307
308
assertEquals (NonInheritedAnnotationClass .class ,
308
- findAnnotationDeclaringClassForTypes (orderCandidateList , NonInheritedAnnotationClass .class ));
309
+ findAnnotationDeclaringClassForTypes (orderCandidateList , NonInheritedAnnotationClass .class ));
309
310
assertEquals (NonInheritedAnnotationClass .class ,
310
- findAnnotationDeclaringClassForTypes (orderCandidateList , SubNonInheritedAnnotationClass .class ));
311
+ findAnnotationDeclaringClassForTypes (orderCandidateList , SubNonInheritedAnnotationClass .class ));
311
312
}
312
313
313
314
@ Test
@@ -320,30 +321,30 @@ public void findAnnotationDeclaringClassForTypesWithMultipleCandidateTypes() {
320
321
321
322
// inherited class-level annotation; note: @Transactional is inherited
322
323
assertEquals (InheritedAnnotationInterface .class ,
323
- findAnnotationDeclaringClassForTypes (candidates , InheritedAnnotationInterface .class ));
324
+ findAnnotationDeclaringClassForTypes (candidates , InheritedAnnotationInterface .class ));
324
325
assertNull (findAnnotationDeclaringClassForTypes (candidates , SubInheritedAnnotationInterface .class ));
325
326
assertEquals (InheritedAnnotationClass .class ,
326
- findAnnotationDeclaringClassForTypes (candidates , InheritedAnnotationClass .class ));
327
+ findAnnotationDeclaringClassForTypes (candidates , InheritedAnnotationClass .class ));
327
328
assertEquals (InheritedAnnotationClass .class ,
328
- findAnnotationDeclaringClassForTypes (candidates , SubInheritedAnnotationClass .class ));
329
+ findAnnotationDeclaringClassForTypes (candidates , SubInheritedAnnotationClass .class ));
329
330
330
331
// non-inherited class-level annotation; note: @Order is not inherited,
331
332
// but findAnnotationDeclaringClassForTypes() should still find it on classes.
332
333
assertEquals (NonInheritedAnnotationInterface .class ,
333
- findAnnotationDeclaringClassForTypes (candidates , NonInheritedAnnotationInterface .class ));
334
+ findAnnotationDeclaringClassForTypes (candidates , NonInheritedAnnotationInterface .class ));
334
335
assertNull (findAnnotationDeclaringClassForTypes (candidates , SubNonInheritedAnnotationInterface .class ));
335
336
assertEquals (NonInheritedAnnotationClass .class ,
336
- findAnnotationDeclaringClassForTypes (candidates , NonInheritedAnnotationClass .class ));
337
+ findAnnotationDeclaringClassForTypes (candidates , NonInheritedAnnotationClass .class ));
337
338
assertEquals (NonInheritedAnnotationClass .class ,
338
- findAnnotationDeclaringClassForTypes (candidates , SubNonInheritedAnnotationClass .class ));
339
+ findAnnotationDeclaringClassForTypes (candidates , SubNonInheritedAnnotationClass .class ));
339
340
340
341
// class hierarchy mixed with @Transactional and @Order declarations
341
342
assertEquals (TransactionalClass .class ,
342
- findAnnotationDeclaringClassForTypes (candidates , TransactionalClass .class ));
343
+ findAnnotationDeclaringClassForTypes (candidates , TransactionalClass .class ));
343
344
assertEquals (TransactionalAndOrderedClass .class ,
344
- findAnnotationDeclaringClassForTypes (candidates , TransactionalAndOrderedClass .class ));
345
+ findAnnotationDeclaringClassForTypes (candidates , TransactionalAndOrderedClass .class ));
345
346
assertEquals (TransactionalAndOrderedClass .class ,
346
- findAnnotationDeclaringClassForTypes (candidates , SubTransactionalAndOrderedClass .class ));
347
+ findAnnotationDeclaringClassForTypes (candidates , SubTransactionalAndOrderedClass .class ));
347
348
}
348
349
349
350
@ Test
@@ -373,9 +374,8 @@ public void isAnnotationInheritedForAllScenarios() throws Exception {
373
374
374
375
// inherited class-level annotation; note: @Transactional is inherited
375
376
assertFalse (isAnnotationInherited (Transactional .class , InheritedAnnotationInterface .class ));
376
- // isAnnotationInherited() does not currently traverse interface
377
- // hierarchies. Thus the following, though perhaps counter intuitive,
378
- // must be false:
377
+ // isAnnotationInherited() does not currently traverse interface hierarchies.
378
+ // Thus the following, though perhaps counter intuitive, must be false:
379
379
assertFalse (isAnnotationInherited (Transactional .class , SubInheritedAnnotationInterface .class ));
380
380
assertFalse (isAnnotationInherited (Transactional .class , InheritedAnnotationClass .class ));
381
381
assertTrue (isAnnotationInherited (Transactional .class , SubInheritedAnnotationClass .class ));
@@ -437,7 +437,7 @@ public void getAnnotationAttributesWithAttributeAliases() throws Exception {
437
437
method = WebController .class .getMethod ("handleMappedWithDifferentPathAndValueAttributes" );
438
438
webMapping = method .getAnnotation (WebMapping .class );
439
439
exception .expect (AnnotationConfigurationException .class );
440
- exception .expectMessage (containsString ("attribute [ value] and its alias [ path] " ));
440
+ exception .expectMessage (containsString ("attribute ' value' and its alias ' path' " ));
441
441
exception .expectMessage (containsString ("values of [/enigma] and [/test]" ));
442
442
exception .expectMessage (containsString ("but only one is permitted" ));
443
443
getAnnotationAttributes (webMapping );
@@ -716,7 +716,8 @@ public void synthesizeAlreadySynthesizedAnnotation() throws Exception {
716
716
717
717
@ Test
718
718
public void synthesizeAnnotationWithAttributeAliasForNonexistentAttribute () throws Exception {
719
- AliasForNonexistentAttribute annotation = AliasForNonexistentAttributeClass .class .getAnnotation (AliasForNonexistentAttribute .class );
719
+ AliasForNonexistentAttribute annotation =
720
+ AliasForNonexistentAttributeClass .class .getAnnotation (AliasForNonexistentAttribute .class );
720
721
exception .expect (AnnotationConfigurationException .class );
721
722
exception .expectMessage (containsString ("Attribute [foo] in" ));
722
723
exception .expectMessage (containsString (AliasForNonexistentAttribute .class .getName ()));
@@ -726,7 +727,8 @@ public void synthesizeAnnotationWithAttributeAliasForNonexistentAttribute() thro
726
727
727
728
@ Test
728
729
public void synthesizeAnnotationWithAttributeAliasWithoutMirroredAliasFor () throws Exception {
729
- AliasForWithoutMirroredAliasFor annotation = AliasForWithoutMirroredAliasForClass .class .getAnnotation (AliasForWithoutMirroredAliasFor .class );
730
+ AliasForWithoutMirroredAliasFor annotation =
731
+ AliasForWithoutMirroredAliasForClass .class .getAnnotation (AliasForWithoutMirroredAliasFor .class );
730
732
exception .expect (AnnotationConfigurationException .class );
731
733
exception .expectMessage (containsString ("Attribute [bar] in" ));
732
734
exception .expectMessage (containsString (AliasForWithoutMirroredAliasFor .class .getName ()));
@@ -736,11 +738,11 @@ public void synthesizeAnnotationWithAttributeAliasWithoutMirroredAliasFor() thro
736
738
737
739
@ Test
738
740
public void synthesizeAnnotationWithAttributeAliasWithMirroredAliasForWrongAttribute () throws Exception {
739
- AliasForWithMirroredAliasForWrongAttribute annotation = AliasForWithMirroredAliasForWrongAttributeClass .class .getAnnotation (AliasForWithMirroredAliasForWrongAttribute .class );
741
+ AliasForWithMirroredAliasForWrongAttribute annotation =
742
+ AliasForWithMirroredAliasForWrongAttributeClass .class .getAnnotation (AliasForWithMirroredAliasForWrongAttribute .class );
740
743
741
744
// Since JDK 7+ does not guarantee consistent ordering of methods returned using
742
745
// reflection, we cannot make the test dependent on any specific ordering.
743
- //
744
746
// In other words, we can't be certain which type of exception message we'll get,
745
747
// so we allow for both possibilities.
746
748
exception .expect (AnnotationConfigurationException .class );
@@ -753,13 +755,14 @@ public void synthesizeAnnotationWithAttributeAliasWithMirroredAliasForWrongAttri
753
755
754
756
@ Test
755
757
public void synthesizeAnnotationWithAttributeAliasForAttributeOfDifferentType () throws Exception {
756
- AliasForAttributeOfDifferentType annotation = AliasForAttributeOfDifferentTypeClass .class .getAnnotation (AliasForAttributeOfDifferentType .class );
758
+ AliasForAttributeOfDifferentType annotation =
759
+ AliasForAttributeOfDifferentTypeClass .class .getAnnotation (AliasForAttributeOfDifferentType .class );
757
760
exception .expect (AnnotationConfigurationException .class );
758
761
exception .expectMessage (startsWith ("Misconfigured aliases" ));
759
762
exception .expectMessage (containsString (AliasForAttributeOfDifferentType .class .getName ()));
763
+
760
764
// Since JDK 7+ does not guarantee consistent ordering of methods returned using
761
765
// reflection, we cannot make the test dependent on any specific ordering.
762
- //
763
766
// In other words, we don't know if "foo" or "bar" will come first.
764
767
exception .expectMessage (containsString ("attribute [foo]" ));
765
768
exception .expectMessage (containsString ("attribute [bar]" ));
@@ -769,12 +772,13 @@ public void synthesizeAnnotationWithAttributeAliasForAttributeOfDifferentType()
769
772
770
773
@ Test
771
774
public void synthesizeAnnotationWithAttributeAliasForWithMissingDefaultValues () throws Exception {
772
- AliasForWithMissingDefaultValues annotation = AliasForWithMissingDefaultValuesClass .class .getAnnotation (AliasForWithMissingDefaultValues .class );
775
+ AliasForWithMissingDefaultValues annotation =
776
+ AliasForWithMissingDefaultValuesClass .class .getAnnotation (AliasForWithMissingDefaultValues .class );
773
777
exception .expectMessage (startsWith ("Misconfigured aliases" ));
774
778
exception .expectMessage (containsString (AliasForWithMissingDefaultValues .class .getName ()));
779
+
775
780
// Since JDK 7+ does not guarantee consistent ordering of methods returned using
776
781
// reflection, we cannot make the test dependent on any specific ordering.
777
- //
778
782
// In other words, we don't know if "foo" or "bar" will come first.
779
783
exception .expectMessage (containsString ("attribute [foo]" ));
780
784
exception .expectMessage (containsString ("attribute [bar]" ));
@@ -784,12 +788,13 @@ public void synthesizeAnnotationWithAttributeAliasForWithMissingDefaultValues()
784
788
785
789
@ Test
786
790
public void synthesizeAnnotationWithAttributeAliasForAttributeWithDifferentDefaultValue () throws Exception {
787
- AliasForAttributeWithDifferentDefaultValue annotation = AliasForAttributeWithDifferentDefaultValueClass .class .getAnnotation (AliasForAttributeWithDifferentDefaultValue .class );
791
+ AliasForAttributeWithDifferentDefaultValue annotation =
792
+ AliasForAttributeWithDifferentDefaultValueClass .class .getAnnotation (AliasForAttributeWithDifferentDefaultValue .class );
788
793
exception .expectMessage (startsWith ("Misconfigured aliases" ));
789
794
exception .expectMessage (containsString (AliasForAttributeWithDifferentDefaultValue .class .getName ()));
795
+
790
796
// Since JDK 7+ does not guarantee consistent ordering of methods returned using
791
797
// reflection, we cannot make the test dependent on any specific ordering.
792
- //
793
798
// In other words, we don't know if "foo" or "bar" will come first.
794
799
exception .expectMessage (containsString ("attribute [foo]" ));
795
800
exception .expectMessage (containsString ("attribute [bar]" ));
@@ -1042,11 +1047,10 @@ public void hashCodeForSynthesizedAnnotations() throws Exception {
1042
1047
@ Test
1043
1048
@ SuppressWarnings ("unchecked" )
1044
1049
public void synthesizeNonPublicAnnotationWithAttributeAliasesFromDifferentPackage () throws Exception {
1045
-
1046
1050
Class <?> clazz =
1047
- ClassUtils .forName ("org.springframework.core.annotation.subpackage.NonPublicAliasedAnnotatedClass" , null );
1051
+ ClassUtils .forName ("org.springframework.core.annotation.subpackage.NonPublicAliasedAnnotatedClass" , null );
1048
1052
Class <? extends Annotation > annotationType = (Class <? extends Annotation >)
1049
- ClassUtils .forName ("org.springframework.core.annotation.subpackage.NonPublicAliasedAnnotation" , null );
1053
+ ClassUtils .forName ("org.springframework.core.annotation.subpackage.NonPublicAliasedAnnotation" , null );
1050
1054
1051
1055
Annotation annotation = clazz .getAnnotation (annotationType );
1052
1056
assertNotNull (annotation );
@@ -1072,7 +1076,7 @@ public void synthesizeAnnotationWithAttributeAliasesInNestedAnnotations() throws
1072
1076
ContextConfig [] configs = synthesizedHierarchy .value ();
1073
1077
assertNotNull (configs );
1074
1078
assertTrue ("nested annotations must be synthesized" ,
1075
- Arrays .stream (configs ).allMatch (c -> c instanceof SynthesizedAnnotation ));
1079
+ Arrays .stream (configs ).allMatch (c -> c instanceof SynthesizedAnnotation ));
1076
1080
1077
1081
List <String > locations = Arrays .stream (configs ).map (ContextConfig ::locations ).collect (toList ());
1078
1082
assertThat (locations , is (expectedLocations ));
0 commit comments