NumberParser { public static Long parseLong(final String str) { if (null != str) { try { return new Long(Long.parseLong(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 testLongParseFailure() { Long num = NumberParser.parseLong("Non Long"); assertNull(num); }
@Test public void testLongParseSuccess() { Long num = NumberParser.parseLong("1"); assertEquals(new Long(1L), num); }
@Test public void testLongParseDefaultSuccess() { long num = NumberParser.parseLong("Non Long", 1L); assertEquals(1L, num); }
@Test public void testLongParseNonDefaultSuccess() { long num = NumberParser.parseLong("0", 1L); assertEquals(0L, num); }