Merge pull request #69 from chrylis/stub-file-exists

stub fileExists for testing
This commit is contained in:
Ramnivas Laddad
2014-07-23 16:16:48 -07:00
2 changed files with 18 additions and 2 deletions

View File

@@ -131,7 +131,7 @@ public class LocalConfigConnector extends AbstractCloudConnector<UriBasedService
return;
}
if (!propertiesFile.exists()) {
if (!fileExists(propertiesFile)) {
logger.info("properties file " + propertiesFile + " does not exist; probably running in a real cloud");
return;
}
@@ -153,7 +153,18 @@ public class LocalConfigConnector extends AbstractCloudConnector<UriBasedService
/**
* Broken out into a separate method for mocking the filesystem.
*
* @param filename
* @param file
* the file to check
* @return whether the file exists
*/
boolean fileExists(File file) {
return file.exists();
}
/**
* Broken out into a separate method for mocking the filesystem.
*
* @param file
* the file to open
* @return a {@code FileInputStream} to the file
* @throws IOException

View File

@@ -25,6 +25,11 @@ class StubbedOpenFileLocalConfigConnector extends LocalConfigConnector {
return fileProvider.openFile(file);
}
@Override
boolean fileExists(File file) {
return true;
}
public void setFileProvider(InputStreamProvider provider) {
this.fileProvider = provider;
}