@Test public void parseSASLFailureExtended() throws FactoryConfigurationError, TransformerException, ParserConfigurationException, XmlPullParserException, IOException, SAXException { // @formatter:off final String saslFailureString = XMLBuilder.create(SASLFailure.ELEMENT, SaslStreamElements.NAMESPACE) .e(SASLError.account_disabled.toString()) .up() .e("text").a("xml:lang", "en") .t("Call 212-555-1212 for assistance.") .up() .e("text").a("xml:lang", "de") .t("Bitte wenden sie sich an (04321) 123-4444") .up() .e("text") .t("Wusel dusel") .asString(); // @formatter:on XmlPullParser parser = TestUtils.getParser(saslFailureString, SASLFailure.ELEMENT); SASLFailure saslFailure = PacketParserUtils.parseSASLFailure(parser); XmlUnitUtils.assertSimilar(saslFailureString, saslFailure.toXML()); }
@Test public void parseSASLFailureSimple() throws FactoryConfigurationError, SAXException, IOException, TransformerException, ParserConfigurationException, XmlPullParserException { // @formatter:off final String saslFailureString = XMLBuilder.create(SASLFailure.ELEMENT, SaslStreamElements.NAMESPACE) .e(SASLError.account_disabled.toString()) .asString(); // @formatter:on XmlPullParser parser = TestUtils.getParser(saslFailureString, SASLFailure.ELEMENT); SASLFailure saslFailure = PacketParserUtils.parseSASLFailure(parser); assertXMLEqual(saslFailureString, saslFailure.toString()); }