@Test
public void testConvert() throws ClassNotFoundException {

  final Object[][] testParameters = new Object[][] {{127, Byte.class, (byte) 127},
      {128, Short.class, (short) 128}, {255, Integer.class, 255}, {256L, Long.class, 256L},
      {new BigInteger("511"), BigInteger.class, BigInteger.valueOf(511)},
      {new BigDecimal("512"), BigInteger.class, new BigDecimal("512").toBigInteger()},
      {1023f, Float.class, 1023f}, {1024d, Double.class, 1024d},
      {new BigDecimal("2047"), BigDecimal.class, new BigDecimal("2047")}};
  for (final Object[] testParameter : testParameters) {
    Object expected = Class.forName(testParameter[2].getClass().getName()).cast(testParameter[2]);
    Number number = (Number) testParameter[0];
    Class<?> targetClass = (Class<?>) testParameter[1];
    assertEquals(expected, NumberUtils.convert(number, targetClass));
  }
}