RemoveEmptyText implements ContentManipulator { @Override public void manipulate(Document document) { Element body = document.body(); while (!removeEmpty(body)) { } }  @Override void manipulate(Document document);  }
@Test public void testAlreadyEmpty() { Document doc = Jsoup.parseBodyFragment(""); m.manipulate(doc); assertNotNull(doc.body()); }
@Test public void testNonEmpty() { Document doc = Jsoup.parseBodyFragment("<p>Hello</p>"); m.manipulate(doc); assertFalse(doc.body().select("p").isEmpty()); }
@Test public void testSingleEmpty() { Document doc = Jsoup.parseBodyFragment("<p></p>"); m.manipulate(doc); assertTrue(doc.body().select("p").isEmpty()); }
@Test public void testTwoEmpty() { Document doc = Jsoup.parseBodyFragment("<p></p><div></div>"); m.manipulate(doc); assertTrue(doc.body().select("*").not("body").isEmpty()); }
@Test public void testMixedEmpty() { Document doc = Jsoup.parseBodyFragment("<p></p><div></div><p>Hello</p>"); m.manipulate(doc); assertEquals(doc.body().select("p").size(), 1); }
@Test public void testHierarchyOfEmpty() { Document doc = Jsoup.parseBodyFragment("<div><p></p></div>"); m.manipulate(doc); assertTrue(doc.body().select("*").not("body").isEmpty()); }