mirror of https://github.com/apache/cloudstack.git
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.
This commit is contained in:
parent
0dcaf197b4
commit
4be5c2e56c
|
|
@ -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"};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue