2828import java .util .Set ;
2929
3030import org .junit .Test ;
31+
3132import org .springframework .core .Ordered ;
3233import org .springframework .core .annotation .subpackage .NonPublicAnnotatedClass ;
3334import org .springframework .stereotype .Component ;
3738import static org .springframework .core .annotation .AnnotationUtils .*;
3839
3940/**
41+ * Unit tests for {@link AnnotationUtils}.
42+ *
4043 * @author Rod Johnson
4144 * @author Juergen Hoeller
4245 * @author Sam Brannen
@@ -97,9 +100,9 @@ public void findMethodAnnotationOnBridgeMethod() throws Exception {
97100 // }
98101
99102 @ Test
100- public void findAnnotationPrefersInteracesOverLocalMetaAnnotations () {
103+ public void findAnnotationPrefersInterfacesOverLocalMetaAnnotations () {
101104 Component component = AnnotationUtils .findAnnotation (
102- ClassWithLocalMetaAnnotationAndMetaAnnotatedInterface .class , Component .class );
105+ ClassWithLocalMetaAnnotationAndMetaAnnotatedInterface .class , Component .class );
103106
104107 // By inspecting ClassWithLocalMetaAnnotationAndMetaAnnotatedInterface, one
105108 // might expect that "meta2" should be found; however, with the current
@@ -144,8 +147,7 @@ public void findAnnotationDeclaringClassForTypesWithSingleCandidateType() {
144147 // inherited class-level annotation; note: @Transactional is inherited
145148 assertEquals (InheritedAnnotationInterface .class ,
146149 findAnnotationDeclaringClassForTypes (transactionalCandidateList , InheritedAnnotationInterface .class ));
147- assertNull (findAnnotationDeclaringClassForTypes (transactionalCandidateList ,
148- SubInheritedAnnotationInterface .class ));
150+ assertNull (findAnnotationDeclaringClassForTypes (transactionalCandidateList , SubInheritedAnnotationInterface .class ));
149151 assertEquals (InheritedAnnotationClass .class ,
150152 findAnnotationDeclaringClassForTypes (transactionalCandidateList , InheritedAnnotationClass .class ));
151153 assertEquals (InheritedAnnotationClass .class ,
@@ -301,8 +303,7 @@ public void findAnnotationFromInterfaceOnSuper() throws Exception {
301303 }
302304
303305 @ Test
304- public void findAnnotationFromInterfaceWhenSuperDoesNotImplementMethod ()
305- throws Exception {
306+ public void findAnnotationFromInterfaceWhenSuperDoesNotImplementMethod () throws Exception {
306307 Method method = SubOfAbstractImplementsInterfaceWithAnnotatedMethod .class .getMethod ("foo" );
307308 Order order = findAnnotation (method , Order .class );
308309 assertNotNull (order );
@@ -322,13 +323,13 @@ public void getRepeatableFromMethod() throws Exception {
322323 }
323324
324325
325- @ Component (value = "meta1" )
326+ @ Component (value = "meta1" )
326327 @ Order
327328 @ Retention (RetentionPolicy .RUNTIME )
328329 @interface Meta1 {
329330 }
330331
331- @ Component (value = "meta2" )
332+ @ Component (value = "meta2" )
332333 @ Transactional
333334 @ Retention (RetentionPolicy .RUNTIME )
334335 @interface Meta2 {
@@ -353,47 +354,44 @@ public static class Root implements AnnotatedInterface {
353354
354355 @ Order (27 )
355356 public void annotatedOnRoot () {
356-
357357 }
358358
359359 public void overrideToAnnotate () {
360-
361360 }
362361
363362 @ Order (27 )
364363 public void overrideWithoutNewAnnotation () {
365-
366364 }
367365
368366 public void notAnnotated () {
369-
370367 }
371368
372369 @ Override
373370 public void fromInterfaceImplementedByRoot () {
374-
375371 }
376372 }
377373
378374 public static class Leaf extends Root {
379375
380376 @ Order (25 )
381377 public void annotatedOnLeaf () {
382-
383378 }
384379
385380 @ Override
386381 @ Order (1 )
387382 public void overrideToAnnotate () {
388-
389383 }
390384
391385 @ Override
392386 public void overrideWithoutNewAnnotation () {
393-
394387 }
395388 }
396389
390+ @ Retention (RetentionPolicy .RUNTIME )
391+ @ Inherited
392+ @interface Transactional {
393+ }
394+
397395 public static abstract class Foo <T > {
398396
399397 @ Order (1 )
@@ -405,7 +403,6 @@ public static class SimpleFoo extends Foo<String> {
405403 @ Override
406404 @ Transactional
407405 public void something (final String arg ) {
408-
409406 }
410407 }
411408
@@ -474,58 +471,45 @@ public void foo() {
474471 }
475472 }
476473
477- public abstract static class AbstractDoesNotImplementInterfaceWithAnnotatedMethod implements
478- InterfaceWithAnnotatedMethod {
474+ public abstract static class AbstractDoesNotImplementInterfaceWithAnnotatedMethod
475+ implements InterfaceWithAnnotatedMethod {
479476 }
480477
481- public static class SubOfAbstractImplementsInterfaceWithAnnotatedMethod extends
482- AbstractDoesNotImplementInterfaceWithAnnotatedMethod {
478+ public static class SubOfAbstractImplementsInterfaceWithAnnotatedMethod
479+ extends AbstractDoesNotImplementInterfaceWithAnnotatedMethod {
483480
484481 @ Override
485482 public void foo () {
486483 }
487484 }
488485
489- public static interface InterfaceWithRepeated {
490-
491- @ MyRepeatable ("a" )
492- @ MyRepeatableContainer ({ @ MyRepeatable ("b" ), @ MyRepeatable ("c" ) })
493- @ MyRepeatableMeta
494- void foo ();
486+ @ Retention (RetentionPolicy .RUNTIME )
487+ @ Inherited
488+ @interface MyRepeatableContainer {
495489
490+ MyRepeatable [] value ();
496491 }
497492
498- }
499-
500-
501- @ Retention (RetentionPolicy .RUNTIME )
502- @ Inherited
503- @interface Transactional {
504-
505- }
506-
507-
508- @ Retention (RetentionPolicy .RUNTIME )
509- @ Inherited
510- @interface MyRepeatableContainer {
511-
512- MyRepeatable [] value ();
513-
514- }
515-
493+ @ Retention (RetentionPolicy .RUNTIME )
494+ @ Inherited
495+ @ Repeatable (MyRepeatableContainer .class )
496+ @interface MyRepeatable {
516497
517- @ Retention (RetentionPolicy .RUNTIME )
518- @ Inherited
519- @ Repeatable (MyRepeatableContainer .class )
520- @interface MyRepeatable {
498+ String value ();
499+ }
521500
522- String value ();
501+ @ Retention (RetentionPolicy .RUNTIME )
502+ @ Inherited
503+ @ MyRepeatable ("meta" )
504+ @interface MyRepeatableMeta {
505+ }
523506
524- }
507+ public static interface InterfaceWithRepeated {
525508
509+ @ MyRepeatable ("a" )
510+ @ MyRepeatableContainer ({ @ MyRepeatable ("b" ), @ MyRepeatable ("c" ) })
511+ @ MyRepeatableMeta
512+ void foo ();
513+ }
526514
527- @ Retention (RetentionPolicy .RUNTIME )
528- @ Inherited
529- @ MyRepeatable ("meta" )
530- @interface MyRepeatableMeta {
531515}
0 commit comments