ConfigParser { public static int parseInteger(final Properties properties, final String param) throws ExitException { return parseInteger(properties, param, null); } private  ConfigParser(); static void checkParamExists(final Properties properties, final String param); static boolean parseBoolean(final Properties properties, final String param); static boolean parseBoolean(final Properties properties, final String param, final Boolean defaultValue); static int parseInteger(final Properties properties, final String param); static int parseInteger(final Properties properties, final String param, final Integer defaultValue); static long parseLong(final Properties properties, final String param); static long parseLong(final Properties properties, final String param, final Long defaultValue); static String parseString(final Properties properties, final String param); static String parseString(final Properties properties, final String param, final String defaultValue); static void validateBooleanParam(final String val); static void validateConfig(final Properties config, final String[] requiredStrings,
        final String[] requiredBooleans, final String[] requiredIntegers, final String[] requiredLongs); static void validateIntegerParam(final String val); static void validateLongParam(final String val);  }
@Test public void testParseInteger() { Properties properties; final String param = "param"; final int defaultValue = 3; try { properties = new Properties(); properties.put(param, Integer.toString(defaultValue)); final int i = ConfigParser.parseInteger(properties, param); assertEquals(defaultValue, i); } catch (final ExitException e) { fail("value is valid"); } try { properties = new Properties(); properties.put(param, "invalid integer"); ConfigParser.parseInteger(properties, param); } catch (final ExitException e) { ; } try { properties = new Properties(); properties.put(param, Integer.toString(defaultValue - 1)); final int i = ConfigParser.parseInteger(properties, param, defaultValue); assertEquals(defaultValue, i + 1); } catch (final ExitException e) { fail("value is valid"); } try { properties = new Properties(); properties.put(param, "invalid integer"); final int i = ConfigParser.parseInteger(properties, param, defaultValue); assertEquals(defaultValue, i); } catch (final ExitException e) { fail("default value is provided"); } }