mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-25 21:42:07 +01:00
Move xml-not-well-formed (RFC 3920) condition handling to StreamError
Fixes SMACK-842.
This commit is contained in:
parent
5f05da2f77
commit
2900c5ae23
3 changed files with 23 additions and 5 deletions
|
@ -385,11 +385,6 @@ public class StanzaError extends AbstractError implements ExtensionElement {
|
|||
}
|
||||
|
||||
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 {
|
||||
|
|
|
@ -186,6 +186,11 @@ public class StreamError extends AbstractError implements Nonza {
|
|||
}
|
||||
|
||||
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 {
|
||||
|
|
|
@ -104,4 +104,22 @@ public class StreamErrorTest {
|
|||
assertNotNull(appSpecificElement);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStreamErrorXmlNotWellFormed() {
|
||||
StreamError error = null;
|
||||
final String xml =
|
||||
// Usually the stream:stream element has more attributes (to, version, ...)
|
||||
// We omit those, since they are not relevant for testing
|
||||
"<stream:stream from='im.example.com' id='++TR84Sm6A3hnt3Q065SnAbbk3Y=' xmlns:stream='http://etherx.jabber.org/streams'>" +
|
||||
"<stream:error><xml-not-well-formed xmlns='urn:ietf:params:xml:ns:xmpp-streams'/></stream:error>" +
|
||||
"</stream:stream>";
|
||||
try {
|
||||
XmlPullParser parser = PacketParserUtils.getParserFor(xml, "error");
|
||||
error = PacketParserUtils.parseStreamError(parser);
|
||||
} catch (Exception e) {
|
||||
fail(e.getMessage());
|
||||
}
|
||||
assertNotNull(error);
|
||||
assertEquals(Condition.not_well_formed, error.getCondition());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue