### Question:
PropertiesFileReader { public static Map<String, String> loadFromClasspath(String fileName) throws EtiqetException { Map<String, String> propertyMap = new HashMap<>(); InputStream stream = PropertiesFileReader.class.getResourceAsStream(fileName); Properties p = new Properties(); try { p.load(stream); Enumeration<?> keys = p.propertyNames(); while (keys.hasMoreElements()) { String key = (String) keys.nextElement(); propertyMap.put(key, p.getProperty(key)); } stream.close(); } catch (Exception e) { throw new EtiqetException("Could not read classpath file " + fileName, e); } return propertyMap; } private  PropertiesFileReader(); static Config loadPropertiesFile(String fileName); static Map<String, String> loadFromClasspath(String fileName);  }### Answer:
@Test public void testLoadFromClasspath() throws EtiqetException { String configPath = "/properties/test.properties"; Map<String, String> properties = PropertiesFileReader.loadFromClasspath(configPath); assertFalse(properties.isEmpty()); assertEquals(12, properties.size()); assertEquals("config.properties", properties.get("fix.config.file.path")); assertEquals("server.cfg", properties.get("fix.server.config.file.path")); assertEquals("database.properties", properties.get("shell.database.properties.path")); assertEquals("remoteshell.properties", properties.get("shell.remoteshell.properties.path")); assertEquals("protocolConfig.properties", properties.get("config.protocol.file.path")); assertEquals("true", properties.get("test.boolean.true")); assertEquals("1", properties.get("test.boolean.convert.true")); assertEquals("false", properties.get("test.boolean.false")); assertEquals("0", properties.get("test.boolean.convert.false")); assertEquals("20", properties.get("test.int")); assertEquals("25.3", properties.get("test.double")); assertEquals("etiqet-core/src/test/resources/properties/testConfig.properties", properties.get("config.client.file.path")); }
@Test public void testLoadFromClasspathException() { String configPath = "/properties/does/not/exist.properties"; try { Map<String, String> properties = PropertiesFileReader.loadFromClasspath(configPath); fail("Exception should be thrown because the test file shouldn't exist"); } catch (Exception e) { assertEquals(EtiqetException.class, e.getClass()); assertEquals("Could not read classpath file " + configPath, e.getMessage()); } }