UriEncoding { public static String encodePathSegment(final String pathSegment) { requireNonNull(pathSegment); return encodeRFC3986UriComponent(pathSegment, ALLOWED_IN_PATH_SEGMENT); }  static String encodePath(final String path); static String encodePathSegment(final String pathSegment); static String encodeQuery(final String query, final EncodingType encType); static String encodeQueryParam(final String queryParam, final EncodingType encType); static String decode(final String source, final EncodingType encType);  }
@Test public void encodePathSegment() { assertEquals("foo", UriEncoding.encodePathSegment("foo")); assertEquals("%2Ftop%2Fsub", UriEncoding.encodePathSegment("/top/sub")); assertEquals("!%22%23$%25&'()*+,%2F:;=%3F@%5B%5C%5D%7B%7C%7D%20%C3%A4aZ0", UriEncoding.encodePathSegment(MANY_DIFFERENT_CHARS)); }