### Question:
VanillaCajaHtmlParser extends GadgetHtmlParser { @Override public Document parseDom(String source) throws GadgetException { return parseDomImpl(source); } @Inject  VanillaCajaHtmlParser(DOMImplementation documentFactory,
                               @Named("vanillaCajaParser.needsDebugData")
                               boolean needsDebugData); @Override Document parseDom(String source);  }### Answer:
@Ignore @Test(expected = GadgetException.class) public void testEmptyDocument() throws Exception { boolean exceptionCaught = false; parser.parseDom(""); }
@Test public void testNonHtml() throws Exception { String html = "var hello=\"world\";"; String expected = "<html><head></head><body>var hello=&#34;world&#34;;" + "</body></html>"; assertEquals(expected, serializer.serialize(parser.parseDom(html))); }
@Test public void testNoHead() throws Exception { String html = "<html><body><a href=\"hello\"></a></body></html>"; String expected = "<html><head></head><body><a href=\"hello\"></a>" + "</body></html>"; assertEquals(expected, serializer.serialize(parser.parseDom(html))); }
@Test public void testParseAndSerialize() throws Exception { String html = "<html><head><script src=\"1.js\"></script></head>" + "<body><a href=\"hello\"></a></body></html>"; String expected = "<html><head><script src=\"1.js\"></script></head>" + "<body><a href=\"hello\"></a>" + "</body></html>"; assertEquals(expected, serializer.serialize(parser.parseDom(html))); }
@Test public void testUnbalanced() throws Exception { String html = "<html><head><script src=\"1.js\"></script></head>" + "<body><p><embed></p></embed></body></html>"; String expected = "<html><head><script src=\"1.js\"></script></head>" + "<body><p><embed /></p>" + "</body></html>"; assertEquals(expected, serializer.serialize(parser.parseDom(html))); }
@Test public void testBadTagBalancing() throws Exception { String html = "<html><head><script src=\"1.js\"></head>" + "<body></body></html>"; String expected = "<html><head><script src=\"1.js\">" + "</head><body></body></html>" + "</script></head><body></body></html>"; assertEquals(expected, serializer.serialize(parser.parseDom(html))); }