ConfigProperties { public static int retrieveConfigSetting(String property, int defaultValue) { int settingValue; try { String propValue = System.getProperty(property); if (propValue == null) { return defaultValue; } settingValue = Integer.parseInt(propValue); if (settingValue <= 0) { LOGGER.error("Invalid {} value: {}, defaulting to {}", property, propValue, defaultValue); settingValue = defaultValue; } } catch (Exception ex) { LOGGER.error("Invalid {} value, defaulting to {}: {}", property, defaultValue, ex.getMessage()); settingValue = defaultValue; } return settingValue; }  static void loadProperties(String propFile); static int getPortNumber(String property, int defaultValue); static int retrieveConfigSetting(String property, int defaultValue);  }
@Test public void testRetrieveConfigValueNull() { assertEquals(ConfigProperties.retrieveConfigSetting("unknown", 10), 10); }
@Test public void testRetrieveConfigValue() { System.setProperty("athenz.port", "4443"); assertEquals(ConfigProperties.retrieveConfigSetting("athenz.port", 4080), 4443); System.setProperty("athenz.port", "-4443"); assertEquals(ConfigProperties.retrieveConfigSetting("athenz.port", 4080), 4080); System.setProperty("athenz.port", "data"); assertEquals(ConfigProperties.retrieveConfigSetting("athenz.port", 4080), 4080); }