test @Nonbinding support

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@1083502 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Matthew Jason Benson 2011-03-20 16:55:24 +00:00
parent 8fdbe09405
commit b39944f756
2 changed files with 32 additions and 1 deletions

View File

@ -428,6 +428,13 @@
<version>2.5.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.enterprise</groupId>
<artifactId>cdi-api</artifactId>
<version>1.0-SP1</version>
<scope>test</scope>
</dependency>
</dependencies>
<properties>

View File

@ -34,6 +34,10 @@ import java.lang.reflect.Field;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.util.Collection;
import java.util.Map;
import javax.enterprise.util.Nonbinding;
import org.junit.Before;
import org.junit.Test;
@ -116,6 +120,7 @@ public class AnnotationUtilsTest {
type = Object.class,
types = { Object.class }
)
@Blah(foo = 6, bar = "x")
public Object dummy1;
@TestAnnotation(
@ -192,6 +197,7 @@ public class AnnotationUtilsTest {
type = Object.class,
types = { Object.class }
)
@Blah(foo = 6, bar = "y")
public Object dummy2;
@TestAnnotation(
@ -293,6 +299,7 @@ public class AnnotationUtilsTest {
type = Object.class,
types = { Object.class }
)
@Blah(foo = 7, bar = "x")
public Object dummy3;
@NestAnnotation(
@ -319,7 +326,6 @@ public class AnnotationUtilsTest {
type = Object[].class,
types = { Object[].class }
)
public Object dummy4;
@Target(FIELD)
@ -380,6 +386,15 @@ public class AnnotationUtilsTest {
MOE, LARRY, CURLY, JOE, SHEMP;
}
@Retention(RUNTIME)
@Target(FIELD)
public @interface Blah {
int foo();
@Nonbinding
String bar();
}
private Field field1;
private Field field2;
private Field field3;
@ -497,4 +512,13 @@ public class AnnotationUtilsTest {
assertTrue(toString.contains("timeout=666000"));
assertTrue(toString.contains(", "));
}
@Test
public void testNonbinding() throws Exception {
Blah blah1 = field1.getAnnotation(Blah.class);
Blah blah2 = field2.getAnnotation(Blah.class);
Blah blah3 = field3.getAnnotation(Blah.class);
assertTrue(AnnotationUtils.equals(blah1, blah2));
assertFalse(AnnotationUtils.equals(blah1, blah3));
}
}