HibernateAccessor { public synchronized File getHibernateFile(String hibernateFileName) throws PropertyAccessException { checkEnvVarSet(); LOG.debug("Checking the hibernate file."); StringBuilder builder = new StringBuilder(); builder.append(propertyFileDir); builder.append(File.separator); builder.append("hibernate"); builder.append(File.separator); builder.append(hibernateFileName); String path = builder.toString(); LOG.info("Hibernate file path is: {} ", path); File result = new File(path); if (!result.exists()) { throw new PropertyAccessException("Unable to locate " + result); } return result; } protected  HibernateAccessor(); static HibernateAccessor getInstance(); synchronized File getHibernateFile(String hibernateFileName);  }
@Test public void testGetHibernateFile() throws PropertyAccessException { HibernateAccessor hibernateAccessor = createHibernateAccessor(); File file = hibernateAccessor.getHibernateFile(HIBERNATE_PROPERTY_FILE_NAME); assertTrue(file.exists()); }
@Test(expected=PropertyAccessException.class) public void testGetHibernateFile_DoesNotExist() throws PropertyAccessException{ HibernateAccessor hibernateAccessor = createHibernateAccessor(); hibernateAccessor.getHibernateFile("nonexistingfile"); }
@Test(expected=PropertyAccessException.class) public void testGetHibernateFile_WrongFileLocation() throws PropertyAccessException { HibernateAccessor hibernateAccessor = createBadHibernateAccessor(); hibernateAccessor.getHibernateFile(HIBERNATE_PROPERTY_FILE_NAME); }