@Override
    public XmlStringBuilder toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
        XmlStringBuilder xml = new XmlStringBuilder(this, enclosingNamespace);
        xml.rightAngleBracket();

        xml.emptyElement(compressFailureError);
        xml.optElement(stanzaError);

        xml.closeElement(this);
        return xml;
    }
@Test
    public void withStanzaErrrorFailureTest() throws SAXException, IOException {
        StanzaError stanzaError = StanzaError.getBuilder()
                        .setCondition(Condition.bad_request)
                        .build();
        Failure failure = new Failure(Failure.CompressFailureError.setup_failed, stanzaError);
        CharSequence xml = failure.toXML();

        final String expectedXml = "<failure xmlns='http://jabber.org/protocol/compress'>"
                        + "<setup-failed/>"
                        + "<error xmlns='jabber:client' type='modify'>"
                          + "<bad-request xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>"
                        + "</error>"
                        + "</failure>";

        assertXmlSimilar(expectedXml, xml.toString());
    }