HttpUtil { public static String concatPaths(String... paths) { StringBuilder buf = new StringBuilder(); for (String path : paths) { if (buf.length() == 0 || buf.charAt(buf.length() - 1) != '/') { buf.append('/'); } if (path.length() > 1 && path.charAt(0) == '/') { buf.append(path, 1, path.length()); } else if (path.length() > 0) { buf.append(path); } } int len = buf.length(); if (len == 0 || len == 1 && buf.charAt(0) == '/') { return "/"; } else { if (buf.charAt(len - 1) == '/') { buf.deleteCharAt(len - 1); } } return buf.toString(); } private  HttpUtil(); static URI buildUri(String uri); static Instant parseHttpDate(String dateText); static String formatHttpDate(Instant instant); static String concatPaths(String... paths); static Multimap<String, String> toMultimap(String... params); static HttpRequest built(HttpRequestOrBuilder rob); static HttpRequest.Builder builder(HttpRequestOrBuilder rob); static HttpResponse built(HttpResponseOrBuilder rob); static HttpResponse.Builder builder(HttpResponseOrBuilder rob); static Cookie built(CookieOrBuilder cookieOrBuilder); static Cookie.Builder builder(CookieOrBuilder cob); static String readContentString(HttpMessage msg); static final DateTimeFormatter HTTP_DATE_FORMAT; }
@Test public void concatPaths_nothing_root() { assertEquals("/", HttpUtil.concatPaths()); }
@Test public void concatPaths_empty_root() { assertEquals("/", HttpUtil.concatPaths("")); }
@Test public void concatPaths_root_root() { assertEquals("/", HttpUtil.concatPaths("/")); }
@Test public void concatPaths_something_slashAdded() { assertEquals("/foo", HttpUtil.concatPaths("foo")); }
@Test public void concatPaths_trailingSlash_slashRemoved() { assertEquals("/foo", HttpUtil.concatPaths("foo/")); }
@Test public void concatPaths_internalSlash_slashUnchanged() { assertEquals("/foo/bar", HttpUtil.concatPaths("foo/bar")); }
@Test public void concatPaths_emptyPlusSomething_something() { assertEquals("/foo", HttpUtil.concatPaths("", "foo")); }
@Test public void concatPaths_emptyPlusSlashSomething_something() { assertEquals("/foo", HttpUtil.concatPaths("", "/foo")); }
@Test public void concatPaths_emptyPlusSomethingSlash_something() { assertEquals("/foo", HttpUtil.concatPaths("", "foo/")); }