brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From henev...@apache.org
Subject [19/21] git commit: New line and path separator related fixes to make the tests happy.
Date Thu, 26 Jun 2014 11:42:25 GMT
New line and path separator related fixes to make the tests happy.


Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/34016c8b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/34016c8b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/34016c8b

Branch: refs/heads/master
Commit: 34016c8b7aa69018ae15b5efc8938e893afe4f14
Parents: 76a00cc
Author: Svetoslav Neykov <svetoslav.neykov@cloudsoftcorp.com>
Authored: Wed Jun 25 15:43:54 2014 +0300
Committer: Svetoslav Neykov <svetoslav.neykov@cloudsoftcorp.com>
Committed: Wed Jun 25 18:28:59 2014 +0300

----------------------------------------------------------------------
 .../entity/basic/SoftwareProcessEntityTest.java      |  6 ++++--
 .../dns/geoscaling/GeoscalingScriptGenerator.java    | 15 ++++++++-------
 utils/common/src/main/java/brooklyn/util/os/Os.java  |  4 +++-
 .../src/test/java/brooklyn/util/os/OsTest.java       |  8 +++++---
 .../util/stream/ThreadLocalStdoutStderrTest.java     |  3 ++-
 5 files changed, 22 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/34016c8b/software/base/src/test/java/brooklyn/entity/basic/SoftwareProcessEntityTest.java
----------------------------------------------------------------------
diff --git a/software/base/src/test/java/brooklyn/entity/basic/SoftwareProcessEntityTest.java
b/software/base/src/test/java/brooklyn/entity/basic/SoftwareProcessEntityTest.java
index 959ed69..d602335 100644
--- a/software/base/src/test/java/brooklyn/entity/basic/SoftwareProcessEntityTest.java
+++ b/software/base/src/test/java/brooklyn/entity/basic/SoftwareProcessEntityTest.java
@@ -99,8 +99,10 @@ public class SoftwareProcessEntityTest extends BrooklynAppUnitTestSupport
{
 
         entity.start(ImmutableList.of(loc));
 
-        Assert.assertEquals(entity.getAttribute(SoftwareProcess.INSTALL_DIR), Os.mergePaths(resolvedDataDir,
"installs/MyService"));
-        Assert.assertEquals(entity.getAttribute(SoftwareProcess.RUN_DIR), Os.mergePaths(resolvedDataDir,
"apps/"+entity.getApplicationId()+"/entities/MyService_"+entity.getId()));
+        Assert.assertEquals(Os.nativePath(entity.getAttribute(SoftwareProcess.INSTALL_DIR)),
+                            Os.nativePath(Os.mergePaths(resolvedDataDir, "installs/MyService")));
+        Assert.assertEquals(Os.nativePath(entity.getAttribute(SoftwareProcess.RUN_DIR)),
+                            Os.nativePath(Os.mergePaths(resolvedDataDir, "apps/"+entity.getApplicationId()+"/entities/MyService_"+entity.getId())));
     }
 
     protected <T extends MyService> void doStartAndCheckVersion(Class<T> type,
String expectedLabel, ConfigBag config) {

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/34016c8b/software/webapp/src/main/java/brooklyn/entity/dns/geoscaling/GeoscalingScriptGenerator.java
----------------------------------------------------------------------
diff --git a/software/webapp/src/main/java/brooklyn/entity/dns/geoscaling/GeoscalingScriptGenerator.java
b/software/webapp/src/main/java/brooklyn/entity/dns/geoscaling/GeoscalingScriptGenerator.java
index b3b6bcb..a89b981 100644
--- a/software/webapp/src/main/java/brooklyn/entity/dns/geoscaling/GeoscalingScriptGenerator.java
+++ b/software/webapp/src/main/java/brooklyn/entity/dns/geoscaling/GeoscalingScriptGenerator.java
@@ -9,6 +9,7 @@ import java.util.TimeZone;
 import brooklyn.location.geo.HostGeoInfo;
 import brooklyn.util.ResourceUtils;
 import brooklyn.util.javalang.JavaClassNames;
+import brooklyn.util.os.Os;
 import brooklyn.util.text.Strings;
 
 public class GeoscalingScriptGenerator {
@@ -35,18 +36,18 @@ public class GeoscalingScriptGenerator {
     
     private static String getHostsDeclaration(Collection<HostGeoInfo> hosts) {
         StringBuffer sb = new StringBuffer();
-        sb.append("$hosts = array(\n");
+        sb.append("$hosts = array(").append(Os.LINE_SEPARATOR);
         Iterator<HostGeoInfo> iServer = hosts.iterator();
         while (iServer.hasNext()) {
             HostGeoInfo server = iServer.next();
-            sb.append("    array('name'      => '").append(escape(server.displayName)).append("',\n");
-            sb.append("          'latitude'  => ").append(server.latitude).append(",\n");
-            sb.append("          'longitude' => ").append(server.longitude).append(",\n");
+            sb.append("    array('name'      => '").append(escape(server.displayName)).append("',").append(Os.LINE_SEPARATOR);
+            sb.append("          'latitude'  => ").append(server.latitude).append(",").append(Os.LINE_SEPARATOR);
+            sb.append("          'longitude' => ").append(server.longitude).append(",").append(Os.LINE_SEPARATOR);
             sb.append("          'ip'        => '").append(escape(server.address)).append("')");
-            if (iServer.hasNext()) sb.append(",\n");
-            sb.append("\n");
+            if (iServer.hasNext()) sb.append(",").append(Os.LINE_SEPARATOR);
+            sb.append(Os.LINE_SEPARATOR);
         }
-        sb.append(");\n");
+        sb.append(");").append(Os.LINE_SEPARATOR);
         return sb.toString();
     }
     

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/34016c8b/utils/common/src/main/java/brooklyn/util/os/Os.java
----------------------------------------------------------------------
diff --git a/utils/common/src/main/java/brooklyn/util/os/Os.java b/utils/common/src/main/java/brooklyn/util/os/Os.java
index 0652c3a..235d666 100644
--- a/utils/common/src/main/java/brooklyn/util/os/Os.java
+++ b/utils/common/src/main/java/brooklyn/util/os/Os.java
@@ -41,6 +41,8 @@ public class Os {
     private static final char SEPARATOR_UNIX = '/';
     private static final char SEPARATOR_WIN = '\\';
     
+    public static final String LINE_SEPARATOR = System.getProperty("line.separator");
+
     /** returns the best tmp dir to use; see {@link TmpDirFinder} for the logic
      * (and the explanation why this is needed!) */
     public static String tmp() {
@@ -183,7 +185,7 @@ public class Os {
         StringBuilder result = new StringBuilder();
         for (String item: items) {
             if (Strings.isEmpty(item)) continue;
-            if (result.length() > 0 && result.charAt(result.length()-1) != separatorChar)
result.append(separatorChar);
+            if (result.length() > 0 && !isSeparator(result.codePointAt(result.length()-1)))
result.append(separatorChar);
             result.append(item);
         }
         return result.toString();

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/34016c8b/utils/common/src/test/java/brooklyn/util/os/OsTest.java
----------------------------------------------------------------------
diff --git a/utils/common/src/test/java/brooklyn/util/os/OsTest.java b/utils/common/src/test/java/brooklyn/util/os/OsTest.java
index b650de3..7e3f430 100644
--- a/utils/common/src/test/java/brooklyn/util/os/OsTest.java
+++ b/utils/common/src/test/java/brooklyn/util/os/OsTest.java
@@ -2,6 +2,8 @@ package brooklyn.util.os;
 
 import static org.testng.Assert.assertEquals;
 
+import java.io.File;
+
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.testng.Assert;
@@ -59,10 +61,10 @@ public class OsTest {
     
     public void testMergePaths() throws Exception {
         assertEquals(Os.mergePaths("a"), "a"); 
-        assertEquals(Os.mergePaths("a", "b"), "a/b"); 
+        assertEquals(Os.mergePaths("a", "b"), "a" + File.separator + "b"); 
         assertEquals(Os.mergePaths("a/", "b"), "a/b");
-        assertEquals(Os.mergePaths("a", "b/"), "a/b/");
-        assertEquals(Os.mergePaths("/a", "b"), "/a/b");
+        assertEquals(Os.mergePaths("a", "b/"), "a" + File.separator + "b/");
+        assertEquals(Os.mergePaths("/a", "b"), "/a" + File.separator + "b");
     }
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/34016c8b/utils/common/src/test/java/brooklyn/util/stream/ThreadLocalStdoutStderrTest.java
----------------------------------------------------------------------
diff --git a/utils/common/src/test/java/brooklyn/util/stream/ThreadLocalStdoutStderrTest.java
b/utils/common/src/test/java/brooklyn/util/stream/ThreadLocalStdoutStderrTest.java
index 5713faf..4ad208e 100644
--- a/utils/common/src/test/java/brooklyn/util/stream/ThreadLocalStdoutStderrTest.java
+++ b/utils/common/src/test/java/brooklyn/util/stream/ThreadLocalStdoutStderrTest.java
@@ -3,6 +3,7 @@ package brooklyn.util.stream;
 import org.testng.Assert;
 import org.testng.annotations.Test;
 
+import brooklyn.util.os.Os;
 import brooklyn.util.stream.ThreadLocalPrintStream.OutputCapturingContext;
 
 public class ThreadLocalStdoutStderrTest {
@@ -65,7 +66,7 @@ public class ThreadLocalStdoutStderrTest {
         
         System.out.println("4 - not captured, restored normal output");
         Assert.assertEquals(TWO, out2.trim());
-        Assert.assertEquals(TWO+"\n"+THREE, out1.trim());
+        Assert.assertEquals(TWO+Os.LINE_SEPARATOR+THREE, out1.trim());
     }
 
 }


Mime
View raw message