Skip to content

Commit a6bae2b

Browse files
committed
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 <williamstevens@gmail.com>
2 parents 939e448 + 4be5c2e commit a6bae2b

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

utils/src/test/java/com/cloud/utils/SwiftUtilTest.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,11 @@
1919

2020
package com.cloud.utils;
2121

22+
2223
import org.junit.Test;
2324
import org.mockito.Mockito;
2425

26+
import java.io.File;
2527
import java.net.URL;
2628
import java.security.InvalidKeyException;
2729
import java.security.NoSuchAlgorithmException;
@@ -32,7 +34,6 @@
3234
import static org.junit.Assert.assertTrue;
3335
import static org.mockito.Mockito.when;
3436

35-
3637
public class SwiftUtilTest {
3738

3839
@Test
@@ -72,7 +73,7 @@ public void testGenerateTempUrl() {
7273

7374
@Test
7475
public void testSplitSwiftPath(){
75-
String input = "container/object";
76+
String input = "container" + File.separator + "object";
7677
String[] output = SwiftUtil.splitSwiftPath(input);
7778
String[] expected = {"container", "object"};
7879

0 commit comments

Comments
 (0)