@Test @SuppressWarnings("unchecked") public void testFilteringDisabled() throws Exception { String source = "abc"; assertEquals( "Filtering should nor be done as the tag set is empty", source, HtmlFilteringInterceptor.filterTags(source, Collections.EMPTY_SET)); }
@Test public void testHr() throws Exception { String source = loadContent("hr.txt"); String out = HtmlFilteringInterceptor.filterTags( source, new HashSet<String>(Arrays.asList("script", "object", "hr"))); assertFalse("<hr/> tag was not removed", out.contains("<hr")); assertTrue("other elements were incorrectly removed", out.contains("My separated text")); assertTrue("other elements were incorrectly removed", out.contains("My separated text 2")); }
@Test public void testFormatting() throws Exception { String source = loadContent("formatting.txt"); String out = HtmlFilteringInterceptor.filterTags( source, new HashSet<String>(Arrays.asList("b", "i", "strong"))); assertFalse("<strong/> tag was not removed", out.contains("<strong")); assertFalse("<i/> tag was not removed", out.contains("<i")); assertFalse("<b/> tag was not removed", out.contains("<b")); assertTrue( "other elements were incorrectly removed", out.contains("video") && out.contains("here:") && out.contains("require") && out.contains("market") && out.contains("Jahia Solutions")); }