checkParserStateNs(xpp, 0, xpp.END_TAG, null, 0, "", "foo", null, false, -1);
checkParserStateNs(xpp, 1, xpp.END_TAG, null, 0, "", "foo", null, false, -1);
    public void testTokenTypes() throws Exception {        XmlPullParser xpp = factory.newPullParser();        assertEquals(true, xpp.getFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES));        xpp.setInput(new StringReader(MISC_XML));        // attempt to set roundtrip        try {            xpp.setFeature(FEATURE_XML_ROUNDTRIP, true);        } catch(Exception ex) {        }        // did we succeeded?        boolean roundtripSupported = xpp.getFeature(FEATURE_XML_ROUNDTRIP);        checkParserStateNs(xpp, 0, xpp.START_DOCUMENT, null, 0, null, null, null, false, -1);        try {            xpp.isWhitespace();            fail("whitespace function must fail for START_DOCUMENT");        } catch(XmlPullParserException ex) {        }        xpp.nextToken();        checkParserStateNs(xpp, 0, xpp.IGNORABLE_WHITESPACE, null, 0, null, null,                           "\n \r\n \n\r", false, -1);        assertTrue(xpp.isWhitespace());        xpp.nextToken();        checkParserStateNs(xpp, 0, xpp.DOCDECL, null, 0, null, null,                           " titlepage SYSTEM \"http://www.foo.bar/dtds/typo.dtd\""+                               "[<!ENTITY % active.links \"INCLUDE\">"+                               "  <!ENTITY   test \"This is test! Do NOT Panic!\" >]", false, -1);        try {            xpp.isWhitespace();            fail("whitespace function must fail for START_DOCUMENT");        } catch(XmlPullParserException ex) {        }        xpp.nextToken();        checkParserStateNs(xpp, 0, xpp.COMMENT, null, 0, null, null, "c", false, -1);        try {            xpp.isWhitespace();            fail("whitespace function must fail for START_DOCUMENT");        } catch(XmlPullParserException ex) {        }        xpp.nextToken();        checkParserStateNs(xpp, 0, xpp.IGNORABLE_WHITESPACE, null, 0, null, null, "  \r\n", false, -1);        assertTrue(xpp.isWhitespace());        xpp.nextToken();        checkParserStateNs(xpp, 1, xpp.START_TAG, null, 0, "", "foo", null, false, 1);        if(roundtripSupported) {            assertEquals("start tag roundtrip", "<foo attrName='attrVal'>", xpp.getText());        }        checkAttribNs(xpp, 0, null, "", "attrName", "attrVal");        try {            xpp.isWhitespace();            fail("whitespace function must fail for START_DOCUMENT");        } catch(XmlPullParserException ex) {        }        xpp.nextToken();        checkParserStateNs(xpp, 1, xpp.TEXT, null, 0, null, null, "bar", false, -1);        assertEquals(false, xpp.isWhitespace());        xpp.nextToken();        checkParserStateNs(xpp, 1, xpp.COMMENT, null, 0, null, null, "comment", false, -1);        try {            xpp.isWhitespace();            fail("whitespace function must fail for START_DOCUMENT");        } catch(XmlPullParserException ex) {        }        boolean processDocdecl = xpp.getFeature(xpp.FEATURE_PROCESS_DOCDECL);        // uresolved entity must be reurned as null by nextToken()        xpp.nextToken();        if(!processDocdecl) {            checkParserStateNs(xpp, 1, xpp.ENTITY_REF, null, 0, null,                               "test", null, false, -1);        } else {            checkParserStateNs(xpp, 1, xpp.ENTITY_REF, null, 0, null,                               "test", "This is test! Do NOT Panic!", false, -1);        }        // now we check if we can resolve entity        if(!processDocdecl) {            xpp.defineEntityReplacementText("test", "This is test! Do NOT Panic!");        }        xpp.nextToken();        checkParserStateNs(xpp, 1, xpp.ENTITY_REF, null, 0, null,                           "test", "This is test! Do NOT Panic!", false, -1);        try {            xpp.isWhitespace();            fail("whitespace function must fail for ENTITY_RED");        } catch(XmlPullParserException ex) {        }        // check standard entities and char refs        xpp.nextToken();        checkParserStateNs(xpp, 1, xpp.ENTITY_REF, null, 0, null, "lt", "<", false, -1);        try {            xpp.isWhitespace();            fail("whitespace function must fail for ENTITY_REF");        } catch(XmlPullParserException ex) {        }        xpp.nextToken();        checkParserStateNs(xpp, 1, xpp.ENTITY_REF, null, 0, null, "#32", " ", false, -1);        try {            xpp.isWhitespace();            fail("whitespace function must fail for ENTITY_REF");        } catch(XmlPullParserException ex) {        }        xpp.nextToken();        checkParserStateNs(xpp, 1, xpp.ENTITY_REF, null, 0, null, "amp", "&", false, -1);        xpp.nextToken();        checkParserStateNs(xpp, 1, xpp.ENTITY_REF, null, 0, null, "gt", ">", false, -1);        xpp.nextToken();        checkParserStateNs(xpp, 1, xpp.ENTITY_REF, null, 0, null, "apos", "'", false, -1);        xpp.nextToken();        checkParserStateNs(xpp, 1, xpp.ENTITY_REF, null, 0, null, "quot", "\"", false, -1);        xpp.nextToken();        checkParserStateNs(xpp, 1, xpp.ENTITY_REF, null, 0, null, "#x20", " ", false, -1);        xpp.nextToken();        checkParserStateNs(xpp, 1, xpp.PROCESSING_INSTRUCTION, null, 0, null, null, "pi ds", false, -1);        try {            xpp.isWhitespace();            fail("whitespace function must fail for START_DOCUMENT");        } catch(XmlPullParserException ex) {        }        xpp.nextToken();        checkParserStateNs(xpp, 1, xpp.CDSECT, null, 0, null, null, " vo<o ", false, -1);        assertEquals(false, xpp.isWhitespace());        xpp.nextToken();        checkParserStateNs(xpp, 0, xpp.END_TAG, null, 0, "", "foo", null, false, -1);        if(roundtripSupported) {            assertEquals("end tag roundtrip", "</foo>", xpp.getText());        }        try {            xpp.isWhitespace();            fail("whitespace function must fail for START_DOCUMENT");        } catch(XmlPullParserException ex) {        }        xpp.nextToken();        checkParserStateNs(xpp, 0, xpp.IGNORABLE_WHITESPACE, null, 0, null, null,                           " \r\n", false, -1);        assertTrue(xpp.isWhitespace());        xpp.nextToken();        checkParserStateNs(xpp, 0, xpp.END_DOCUMENT, null, 0, null, null, null, false, -1);        try {            xpp.isWhitespace();            fail("whitespace function must fail for START_DOCUMENT");        } catch(XmlPullParserException ex) {        }    }