Skip to content

Commit

Permalink
Merge remote-tracking branch 'private/issue/455-M3' into 0.7-develop
Browse files Browse the repository at this point in the history
  • Loading branch information
akirakw committed Dec 12, 2014
2 parents d72296f + 08c7965 commit f82d4d2
Showing 1 changed file with 22 additions and 17 deletions.
Expand Up @@ -64,6 +64,8 @@ public final class DirectIoTestHelper {

private static final String WILDCARD_REPLACEMENT = "__testing__";

private static final String ENV_FRAMEWORK_HOME = "ASAKUSA_HOME";

static final Logger LOG = LoggerFactory.getLogger(DirectIoTestHelper.class);

private static final WeakHashMap<TestContext, DirectDataSourceRepository> REPOSITORY_CACHE =
Expand Down Expand Up @@ -155,29 +157,32 @@ private DirectDataSourceRepository createRepository() {
}

private URL findExtraConfiguration() throws IOException {
File file = findFileOnHomePath(context, RuntimeResourceManager.CONFIGURATION_FILE_PATH);
if (file == null) {
File home = getHomePath(context);
if (home == null) {
throw new IOException(MessageFormat.format(
"Environment variable \"{0}\" is not set",
ENV_FRAMEWORK_HOME));
} else if (home.isDirectory() == false) {
throw new IOException(MessageFormat.format(
"Asakusa Framework is not installed: {0}",
home));
}
File file = new File(home, RuntimeResourceManager.CONFIGURATION_FILE_PATH);
if (file.exists() == false) {
throw new IOException(MessageFormat.format(
"Direct I/O configuration is not set: {0}/{1}",
"$ASAKUSA_HOME",
RuntimeResourceManager.CONFIGURATION_FILE_PATH));
"Direct I/O configuration file is not found: {0}",
file));
}
return file.toURI().toURL();
}

private static File findFileOnHomePath(TestContext context, String path) {
assert context != null;
assert path != null;
String home = context.getEnvironmentVariables().get("ASAKUSA_HOME");
if (home != null) {
File file = new File(home, path);
if (file.exists()) {
return file;
}
} else {
LOG.warn("ASAKUSA_HOME is not defined");
private static File getHomePath(TestContext context) {
String home = context.getEnvironmentVariables().get(ENV_FRAMEWORK_HOME);
if (home == null || home.trim().isEmpty()) {
return null;
}
return null;
File file = new File(home);
return file;
}

/**
Expand Down

0 comments on commit f82d4d2

Please sign in to comment.