commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mben...@apache.org
Subject svn commit: r1594385 - /commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/reflect/TypeUtilsTest.java
Date Tue, 13 May 2014 21:12:32 GMT
Author: mbenson
Date: Tue May 13 21:12:31 2014
New Revision: 1594385

URL: http://svn.apache.org/r1594385
Log:
add some failing tests with wildcards

Modified:
    commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/reflect/TypeUtilsTest.java

Modified: commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/reflect/TypeUtilsTest.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/reflect/TypeUtilsTest.java?rev=1594385&r1=1594384&r2=1594385&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/reflect/TypeUtilsTest.java
(original)
+++ commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/reflect/TypeUtilsTest.java
Tue May 13 21:12:31 2014
@@ -32,6 +32,7 @@ import java.util.List;
 import java.util.Map;
 import java.util.TreeSet;
 
+import org.apache.commons.lang3.ArrayUtils;
 import org.apache.commons.lang3.StringEscapeUtils;
 import org.apache.commons.lang3.reflect.testbed.Foo;
 import org.apache.commons.lang3.reflect.testbed.GenericParent;
@@ -696,6 +697,30 @@ public class TypeUtilsTest<B> {
         final Field cClass = AClass.class.getField("cClass");
         Assert.assertTrue(TypeUtils.equals(((ParameterizedType) cClass.getGenericType()).getActualTypeArguments()[0],
             simpleWildcard));
+        Assert.assertEquals(String.format("? extends %s", String.class.getName()), TypeUtils.toString(simpleWildcard));
+        Assert.assertEquals(String.format("? extends %s", String.class.getName()), simpleWildcard.toString());
+    }
+
+    @Test
+    public void testUnboundedWildcardType() {
+        final WildcardType unbounded = TypeUtils.wildcardType().withLowerBounds((Type) null).withUpperBounds().build();
+        Assert.assertTrue(TypeUtils.equals(TypeUtils.WILDCARD_ALL, unbounded));
+        Assert.assertArrayEquals(new Type[] { Object.class }, TypeUtils.getImplicitUpperBounds(unbounded));
+        Assert.assertArrayEquals(new Type[] { null }, TypeUtils.getImplicitLowerBounds(unbounded));
+        Assert.assertEquals("?", TypeUtils.toString(unbounded));
+        Assert.assertEquals("?", unbounded.toString());
+    }
+
+    @Test
+    public void testLowerBoundedWildcardType() {
+       final WildcardType lowerBounded = TypeUtils.wildcardType().withLowerBounds(java.sql.Date.class).build();
+       Assert.assertEquals(String.format("? super %s", java.sql.Date.class.getName()), TypeUtils.toString(lowerBounded));
+       Assert.assertEquals(String.format("? super %s", java.sql.Date.class.getName()), lowerBounded.toString());
+
+       final TypeVariable<Class<Iterable>> iterableT0 = Iterable.class.getTypeParameters()[0];
+       final WildcardType lowerTypeVariable = TypeUtils.wildcardType().withLowerBounds(iterableT0).build();
+       Assert.assertEquals(String.format("? super %s", iterableT0.getName()), TypeUtils.toString(lowerTypeVariable));
+       Assert.assertEquals(String.format("? super %s", iterableT0.getName()), lowerTypeVariable.toString());
     }
 
     @Test



Mime
View raw message