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:
parent
8fdbe09405
commit
b39944f756
7
pom.xml
7
pom.xml
|
@ -428,6 +428,13 @@
|
||||||
<version>2.5.2</version>
|
<version>2.5.2</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>javax.enterprise</groupId>
|
||||||
|
<artifactId>cdi-api</artifactId>
|
||||||
|
<version>1.0-SP1</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
|
|
|
@ -34,6 +34,10 @@ import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.InvocationHandler;
|
import java.lang.reflect.InvocationHandler;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.lang.reflect.Proxy;
|
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.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
@ -116,6 +120,7 @@ public class AnnotationUtilsTest {
|
||||||
type = Object.class,
|
type = Object.class,
|
||||||
types = { Object.class }
|
types = { Object.class }
|
||||||
)
|
)
|
||||||
|
@Blah(foo = 6, bar = "x")
|
||||||
public Object dummy1;
|
public Object dummy1;
|
||||||
|
|
||||||
@TestAnnotation(
|
@TestAnnotation(
|
||||||
|
@ -192,6 +197,7 @@ public class AnnotationUtilsTest {
|
||||||
type = Object.class,
|
type = Object.class,
|
||||||
types = { Object.class }
|
types = { Object.class }
|
||||||
)
|
)
|
||||||
|
@Blah(foo = 6, bar = "y")
|
||||||
public Object dummy2;
|
public Object dummy2;
|
||||||
|
|
||||||
@TestAnnotation(
|
@TestAnnotation(
|
||||||
|
@ -293,6 +299,7 @@ public class AnnotationUtilsTest {
|
||||||
type = Object.class,
|
type = Object.class,
|
||||||
types = { Object.class }
|
types = { Object.class }
|
||||||
)
|
)
|
||||||
|
@Blah(foo = 7, bar = "x")
|
||||||
public Object dummy3;
|
public Object dummy3;
|
||||||
|
|
||||||
@NestAnnotation(
|
@NestAnnotation(
|
||||||
|
@ -319,7 +326,6 @@ public class AnnotationUtilsTest {
|
||||||
type = Object[].class,
|
type = Object[].class,
|
||||||
types = { Object[].class }
|
types = { Object[].class }
|
||||||
)
|
)
|
||||||
|
|
||||||
public Object dummy4;
|
public Object dummy4;
|
||||||
|
|
||||||
@Target(FIELD)
|
@Target(FIELD)
|
||||||
|
@ -380,6 +386,15 @@ public class AnnotationUtilsTest {
|
||||||
MOE, LARRY, CURLY, JOE, SHEMP;
|
MOE, LARRY, CURLY, JOE, SHEMP;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Retention(RUNTIME)
|
||||||
|
@Target(FIELD)
|
||||||
|
public @interface Blah {
|
||||||
|
int foo();
|
||||||
|
|
||||||
|
@Nonbinding
|
||||||
|
String bar();
|
||||||
|
}
|
||||||
|
|
||||||
private Field field1;
|
private Field field1;
|
||||||
private Field field2;
|
private Field field2;
|
||||||
private Field field3;
|
private Field field3;
|
||||||
|
@ -497,4 +512,13 @@ public class AnnotationUtilsTest {
|
||||||
assertTrue(toString.contains("timeout=666000"));
|
assertTrue(toString.contains("timeout=666000"));
|
||||||
assertTrue(toString.contains(", "));
|
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));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue