PropertyFileDAO { public long getPropertyLong(String propertyFileName, String propertyName) throws PropertyAccessException { PropertiesConfiguration properties = propertyFilesHashmap.get(propertyFileName); if (properties != null && properties.containsKey(propertyName)) { try { return properties.getLong(propertyName); } catch (ConversionException ex) { throw new PropertyAccessException("Could not convert property value to long for: " + propertyName, ex); } } throw new PropertyAccessException(getErrorMessage(propertyFileName, propertyName)); } 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 testGetPropertyLong() throws PropertyAccessException { PropertyFileDAO propDAO = loadTestProperties(); assertEquals(1500, propDAO.getPropertyLong(TEST_PROPERTIES_NAME, "longTest")); }
@Test(expected = PropertyAccessException.class) public void testGetPropertyLong_BadValue() throws PropertyAccessException { PropertyFileDAO propDAO = loadTestProperties(); propDAO.getPropertyLong(TEST_PROPERTIES_NAME, "longErrorTest"); }
@Test(expected = PropertyAccessException.class) public void testGetPropertyLong_MissingField() throws PropertyAccessException { PropertyFileDAO propDAO = loadTestProperties(); propDAO.getPropertyLong(TEST_PROPERTIES_NAME, "nonexistantfield"); }
@Test(expected = PropertyAccessException.class) public void testGetPropertyLong_NoPropertyFile() throws PropertyAccessException { PropertyFileDAO propDAO = loadTestProperties(); propDAO.getPropertyLong("nonexistant", "nonexistantfield"); }