PropertyFileDAO { public Set<String> getPropertyNames(String propertyFileName) { Set<String> setPropNames = null; PropertiesConfiguration properties = propertyFilesHashmap.get(propertyFileName); if (properties != null && properties.getKeys() != null) { setPropNames = new HashSet<>(); Iterator<String> keys = properties.getKeys(); while (keys.hasNext()) { setPropNames.add(keys.next()); } } return setPropNames; } PropertyFileDAO(); void loadPropertyFile(File propertyFile, String propertyFileName); String getProperty(String propertyFileName, String propertyName); void setProperty(String propertyFileName, String key, Object value); String getPropertyComment(String propertyFileName, String key); boolean getPropertyBoolean(String propertyFileName, String propertyName); long getPropertyLong(String propertyFileName, String propertyName); Long getPropertyLongObject(String propertyFileName, String propertyName, Long defaultValue); Set<String> getPropertyNames(String propertyFileName); Properties getProperties(String propertyFileName); void printToLog(String propertyFileName); boolean containsPropFile(String fileName);  }
@Test public void testGetPropertyNames() throws PropertyAccessException { PropertyFileDAO propDAO = loadTestProperties(); Set<String> properties = propDAO.getPropertyNames(TEST_PROPERTIES_NAME); assertEquals(9, properties.size()); assertTrue(properties.contains("stringTest")); properties = propDAO.getPropertyNames("nonexistant"); assertNull(properties); }
@Test public void testGetPropertyNames_NoPropertyFile() throws PropertyAccessException { PropertyFileDAO propDAO = loadTestProperties(); Set<String> properties = propDAO.getPropertyNames("nonexistant"); assertNull(properties); }