From 28d6b2a860740557bf93dd0f9a48d059379ed696 Mon Sep 17 00:00:00 2001 From: James Moger <james.moger@gitblit.com> Date: Sat, 28 May 2011 17:05:34 -0400 Subject: [PATCH] Unit testing. Removal of some unused code paths. --- src/com/gitblit/FileSettings.java | 17 +++++++++++------ 1 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/com/gitblit/FileSettings.java b/src/com/gitblit/FileSettings.java index e6fb939..393e76c 100644 --- a/src/com/gitblit/FileSettings.java +++ b/src/com/gitblit/FileSettings.java @@ -34,10 +34,16 @@ private final Logger logger = LoggerFactory.getLogger(FileSettings.class); + private final File propertiesFile; + private Properties properties = new Properties(); private long lastread; + public FileSettings(String file) { + this.propertiesFile = new File(file); + } + @Override public List<String> getAllKeys(String startingWith) { startingWith = startingWith.toLowerCase(); @@ -138,15 +144,14 @@ return strings; } - private synchronized Properties read() { - File file = new File(Constants.PROPERTIES_FILE); - if (file.exists() && (file.lastModified() > lastread)) { + private synchronized Properties read() { + if (propertiesFile.exists() && (propertiesFile.lastModified() > lastread)) { FileInputStream is = null; try { properties = new Properties(); - is = new FileInputStream(Constants.PROPERTIES_FILE); + is = new FileInputStream(propertiesFile); properties.load(is); - lastread = file.lastModified(); + lastread = propertiesFile.lastModified(); } catch (FileNotFoundException f) { // IGNORE - won't happen because file.exists() check above } catch (Throwable t) { @@ -166,6 +171,6 @@ @Override public String toString() { - return new File(Constants.PROPERTIES_FILE).getAbsolutePath(); + return propertiesFile.getAbsolutePath(); } } -- Gitblit v1.9.1