PathUtils { public static String[] splitPath(String path) { path = path.replaceAll("(^/+)|(/+$)", ""); return path.split("/+"); } private  PathUtils(); @VisibleForTesting static Configuration getConfiguration(); static boolean impliesURI(URI privilegeURI, URI requestURI); static boolean impliesURI(String privilege, String request); static String parseDFSURI(String warehouseDir, String uri); static String parseURI(String warehouseDir, String uri, boolean isLocal); static String parseLocalURI(String uri); static String[] splitPath(String path);  }
@Test public void testStripSurplusSlashesAndSplitPath() throws Exception { List<String> expected = Arrays.asList("a", "b", "c"); String path = "a/b/c"; assertEquals("Invalid split doesn't match expected output", expected, Lists.newArrayList(PathUtils.splitPath(path))); path = "/a/b/c"; assertEquals("Invalid split doesn't match expected output", expected, Lists.newArrayList(PathUtils.splitPath(path))); path = "a/b/c/"; assertEquals("Invalid split doesn't match expected output", expected, Lists.newArrayList(PathUtils.splitPath(path))); path = "/a/b/c/"; assertEquals("Invalid split doesn't match expected output", expected, Lists.newArrayList(PathUtils.splitPath(path))); path = " assertEquals("Invalid split doesn't match expected output", expected, Lists.newArrayList(PathUtils.splitPath(path))); path = " assertEquals("Invalid split doesn't match expected output", expected, Lists.newArrayList(PathUtils.splitPath(path))); }