### Question:
PropertiesFileReader { public static Config loadPropertiesFile(String fileName) throws EtiqetException { Map<String, String> propertyMap = new HashMap<>(); try (FileReader reader = new FileReader(fileName)) { Properties p = new Properties(); p.load(reader); Enumeration<?> keys = p.propertyNames(); while (keys.hasMoreElements()) { String key = (String) keys.nextElement(); propertyMap.put(key, p.getProperty(key)); } Config config = new Config(); config.setProperties(propertyMap); return config; } catch (Exception e) { throw new EtiqetException(e); } } private  PropertiesFileReader(); static Config loadPropertiesFile(String fileName); static Map<String, String> loadFromClasspath(String fileName);  }### Answer:
@Test public void testLoadPropertiesFile() throws EtiqetException { String configPath = System.getProperty("user.dir") + "/src/test/resources/properties/test.properties"; Config properties = PropertiesFileReader.loadPropertiesFile(configPath); assertFalse(properties.isEmpty()); assertEquals(12, properties.getKeySet().size()); assertEquals("config.properties", properties.getString("fix.config.file.path")); assertEquals("server.cfg", properties.getString("fix.server.config.file.path")); assertEquals("database.properties", properties.getString("shell.database.properties.path")); assertEquals("remoteshell.properties", properties.getString("shell.remoteshell.properties.path")); assertEquals("protocolConfig.properties", properties.getString("config.protocol.file.path")); assertTrue(properties.getBoolean("test.boolean.true")); assertTrue(properties.getBoolean("test.boolean.convert.true")); assertFalse(properties.getBoolean("test.boolean.false")); assertFalse(properties.getBoolean("test.boolean.convert.false")); assertEquals(Integer.valueOf(20), properties.getInteger("test.int")); assertEquals(Long.valueOf(20L), properties.getLong("test.int")); assertEquals(Double.valueOf(25.3), properties.getDouble("test.double")); assertEquals("etiqet-core/src/test/resources/properties/testConfig.properties", properties.getString("config.client.file.path")); }
@Test public void testLoadPropertiesException() { String configPath = System.getProperty("user.dir") + "/src/test/resources/does/not/exist.properties"; try { Config properties = PropertiesFileReader.loadPropertiesFile(configPath); fail("Exception should be thrown because the test file shouldn't exist"); } catch (Exception e) { assertEquals(EtiqetException.class, e.getClass()); assertTrue(e.getMessage().startsWith("java.io.FileNotFoundException")); } }