IntegerTypeConverter extends IntegerPrimitiveTypeConverter { @Override public Object convert(String value) throws ConversionException { return (Integer)super.convert(value); }  @Override Object convert(String value);  }
@Test public void validConversions() throws Exception { for (TypeConverter pc : pcs) { Object obj = pc.convert("0"); Assert.assertEquals(obj, TypeConverterUtil.convert("0", obj.getClass())); Assert.assertEquals(Integer.valueOf(0), pc.convert("0")); Assert.assertEquals(Integer.valueOf(-2147483648), pc.convert("-2147483648")); Assert.assertEquals(Integer.valueOf(2147483647), pc.convert("2147483647")); Assert.assertEquals(Integer.valueOf(0), pc.convert("0x0")); Assert.assertEquals(Integer.valueOf(0), pc.convert("0X0")); Assert.assertEquals(Integer.valueOf(2147483647), pc.convert("0x7FFFFFFF")); Assert.assertEquals(Integer.valueOf(0xFFFFFFFF), pc.convert("0xFFFFFFFF")); } }
@Test public void overflow() throws Exception { for (TypeConverter pc : pcs) { try { pc.convert("0x100000000"); } catch (ConversionOverflowException e) { } } }
@Test public void negativeInHexNotAllowed() throws Exception { for (TypeConverter pc : pcs) { try { pc.convert("-0x01"); } catch (ConversionException e) { } } }