try {
FileUtils.forceDeleteOnExit(tmpHome);
} catch (IOException e) {
LOG.error("Error while setting forceDeleteOnExit on {}", tmpHome);
}
return new Home(tmpHome);
}
String userHomeFromEnv = System.getenv("NGRINDER_HOME");
String userHomeFromProperty = System.getProperty("ngrinder.home");
if (!StringUtils.equals(userHomeFromEnv, userHomeFromProperty)) {
CoreLogger.LOGGER.warn("The path to ngrinder-home is ambiguous:");
CoreLogger.LOGGER.warn(" System Environment: NGRINDER_HOME=" + userHomeFromEnv);
CoreLogger.LOGGER.warn(" Java System Property: ngrinder.home=" + userHomeFromProperty);
CoreLogger.LOGGER.warn(" '" + userHomeFromProperty + "' is accepted.");
}
String userHome = StringUtils.defaultIfEmpty(userHomeFromProperty, userHomeFromEnv);
if (StringUtils.isEmpty(userHome)) {
userHome = System.getProperty("user.home") + File.separator + NGRINDER_DEFAULT_FOLDER;
} else if (StringUtils.startsWith(userHome, "~" + File.separator)) {
userHome = System.getProperty("user.home") + File.separator + userHome.substring(2);
} else if (StringUtils.startsWith(userHome, "." + File.separator)) {
userHome = System.getProperty("user.dir") + File.separator + userHome.substring(2);
}
userHome = FilenameUtils.normalize(userHome);
File homeDirectory = new File(userHome);
CoreLogger.LOGGER.info("nGrinder home directory:{}.", homeDirectory.getPath());
return new Home(homeDirectory);
}