ConfigProperties { public static void loadProperties(String propFile) { Properties prop = new Properties(); try (InputStream is = new FileInputStream(propFile)) { prop.load(is); } catch (Exception ex) { throw new RuntimeException("Error while loading " + propFile, ex); } if (prop.isEmpty()) { throw new RuntimeException("No data set in " + propFile); } LOGGER.info("Loading system properties from {}...", propFile); Enumeration<?> enumeration = prop.propertyNames(); while (enumeration.hasMoreElements()) { String key = (String) enumeration.nextElement(); String value = prop.getProperty(key); if (!value.isEmpty()) { System.setProperty(key, value); LOGGER.info("property name={}, value={}", key, value); } } }  static void loadProperties(String propFile); static int getPortNumber(String property, int defaultValue); static int retrieveConfigSetting(String property, int defaultValue);  }
@Test public void testLoadProperties() throws IOException { assertThrows(RuntimeException.class, () -> { ConfigProperties.loadProperties("FailFile.txt"); }); File currentDirectory = new File(new File(".").getAbsolutePath()); assertThrows(RuntimeException.class, () -> { ConfigProperties.loadProperties(currentDirectory.getCanonicalPath() + "/src/test/resources/testFileConfigEmpty.properties"); }); ConfigProperties.loadProperties(currentDirectory.getCanonicalPath() + "/src/test/resources/testFileConfig.properties"); }