PropertyFileDAO { public void loadPropertyFile(File propertyFile, String propertyFileName) throws PropertyAccessException { PropertiesConfiguration properties = new PropertiesConfiguration(); try { properties.setReloadingStrategy(new FileChangedReloadingStrategy()); properties.load(propertyFile); properties.setFile(propertyFile); properties.setAutoSave(false); properties.refresh(); propertyFilesHashmap.put(propertyFileName, properties); } catch (ConfigurationException e) { String sMessage = "Failed to load property file. Error: " + e.getMessage(); throw new PropertyAccessException(sMessage, e); } } 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 testLoadPropertyFile() throws PropertyAccessException { PropertyFileDAO propDAO = loadTestProperties(); assertTrue(propDAO.getProperty(TEST_PROPERTIES_NAME, "booleanTrueTest").equals("true")); }
@Test(expected = PropertyAccessException.class) public void testLoadPropertyFile_FileDoesNotExists() throws PropertyAccessException { File propertyFile = new File("/config/PropertyAccessorTest/doesnotexist"); PropertyFileDAO propDAO = new PropertyFileDAO(); propDAO.loadPropertyFile(propertyFile, "doesnotexist"); }