@Test public void testGetText() throws XmlPullParserException, IOException { forgeAndOpenDocument("<foo/>"); assertThat(parser.getText()).isEqualTo(""); forgeAndOpenDocument("<foo>bar</foo>"); assertThat(parser.getText()).isEqualTo("bar"); }
@Test public void testNextText_noText() throws XmlPullParserException, IOException { forgeAndOpenDocument("<foo><bar/></foo>"); try { assertThat(parser.nextText()).isEqualTo(parser.getText()); fail("nextText on a document with no text should have failed"); } catch (XmlPullParserException ex) { assertThat(parser.getEventType()) .isIn(XmlResourceParser.START_TAG, XmlResourceParser.END_DOCUMENT); } }