cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sw...@apache.org
Subject [1/2] git commit: updated refs/heads/master to a6bae2b
Date Mon, 25 Apr 2016 19:58:39 GMT
Repository: cloudstack
Updated Branches:
  refs/heads/master 939e44822 -> a6bae2b9c


Test fails in Widows as the file separator "/" is different from "\"

File separator in windows is different from linux (the expected in the
test); thus, the test
*com.cloud.utils.SwiftUtilTest.testSplitSwiftPath()* will fail in
windows. The problem is that the input of the test is
*"container/object"* but the tested method uses the *File.separator*
(that depends from the OS), in the windows the tested method
(*com.cloud.utils.SwiftUtil.splitSwiftPath(String)*) looks for a "\" in
windows systems, resulting in an empty string and consequently a failure
in the test.

Some solutions:
- the simple way is to create a string `String input = "container" +
File.separator + "object";`, thus independent of the OS, the test will
succeed.
- a tricky solution is to mock the final static variable
*File.separator* and return "/".

I picked the easy way.

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

Branch: refs/heads/master
Commit: 4be5c2e56cd99d7d1bf6a129cf26c3cbc1e2e926
Parents: 0dcaf19
Author: gabrascher <gabrascher@hotmail.com>
Authored: Sat Apr 16 15:35:17 2016 -0300
Committer: gabrascher <gabrascher@hotmail.com>
Committed: Thu Apr 21 17:55:59 2016 -0300

----------------------------------------------------------------------
 utils/src/test/java/com/cloud/utils/SwiftUtilTest.java | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4be5c2e5/utils/src/test/java/com/cloud/utils/SwiftUtilTest.java
----------------------------------------------------------------------
diff --git a/utils/src/test/java/com/cloud/utils/SwiftUtilTest.java b/utils/src/test/java/com/cloud/utils/SwiftUtilTest.java
index 55f7a34..20c1623 100644
--- a/utils/src/test/java/com/cloud/utils/SwiftUtilTest.java
+++ b/utils/src/test/java/com/cloud/utils/SwiftUtilTest.java
@@ -19,9 +19,11 @@
 
 package com.cloud.utils;
 
+
 import org.junit.Test;
 import org.mockito.Mockito;
 
+import java.io.File;
 import java.net.URL;
 import java.security.InvalidKeyException;
 import java.security.NoSuchAlgorithmException;
@@ -32,7 +34,6 @@ import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 import static org.mockito.Mockito.when;
 
-
 public class SwiftUtilTest {
 
     @Test
@@ -72,7 +73,7 @@ public class SwiftUtilTest {
 
     @Test
     public void testSplitSwiftPath(){
-        String input = "container/object";
+        String input = "container" + File.separator + "object";
         String[] output = SwiftUtil.splitSwiftPath(input);
         String[] expected = {"container", "object"};
 


Mime
View raw message