@ -1,5 +1,5 @@
@@ -1,5 +1,5 @@
/ *
* Copyright 2002 - 2012 the original author or authors .
* Copyright 2002 - 2013 the original author or authors .
*
* Licensed under the Apache License , Version 2 . 0 ( the "License" ) ;
* you may not use this file except in compliance with the License .
@ -13,16 +13,19 @@
@@ -13,16 +13,19 @@
* See the License for the specific language governing permissions and
* limitations under the License .
* /
package org.springframework.core.annotation ;
import static org.hamcrest.CoreMatchers.* ;
import static org.junit.Assert.* ;
import java.util.ArrayList ;
import java.util.List ;
import org.junit.Test ;
import static org.hamcrest.CoreMatchers.* ;
import static org.junit.Assert.* ;
/ * *
* Unit tests for { @link AnnotationAwareOrderComparator } .
*
* @author Juergen Hoeller
* @author Oliver Gierke
* /
public class AnnotationAwareOrderComparatorTests {
@ -31,4 +34,34 @@ public class AnnotationAwareOrderComparatorTests {
@@ -31,4 +34,34 @@ public class AnnotationAwareOrderComparatorTests {
public void instanceVariableIsAnAnnotationAwareOrderComparator ( ) {
assertThat ( AnnotationAwareOrderComparator . INSTANCE , is ( instanceOf ( AnnotationAwareOrderComparator . class ) ) ) ;
}
@Test
public void sortInstances ( ) {
List < Object > list = new ArrayList < > ( ) ;
list . add ( new B ( ) ) ;
list . add ( new A ( ) ) ;
AnnotationAwareOrderComparator . sort ( list ) ;
assertTrue ( list . get ( 0 ) instanceof A ) ;
assertTrue ( list . get ( 1 ) instanceof B ) ;
}
@Test
public void sortClasses ( ) {
List < Object > list = new ArrayList < > ( ) ;
list . add ( B . class ) ;
list . add ( A . class ) ;
AnnotationAwareOrderComparator . sort ( list ) ;
assertEquals ( A . class , list . get ( 0 ) ) ;
assertEquals ( B . class , list . get ( 1 ) ) ;
}
@Order ( 1 )
private static class A {
}
@Order ( 2 )
private static class B {
}
}