@Override public String toString() { StringBuilder sb = new StringBuilder("XMPPError: "); sb.append(condition.toString()).append(" - ").append(type.toString()); if (errorGenerator != null) { sb.append(". Generated by ").append(errorGenerator); } return sb.toString(); }
textElements.add(stanzaErrorTextElement); } else { condition = StanzaError.Condition.fromString(name);
@Override public String toString() { return this.name().replace('_', '-'); }
if ( StanzaError.Condition.conflict.equals( error.getCondition() ) )
break; default: builder.setCondition(StanzaError.Condition.fromString(name)); if (!parser.isEmptyElementTag()) { builder.setConditionText(parser.nextText());
@Override public XmlStringBuilder toXML(String enclosingNamespace) { XmlStringBuilder xml = new XmlStringBuilder(this, enclosingNamespace); xml.attribute("type", type.toString()); xml.optAttribute("by", errorGenerator); xml.rightAngleBracket(); xml.halfOpenElement(condition.toString()); xml.xmlnsAttribute(ERROR_CONDITION_AND_TEXT_NAMESPACE); if (conditionText != null) { xml.rightAngleBracket(); xml.escape(conditionText); xml.closeElement(condition.toString()); } else { xml.closeEmptyElement(); } addDescriptiveTextsAndExtensions(xml); xml.closeElement(this); return xml; }
public static Condition fromString(String string) { // Backwards compatibility for older implementations still using RFC 3920. RFC 6120 // changed 'xml-not-well-formed' to 'not-well-formed'. if ("xml-not-well-formed".equals(string)) { string = "not-well-formed"; } string = string.replace('-', '_'); Condition condition = null; try { condition = Condition.valueOf(string); } catch (Exception e) { throw new IllegalStateException("Could not transform string '" + string + "' to XMPPErrorCondition", e); } return condition; } }
@Override public String toString() { return this.name().replace('_', '-'); }
@Override public String toString() { StringBuilder sb = new StringBuilder("XMPPError: "); sb.append(condition.toString()).append(" - ").append(type.toString()); if (errorGenerator != null) { sb.append(". Generated by ").append(errorGenerator); } return sb.toString(); }
break; default: builder.setCondition(StanzaError.Condition.fromString(name)); if (!parser.isEmptyElementTag()) { builder.setConditionText(parser.nextText());
assertTrue(StanzaError.Condition.internal_server_error.equals(e.getStanzaError().getCondition())); protocol.verifyAll();
@Override public XmlStringBuilder toXML(String enclosingNamespace) { XmlStringBuilder xml = new XmlStringBuilder(this, enclosingNamespace); xml.attribute("type", type.toString()); xml.optAttribute("by", errorGenerator); xml.rightAngleBracket(); xml.halfOpenElement(condition.toString()); xml.xmlnsAttribute(ERROR_CONDITION_AND_TEXT_NAMESPACE); if (conditionText != null) { xml.rightAngleBracket(); xml.escape(conditionText); xml.closeElement(condition.toString()); } else { xml.closeEmptyElement(); } addDescriptiveTextsAndExtensions(xml); xml.closeElement(this); return xml; }
@Override public CharSequence toXML(String enclosingNamespace) { XmlStringBuilder xml = new XmlStringBuilder(this, enclosingNamespace); if (condition == null && textElements.isEmpty()) { xml.closeEmptyElement(); } else { if (condition != null) { xml.rightAngleBracket(); xml.append(condition.toString()); xml.xmlnsAttribute(StanzaError.ERROR_CONDITION_AND_TEXT_NAMESPACE); xml.closeEmptyElement(); } xml.append(textElements); xml.closeElement(ELEMENT); } return xml; }
@Test public void testConditionHasDefaultTypeMapping() throws NoSuchFieldException, IllegalAccessException { Map<Condition, Type> conditionToTypeMap = StanzaError.CONDITION_TO_TYPE; assertEquals("CONDITION_TO_TYPE map is likely out of sync with Condition enum", Condition.values().length, conditionToTypeMap.size()); } }
public static Condition fromString(String string) { string = string.replace('-', '_'); Condition condition = null; try { condition = Condition.valueOf(string); } catch (Exception e) { throw new IllegalStateException("Could not transform string '" + string + "' to XMPPErrorCondition", e); } return condition; } }
@Test public void testParseFailedError() throws Exception { StanzaError.Condition errorCondition = StanzaError.Condition.unexpected_request; String failedStanza = XMLBuilder.create("failed") .a("xmlns", "urn:xmpp:sm:3") .element(errorCondition.toString(), StanzaError.ERROR_CONDITION_AND_TEXT_NAMESPACE) .asString(outputProperties); StreamManagement.Failed failedPacket = ParseStreamManagement.failed( PacketParserUtils.getParserFor(failedStanza)); assertThat(failedPacket, is(notNullValue())); assertTrue(failedPacket.getStanzaErrorCondition() == errorCondition); }