// can set test_data env variable to override default behavior of
// finding data using class loader
// useful when running in plugin environment, where test data is inside
// bundled jar, and must be extracted to temp filesystem location to be
// accessed normally
mOsRootDataPath = System.getProperty("test_data");
if (mOsRootDataPath == null) {
sLogger.info("Cannot find test_data environment variable, init to class loader");
URL url = this.getClass().getClassLoader().getResource("data"); //$NON-NLS-1$
if (Platform.isRunning()) {
sLogger.info("Running as an Eclipse Plug-in JUnit test, using FileLocator");
try {
mOsRootDataPath = FileLocator.resolve(url).getFile();
} catch (IOException e) {
sLogger.warning("IOException while using FileLocator, reverting to url");
mOsRootDataPath = url.getFile();
}
} else {
sLogger.info("Running as an plain JUnit test, using url as-is");
mOsRootDataPath = url.getFile();
}
}
if (mOsRootDataPath.equals(AndroidConstants.WS_SEP + "data")) {
sLogger.warning("Resource data not found using class loader!, Defaulting to no path");
}
if (!mOsRootDataPath.endsWith(File.separator)) {
sLogger.info("Fixing test_data env variable (does not end with path separator)");
mOsRootDataPath = mOsRootDataPath.concat(File.separator);
}