ConfigFacade extends MBeanSupport implements ConfigFacadeMBean { public File getConfigDirectory() { String dirName = getConfigDir(); File answer = null; if (Strings.isNotBlank(dirName)) { answer = new File(dirName); } else { answer = new File(".hawtio"); } answer.mkdirs(); return answer; }  static ConfigFacade getSingleton(); @Override void init(); @Override String getVersion(); File getConfigDirectory(); @Override String getConfigDir(); void setConfigDir(String configDir); InputStream openURL(String url); URLHandler getUrlHandler(String protocol); void addUrlHandler(String protocol, URLHandler handler); void removeUrlHandler(String protocol);  }
@Test public void testDefaultsToHomeDirectory() throws Exception { File configDirectory = facade.getConfigDirectory(); assertTrue("the config directory should exist " + configDirectory, configDirectory.exists()); assertTrue("the config directory should be a directory " + configDirectory, configDirectory.isDirectory()); assertEquals("The config directory name", ".hawtio", configDirectory.getName()); File homeDir = new File(System.getProperty("user.home", "noHomeDir")); File parentFile = configDirectory.getParentFile(); assertNotNull("Should have a parent directory", parentFile); assertEquals("config dir should be in the home directory", homeDir.getCanonicalPath(), parentFile.getCanonicalPath()); }