From 793f76563d4bb3f58fa62ff53985e20561c6e330 Mon Sep 17 00:00:00 2001
From: James Moger <james.moger@gitblit.com>
Date: Wed, 01 Jun 2011 21:01:51 -0400
Subject: [PATCH] Refactored some unit tests and utils.
---
src/com/gitblit/FileSettings.java | 15 ++++++++++-----
1 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/src/com/gitblit/FileSettings.java b/src/com/gitblit/FileSettings.java
index e6fb939..01176c0 100644
--- a/src/com/gitblit/FileSettings.java
+++ b/src/com/gitblit/FileSettings.java
@@ -34,9 +34,15 @@
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) {
@@ -139,14 +145,13 @@
}
private synchronized Properties read() {
- File file = new File(Constants.PROPERTIES_FILE);
- if (file.exists() && (file.lastModified() > lastread)) {
+ 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