Skip to content

Conversation

@GabrielBrascher
Copy link
Member

@GabrielBrascher GabrielBrascher commented Apr 16, 2016

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

@GabrielBrascher GabrielBrascher changed the title Test fails in Widows as the file separator "/" is different from "\" CLOUDSTACK-9352: Test fails in Widows as the file separator "/" is different from "\" Apr 16, 2016
@cloudsadhu
Copy link
Contributor

reviewed your code change and looks good. Please post the test result.
LGTM based on code review !!

@swill
Copy link
Contributor

swill commented Apr 21, 2016

I need one more LGTM and if you can post some proof this is working as expected, I will feel better about merging it. Thanks... :)

@GabrielBrascher
Copy link
Member Author

GabrielBrascher commented Apr 21, 2016

@swill it succesfully builds in windows: build-result.txt;

Not sure if it helps, but there is also a print showing the test failing. After the adjustment the test is ok: testrun

Let me know if you need more information :)

@swill
Copy link
Contributor

swill commented Apr 21, 2016

That is what I was looking for. Thank you sir... :)

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.
@asfgit asfgit merged commit 4be5c2e into apache:master Apr 25, 2016
asfgit pushed a commit that referenced this pull request Apr 25, 2016
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 <williamstevens@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants