checkParserState(xpp, 0, xpp.END_DOCUMENT, null, null, false, -1);
checkParserState(xpp, 0, XmlPullParser.END_DOCUMENT, null, null, false, -1);
    public void testEscaping() throws Exception {        XmlSerializer ser = factory.newSerializer();                ByteArrayOutputStream baos = new ByteArrayOutputStream();        ser.setOutput(baos, "UTF-8");        ser.startDocument("UTF-8", null);        ser.startTag("", "foo");        String s = "test\u0008\t\r\n";        try {            ser.attribute(null, "att", s);            fail("expected to fail for control character (<32)");        } catch(IllegalArgumentException e) {        } catch(IllegalStateException e){        }                ser = factory.newSerializer();        baos = new ByteArrayOutputStream();        ser.setOutput(baos, "UTF-8");        ser.startDocument("UTF-8", null);        ser.startTag("", "foo");        try {            ser.text(s);        } catch(IllegalArgumentException e) {        } catch(IllegalStateException e){        }                ser = factory.newSerializer();        baos = new ByteArrayOutputStream();        ser.setOutput(baos, "UTF-8");        ser.startDocument("UTF-8", null);        ser.startTag("", "foo");        s = "test\u0009\t\r\n";        String expectedS = "test\u0009\t\n";        ser.attribute(null, "att", s);        ser.text(s);                ser.endTag("", "foo");        ser.endDocument();                //check taking input form input stream        //byte[] binput = "<foo>test</foo>".getBytes("UTF8");                byte[] binput = baos.toByteArray();        //System.out.println(getClass()+" binput="+printable(new String(binput)));                xpp.setInput(new ByteArrayInputStream( binput ), "UTF-8" );        assertEquals("UTF-8", xpp.getInputEncoding());                //xpp.setInput(new StringReader( "<foo/>" ) );        checkParserState(xpp, 0, xpp.START_DOCUMENT, null, null, false, -1);        xpp.next();        checkParserState(xpp, 1, xpp.START_TAG, "foo", null, false /*empty*/, 1);        assertEquals(printable(s), printable(xpp.getAttributeValue(null, "att")));        xpp.next();        checkParserState(xpp, 1, xpp.TEXT, null, expectedS, false, -1);        assertEquals(false, xpp.isWhitespace());        xpp.next();        checkParserState(xpp, 1, xpp.END_TAG, "foo", null, false, -1);        xpp.next();        checkParserState(xpp, 0, xpp.END_DOCUMENT, null, null, false, -1);                baos = new ByteArrayOutputStream();        ser.setOutput(baos, "UTF-8");        ser.startDocument("UTF-8", null);        ser.startTag("", "foo");        s = "test\u0000\t\r\n";        try {            ser.attribute(null, "att", s);            fail("expected to fail as zero chartacter is illegal both in XML 1.0 and 1.1");        } catch(Exception e) {}        try {            ser.text(s);            fail("expected to fail as zero chartacter is illegal both in XML 1.0 and 1.1");        } catch(Exception e) {}    }