Ejemplo n.º 1
0
 @Test
 public void testCleanPath() {
   assertEquals("mypath/myfile", StringUtils.cleanPath("mypath/myfile"));
   assertEquals("mypath/myfile", StringUtils.cleanPath("mypath\\myfile"));
   assertEquals("mypath/myfile", StringUtils.cleanPath("mypath/../mypath/myfile"));
   assertEquals("mypath/myfile", StringUtils.cleanPath("mypath/myfile/../../mypath/myfile"));
   assertEquals("../mypath/myfile", StringUtils.cleanPath("../mypath/myfile"));
   assertEquals("../mypath/myfile", StringUtils.cleanPath("../mypath/../mypath/myfile"));
   assertEquals("../mypath/myfile", StringUtils.cleanPath("mypath/../../mypath/myfile"));
   assertEquals("/../mypath/myfile", StringUtils.cleanPath("/../mypath/myfile"));
   assertEquals("/mypath/myfile", StringUtils.cleanPath("/a/:b/../../mypath/myfile"));
   assertEquals(
       "file:///c:/path/to/the%20file.txt",
       StringUtils.cleanPath("file:///c:/some/../path/to/the%20file.txt"));
 }