@Test
    public void testNormalUsage() {
        XmlStream xml = new XmlStream();
        xml.setIndent("  ");
        xml.beginTag("foo");
        xml.addAttribute("bar", "foo");
        xml.addAttribute("foo", "bar");
        xml.addContent("foo");
        xml.beginTag("bar");
        xml.endTag();
        xml.beginTag("foo");
        xml.beginTag("bar");
        xml.addAttribute("foo", "bar");
        xml.addContent("bar");
        xml.endTag();
        xml.endTag();
        xml.addContent("bar");
        xml.beginTag("foo");
        xml.addContent("foo");
        xml.addContent("bar");
        xml.endTag();
        xml.endTag();
        String expected =
              "<foo bar=\"foo\" foo=\"bar\">\n"
            + "  foo\n"
            + "  <bar/>\n"
            + "  <foo>\n"
            + "    <bar foo=\"bar\">bar</bar>\n"
            + "  </foo>\n"
            + "  bar\n"
            + "  <foo>foobar</foo>\n"
            + "</foo>\n";
        assertEquals(expected, xml.toString());
    }
A catch all test checking that regular usage looks good.
document/src/test/java/com/yahoo/document/serialization/XmlStreamTestCase.java