ConfigProperties { public static int getPortNumber(String property, int defaultValue) { String propValue = System.getProperty(property); if (propValue == null) { return defaultValue; } int port; try { port = Integer.parseInt(propValue); if (port < 0 || port > 65535) { throw new NumberFormatException(); } } catch (NumberFormatException ex) { LOGGER.info("invalid port: {}. Using default port: {}", propValue, defaultValue); port = defaultValue; } return port; }  static void loadProperties(String propFile); static int getPortNumber(String property, int defaultValue); static int retrieveConfigSetting(String property, int defaultValue);  }
@Test public void testGetPortNumberDefault() { assertEquals(ConfigProperties.getPortNumber("NotExistantProperty", 4080), 4080); }
@Test public void testGetPortNumberValid() { System.setProperty("athenz.port", "4085"); assertEquals(ConfigProperties.getPortNumber("athenz.port", 4080), 4085); }
@Test public void testGetPortNumberInvalidFormat() { System.setProperty("athenz.port", "abc"); assertEquals(ConfigProperties.getPortNumber("athenz.port", 4080), 4080); }
@Test public void testGetPortNumberOutOfRangeNegative() { System.setProperty("athenz.port", "-1"); assertEquals(ConfigProperties.getPortNumber("athenz.port", 4080), 4080); }
@Test public void testGetPortNumberOutOfRangePositive() { System.setProperty("athenz.port", "65536"); assertEquals(ConfigProperties.getPortNumber("athenz.port", 4080), 4080); }