You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2025/06/15 18:25:55 UTC
(commons-lang) 01/02: Add missing test coverage for org.apache.commons.lang3.reflect.TypeUtils.toLongString(TypeVariable>)
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-lang.git
commit d6984c4c37fac5852591404214d88cde7337583d
Author: Gary D. Gregory <ga...@gmail.com>
AuthorDate: Sun Jun 15 14:20:35 2025 -0400
Add missing test coverage for
org.apache.commons.lang3.reflect.TypeUtils.toLongString(TypeVariable<?>)
Use longer lines
---
.../commons/lang3/reflect/TypeUtilsTest.java | 22 ++++++++++++----------
1 file changed, 12 insertions(+), 10 deletions(-)
diff --git a/src/test/java/org/apache/commons/lang3/reflect/TypeUtilsTest.java b/src/test/java/org/apache/commons/lang3/reflect/TypeUtilsTest.java
index b81bc1732..ecfa44491 100644
--- a/src/test/java/org/apache/commons/lang3/reflect/TypeUtilsTest.java
+++ b/src/test/java/org/apache/commons/lang3/reflect/TypeUtilsTest.java
@@ -191,7 +191,10 @@ public static <U> Iterable<U> methodWithGenericReturnType() {
/** This non-static inner class is parameterized. */
private class MyInnerClass<T> {
- // empty
+
+ class MyInnerClass2<X> {
+ // empty
+ }
}
public class Other<T> implements This<String, T> {
@@ -1032,8 +1035,12 @@ void testParameterizeWithOwnerVarArgsNullPointerException() {
@Test
void testToLongString() {
- assertEquals(getClass().getName() + ":B", TypeUtils.toLongString(getClass().getTypeParameters()[0]));
assertThrows(NullPointerException.class, () -> TypeUtils.toLongString(null));
+ assertEquals(getClass().getName() + ":B", TypeUtils.toLongString(getClass().getTypeParameters()[0]));
+ assertEquals(getClass().getName() + ".MyInnerClass:T", TypeUtils.toLongString(MyInnerClass.class.getTypeParameters()[0]));
+ assertEquals(getClass().getName() + ".That:K", TypeUtils.toLongString(That.class.getTypeParameters()[0]));
+ assertEquals(getClass().getName() + ".The:K", TypeUtils.toLongString(The.class.getTypeParameters()[0]));
+ assertEquals(getClass().getName() + ".MyInnerClass.MyInnerClass2:X", TypeUtils.toLongString(MyInnerClass.MyInnerClass2.class.getTypeParameters()[0]));
}
@Test
@@ -1074,19 +1081,15 @@ void testUnboundedWildcardType() {
assertArrayEquals(new Type[] { null }, TypeUtils.getImplicitLowerBounds(unbounded));
assertEquals("?", TypeUtils.toString(unbounded));
assertEquals("?", unbounded.toString());
-
- assertThrows(NullPointerException.class,
- () -> TypeUtils.getImplicitLowerBounds(null));
- assertThrows(NullPointerException.class,
- () -> TypeUtils.getImplicitUpperBounds(null));
+ assertThrows(NullPointerException.class, () -> TypeUtils.getImplicitLowerBounds(null));
+ assertThrows(NullPointerException.class, () -> TypeUtils.getImplicitUpperBounds(null));
}
@Test
void testWildcardType() throws NoSuchFieldException {
final WildcardType simpleWildcard = TypeUtils.wildcardType().withUpperBounds(String.class).build();
final Field cClass = AClass.class.getField("cClass");
- assertTrue(TypeUtils.equals(((ParameterizedType) cClass.getGenericType()).getActualTypeArguments()[0],
- simpleWildcard));
+ assertTrue(TypeUtils.equals(((ParameterizedType) cClass.getGenericType()).getActualTypeArguments()[0], simpleWildcard));
assertEquals(String.format("? extends %s", String.class.getName()), TypeUtils.toString(simpleWildcard));
assertEquals(String.format("? extends %s", String.class.getName()), simpleWildcard.toString());
}
@@ -1095,7 +1098,6 @@ void testWildcardType() throws NoSuchFieldException {
void testWrap() {
final Type t = getClass().getTypeParameters()[0];
assertTrue(TypeUtils.equals(t, TypeUtils.wrap(t).getType()));
-
assertEquals(String.class, TypeUtils.wrap(String.class).getType());
}
}