From b39944f7568673eb04f55580e169821816c5a1f0 Mon Sep 17 00:00:00 2001 From: Matthew Jason Benson Date: Sun, 20 Mar 2011 16:55:24 +0000 Subject: [PATCH] test @Nonbinding support git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@1083502 13f79535-47bb-0310-9956-ffa450edef68 --- pom.xml | 7 +++++ .../commons/lang3/AnnotationUtilsTest.java | 26 ++++++++++++++++++- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index ce35d7597..f21c33324 100644 --- a/pom.xml +++ b/pom.xml @@ -428,6 +428,13 @@ 2.5.2 test + + + javax.enterprise + cdi-api + 1.0-SP1 + test + diff --git a/src/test/java/org/apache/commons/lang3/AnnotationUtilsTest.java b/src/test/java/org/apache/commons/lang3/AnnotationUtilsTest.java index 9ce511914..952c84579 100644 --- a/src/test/java/org/apache/commons/lang3/AnnotationUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/AnnotationUtilsTest.java @@ -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)); + } }