hello", StringUtils .stripHtmlTags("
hello")); assertEquals("kdHydro < 12.53", StringUtils.stripHtmlTags("kdHydro < 12.53")); } @Test(groups = { "Functional" }) public void testUrlEncode() { // degenerate cases assertNull(StringUtils.urlEncode(null, ";,")); assertEquals("", StringUtils.urlEncode("", "")); assertEquals("", StringUtils.urlEncode("", ";,")); // sanity checks, see // https://en.wikipedia.org/wiki/Percent-encoding#Percent-encoding_reserved_characters assertEquals("+", StringUtils.urlEncode(" ", " ")); assertEquals("%25", StringUtils.urlEncode("%", "%")); assertEquals(".", StringUtils.urlEncode(".", ".")); // note . is not encoded assertEquals("%3A", StringUtils.urlEncode(":", ":")); assertEquals("%3B", StringUtils.urlEncode(";", ";")); assertEquals("%3D", StringUtils.urlEncode("=", "=")); assertEquals("%2C", StringUtils.urlEncode(",", ",")); // check % does not get recursively encoded! assertEquals("a%25b%3Dc%3Bd%3Ae%2C%2C", StringUtils.urlEncode("a%b=c;d:e,,", "=,;:%")); // = not in the list for encoding assertEquals("a=b", StringUtils.urlEncode("a=b", ";,")); // encode = (as %3B) and ; (as %3D) assertEquals("a%3Db.c%3B", StringUtils.urlEncode("a=b.c;", ";=,")); // . and space not in the list for encoding assertEquals("a%3Db.c d", StringUtils.urlEncode("a=b.c d", ";=,")); // encode space also (as +) assertEquals("a%3Db.c+d", StringUtils.urlEncode("a=b.c d", ";=, ")); // . does not get encoded even if requested - behaviour of URLEncoder assertEquals("a%3Db.c+d.e%3Df", StringUtils.urlEncode("a=b.c d.e=f", ";=,. ")); } @Test(groups = { "Functional" }) public void testUrlDecode() { // degenerate cases assertNull(StringUtils.urlDecode(null, ";,")); assertEquals("", StringUtils.urlDecode("", "")); assertEquals("", StringUtils.urlDecode("", ";,")); // = not in the list for encoding assertEquals("a%3Db", StringUtils.urlDecode("a%3Db", ";,")); // decode = and ; but not . assertEquals("a=b%3Ec; d", StringUtils.urlDecode("a%3Db%3Ec; d", ";=,")); // space not in the list for decoding assertEquals("a=b;c+d", StringUtils.urlDecode("a%3Db%3Bc+d", ";=,")); // decode space also; %3E is not decoded to . assertEquals("a=b%3Ec d=,", StringUtils.urlDecode("a%3Db%3Ec+d%3D%2C", ";=, ")); // decode encoded % (%25) assertEquals("a,=;\t%z", StringUtils.urlDecode("a%2C%3D%3B%09%25z", ";=,\t%")); } }