ReflectionUtils { public static void assertArrayType(Object array) throws IllegalArgumentException { Class<?> type = array.getClass(); if (!type.isArray()) { String message = String.format("The argument is not an array object, its type is %s", type.getName()); throw new IllegalArgumentException(message); } }  @Nonnull static String getCallerClassName(); @Nonnull static Class<?> getCallerClass(); static Package getCallerPackage(); static void assertArrayIndex(Object array, int index); static void assertArrayType(Object array); static void assertFieldMatchType(Object object, String fieldName, Class<?> expectedType); @Nonnull static List<T> toList(Object array); @Nonnull static Map<String, Object> readFieldsAsMap(Object object); static final String SUN_REFLECT_REFLECTION_CLASS_NAME; }
@Test public void testAssertArrayTypeOnException() { IllegalArgumentException exception = null; try { ReflectionUtils.assertArrayType(new Object()); } catch (IllegalArgumentException e) { exception = e; System.err.println(e.getMessage()); } Assert.assertNotNull(exception); }
@Test public void testAssertArrayType() { testAssertArrayType(long.class); testAssertArrayType(int.class); testAssertArrayType(short.class); testAssertArrayType(byte.class); testAssertArrayType(boolean.class); testAssertArrayType(double.class); testAssertArrayType(float.class); testAssertArrayType(char.class); testAssertArrayType(String.class); testAssertArrayType(Object.class); }