### Question:
StringUtil { public static String urlEncode(String str) { if (StringUtils.isBlank(str)) { return str; } String result = str; try { UriComponents uriComponents = UriComponentsBuilder.fromUriString(str).build(); return uriComponents.encode().toUriString(); } catch (Exception e) { LOGGER.error(e.getMessage()); } return result; } private  StringUtil(); static List<MediaType> parseMediaTypes(String mediaTypesStr); static MediaType parseMediaType(String mediaTypeStr); static boolean containNonAsciiPrintableChars(String decodeUri); static String generateEncodedRedirectURL(String param,
            String servicePartUri, String baseUrl); static List<String> parseSeparatedStringToListIfListIsNull(
            String separatedStr, List<String> list); static String addQuotas(String str); static boolean checkIsValidSearchPattern(String str); static boolean containsAtMostOnce(String str, String searchStr); static boolean isValidEntityHandleOrName(String handle); static String urlEncode(String str); static String getNormalization(String str); static long parseUnsignedLong(String s); static String foldCase(String strParam); static String foldCaseAndNormalization(String strParam); static List<String> getNotEmptyStringList(List<String> stringList); static final String SPACE; static final String TLD_SPLITOR; static final String ASTERISK; static final String CHAR_SET_UTF8; static final String CHAR_SET_ISO8859; static final int MAX_ENTITY_HANDLE_LENGTH; }### Answer:
@Test public void test_encodedURL() throws UnsupportedEncodingException { String url = "http: String param = "中文。中国"; String qEncode = URLEncoder.encode(param, "UTF-8"); String expectURL = url + qEncode; String result = StringUtil.urlEncode(url + param); assertEquals(expectURL, result); }
@Test public void test_encodedURL_with_space() throws UnsupportedEncodingException { String url = "http: String param = "中文 中国"; String result = StringUtil.urlEncode(url + param); assertEquals( "http: result); }
@Test public void test_encodedURL_with_special_char() throws UnsupportedEncodingException { String url = "http: String result = StringUtil.urlEncode(url); assertEquals("http: }
@Test public void testDecodedURL() throws UnsupportedEncodingException { String qEncode = URLEncoder.encode("中文。中国", "UTF-8"); String expectURL = "http: + qEncode; String decodedURL = "http: String result = StringUtil.urlEncode(decodedURL); assertEquals(expectURL, result); }
@Test public void testDecodedURLForIDN() throws UnsupportedEncodingException { String decodedURL = "http: String expectURL = "http: String result = StringUtil.urlEncode(decodedURL); assertEquals(expectURL, result); }