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


The following commit(s) were added to refs/heads/master by this push:
     new 230611601 Add MethodUtilsTest tests
230611601 is described below

commit 2306116014ca0b166d58db1f561535bd556ecb1c
Author: Gary Gregory <garydgreg...@gmail.com>
AuthorDate: Thu Aug 28 15:49:41 2025 -0400

    Add MethodUtilsTest tests
    
    - Reduce vertical whitespace
    - Normalize test method name
    - Normalize test method visibility
---
 .../commons/lang3/reflect/MethodUtilsTest.java     | 233 ++++++++-------------
 1 file changed, 90 insertions(+), 143 deletions(-)

diff --git 
a/src/test/java/org/apache/commons/lang3/reflect/MethodUtilsTest.java 
b/src/test/java/org/apache/commons/lang3/reflect/MethodUtilsTest.java
index 81aee5c65..41f3bff04 100644
--- a/src/test/java/org/apache/commons/lang3/reflect/MethodUtilsTest.java
+++ b/src/test/java/org/apache/commons/lang3/reflect/MethodUtilsTest.java
@@ -323,6 +323,8 @@ static void verify(final ImmutablePair<String, Object[]> a, 
final Object obj) {
 
         boolean unboxLongArray;
 
+        boolean unboxShortArray;
+
         public String foo() {
             return "foo()";
         }
@@ -440,6 +442,11 @@ public long[] unboxing(final long... values) {
             return values;
         }
 
+        public short[] unboxing(final short... values) {
+            unboxShortArray = true;
+            return values;
+        }
+
         public ImmutablePair<String, Object[]> varOverloadEcho(final Number... 
args) {
             return new ImmutablePair<>("Number...", args);
         }
@@ -474,7 +481,7 @@ public void setValue(final Object value) {
     }
 
     private static final class TestMutableSubclass extends TestMutable {
-
+        // empty
     }
 
     private final Map<Class<?>, Class<?>[]> classCache = new HashMap<>();
@@ -512,12 +519,10 @@ void testConstructor() throws Exception {
     void testDistance() throws Exception {
         final Method distanceMethod = 
MethodUtils.getMatchingMethod(MethodUtils.class, "distance", Class[].class, 
Class[].class);
         distanceMethod.setAccessible(true);
-
-        assertEquals(-1, distanceMethod.invoke(null, new 
Class[]{String.class}, new Class[]{Date.class}));
-        assertEquals(0, distanceMethod.invoke(null, new Class[]{Date.class}, 
new Class[]{Date.class}));
-        assertEquals(1, distanceMethod.invoke(null, new 
Class[]{Integer.class}, new 
Class[]{ClassUtils.wrapperToPrimitive(Integer.class)}));
-        assertEquals(2, distanceMethod.invoke(null, new 
Class[]{Integer.class}, new Class[]{Object.class}));
-
+        assertEquals(-1, distanceMethod.invoke(null, new Class[] { 
String.class }, new Class[] { Date.class }));
+        assertEquals(0, distanceMethod.invoke(null, new Class[] { Date.class 
}, new Class[] { Date.class }));
+        assertEquals(1, distanceMethod.invoke(null, new Class[] { 
Integer.class }, new Class[] { ClassUtils.wrapperToPrimitive(Integer.class) }));
+        assertEquals(2, distanceMethod.invoke(null, new Class[] { 
Integer.class }, new Class[] { Object.class }));
         distanceMethod.setAccessible(false);
     }
 
@@ -770,49 +775,30 @@ void testGetMatchingAccessibleMethod() {
 
     @Test
     void testGetMatchingMethod() throws NoSuchMethodException {
-        
assertEquals(MethodUtils.getMatchingMethod(GetMatchingMethodClass.class, 
"testMethod"),
-                GetMatchingMethodClass.class.getMethod("testMethod"));
-
+        
assertEquals(MethodUtils.getMatchingMethod(GetMatchingMethodClass.class, 
"testMethod"), GetMatchingMethodClass.class.getMethod("testMethod"));
         
assertEquals(MethodUtils.getMatchingMethod(GetMatchingMethodClass.class, 
"testMethod", Long.TYPE),
                 GetMatchingMethodClass.class.getMethod("testMethod", 
Long.TYPE));
-
         
assertEquals(MethodUtils.getMatchingMethod(GetMatchingMethodClass.class, 
"testMethod", Long.class),
                 GetMatchingMethodClass.class.getMethod("testMethod", 
Long.class));
-
         
assertEquals(MethodUtils.getMatchingMethod(GetMatchingMethodClass.class, 
"testMethod", (Class<?>) null),
                 GetMatchingMethodClass.class.getMethod("testMethod", 
Long.class));
-
-        assertThrows(IllegalStateException.class,
-                () -> 
MethodUtils.getMatchingMethod(GetMatchingMethodClass.class, "testMethod2", 
(Class<?>) null));
-
+        assertThrows(IllegalStateException.class, () -> 
MethodUtils.getMatchingMethod(GetMatchingMethodClass.class, "testMethod2", 
(Class<?>) null));
         
assertEquals(MethodUtils.getMatchingMethod(GetMatchingMethodClass.class, 
"testMethod3", Long.TYPE, Long.class),
                 GetMatchingMethodClass.class.getMethod("testMethod3", 
Long.TYPE, Long.class));
-
         
assertEquals(MethodUtils.getMatchingMethod(GetMatchingMethodClass.class, 
"testMethod3", Long.class, Long.TYPE),
                 GetMatchingMethodClass.class.getMethod("testMethod3", 
Long.class, Long.TYPE));
-
         
assertEquals(MethodUtils.getMatchingMethod(GetMatchingMethodClass.class, 
"testMethod3", null, Long.TYPE),
                 GetMatchingMethodClass.class.getMethod("testMethod3", 
Long.class, Long.TYPE));
-
         
assertEquals(MethodUtils.getMatchingMethod(GetMatchingMethodClass.class, 
"testMethod3", Long.TYPE, null),
                 GetMatchingMethodClass.class.getMethod("testMethod3", 
Long.TYPE, Long.class));
-
-        assertThrows(IllegalStateException.class,
-                () -> 
MethodUtils.getMatchingMethod(GetMatchingMethodClass.class, "testMethod4", 
null, null));
-
+        assertThrows(IllegalStateException.class, () -> 
MethodUtils.getMatchingMethod(GetMatchingMethodClass.class, "testMethod4", 
null, null));
         
assertEquals(MethodUtils.getMatchingMethod(GetMatchingMethodImpl.class, 
"testMethod5", RuntimeException.class),
                 GetMatchingMethodImpl.class.getMethod("testMethod5", 
Exception.class));
-
-        assertEquals(GetMatchingMethodImpl.class.getMethod("testMethod6"),
-            MethodUtils.getMatchingMethod(GetMatchingMethodImpl.class, 
"testMethod6"));
-
-        assertNullPointerException(
-                () -> MethodUtils.getMatchingMethod(null, "testMethod5", 
RuntimeException.class));
-
+        assertEquals(GetMatchingMethodImpl.class.getMethod("testMethod6"), 
MethodUtils.getMatchingMethod(GetMatchingMethodImpl.class, "testMethod6"));
+        assertNullPointerException(() -> MethodUtils.getMatchingMethod(null, 
"testMethod5", RuntimeException.class));
         Method testMethod6 = 
MethodUtils.getMatchingMethod(ConcreteGetMatchingMethod2.class, "testMethod6");
         assertNotNull(testMethod6);
         assertEquals(AbstractGetMatchingMethod2.class, 
testMethod6.getDeclaringClass());
-
         testMethod6 = 
MethodUtils.getMatchingMethod(ConcreteGetMatchingMethod22.class, "testMethod6");
         assertNotNull(testMethod6);
         assertEquals(ConcreteGetMatchingMethod22.class, 
testMethod6.getDeclaringClass());
@@ -833,6 +819,9 @@ void testGetMethodObject() throws Exception {
         assertNull(MethodUtils.getMethodObject(MutableObject.class, "equals", 
new Class[] { String.class, null, String.class }));
     }
 
+    /**
+     * Tests a {@code public} method.
+     */
     @Test
     @Annotated
     public void testGetMethodsListWithAnnotation() throws 
NoSuchMethodException {
@@ -887,24 +876,17 @@ void 
testGetMethodsWithAnnotationIllegalArgumentException3() {
 
     @Test
     void testGetMethodsWithAnnotationNotSearchSupersAndNotIgnoreAccess() {
-        assertArrayEquals(new Method[0], 
MethodUtils.getMethodsWithAnnotation(Object.class, Annotated.class,
-                false, false));
-
-        final Method[] methodsWithAnnotation = 
MethodUtils.getMethodsWithAnnotation(PublicChild.class, Annotated.class,
-                false, false);
+        assertArrayEquals(new Method[0], 
MethodUtils.getMethodsWithAnnotation(Object.class, Annotated.class, false, 
false));
+        final Method[] methodsWithAnnotation = 
MethodUtils.getMethodsWithAnnotation(PublicChild.class, Annotated.class, false, 
false);
         assertEquals(1, methodsWithAnnotation.length);
         assertEquals("PublicChild.publicAnnotatedMethod",
-                methodsWithAnnotation[0].getDeclaringClass().getSimpleName() + 
'.' +
-                        methodsWithAnnotation[0].getName());
+                methodsWithAnnotation[0].getDeclaringClass().getSimpleName() + 
'.' + methodsWithAnnotation[0].getName());
     }
 
     @Test
     void testGetMethodsWithAnnotationNotSearchSupersButIgnoreAccess() {
-        assertArrayEquals(new Method[0], 
MethodUtils.getMethodsWithAnnotation(Object.class, Annotated.class,
-                false, true));
-
-        final Method[] methodsWithAnnotation = 
MethodUtils.getMethodsWithAnnotation(PublicChild.class, Annotated.class,
-                false, true);
+        assertArrayEquals(new Method[0], 
MethodUtils.getMethodsWithAnnotation(Object.class, Annotated.class, false, 
true));
+        final Method[] methodsWithAnnotation = 
MethodUtils.getMethodsWithAnnotation(PublicChild.class, Annotated.class, false, 
true);
         assertEquals(2, methodsWithAnnotation.length);
         assertEquals("PublicChild", 
methodsWithAnnotation[0].getDeclaringClass().getSimpleName());
         assertEquals("PublicChild", 
methodsWithAnnotation[1].getDeclaringClass().getSimpleName());
@@ -914,38 +896,26 @@ void 
testGetMethodsWithAnnotationNotSearchSupersButIgnoreAccess() {
 
     @Test
     void testGetMethodsWithAnnotationSearchSupersAndIgnoreAccess() {
-        assertArrayEquals(new Method[0], 
MethodUtils.getMethodsWithAnnotation(Object.class, Annotated.class,
-                true, true));
-
-        final Method[] methodsWithAnnotation = 
MethodUtils.getMethodsWithAnnotation(PublicChild.class, Annotated.class,
-                true, true);
+        assertArrayEquals(new Method[0], 
MethodUtils.getMethodsWithAnnotation(Object.class, Annotated.class, true, 
true));
+        final Method[] methodsWithAnnotation = 
MethodUtils.getMethodsWithAnnotation(PublicChild.class, Annotated.class, true, 
true);
         assertEquals(4, methodsWithAnnotation.length);
         assertEquals("PublicChild", 
methodsWithAnnotation[0].getDeclaringClass().getSimpleName());
         assertEquals("PublicChild", 
methodsWithAnnotation[1].getDeclaringClass().getSimpleName());
         
assertTrue(methodsWithAnnotation[0].getName().endsWith("AnnotatedMethod"));
         
assertTrue(methodsWithAnnotation[1].getName().endsWith("AnnotatedMethod"));
-        assertEquals("Foo.doIt",
-                methodsWithAnnotation[2].getDeclaringClass().getSimpleName() + 
'.' +
-                        methodsWithAnnotation[2].getName());
+        assertEquals("Foo.doIt", 
methodsWithAnnotation[2].getDeclaringClass().getSimpleName() + '.' + 
methodsWithAnnotation[2].getName());
         assertEquals("Parent.parentProtectedAnnotatedMethod",
-                methodsWithAnnotation[3].getDeclaringClass().getSimpleName() + 
'.' +
-                        methodsWithAnnotation[3].getName());
+                methodsWithAnnotation[3].getDeclaringClass().getSimpleName() + 
'.' + methodsWithAnnotation[3].getName());
     }
 
     @Test
     void testGetMethodsWithAnnotationSearchSupersButNotIgnoreAccess() {
-        assertArrayEquals(new Method[0], 
MethodUtils.getMethodsWithAnnotation(Object.class, Annotated.class,
-                true, false));
-
-        final Method[] methodsWithAnnotation = 
MethodUtils.getMethodsWithAnnotation(PublicChild.class, Annotated.class,
-                true, false);
+        assertArrayEquals(new Method[0], 
MethodUtils.getMethodsWithAnnotation(Object.class, Annotated.class, true, 
false));
+        final Method[] methodsWithAnnotation = 
MethodUtils.getMethodsWithAnnotation(PublicChild.class, Annotated.class, true, 
false);
         assertEquals(2, methodsWithAnnotation.length);
         assertEquals("PublicChild.publicAnnotatedMethod",
-                methodsWithAnnotation[0].getDeclaringClass().getSimpleName() + 
'.' +
-                        methodsWithAnnotation[0].getName());
-        assertEquals("Foo.doIt",
-                methodsWithAnnotation[1].getDeclaringClass().getSimpleName() + 
'.' +
-                        methodsWithAnnotation[1].getName());
+                methodsWithAnnotation[0].getDeclaringClass().getSimpleName() + 
'.' + methodsWithAnnotation[0].getName());
+        assertEquals("Foo.doIt", 
methodsWithAnnotation[1].getDeclaringClass().getSimpleName() + '.' + 
methodsWithAnnotation[1].getName());
     }
 
     @Test
@@ -1027,50 +997,36 @@ void testInvokeExactStaticMethod() throws Exception {
 
     @Test
     void testInvokeJavaVarargsOverloadingResolution() throws Exception {
-        assertEquals("Byte...", MethodUtils.invokeStaticMethod(TestBean.class,
-                "varOverload", (byte) 1, (byte) 2));
-        assertEquals("Short...", MethodUtils.invokeStaticMethod(TestBean.class,
-                "varOverload", (short) 1, (short) 2));
-        assertEquals("Integer...", 
MethodUtils.invokeStaticMethod(TestBean.class,
-                "varOverload", 1, 2));
-        assertEquals("Long...", MethodUtils.invokeStaticMethod(TestBean.class,
-                "varOverload", 1L, 2L));
-        assertEquals("Float...", MethodUtils.invokeStaticMethod(TestBean.class,
-                "varOverload", 1f, 2f));
-        assertEquals("Double...", 
MethodUtils.invokeStaticMethod(TestBean.class,
-                "varOverload", 1d, 2d));
-        assertEquals("Character...", 
MethodUtils.invokeStaticMethod(TestBean.class,
-                "varOverload", 'a', 'b'));
-        assertEquals("String...", 
MethodUtils.invokeStaticMethod(TestBean.class,
-                "varOverload", "a", "b"));
-        assertEquals("Boolean...", 
MethodUtils.invokeStaticMethod(TestBean.class,
-                "varOverload", true, false));
-
-        assertEquals("Object...", 
MethodUtils.invokeStaticMethod(TestBean.class,
-                "varOverload", 1, "s"));
-        assertEquals("Object...", 
MethodUtils.invokeStaticMethod(TestBean.class,
-                "varOverload", 1, true));
-        assertEquals("Object...", 
MethodUtils.invokeStaticMethod(TestBean.class,
-                "varOverload", 1.1, true));
-        assertEquals("Object...", 
MethodUtils.invokeStaticMethod(TestBean.class,
-                "varOverload", 'c', true));
-        assertEquals("Number...", 
MethodUtils.invokeStaticMethod(TestBean.class,
-                "varOverload", 1, 1.1));
-        assertEquals("Number...", 
MethodUtils.invokeStaticMethod(TestBean.class,
-                "varOverload", 1, 1L));
-        assertEquals("Number...", 
MethodUtils.invokeStaticMethod(TestBean.class,
-                "varOverload", 1d, 1f));
-        assertEquals("Number...", 
MethodUtils.invokeStaticMethod(TestBean.class,
-                "varOverload", (short) 1, (byte) 1));
-        assertEquals("Object...", 
MethodUtils.invokeStaticMethod(TestBean.class,
-                "varOverload", 1, 'c'));
-        assertEquals("Object...", 
MethodUtils.invokeStaticMethod(TestBean.class,
-                "varOverload", 'c', "s"));
-
-        assertEquals("Object...", 
MethodUtils.invokeStaticMethod(TestBean.class, "varOverload",
-                (Object[]) ArrayUtils.EMPTY_CLASS_ARRAY));
-        assertEquals("Number...", 
MethodUtils.invokeStaticMethod(TestBean.class, "numOverload",
-                (Object[]) ArrayUtils.EMPTY_CLASS_ARRAY));
+        // Primitive wrappers
+        assertEquals("Byte...", MethodUtils.invokeStaticMethod(TestBean.class, 
"varOverload", (byte) 1, (byte) 2));
+        assertEquals("Short...", 
MethodUtils.invokeStaticMethod(TestBean.class, "varOverload", (short) 1, 
(short) 2));
+        assertEquals("Integer...", 
MethodUtils.invokeStaticMethod(TestBean.class, "varOverload", 1, 2));
+        assertEquals("Long...", MethodUtils.invokeStaticMethod(TestBean.class, 
"varOverload", 1L, 2L));
+        assertEquals("Float...", 
MethodUtils.invokeStaticMethod(TestBean.class, "varOverload", 1f, 2f));
+        assertEquals("Double...", 
MethodUtils.invokeStaticMethod(TestBean.class, "varOverload", 1d, 2d));
+        assertEquals("Boolean...", 
MethodUtils.invokeStaticMethod(TestBean.class, "varOverload", true, false));
+        // Number
+        assertEquals("Number...", 
MethodUtils.invokeStaticMethod(TestBean.class, "varOverload", 1, 1.1));
+        assertEquals("Number...", 
MethodUtils.invokeStaticMethod(TestBean.class, "varOverload", 1, 1L));
+        assertEquals("Number...", 
MethodUtils.invokeStaticMethod(TestBean.class, "varOverload", 1d, 1f));
+        assertEquals("Number...", 
MethodUtils.invokeStaticMethod(TestBean.class, "varOverload", (short) 1, (byte) 
1));
+        assertEquals("Number...", 
MethodUtils.invokeStaticMethod(TestBean.class, "numOverload", 
ArrayUtils.EMPTY_OBJECT_ARRAY));
+        assertEquals("Number...", 
MethodUtils.invokeStaticMethod(TestBean.class, "numOverload", (Object[]) 
ArrayUtils.EMPTY_CLASS_ARRAY));
+        assertEquals("Number...", 
MethodUtils.invokeStaticMethod(TestBean.class, "numOverload", (Object[]) 
ArrayUtils.EMPTY_INTEGER_OBJECT_ARRAY));
+        // Object
+        assertEquals("Object...", 
MethodUtils.invokeStaticMethod(TestBean.class, "varOverload", 1, "s"));
+        assertEquals("Object...", 
MethodUtils.invokeStaticMethod(TestBean.class, "varOverload", 1, true));
+        assertEquals("Object...", 
MethodUtils.invokeStaticMethod(TestBean.class, "varOverload", 1.1, true));
+        assertEquals("Object...", 
MethodUtils.invokeStaticMethod(TestBean.class, "varOverload", 'c', true));
+        assertEquals("Object...", 
MethodUtils.invokeStaticMethod(TestBean.class, "varOverload", 1, 'c'));
+        assertEquals("Object...", 
MethodUtils.invokeStaticMethod(TestBean.class, "varOverload", 'c', "s"));
+        assertEquals("Object...", 
MethodUtils.invokeStaticMethod(TestBean.class, "varOverload", 
ArrayUtils.EMPTY_OBJECT_ARRAY));
+        assertEquals("Object...", 
MethodUtils.invokeStaticMethod(TestBean.class, "varOverload", (Object[]) 
ArrayUtils.EMPTY_CLASS_ARRAY));
+        assertEquals("Object...", 
MethodUtils.invokeStaticMethod(TestBean.class, "varOverload", (Object[]) 
ArrayUtils.EMPTY_INTEGER_OBJECT_ARRAY));
+        assertEquals("Object...", 
MethodUtils.invokeStaticMethod(TestBean.class, "varOverload"));
+        // Other
+        assertEquals("String...", 
MethodUtils.invokeStaticMethod(TestBean.class, "varOverload", "a", "b"));
+        assertEquals("Character...", 
MethodUtils.invokeStaticMethod(TestBean.class, "varOverload", 'a', 'b'));
     }
 
     @Test
@@ -1128,48 +1084,32 @@ void testInvokeMethodForceAccessWithArgs() throws 
Exception {
 
     @Test
     void testInvokeStaticMethod() throws Exception {
-        assertEquals("bar()", MethodUtils.invokeStaticMethod(TestBean.class,
-                "bar", (Object[]) ArrayUtils.EMPTY_CLASS_ARRAY));
-        assertEquals("bar()", MethodUtils.invokeStaticMethod(TestBean.class,
-                "bar", (Object[]) null));
-        assertEquals("bar()", MethodUtils.invokeStaticMethod(TestBean.class,
-                "bar", null, null));
-        assertEquals("bar(String)", MethodUtils.invokeStaticMethod(
-                TestBean.class, "bar", ""));
-        assertEquals("bar(Object)", MethodUtils.invokeStaticMethod(
-                TestBean.class, "bar", new Object()));
-        assertEquals("bar(Object)", MethodUtils.invokeStaticMethod(
-                TestBean.class, "bar", Boolean.TRUE));
-        assertEquals("bar(Integer)", MethodUtils.invokeStaticMethod(
-                TestBean.class, "bar", NumberUtils.INTEGER_ONE));
-        assertEquals("bar(int)", MethodUtils.invokeStaticMethod(TestBean.class,
-                "bar", NumberUtils.BYTE_ONE));
-        assertEquals("bar(double)", MethodUtils.invokeStaticMethod(
-                TestBean.class, "bar", NumberUtils.DOUBLE_ONE));
-        assertEquals("bar(String...)", MethodUtils.invokeStaticMethod(
-                TestBean.class, "bar", "a", "b"));
-        assertEquals("bar(long...)", MethodUtils.invokeStaticMethod(
-                TestBean.class, "bar", 1L, 2L));
-        assertEquals("bar(int, String...)", MethodUtils.invokeStaticMethod(
-                TestBean.class, "bar", NumberUtils.INTEGER_ONE, "a", "b"));
-
-        TestBean.verify(new ImmutablePair<>("String...", new String[]{"x", 
"y"}),
+        assertEquals("bar()", MethodUtils.invokeStaticMethod(TestBean.class, 
"bar", (Object[]) ArrayUtils.EMPTY_CLASS_ARRAY));
+        assertEquals("bar()", MethodUtils.invokeStaticMethod(TestBean.class, 
"bar", (Object[]) null));
+        assertEquals("bar()", MethodUtils.invokeStaticMethod(TestBean.class, 
"bar", null, null));
+        assertEquals("bar(String)", 
MethodUtils.invokeStaticMethod(TestBean.class, "bar", ""));
+        assertEquals("bar(Object)", 
MethodUtils.invokeStaticMethod(TestBean.class, "bar", new Object()));
+        assertEquals("bar(Object)", 
MethodUtils.invokeStaticMethod(TestBean.class, "bar", Boolean.TRUE));
+        assertEquals("bar(Integer)", 
MethodUtils.invokeStaticMethod(TestBean.class, "bar", NumberUtils.INTEGER_ONE));
+        assertEquals("bar(int)", 
MethodUtils.invokeStaticMethod(TestBean.class, "bar", NumberUtils.BYTE_ONE));
+        assertEquals("bar(double)", 
MethodUtils.invokeStaticMethod(TestBean.class, "bar", NumberUtils.DOUBLE_ONE));
+        assertEquals("bar(String...)", 
MethodUtils.invokeStaticMethod(TestBean.class, "bar", "a", "b"));
+        assertEquals("bar(long...)", 
MethodUtils.invokeStaticMethod(TestBean.class, "bar", 1L, 2L));
+        assertEquals("bar(int, String...)", 
MethodUtils.invokeStaticMethod(TestBean.class, "bar", NumberUtils.INTEGER_ONE, 
"a", "b"));
+        TestBean.verify(new ImmutablePair<>("String...", new String[] { "x", 
"y" }),
                 MethodUtils.invokeStaticMethod(TestBean.class, 
"varOverloadEchoStatic", "x", "y"));
-        TestBean.verify(new ImmutablePair<>("Number...", new Number[]{17, 23, 
42}),
+        TestBean.verify(new ImmutablePair<>("Number...", new Number[] { 17, 
23, 42 }),
                 MethodUtils.invokeStaticMethod(TestBean.class, 
"varOverloadEchoStatic", 17, 23, 42));
-        TestBean.verify(new ImmutablePair<>("String...", new String[]{"x", 
"y"}),
+        TestBean.verify(new ImmutablePair<>("String...", new String[] { "x", 
"y" }),
                 MethodUtils.invokeStaticMethod(TestBean.class, 
"varOverloadEchoStatic", "x", "y"));
-        TestBean.verify(new ImmutablePair<>("Number...", new Number[]{17, 23, 
42}),
+        TestBean.verify(new ImmutablePair<>("Number...", new Number[] { 17, 
23, 42 }),
                 MethodUtils.invokeStaticMethod(TestBean.class, 
"varOverloadEchoStatic", 17, 23, 42));
-
-        assertThrows(
-                NoSuchMethodException.class, () -> 
MethodUtils.invokeStaticMethod(TestBean.class, "does_not_exist"));
+        assertThrows(NoSuchMethodException.class, () -> 
MethodUtils.invokeStaticMethod(TestBean.class, "does_not_exist"));
     }
 
     @Test
     void testNullArgument() {
-        expectMatchingAccessibleMethodParameterTypes(TestBean.class, 
"oneParameter",
-                singletonArray(null), singletonArray(String.class));
+        expectMatchingAccessibleMethodParameterTypes(TestBean.class, 
"oneParameter", singletonArray(null), singletonArray(String.class));
     }
 
     @Test
@@ -1228,12 +1168,20 @@ void testVarArgsUnboxingLongArray() throws Exception {
         assertTrue(testBean.unboxLongArray);
     }
 
+    @Test
+    void testVarArgsUnboxingShortArray() throws Exception {
+        final TestBean testBean = new TestBean();
+        final short[] actual = (short[]) MethodUtils.invokeMethod(testBean, 
"unboxing", Short.valueOf((short) 1), Short.valueOf((short) 2));
+        assertArrayEquals(new short[] { 1, 2 }, actual);
+        assertTrue(testBean.unboxShortArray);
+    }
+
     private String toString(final Class<?>[] c) {
         return Arrays.asList(c).toString();
     }
 
     @Test
-    public void verifyJavaVarargsOverloadingResolution() {
+    void testJavaVarargsOverloadingResolution() {
         // This code is not a test of MethodUtils.
         // Rather it makes explicit the behavior of the Java specification for
         // various cases of overload resolution.
@@ -1246,7 +1194,6 @@ public void verifyJavaVarargsOverloadingResolution() {
         assertEquals("Character...", TestBean.varOverload('a', 'b'));
         assertEquals("String...", TestBean.varOverload("a", "b"));
         assertEquals("Boolean...", TestBean.varOverload(true, false));
-
         assertEquals("Object...", TestBean.varOverload(1, "s"));
         assertEquals("Object...", TestBean.varOverload(1, true));
         assertEquals("Object...", TestBean.varOverload(1.1, true));

Reply via email to