mirror of
https://github.com/vanitasvitae/Smack.git
synced 2025-09-10 09:39:39 +02:00
Rework XMPP Error class design
Introduce AbstractError, change 'Conditions' to enums. Because of AbstractError, it was necessary that PlainStreamElement and TopLevelStreamElement becomes an interface. Thus the implementation of TopLevelStreamElement.toString() had to be removed. This adds - policy-violation - unexpected-request to XMPPError.Condition, and removes the - payment-required - remote-server-error - unexpected-condition - request-timeout Conditions The file transfer code does now no longer throw XMPPErrorExceptions, but SmackExceptions. Fixes SMACK-608. Makes it possible to resolves SMACK-386.
This commit is contained in:
parent
cc09192095
commit
9286a1decb
31 changed files with 582 additions and 548 deletions
|
@ -20,6 +20,7 @@ import static org.junit.Assert.assertEquals;
|
|||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import org.jivesoftware.smack.packet.StreamError.Condition;
|
||||
import org.jivesoftware.smack.util.PacketParserUtils;
|
||||
import org.junit.Test;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
|
@ -44,7 +45,7 @@ public class StreamErrorTest {
|
|||
fail(e.getMessage());
|
||||
}
|
||||
assertNotNull(error);
|
||||
assertEquals("conflict", error.getCode());
|
||||
assertEquals(Condition.conflict, error.getCondition());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -68,8 +69,8 @@ public class StreamErrorTest {
|
|||
fail(e.getMessage());
|
||||
}
|
||||
assertNotNull(error);
|
||||
assertEquals("conflict", error.getCode());
|
||||
assertEquals("Replaced by new connection", error.getText());
|
||||
assertEquals(Condition.conflict, error.getCondition());
|
||||
assertEquals("Replaced by new connection", error.getDescriptiveText());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -84,7 +85,7 @@ public class StreamErrorTest {
|
|||
"<text xml:lang='' xmlns='urn:ietf:params:xml:ns:xmpp-streams'>" +
|
||||
"Replaced by new connection" +
|
||||
"</text>" +
|
||||
"<appSpecificElement>" +
|
||||
"<appSpecificElement xmlns='myns'>" +
|
||||
"Text contents of application-specific condition element: Foo Bar" +
|
||||
"</appSpecificElement>" +
|
||||
"</stream:error>" +
|
||||
|
@ -96,10 +97,10 @@ public class StreamErrorTest {
|
|||
fail(e.getMessage());
|
||||
}
|
||||
assertNotNull(error);
|
||||
assertEquals("conflict", error.getCode());
|
||||
assertEquals("Replaced by new connection", error.getText());
|
||||
// As of now, Smack ignores application-specific condition elements, so we don't
|
||||
// test them.
|
||||
assertEquals(Condition.conflict, error.getCondition());
|
||||
assertEquals("Replaced by new connection", error.getDescriptiveText());
|
||||
PacketExtension appSpecificElement = error.getExtension("appSpecificElement", "myns");
|
||||
assertNotNull(appSpecificElement);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue