1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2025-09-10 10:49:41 +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:
Florian Schmaus 2014-11-25 13:11:24 +01:00
parent cc09192095
commit 9286a1decb
31 changed files with 582 additions and 548 deletions

View file

@ -19,6 +19,7 @@
package org.jivesoftware.smack.tcp.sm.provider;
import com.jamesmurty.utils.XMLBuilder;
import org.jivesoftware.smack.packet.XMPPError;
import org.jivesoftware.smack.tcp.sm.packet.StreamManagement;
import org.jivesoftware.smack.util.PacketParserUtils;
@ -34,6 +35,7 @@ import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.notNullValue;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
public class ParseStreamManagementTest {
private static final Properties outputProperties = initOutputProperties();
@ -83,19 +85,16 @@ public class ParseStreamManagementTest {
PacketParserUtils.getParserFor(failedStanza));
assertThat(failedPacket, is(notNullValue()));
XMPPError error = failedPacket.getXMPPError();
assertThat(error, is(notNullValue()));
assertThat(error.getCondition(), equalTo("unknown"));
assertTrue(failedPacket.getXMPPErrorCondition() == null);
}
@Test
public void testParseFailedError() throws Exception {
String errorCondition = "failure";
XMPPError.Condition errorCondition = XMPPError.Condition.unexpected_request;
String failedStanza = XMLBuilder.create("failed")
.a("xmlns", "urn:xmpp:sm:3")
.element(errorCondition, XMPPError.NAMESPACE)
.element(errorCondition.toString(), XMPPError.NAMESPACE)
.asString(outputProperties);
System.err.println(failedStanza);
@ -104,10 +103,7 @@ public class ParseStreamManagementTest {
PacketParserUtils.getParserFor(failedStanza));
assertThat(failedPacket, is(notNullValue()));
XMPPError error = failedPacket.getXMPPError();
assertThat(error, is(notNullValue()));
assertThat(error.getCondition(), equalTo(errorCondition));
assertTrue(failedPacket.getXMPPErrorCondition() == errorCondition);
}
@Test