### Question:
HtmlTextFilter { public static String filter(String text) { if ( text == null ) { return text; } Document document = Jsoup.parse(text); document.outputSettings(new Document.OutputSettings().prettyPrint(false)); document.select("br").append("\\n"); document.select("p").prepend("\\n\\n"); String s = document.html().replaceAll("\\\\n", "\n"); return Jsoup.clean(s, "", Whitelist.none(), new Document.OutputSettings().prettyPrint(false)); } private  HtmlTextFilter(); static String filter(String text);  }### Answer:
@Test public void testFilterHtmlUsingMatchedHtml() { String text = "XSS <script type=\"text/javascript\">alert('XSS')</script>."; Assertions.assertEquals("XSS .", HtmlTextFilter.filter(text)); }
@Test public void testFilterHtmlUsingUnmatchedHtml() { String text = "XSS <a href=\"http: Assertions.assertEquals("XSS alert('XSS').", HtmlTextFilter.filter(text)); }