NumberUtils { private static void throwOverflowException(final Number number, final Class<?> targetClass) { throw new IllegalArgumentException( "Could not convert number [" + number + "] of type [" + number.getClass().getName() + "] to target class [" + targetClass.getName() + "]: overflow"); }  @SuppressWarnings("unchecked") static T convert(final Number number, final Class<T> targetClass); @SuppressWarnings("unchecked") static T parse(final String text, final Class<?> clazz); static T parse(final String text, final Class<T> targetClass,
      final NumberFormat numberFormat); static byte[] positiveToByteArray(final BigInteger positiveNumber); static BigInteger byteArrayToPositive(final byte[] rawBytes);  }
@Test public void testThrowOverflowException() { final Object[][] testParameters = new Object[][] {{Byte.MIN_VALUE - 1, Byte.class}, {Byte.MAX_VALUE + 1, Byte.class}, {Short.MIN_VALUE - 1, Short.class}, {Short.MAX_VALUE + 1, Short.class}, {-2147483649L, Integer.class}, {2147483648L, Integer.class}}; for (final Object[] testParameter : testParameters) { Number number = (Number) testParameter[0]; Class<?> targetClass = (Class<?>) testParameter[1]; try { NumberUtils.convert(number, targetClass); } catch (Exception e) { assertSame(IllegalArgumentException.class, e.getClass()); } } }