### Question:
XHTMLExtensionProvider extends ExtensionElementProvider<XHTMLExtension> { @Override public XHTMLExtension parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment) throws IOException, XmlPullParserException { XHTMLExtension xhtmlExtension = new XHTMLExtension(); while (true) { XmlPullParser.Event eventType = parser.getEventType(); String name = parser.getName(); if (eventType == XmlPullParser.Event.START_ELEMENT) { if (name.equals(Message.BODY)) { xhtmlExtension.addBody(PacketParserUtils.parseElement(parser)); } } else if (eventType == XmlPullParser.Event.END_ELEMENT) { if (parser.getDepth() == initialDepth) { return xhtmlExtension; } } parser.next(); } }  @Override XHTMLExtension parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment);  }### Answer:
@Test public void parsesWell() throws IOException, XmlPullParserException { InputStream inputStream = getClass().getResourceAsStream(XHTML_EXTENSION_SAMPLE_RESOURCE_NAME); XmlPullParser parser = PacketParserUtils.getParserFor(inputStream); parser.next(); XHTMLExtensionProvider provider = new XHTMLExtensionProvider(); ExtensionElement extension = provider.parse(parser, parser.getDepth(), null); assertThat(extension, instanceOf(XHTMLExtension.class)); XHTMLExtension attachmentsInfo = (XHTMLExtension) extension; assertThat(sampleXhtml(), equalsCharSequence(attachmentsInfo.getBodies().get(0))); }