ZKPaths { public static String makePath(String parent, String child) { int maxPathLength = nullableStringLength(parent) + nullableStringLength(child) + 2; StringBuilder path = new StringBuilder(maxPathLength); joinPath(path, parent, child); return path.toString(); } private  ZKPaths(); static CreateMode getContainerCreateMode(); static boolean hasContainerSupport(); static String fixForNamespace(String namespace, String path); static String fixForNamespace(String namespace, String path, boolean isSequential); static String getNodeFromPath(String path); static PathAndNode getPathAndNode(String path); static String extractSequentialSuffix(String path); static List<String> split(String path); static void mkdirs(ZooKeeper zookeeper, String path); static void mkdirs(ZooKeeper zookeeper, String path, boolean makeLastNode); static void mkdirs(ZooKeeper zookeeper, String path, boolean makeLastNode, InternalACLProvider aclProvider); static void mkdirs(ZooKeeper zookeeper, String path, boolean makeLastNode, InternalACLProvider aclProvider, boolean asContainers); static void deleteChildren(ZooKeeper zookeeper, String path, boolean deleteSelf); static List<String> getSortedChildren(ZooKeeper zookeeper, String path); static String makePath(String parent, String child); static String makePath(String parent, String firstChild, String... restChildren); static final String PATH_SEPARATOR; }
@SuppressWarnings("NullArgumentToVariableArgMethod") @Test public void testMakePath() { Assert.assertEquals(ZKPaths.makePath(null, "/"), "/"); Assert.assertEquals(ZKPaths.makePath("", null), "/"); Assert.assertEquals(ZKPaths.makePath("/", null), "/"); Assert.assertEquals(ZKPaths.makePath(null, null), "/"); Assert.assertEquals(ZKPaths.makePath("/", "/"), "/"); Assert.assertEquals(ZKPaths.makePath("", "/"), "/"); Assert.assertEquals(ZKPaths.makePath("/", ""), "/"); Assert.assertEquals(ZKPaths.makePath("", ""), "/"); Assert.assertEquals(ZKPaths.makePath("foo", ""), "/foo"); Assert.assertEquals(ZKPaths.makePath("foo", "/"), "/foo"); Assert.assertEquals(ZKPaths.makePath("/foo", ""), "/foo"); Assert.assertEquals(ZKPaths.makePath("/foo", "/"), "/foo"); Assert.assertEquals(ZKPaths.makePath("foo", null), "/foo"); Assert.assertEquals(ZKPaths.makePath("foo", null), "/foo"); Assert.assertEquals(ZKPaths.makePath("/foo", null), "/foo"); Assert.assertEquals(ZKPaths.makePath("/foo", null), "/foo"); Assert.assertEquals(ZKPaths.makePath("", "bar"), "/bar"); Assert.assertEquals(ZKPaths.makePath("/", "bar"), "/bar"); Assert.assertEquals(ZKPaths.makePath("", "/bar"), "/bar"); Assert.assertEquals(ZKPaths.makePath("/", "/bar"), "/bar"); Assert.assertEquals(ZKPaths.makePath(null, "bar"), "/bar"); Assert.assertEquals(ZKPaths.makePath(null, "bar"), "/bar"); Assert.assertEquals(ZKPaths.makePath(null, "/bar"), "/bar"); Assert.assertEquals(ZKPaths.makePath(null, "/bar"), "/bar"); Assert.assertEquals(ZKPaths.makePath("foo", "bar"), "/foo/bar"); Assert.assertEquals(ZKPaths.makePath("/foo", "bar"), "/foo/bar"); Assert.assertEquals(ZKPaths.makePath("foo", "/bar"), "/foo/bar"); Assert.assertEquals(ZKPaths.makePath("/foo", "/bar"), "/foo/bar"); Assert.assertEquals(ZKPaths.makePath("/foo", "bar/"), "/foo/bar"); Assert.assertEquals(ZKPaths.makePath("/foo/", "/bar/"), "/foo/bar"); Assert.assertEquals(ZKPaths.makePath("foo", "bar", "baz"), "/foo/bar/baz"); Assert.assertEquals(ZKPaths.makePath("foo", "bar", "baz", "qux"), "/foo/bar/baz/qux"); Assert.assertEquals(ZKPaths.makePath("/foo", "/bar", "/baz"), "/foo/bar/baz"); Assert.assertEquals(ZKPaths.makePath("/foo/", "/bar/", "/baz/"), "/foo/bar/baz"); Assert.assertEquals(ZKPaths.makePath("foo", null, null), "/foo"); Assert.assertEquals(ZKPaths.makePath("foo", "bar", null), "/foo/bar"); Assert.assertEquals(ZKPaths.makePath("foo", null, "baz"), "/foo/baz"); }