You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by sw...@apache.org on 2016/04/25 21:58:39 UTC

[1/2] git commit: updated refs/heads/master to a6bae2b

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 <ga...@hotmail.com>
Authored: Sat Apr 16 15:35:17 2016 -0300
Committer: gabrascher <ga...@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"};
 


[2/2] git commit: updated refs/heads/master to a6bae2b

Posted by sw...@apache.org.
Merge pull request #1498 from GabrielBrascher/lrg-cs-hackday-038

CLOUDSTACK-9352: Test fails in Widows as the file separator "/" is different from "\"**Problem:**
File separator in windows ("\") is different from the expected in the test ("/"); thus, the test *com.cloud.utils.SwiftUtilTest.testSplitSwiftPath()* will fail in Windows systems.

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 windows systems the tested method (*com.cloud.utils.SwiftUtil.splitSwiftPath(String)*) looks for a "\", as the string does not contain "\" it returns an empty string and consequently results in a test failure.

**Solution:**
Create a string `String input = "container" + File.separator + "object";`, with that the test will validate the tested method verifying if the method splits the string around matches of the given regular expression (in this case *File.separator*).

*JIRA link: https://issues.apache.org/jira/browse/CLOUDSTACK-9352*

* pr/1498:
  Test fails in Widows as the file separator "/" is different from "\"

Signed-off-by: Will Stevens <wi...@gmail.com>


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

Branch: refs/heads/master
Commit: a6bae2b9c200cff725fbdabddab6c69a94811561
Parents: 939e448 4be5c2e
Author: Will Stevens <wi...@gmail.com>
Authored: Mon Apr 25 15:58:17 2016 -0400
Committer: Will Stevens <wi...@gmail.com>
Committed: Mon Apr 25 15:58:17 2016 -0400

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