NumberParser { public static Integer parseInt(final String str) { if (null != str) { try { return new Integer(Integer.parseInt(str.trim())); } catch (final Exception e) { } } return null; } private  NumberParser(); static Long parseLong(final String str); static Integer parseInt(final String str); static Float parseFloat(final String str); static float parseFloat(final String str, final float def); static long parseLong(final String str, final long def);  }
@Test public void testIntParseFailure() { Integer num = NumberParser.parseInt("Non Int"); assertNull(num); }
@Test public void testIntParseSuccess() { Integer num = NumberParser.parseInt("1"); assertEquals(new Integer(1), num); }