changeset 195:af1dff836e60

Don't create any files when running ConfigUtilsTest Reviewed-by: neugens, rkennke Review-thread: http://icedtea.classpath.org/pipermail/thermostat/2012-April/000654.html
author Omair Majid <omajid@redhat.com>
date Tue, 03 Apr 2012 15:42:38 -0400
parents 729a0b0d861c
children 585a09251bf6
files agent/src/main/java/com/redhat/thermostat/agent/config/AgentStartupConfiguration.java common/src/main/java/com/redhat/thermostat/common/config/ConfigUtils.java common/src/test/java/com/redhat/thermostat/common/config/ConfigUtilsTest.java
diffstat 3 files changed, 7 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/agent/src/main/java/com/redhat/thermostat/agent/config/AgentStartupConfiguration.java	Tue Apr 03 13:23:57 2012 -0400
+++ b/agent/src/main/java/com/redhat/thermostat/agent/config/AgentStartupConfiguration.java	Tue Apr 03 15:42:38 2012 -0400
@@ -88,6 +88,10 @@
             
             // a file must exist, at least with the class name
             File backendSettings = ConfigUtils.getBackendPropertyFile(backendName);
+            if (!backendSettings.exists())
+                throw new InvalidConfigurationException("backends configuration " +
+                                                        "directory doesn't exist: " +
+                                                        backendSettings);
             Properties backendProps = new Properties();
             try {
                 backendProps.load(new FileInputStream(backendSettings));
--- a/common/src/main/java/com/redhat/thermostat/common/config/ConfigUtils.java	Tue Apr 03 13:23:57 2012 -0400
+++ b/common/src/main/java/com/redhat/thermostat/common/config/ConfigUtils.java	Tue Apr 03 15:42:38 2012 -0400
@@ -94,10 +94,6 @@
         File backendsConfigDir = ConfigUtils.getBackendsBaseDirectory();
         File backendConfig = new File(backendsConfigDir, backendName);
         backendConfig = new File(backendConfig, "backend.properties");
-        if (!backendConfig.exists())
-            throw new InvalidConfigurationException("backends configuration " +
-                                                    "directory doesn't exist: " + 
-                                                    backendConfig);
         return backendConfig;
     }
 
--- a/common/src/test/java/com/redhat/thermostat/common/config/ConfigUtilsTest.java	Tue Apr 03 13:23:57 2012 -0400
+++ b/common/src/test/java/com/redhat/thermostat/common/config/ConfigUtilsTest.java	Tue Apr 03 15:42:38 2012 -0400
@@ -38,23 +38,17 @@
 
 import java.io.File;
 import java.io.IOException;
-import java.util.Random;
 
 import junit.framework.Assert;
 
-import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 
-import com.redhat.thermostat.common.TestUtils;
-
 public class ConfigUtilsTest {
-
-    private String oldLocation;
     
     @Before
     public void setUp() throws IOException {
-        TestUtils.setupAgentConfigs();
+        System.setProperty("THERMOSTAT_HOME", "/tmp/");
     }
     
     @Test
@@ -64,6 +58,8 @@
         
         Assert.assertEquals(path, ConfigUtils.getThermostatHome());
         
+        Assert.assertEquals(path + "agent" + s + "agent.properties",
+                            ConfigUtils.getAgentConfigurationFile().getCanonicalPath());
         Assert.assertEquals(path + "backends", ConfigUtils.getBackendsBaseDirectory().getCanonicalPath());
         Assert.assertEquals(path + "storage", ConfigUtils.getStorageBaseDirectory().getCanonicalPath());
         Assert.assertEquals(path + "storage" + s + "db.properties",