cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ko...@apache.org
Subject [4/6] git commit: updated refs/heads/master to c72f65d
Date Sat, 26 Oct 2013 16:30:05 GMT
InputStream use fix in PropertiesUtil

- use PropertiesUtil.loadFromFile to read the properties
- test added

Signed-off-by: Laszlo Hornyak <laszlo.hornyak@gmail.com>


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/58477834
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/58477834
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/58477834

Branch: refs/heads/master
Commit: 58477834b6a4170022235a5ed0d495ee9c3ddd57
Parents: 5e1ea1a
Author: Laszlo Hornyak <laszlo.hornyak@gmail.com>
Authored: Thu Oct 24 22:37:14 2013 +0200
Committer: Laszlo Hornyak <laszlo.hornyak@gmail.com>
Committed: Sat Oct 26 17:47:34 2013 +0200

----------------------------------------------------------------------
 utils/src/com/cloud/utils/PropertiesUtil.java       |  2 +-
 utils/test/com/cloud/utils/PropertiesUtilsTest.java | 13 +++++++++++++
 2 files changed, 14 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/58477834/utils/src/com/cloud/utils/PropertiesUtil.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/PropertiesUtil.java b/utils/src/com/cloud/utils/PropertiesUtil.java
index 6db66ff..6f3796a 100755
--- a/utils/src/com/cloud/utils/PropertiesUtil.java
+++ b/utils/src/com/cloud/utils/PropertiesUtil.java
@@ -130,7 +130,7 @@ public class PropertiesUtil {
             File commandsFile = findConfigFile(configFile);
             if (commandsFile != null) {
                 try {
-                    preProcessedCommands.load(new FileInputStream(commandsFile));
+                    loadFromFile(preProcessedCommands, commandsFile);
                 } catch (FileNotFoundException fnfex) {
                     // in case of a file within a jar in classpath, try to open stream using
url
                     InputStream stream = PropertiesUtil.openStreamFromURL(configFile);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/58477834/utils/test/com/cloud/utils/PropertiesUtilsTest.java
----------------------------------------------------------------------
diff --git a/utils/test/com/cloud/utils/PropertiesUtilsTest.java b/utils/test/com/cloud/utils/PropertiesUtilsTest.java
index 5ebe095..d27a0b4 100644
--- a/utils/test/com/cloud/utils/PropertiesUtilsTest.java
+++ b/utils/test/com/cloud/utils/PropertiesUtilsTest.java
@@ -18,6 +18,7 @@ package com.cloud.utils;
 
 import java.io.File;
 import java.io.IOException;
+import java.util.Map;
 import java.util.Properties;
 
 import org.apache.commons.io.FileUtils;
@@ -30,6 +31,7 @@ public class PropertiesUtilsTest {
         File configFile = PropertiesUtil.findConfigFile("notexistingresource");
         Assert.assertNull(configFile);
     }
+
     @Test
     public void loadFromFile() throws IOException {
         File file = File.createTempFile("test", ".properties");
@@ -38,4 +40,15 @@ public class PropertiesUtilsTest {
         PropertiesUtil.loadFromFile(properties, file);
         Assert.assertEquals("b", properties.get("a"));
     }
+
+    @Test
+    public void processConfigFile() throws IOException {
+        File tempFile = File.createTempFile("temp", ".properties");
+        FileUtils.writeStringToFile(tempFile, "a=b\nc=d\n");
+        Map<String, String> config = PropertiesUtil
+                .processConfigFile(new String[] { tempFile.getAbsolutePath() });
+        Assert.assertEquals("b", config.get("a"));
+        Assert.assertEquals("d", config.get("c"));
+        tempFile.delete();
+    }
 }


Mime
View raw message