mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2024-11-22 06:12:05 +01:00
Add XMPPErrorException.getStanzaError()
Also deprecate getXMPPError and let StanzaError implement ExtensionElement.
This commit is contained in:
parent
651ee7b85e
commit
23bb5c5625
31 changed files with 108 additions and 75 deletions
|
@ -120,7 +120,7 @@ public class LoginTest extends SmackTestCase {
|
||||||
conn.getAccountManager().createAccount("user_1", "user_1", getAccountCreationParameters());
|
conn.getAccountManager().createAccount("user_1", "user_1", getAccountCreationParameters());
|
||||||
} catch (XMPPException e) {
|
} catch (XMPPException e) {
|
||||||
// Do nothing if the account already exists
|
// Do nothing if the account already exists
|
||||||
if (e.getXMPPError().getCode() != 409) {
|
if (e.getStanzaError().getCode() != 409) {
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
// Else recreate the connection, ins case the server closed it as
|
// Else recreate the connection, ins case the server closed it as
|
||||||
|
@ -141,8 +141,8 @@ public class LoginTest extends SmackTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (XMPPException e) {
|
} catch (XMPPException e) {
|
||||||
if (e.getXMPPError() != null) {
|
if (e.getStanzaError() != null) {
|
||||||
assertEquals("Wrong error code returned", 406, e.getXMPPError().getCode());
|
assertEquals("Wrong error code returned", 406, e.getStanzaError().getCode());
|
||||||
} else {
|
} else {
|
||||||
fail(e.getMessage());
|
fail(e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
|
@ -228,7 +228,7 @@ public class PrivacyTest extends SmackTestCase {
|
||||||
// The list should not exist and an error will be raised
|
// The list should not exist and an error will be raised
|
||||||
privacyManager.getDefaultList();
|
privacyManager.getDefaultList();
|
||||||
} catch (XMPPException xmppException) {
|
} catch (XMPPException xmppException) {
|
||||||
assertEquals(404, xmppException.getXMPPError().getCode());
|
assertEquals(404, xmppException.getStanzaError().getCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
assertEquals(null, null);
|
assertEquals(null, null);
|
||||||
|
@ -255,7 +255,7 @@ public class PrivacyTest extends SmackTestCase {
|
||||||
// The list should not exist and an error will be raised
|
// The list should not exist and an error will be raised
|
||||||
privacyManager.getActiveList();
|
privacyManager.getActiveList();
|
||||||
} catch (XMPPException xmppException) {
|
} catch (XMPPException xmppException) {
|
||||||
assertEquals(404, xmppException.getXMPPError().getCode());
|
assertEquals(404, xmppException.getStanzaError().getCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
assertEquals(null, null);
|
assertEquals(null, null);
|
||||||
|
@ -341,7 +341,7 @@ public class PrivacyTest extends SmackTestCase {
|
||||||
// The list should not exist and an error will be raised
|
// The list should not exist and an error will be raised
|
||||||
privacyManager.getPrivacyList(listName);
|
privacyManager.getPrivacyList(listName);
|
||||||
} catch (XMPPException xmppException) {
|
} catch (XMPPException xmppException) {
|
||||||
assertEquals(404, xmppException.getXMPPError().getCode());
|
assertEquals(404, xmppException.getStanzaError().getCode());
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
|
@ -123,11 +123,23 @@ public abstract class XMPPException extends Exception {
|
||||||
* one.
|
* one.
|
||||||
*
|
*
|
||||||
* @return the XMPPError associated with this exception.
|
* @return the XMPPError associated with this exception.
|
||||||
|
* @deprecated use {@link #getStanzaError()} instead.
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
|
// TODO Remove in Smack 4.4.
|
||||||
public StanzaError getXMPPError() {
|
public StanzaError getXMPPError() {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the stanza error extension element associated with this exception.
|
||||||
|
*
|
||||||
|
* @return the stanza error extension element associated with this exception.
|
||||||
|
*/
|
||||||
|
public StanzaError getStanzaError() {
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the request which triggered the error response causing this exception.
|
* Get the request which triggered the error response causing this exception.
|
||||||
*
|
*
|
||||||
|
|
|
@ -62,9 +62,16 @@ import org.jivesoftware.smack.util.XmlStringBuilder;
|
||||||
* @see <a href="http://xmpp.org/rfcs/rfc6120.html#stanzas-error-syntax">RFC 6120 - 8.3.2 Syntax: The Syntax of XMPP error stanzas</a>
|
* @see <a href="http://xmpp.org/rfcs/rfc6120.html#stanzas-error-syntax">RFC 6120 - 8.3.2 Syntax: The Syntax of XMPP error stanzas</a>
|
||||||
*/
|
*/
|
||||||
// TODO Use StanzaErrorTextElement here.
|
// TODO Use StanzaErrorTextElement here.
|
||||||
public class StanzaError extends AbstractError {
|
public class StanzaError extends AbstractError implements ExtensionElement {
|
||||||
|
|
||||||
|
public static final String ERROR_CONDITION_AND_TEXT_NAMESPACE = "urn:ietf:params:xml:ns:xmpp-stanzas";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO describe me.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public static final String NAMESPACE = ERROR_CONDITION_AND_TEXT_NAMESPACE;
|
||||||
|
|
||||||
public static final String NAMESPACE = "urn:ietf:params:xml:ns:xmpp-stanzas";
|
|
||||||
public static final String ERROR = "error";
|
public static final String ERROR = "error";
|
||||||
|
|
||||||
private static final Logger LOGGER = Logger.getLogger(StanzaError.class.getName());
|
private static final Logger LOGGER = Logger.getLogger(StanzaError.class.getName());
|
||||||
|
@ -117,7 +124,7 @@ public class StanzaError extends AbstractError {
|
||||||
*/
|
*/
|
||||||
public StanzaError(Condition condition, String conditionText, String errorGenerator, Type type, Map<String, String> descriptiveTexts,
|
public StanzaError(Condition condition, String conditionText, String errorGenerator, Type type, Map<String, String> descriptiveTexts,
|
||||||
List<ExtensionElement> extensions, Stanza stanza) {
|
List<ExtensionElement> extensions, Stanza stanza) {
|
||||||
super(descriptiveTexts, NAMESPACE, extensions);
|
super(descriptiveTexts, ERROR_CONDITION_AND_TEXT_NAMESPACE, extensions);
|
||||||
this.condition = Objects.requireNonNull(condition, "condition must not be null");
|
this.condition = Objects.requireNonNull(condition, "condition must not be null");
|
||||||
this.stanza = stanza;
|
this.stanza = stanza;
|
||||||
// Some implementations may send the condition as non-empty element containing the empty string, that is
|
// Some implementations may send the condition as non-empty element containing the empty string, that is
|
||||||
|
@ -197,20 +204,34 @@ public class StanzaError extends AbstractError {
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getElementName() {
|
||||||
|
return ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getNamespace() {
|
||||||
|
return StreamOpen.CLIENT_NAMESPACE;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the error as XML.
|
* Returns the error as XML.
|
||||||
*
|
*
|
||||||
* @return the error as XML.
|
* @return the error as XML.
|
||||||
*/
|
*/
|
||||||
public XmlStringBuilder toXML() {
|
public XmlStringBuilder toXML() {
|
||||||
XmlStringBuilder xml = new XmlStringBuilder();
|
return toXML(null);
|
||||||
xml.halfOpenElement(ERROR);
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public XmlStringBuilder toXML(String enclosingNamespace) {
|
||||||
|
XmlStringBuilder xml = new XmlStringBuilder(this, enclosingNamespace);
|
||||||
xml.attribute("type", type.toString());
|
xml.attribute("type", type.toString());
|
||||||
xml.optAttribute("by", errorGenerator);
|
xml.optAttribute("by", errorGenerator);
|
||||||
xml.rightAngleBracket();
|
xml.rightAngleBracket();
|
||||||
|
|
||||||
xml.halfOpenElement(condition.toString());
|
xml.halfOpenElement(condition.toString());
|
||||||
xml.xmlnsAttribute(NAMESPACE);
|
xml.xmlnsAttribute(ERROR_CONDITION_AND_TEXT_NAMESPACE);
|
||||||
if (conditionText != null) {
|
if (conditionText != null) {
|
||||||
xml.rightAngleBracket();
|
xml.rightAngleBracket();
|
||||||
xml.escape(conditionText);
|
xml.escape(conditionText);
|
||||||
|
@ -222,7 +243,7 @@ public class StanzaError extends AbstractError {
|
||||||
|
|
||||||
addDescriptiveTextsAndExtensions(xml);
|
addDescriptiveTextsAndExtensions(xml);
|
||||||
|
|
||||||
xml.closeElement(ERROR);
|
xml.closeElement(this);
|
||||||
return xml;
|
return xml;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ package org.jivesoftware.smack.packet;
|
||||||
|
|
||||||
public class StanzaErrorTextElement extends AbstractTextElement {
|
public class StanzaErrorTextElement extends AbstractTextElement {
|
||||||
|
|
||||||
public static final String NAMESPACE = StanzaError.NAMESPACE;
|
public static final String NAMESPACE = StanzaError.ERROR_CONDITION_AND_TEXT_NAMESPACE;
|
||||||
|
|
||||||
public StanzaErrorTextElement(String text, String lang) {
|
public StanzaErrorTextElement(String text, String lang) {
|
||||||
super(text, lang);
|
super(text, lang);
|
||||||
|
|
|
@ -855,7 +855,7 @@ public class PacketParserUtils {
|
||||||
String name = parser.getName();
|
String name = parser.getName();
|
||||||
String namespace = parser.getNamespace();
|
String namespace = parser.getNamespace();
|
||||||
switch (namespace) {
|
switch (namespace) {
|
||||||
case StanzaError.NAMESPACE:
|
case StanzaError.ERROR_CONDITION_AND_TEXT_NAMESPACE:
|
||||||
switch (name) {
|
switch (name) {
|
||||||
case Stanza.TEXT:
|
case Stanza.TEXT:
|
||||||
descriptiveTexts = parseDescriptiveTexts(parser, descriptiveTexts);
|
descriptiveTexts = parseDescriptiveTexts(parser, descriptiveTexts);
|
||||||
|
|
|
@ -906,10 +906,10 @@ public class PacketParserUtilsTest {
|
||||||
.build();
|
.build();
|
||||||
final String errorXml = XMLBuilder
|
final String errorXml = XMLBuilder
|
||||||
.create(StanzaError.ERROR).a("type", "cancel").up()
|
.create(StanzaError.ERROR).a("type", "cancel").up()
|
||||||
.element("internal-server-error", StanzaError.NAMESPACE).up()
|
.element("internal-server-error", StanzaError.ERROR_CONDITION_AND_TEXT_NAMESPACE).up()
|
||||||
.element("text", StanzaError.NAMESPACE).t(text).up()
|
.element("text", StanzaError.ERROR_CONDITION_AND_TEXT_NAMESPACE).t(text).up()
|
||||||
.asString();
|
.asString();
|
||||||
XmlUnitUtils.assertSimilar(errorXml, error.toXML());
|
XmlUnitUtils.assertSimilar(errorXml, error.toXML(StreamOpen.CLIENT_NAMESPACE));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -917,8 +917,8 @@ public class PacketParserUtilsTest {
|
||||||
final String text = "Dummy descriptive text";
|
final String text = "Dummy descriptive text";
|
||||||
final String errorXml = XMLBuilder
|
final String errorXml = XMLBuilder
|
||||||
.create(StanzaError.ERROR).a("type", "cancel").up()
|
.create(StanzaError.ERROR).a("type", "cancel").up()
|
||||||
.element("internal-server-error", StanzaError.NAMESPACE).up()
|
.element("internal-server-error", StanzaError.ERROR_CONDITION_AND_TEXT_NAMESPACE).up()
|
||||||
.element("text", StanzaError.NAMESPACE).t(text).up()
|
.element("text", StanzaError.ERROR_CONDITION_AND_TEXT_NAMESPACE).t(text).up()
|
||||||
.asString();
|
.asString();
|
||||||
XmlPullParser parser = TestUtils.getParser(errorXml);
|
XmlPullParser parser = TestUtils.getParser(errorXml);
|
||||||
StanzaError error = PacketParserUtils.parseError(parser).build();
|
StanzaError error = PacketParserUtils.parseError(parser).build();
|
||||||
|
|
|
@ -90,7 +90,7 @@ public final class IoTControlManager extends IoTManager {
|
||||||
try {
|
try {
|
||||||
controlRequest.processRequest(iotSetRequest.getFrom(), iotSetRequest.getSetData());
|
controlRequest.processRequest(iotSetRequest.getFrom(), iotSetRequest.getSetData());
|
||||||
} catch (XMPPErrorException e) {
|
} catch (XMPPErrorException e) {
|
||||||
return IQ.createErrorResponse(iotSetRequest, e.getXMPPError());
|
return IQ.createErrorResponse(iotSetRequest, e.getStanzaError());
|
||||||
}
|
}
|
||||||
|
|
||||||
return new IoTSetResponse(iotSetRequest);
|
return new IoTSetResponse(iotSetRequest);
|
||||||
|
|
|
@ -94,7 +94,7 @@ public class CompressionTest extends SmackTestCase {
|
||||||
setupConnection.getAccountManager().createAccount("user0", "user0");
|
setupConnection.getAccountManager().createAccount("user0", "user0");
|
||||||
} catch (XMPPException e) {
|
} catch (XMPPException e) {
|
||||||
// Do nothing if the accout already exists
|
// Do nothing if the accout already exists
|
||||||
if (e.getXMPPError().getCode() != 409) {
|
if (e.getStanzaError().getCode() != 409) {
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -84,9 +84,9 @@ public class LastActivityManagerTest extends SmackTestCase {
|
||||||
LastActivityManager.getLastActivity(conn0, getFullJID(2));
|
LastActivityManager.getLastActivity(conn0, getFullJID(2));
|
||||||
fail("No error was received from the server. User was able to get info of other user not in his roster.");
|
fail("No error was received from the server. User was able to get info of other user not in his roster.");
|
||||||
} catch (XMPPException e) {
|
} catch (XMPPException e) {
|
||||||
assertNotNull("No error was returned from the server", e.getXMPPError());
|
assertNotNull("No error was returned from the server", e.getStanzaError());
|
||||||
assertEquals("Forbidden error was not returned from the server", 403,
|
assertEquals("Forbidden error was not returned from the server", 403,
|
||||||
e.getXMPPError().getCode());
|
e.getStanzaError().getCode());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,7 +121,7 @@ public class LastActivityManagerTest extends SmackTestCase {
|
||||||
try {
|
try {
|
||||||
lastActivity = LastActivityManager.getLastActivity(conn0, getHost());
|
lastActivity = LastActivityManager.getLastActivity(conn0, getHost());
|
||||||
} catch (XMPPException e) {
|
} catch (XMPPException e) {
|
||||||
if (e.getXMPPError().getCode() == 403) {
|
if (e.getStanzaError().getCode() == 403) {
|
||||||
//The test can not be done since the host do not allow this kind of request
|
//The test can not be done since the host do not allow this kind of request
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,7 +77,7 @@ public class ServiceDiscoveryManagerTest extends SmackTestCase {
|
||||||
fail("Unexpected identities were returned instead of a 404 error");
|
fail("Unexpected identities were returned instead of a 404 error");
|
||||||
}
|
}
|
||||||
catch (XMPPException e) {
|
catch (XMPPException e) {
|
||||||
assertEquals("Incorrect error", 404, e.getXMPPError().getCode());
|
assertEquals("Incorrect error", 404, e.getStanzaError().getCode());
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
|
@ -527,7 +527,7 @@ public class MultiUserChatTest extends SmackTestCase {
|
||||||
fail("Other user was able to join with other user's reserved nickname");
|
fail("Other user was able to join with other user's reserved nickname");
|
||||||
}
|
}
|
||||||
catch (XMPPException e) {
|
catch (XMPPException e) {
|
||||||
XMPPError xmppError = e.getXMPPError();
|
XMPPError xmppError = e.getStanzaError();
|
||||||
assertNotNull(
|
assertNotNull(
|
||||||
"No XMPPError was received when joining with other user's reserved nickname",
|
"No XMPPError was received when joining with other user's reserved nickname",
|
||||||
xmppError);
|
xmppError);
|
||||||
|
@ -551,7 +551,7 @@ public class MultiUserChatTest extends SmackTestCase {
|
||||||
muc3.sendRegistrationForm(answerForm);
|
muc3.sendRegistrationForm(answerForm);
|
||||||
}
|
}
|
||||||
catch (XMPPException e) {
|
catch (XMPPException e) {
|
||||||
XMPPError xmppError = e.getXMPPError();
|
XMPPError xmppError = e.getStanzaError();
|
||||||
assertNotNull(
|
assertNotNull(
|
||||||
"No XMPPError was received when reserving an already reserved nickname",
|
"No XMPPError was received when reserving an already reserved nickname",
|
||||||
xmppError);
|
xmppError);
|
||||||
|
@ -605,7 +605,7 @@ public class MultiUserChatTest extends SmackTestCase {
|
||||||
fail("User2 was allowed to change the room's subject");
|
fail("User2 was allowed to change the room's subject");
|
||||||
}
|
}
|
||||||
catch (XMPPException e) {
|
catch (XMPPException e) {
|
||||||
XMPPError xmppError = e.getXMPPError();
|
XMPPError xmppError = e.getStanzaError();
|
||||||
assertNotNull(
|
assertNotNull(
|
||||||
"No XMPPError was received when changing the room's subject",
|
"No XMPPError was received when changing the room's subject",
|
||||||
xmppError);
|
xmppError);
|
||||||
|
@ -677,7 +677,7 @@ public class MultiUserChatTest extends SmackTestCase {
|
||||||
fail("User2 was able to kick a room owner");
|
fail("User2 was able to kick a room owner");
|
||||||
}
|
}
|
||||||
catch (XMPPException e) {
|
catch (XMPPException e) {
|
||||||
XMPPError xmppError = e.getXMPPError();
|
XMPPError xmppError = e.getStanzaError();
|
||||||
assertNotNull("No XMPPError was received when kicking a room owner", xmppError);
|
assertNotNull("No XMPPError was received when kicking a room owner", xmppError);
|
||||||
assertEquals(
|
assertEquals(
|
||||||
"A simple participant was able to kick another participant from the room",
|
"A simple participant was able to kick another participant from the room",
|
||||||
|
@ -754,7 +754,7 @@ public class MultiUserChatTest extends SmackTestCase {
|
||||||
fail("User2 was able to ban a room owner");
|
fail("User2 was able to ban a room owner");
|
||||||
}
|
}
|
||||||
catch (XMPPException e) {
|
catch (XMPPException e) {
|
||||||
XMPPError xmppError = e.getXMPPError();
|
XMPPError xmppError = e.getStanzaError();
|
||||||
assertNotNull("No XMPPError was received when banning a room owner", xmppError);
|
assertNotNull("No XMPPError was received when banning a room owner", xmppError);
|
||||||
assertEquals(
|
assertEquals(
|
||||||
"A simple participant was able to ban another participant from the room",
|
"A simple participant was able to ban another participant from the room",
|
||||||
|
@ -842,7 +842,7 @@ public class MultiUserChatTest extends SmackTestCase {
|
||||||
fail("User2 was able to grant voice");
|
fail("User2 was able to grant voice");
|
||||||
}
|
}
|
||||||
catch (XMPPException e) {
|
catch (XMPPException e) {
|
||||||
XMPPError xmppError = e.getXMPPError();
|
XMPPError xmppError = e.getStanzaError();
|
||||||
assertNotNull("No XMPPError was received granting voice", xmppError);
|
assertNotNull("No XMPPError was received granting voice", xmppError);
|
||||||
assertEquals(
|
assertEquals(
|
||||||
"A visitor was able to grant voice to another visitor",
|
"A visitor was able to grant voice to another visitor",
|
||||||
|
@ -947,7 +947,7 @@ public class MultiUserChatTest extends SmackTestCase {
|
||||||
fail("User2 was able to grant moderator privileges");
|
fail("User2 was able to grant moderator privileges");
|
||||||
}
|
}
|
||||||
catch (XMPPException e) {
|
catch (XMPPException e) {
|
||||||
XMPPError xmppError = e.getXMPPError();
|
XMPPError xmppError = e.getStanzaError();
|
||||||
assertNotNull("No XMPPError was received granting moderator privileges", xmppError);
|
assertNotNull("No XMPPError was received granting moderator privileges", xmppError);
|
||||||
assertEquals(
|
assertEquals(
|
||||||
"A visitor was able to grant moderator privileges to another visitor",
|
"A visitor was able to grant moderator privileges to another visitor",
|
||||||
|
@ -1078,7 +1078,7 @@ public class MultiUserChatTest extends SmackTestCase {
|
||||||
fail("User2 was able to grant membership privileges");
|
fail("User2 was able to grant membership privileges");
|
||||||
}
|
}
|
||||||
catch (XMPPException e) {
|
catch (XMPPException e) {
|
||||||
XMPPError xmppError = e.getXMPPError();
|
XMPPError xmppError = e.getStanzaError();
|
||||||
assertNotNull(
|
assertNotNull(
|
||||||
"No XMPPError was received granting membership privileges",
|
"No XMPPError was received granting membership privileges",
|
||||||
xmppError);
|
xmppError);
|
||||||
|
@ -1188,7 +1188,7 @@ public class MultiUserChatTest extends SmackTestCase {
|
||||||
fail("User2 was able to grant admin privileges");
|
fail("User2 was able to grant admin privileges");
|
||||||
}
|
}
|
||||||
catch (XMPPException e) {
|
catch (XMPPException e) {
|
||||||
XMPPError xmppError = e.getXMPPError();
|
XMPPError xmppError = e.getStanzaError();
|
||||||
assertNotNull("No XMPPError was received granting admin privileges", xmppError);
|
assertNotNull("No XMPPError was received granting admin privileges", xmppError);
|
||||||
assertEquals(
|
assertEquals(
|
||||||
"A visitor was able to grant admin privileges to another visitor",
|
"A visitor was able to grant admin privileges to another visitor",
|
||||||
|
@ -1363,7 +1363,7 @@ public class MultiUserChatTest extends SmackTestCase {
|
||||||
fail("User2 was able to grant ownership privileges");
|
fail("User2 was able to grant ownership privileges");
|
||||||
}
|
}
|
||||||
catch (XMPPException e) {
|
catch (XMPPException e) {
|
||||||
XMPPError xmppError = e.getXMPPError();
|
XMPPError xmppError = e.getStanzaError();
|
||||||
assertNotNull("No XMPPError was received granting ownership privileges", xmppError);
|
assertNotNull("No XMPPError was received granting ownership privileges", xmppError);
|
||||||
assertEquals(
|
assertEquals(
|
||||||
"A visitor was able to grant ownership privileges to another visitor",
|
"A visitor was able to grant ownership privileges to another visitor",
|
||||||
|
@ -1609,7 +1609,7 @@ public class MultiUserChatTest extends SmackTestCase {
|
||||||
fail("User2 was able to get the list of owners");
|
fail("User2 was able to get the list of owners");
|
||||||
}
|
}
|
||||||
catch (XMPPException e) {
|
catch (XMPPException e) {
|
||||||
XMPPError xmppError = e.getXMPPError();
|
XMPPError xmppError = e.getStanzaError();
|
||||||
assertNotNull("No XMPPError was received getting the list of owners", xmppError);
|
assertNotNull("No XMPPError was received getting the list of owners", xmppError);
|
||||||
assertEquals(
|
assertEquals(
|
||||||
"A member was able to get the list of owners",
|
"A member was able to get the list of owners",
|
||||||
|
|
|
@ -73,8 +73,8 @@ public class MultiUserSubscriptionUseCases extends PubSubTestCase
|
||||||
}
|
}
|
||||||
catch (XMPPException exc)
|
catch (XMPPException exc)
|
||||||
{
|
{
|
||||||
assertEquals("bad-request", exc.getXMPPError().getCondition());
|
assertEquals("bad-request", exc.getStanzaError().getCondition());
|
||||||
assertEquals(XMPPError.Type.MODIFY, exc.getXMPPError().getType());
|
assertEquals(XMPPError.Type.MODIFY, exc.getStanzaError().getType());
|
||||||
}
|
}
|
||||||
List<Item> items = user2Node.getItems(sub1.getId());
|
List<Item> items = user2Node.getItems(sub1.getId());
|
||||||
assertTrue(items.size() == 5);
|
assertTrue(items.size() == 5);
|
||||||
|
|
|
@ -47,7 +47,7 @@ public class PublisherUseCases extends SingleUserTestCase
|
||||||
fail("Exception should be thrown when there is no payload");
|
fail("Exception should be thrown when there is no payload");
|
||||||
}
|
}
|
||||||
catch (XMPPException e) {
|
catch (XMPPException e) {
|
||||||
XMPPError err = e.getXMPPError();
|
XMPPError err = e.getStanzaError();
|
||||||
assertTrue(err.getType().equals(XMPPError.Type.MODIFY));
|
assertTrue(err.getType().equals(XMPPError.Type.MODIFY));
|
||||||
assertTrue(err.getCondition().equals(Condition.bad_request.toString()));
|
assertTrue(err.getCondition().equals(Condition.bad_request.toString()));
|
||||||
assertNotNull(err.getExtension("payload-required", PubSubNamespace.ERROR.getXmlns()));
|
assertNotNull(err.getExtension("payload-required", PubSubNamespace.ERROR.getXmlns()));
|
||||||
|
@ -59,7 +59,7 @@ public class PublisherUseCases extends SingleUserTestCase
|
||||||
fail("Exception should be thrown when there is no payload");
|
fail("Exception should be thrown when there is no payload");
|
||||||
}
|
}
|
||||||
catch (XMPPException e) {
|
catch (XMPPException e) {
|
||||||
XMPPError err = e.getXMPPError();
|
XMPPError err = e.getStanzaError();
|
||||||
assertTrue(err.getType().equals(XMPPError.Type.MODIFY));
|
assertTrue(err.getType().equals(XMPPError.Type.MODIFY));
|
||||||
assertTrue(err.getCondition().equals(Condition.bad_request.toString()));
|
assertTrue(err.getCondition().equals(Condition.bad_request.toString()));
|
||||||
assertNotNull(err.getExtension("payload-required", PubSubNamespace.ERROR.getXmlns()));
|
assertNotNull(err.getExtension("payload-required", PubSubNamespace.ERROR.getXmlns()));
|
||||||
|
@ -104,7 +104,7 @@ public class PublisherUseCases extends SingleUserTestCase
|
||||||
fail("Exception should be thrown when there is no payload");
|
fail("Exception should be thrown when there is no payload");
|
||||||
}
|
}
|
||||||
catch (XMPPException e) {
|
catch (XMPPException e) {
|
||||||
XMPPError err = e.getXMPPError();
|
XMPPError err = e.getStanzaError();
|
||||||
assertTrue(err.getType().equals(XMPPError.Type.MODIFY));
|
assertTrue(err.getType().equals(XMPPError.Type.MODIFY));
|
||||||
assertTrue(err.getCondition().equals(Condition.bad_request.toString()));
|
assertTrue(err.getCondition().equals(Condition.bad_request.toString()));
|
||||||
assertNotNull(err.getExtension("payload-required", PubSubNamespace.ERROR.getXmlns()));
|
assertNotNull(err.getExtension("payload-required", PubSubNamespace.ERROR.getXmlns()));
|
||||||
|
@ -116,7 +116,7 @@ public class PublisherUseCases extends SingleUserTestCase
|
||||||
fail("Exception should be thrown when there is no payload");
|
fail("Exception should be thrown when there is no payload");
|
||||||
}
|
}
|
||||||
catch (XMPPException e) {
|
catch (XMPPException e) {
|
||||||
XMPPError err = e.getXMPPError();
|
XMPPError err = e.getStanzaError();
|
||||||
assertTrue(err.getType().equals(XMPPError.Type.MODIFY));
|
assertTrue(err.getType().equals(XMPPError.Type.MODIFY));
|
||||||
assertTrue(err.getCondition().equals(Condition.bad_request.toString()));
|
assertTrue(err.getCondition().equals(Condition.bad_request.toString()));
|
||||||
assertNotNull(err.getExtension("payload-required", PubSubNamespace.ERROR.getXmlns()));
|
assertNotNull(err.getExtension("payload-required", PubSubNamespace.ERROR.getXmlns()));
|
||||||
|
|
|
@ -67,7 +67,7 @@ public class TestEvents extends SmackTestCase
|
||||||
}
|
}
|
||||||
catch (XMPPException e)
|
catch (XMPPException e)
|
||||||
{
|
{
|
||||||
if (e.getXMPPError().getType() == Type.CANCEL && e.getXMPPError().getCondition().equals("item-not-found"))
|
if (e.getStanzaError().getType() == Type.CANCEL && e.getXMPPError().getCondition().equals("item-not-found"))
|
||||||
creatorNode = creatorMgr.createNode(nodeId);
|
creatorNode = creatorMgr.createNode(nodeId);
|
||||||
else
|
else
|
||||||
throw e;
|
throw e;
|
||||||
|
|
|
@ -460,7 +460,7 @@ public final class AdHocCommandManager extends Manager {
|
||||||
// If there is an exception caused by the next, complete,
|
// If there is an exception caused by the next, complete,
|
||||||
// prev or cancel method, then that error is returned to the
|
// prev or cancel method, then that error is returned to the
|
||||||
// requester.
|
// requester.
|
||||||
StanzaError error = e.getXMPPError();
|
StanzaError error = e.getStanzaError();
|
||||||
|
|
||||||
// If the error type is cancel, then the execution is
|
// If the error type is cancel, then the execution is
|
||||||
// canceled therefore the status must show that, and the
|
// canceled therefore the status must show that, and the
|
||||||
|
@ -570,7 +570,7 @@ public final class AdHocCommandManager extends Manager {
|
||||||
// If there is an exception caused by the next, complete,
|
// If there is an exception caused by the next, complete,
|
||||||
// prev or cancel method, then that error is returned to the
|
// prev or cancel method, then that error is returned to the
|
||||||
// requester.
|
// requester.
|
||||||
StanzaError error = e.getXMPPError();
|
StanzaError error = e.getStanzaError();
|
||||||
|
|
||||||
// If the error type is cancel, then the execution is
|
// If the error type is cancel, then the execution is
|
||||||
// canceled therefore the status must show that, and the
|
// canceled therefore the status must show that, and the
|
||||||
|
|
|
@ -344,7 +344,7 @@ public class OutgoingFileTransfer extends FileTransfer {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleXMPPException(XMPPErrorException e) {
|
private void handleXMPPException(XMPPErrorException e) {
|
||||||
StanzaError error = e.getXMPPError();
|
StanzaError error = e.getStanzaError();
|
||||||
if (error != null) {
|
if (error != null) {
|
||||||
switch (error.getCondition()) {
|
switch (error.getCondition()) {
|
||||||
case forbidden:
|
case forbidden:
|
||||||
|
|
|
@ -221,7 +221,7 @@ public final class PrivateDataManager extends Manager {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
catch (XMPPErrorException e) {
|
catch (XMPPErrorException e) {
|
||||||
if (e.getXMPPError().getCondition() == Condition.service_unavailable) {
|
if (e.getStanzaError().getCondition() == Condition.service_unavailable) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -149,7 +149,7 @@ public final class PingManager extends Manager {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
final StanzaError xmppError = xmppErrorException.getXMPPError();
|
final StanzaError xmppError = xmppErrorException.getStanzaError();
|
||||||
|
|
||||||
// We may received an error response from an intermediate service returning an error like
|
// We may received an error response from an intermediate service returning an error like
|
||||||
// 'remote-server-not-found' or 'remote-server-timeout' to us (which would fake the 'from' address,
|
// 'remote-server-not-found' or 'remote-server-timeout' to us (which would fake the 'from' address,
|
||||||
|
|
|
@ -276,12 +276,12 @@ public final class PubSubManager extends Manager {
|
||||||
return createNode(id);
|
return createNode(id);
|
||||||
}
|
}
|
||||||
catch (XMPPErrorException e1) {
|
catch (XMPPErrorException e1) {
|
||||||
if (e1.getXMPPError().getCondition() == Condition.item_not_found) {
|
if (e1.getStanzaError().getCondition() == Condition.item_not_found) {
|
||||||
try {
|
try {
|
||||||
return createNode(id);
|
return createNode(id);
|
||||||
}
|
}
|
||||||
catch (XMPPErrorException e2) {
|
catch (XMPPErrorException e2) {
|
||||||
if (e2.getXMPPError().getCondition() == Condition.conflict) {
|
if (e2.getStanzaError().getCondition() == Condition.conflict) {
|
||||||
// The node was created in the meantime, re-try getNode(). Note that this case should be rare.
|
// The node was created in the meantime, re-try getNode(). Note that this case should be rare.
|
||||||
try {
|
try {
|
||||||
return getNode(id);
|
return getNode(id);
|
||||||
|
@ -294,7 +294,7 @@ public final class PubSubManager extends Manager {
|
||||||
throw e2;
|
throw e2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (e1.getXMPPError().getCondition() == Condition.service_unavailable) {
|
if (e1.getStanzaError().getCondition() == Condition.service_unavailable) {
|
||||||
// This could be caused by Prosody bug #805 (see https://prosody.im/issues/issue/805). Prosody does not
|
// This could be caused by Prosody bug #805 (see https://prosody.im/issues/issue/805). Prosody does not
|
||||||
// answer to disco#info requests on the node ID, which makes it undecidable if a node is a leaf or
|
// answer to disco#info requests on the node ID, which makes it undecidable if a node is a leaf or
|
||||||
// collection node.
|
// collection node.
|
||||||
|
@ -326,7 +326,7 @@ public final class PubSubManager extends Manager {
|
||||||
node = getNode(id);
|
node = getNode(id);
|
||||||
}
|
}
|
||||||
catch (XMPPErrorException e) {
|
catch (XMPPErrorException e) {
|
||||||
if (e.getXMPPError().getCondition() == Condition.service_unavailable) {
|
if (e.getStanzaError().getCondition() == Condition.service_unavailable) {
|
||||||
// This could be caused by Prosody bug #805 (see https://prosody.im/issues/issue/805). Prosody does not
|
// This could be caused by Prosody bug #805 (see https://prosody.im/issues/issue/805). Prosody does not
|
||||||
// answer to disco#info requests on the node ID, which makes it undecidable if a node is a leaf or
|
// answer to disco#info requests on the node ID, which makes it undecidable if a node is a leaf or
|
||||||
// collection node.
|
// collection node.
|
||||||
|
@ -349,7 +349,7 @@ public final class PubSubManager extends Manager {
|
||||||
// Try to ensure that this is not a collection node by asking for one item form the node.
|
// Try to ensure that this is not a collection node by asking for one item form the node.
|
||||||
leafNode.getItems(1);
|
leafNode.getItems(1);
|
||||||
} catch (XMPPErrorException e) {
|
} catch (XMPPErrorException e) {
|
||||||
Condition condition = e.getXMPPError().getCondition();
|
Condition condition = e.getStanzaError().getCondition();
|
||||||
if (condition == Condition.feature_not_implemented) {
|
if (condition == Condition.feature_not_implemented) {
|
||||||
// XEP-0060 § 6.5.9.5: Item retrieval not supported, e.g. because node is a collection node
|
// XEP-0060 § 6.5.9.5: Item retrieval not supported, e.g. because node is a collection node
|
||||||
throw new PubSubException.NotALeafNodeException(id, pubSubService);
|
throw new PubSubException.NotALeafNodeException(id, pubSubService);
|
||||||
|
@ -369,7 +369,7 @@ public final class PubSubManager extends Manager {
|
||||||
return createNode(id);
|
return createNode(id);
|
||||||
}
|
}
|
||||||
catch (XMPPErrorException e1) {
|
catch (XMPPErrorException e1) {
|
||||||
if (e1.getXMPPError().getCondition() == Condition.conflict) {
|
if (e1.getStanzaError().getCondition() == Condition.conflict) {
|
||||||
return getLeafNodeProsodyWorkaround(id);
|
return getLeafNodeProsodyWorkaround(id);
|
||||||
}
|
}
|
||||||
throw e1;
|
throw e1;
|
||||||
|
@ -556,7 +556,7 @@ public final class PubSubManager extends Manager {
|
||||||
leafNode = createNode();
|
leafNode = createNode();
|
||||||
}
|
}
|
||||||
catch (XMPPErrorException e) {
|
catch (XMPPErrorException e) {
|
||||||
if (e.getXMPPError().getCondition() == StanzaError.Condition.forbidden) {
|
if (e.getStanzaError().getCondition() == StanzaError.Condition.forbidden) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
throw e;
|
throw e;
|
||||||
|
|
|
@ -125,7 +125,7 @@ public class InBandBytestreamManagerTest extends InitExtensions {
|
||||||
}
|
}
|
||||||
catch (XMPPErrorException e) {
|
catch (XMPPErrorException e) {
|
||||||
assertEquals(StanzaError.Condition.feature_not_implemented,
|
assertEquals(StanzaError.Condition.feature_not_implemented,
|
||||||
e.getXMPPError().getCondition());
|
e.getStanzaError().getCondition());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -451,7 +451,7 @@ public class Socks5ByteStreamManagerTest {
|
||||||
}
|
}
|
||||||
catch (XMPPErrorException e) {
|
catch (XMPPErrorException e) {
|
||||||
protocol.verifyAll();
|
protocol.verifyAll();
|
||||||
assertEquals(rejectPacket.getError(), e.getXMPPError());
|
assertEquals(rejectPacket.getError(), e.getStanzaError());
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
fail(e.getMessage());
|
fail(e.getMessage());
|
||||||
|
|
|
@ -110,7 +110,7 @@ public class Socks5ByteStreamRequestTest {
|
||||||
fail("exception should be thrown");
|
fail("exception should be thrown");
|
||||||
}
|
}
|
||||||
catch (XMPPErrorException e) {
|
catch (XMPPErrorException e) {
|
||||||
assertTrue(e.getXMPPError().getDescriptiveText("en").contains("Could not establish socket with any provided host"));
|
assertTrue(e.getStanzaError().getDescriptiveText("en").contains("Could not establish socket with any provided host"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// verify targets response
|
// verify targets response
|
||||||
|
@ -154,7 +154,7 @@ public class Socks5ByteStreamRequestTest {
|
||||||
fail("exception should be thrown");
|
fail("exception should be thrown");
|
||||||
}
|
}
|
||||||
catch (XMPPErrorException e) {
|
catch (XMPPErrorException e) {
|
||||||
assertTrue(e.getXMPPError().getDescriptiveText("en").contains("Could not establish socket with any provided host"));
|
assertTrue(e.getStanzaError().getDescriptiveText("en").contains("Could not establish socket with any provided host"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// verify targets response
|
// verify targets response
|
||||||
|
@ -201,7 +201,7 @@ public class Socks5ByteStreamRequestTest {
|
||||||
fail("exception should be thrown");
|
fail("exception should be thrown");
|
||||||
}
|
}
|
||||||
catch (XMPPErrorException e) {
|
catch (XMPPErrorException e) {
|
||||||
assertTrue(e.getXMPPError().getDescriptiveText("en").contains(
|
assertTrue(e.getStanzaError().getDescriptiveText("en").contains(
|
||||||
"Could not establish socket with any provided host"));
|
"Could not establish socket with any provided host"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -293,7 +293,7 @@ public class Socks5ByteStreamRequestTest {
|
||||||
fail("exception should be thrown");
|
fail("exception should be thrown");
|
||||||
}
|
}
|
||||||
catch (XMPPErrorException e) {
|
catch (XMPPErrorException e) {
|
||||||
assertTrue(e.getXMPPError().getDescriptiveText("en").contains(
|
assertTrue(e.getStanzaError().getDescriptiveText("en").contains(
|
||||||
"Could not establish socket with any provided host"));
|
"Could not establish socket with any provided host"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -231,7 +231,7 @@ public class Socks5ClientForInitiatorTest {
|
||||||
fail("exception should be thrown");
|
fail("exception should be thrown");
|
||||||
}
|
}
|
||||||
catch (XMPPErrorException e) {
|
catch (XMPPErrorException e) {
|
||||||
assertTrue(StanzaError.Condition.internal_server_error.equals(e.getXMPPError().getCondition()));
|
assertTrue(StanzaError.Condition.internal_server_error.equals(e.getStanzaError().getCondition()));
|
||||||
protocol.verifyAll();
|
protocol.verifyAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -77,7 +77,7 @@ public class ConfigureFormTest extends InitExtensions {
|
||||||
fail();
|
fail();
|
||||||
}
|
}
|
||||||
catch (XMPPErrorException e) {
|
catch (XMPPErrorException e) {
|
||||||
Assert.assertEquals(StanzaError.Type.AUTH, e.getXMPPError().getType());
|
Assert.assertEquals(StanzaError.Type.AUTH, e.getStanzaError().getType());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -85,8 +85,8 @@ public class SmackIntegrationTestFrameworkUnitTest {
|
||||||
FailedTest failedTest = failedTests.get(0);
|
FailedTest failedTest = failedTests.get(0);
|
||||||
assertTrue(failedTest.failureReason instanceof XMPPErrorException);
|
assertTrue(failedTest.failureReason instanceof XMPPErrorException);
|
||||||
XMPPErrorException ex = (XMPPErrorException) failedTest.failureReason;
|
XMPPErrorException ex = (XMPPErrorException) failedTest.failureReason;
|
||||||
assertEquals(StanzaError.Condition.bad_request, ex.getXMPPError().getCondition());
|
assertEquals(StanzaError.Condition.bad_request, ex.getStanzaError().getCondition());
|
||||||
assertEquals(ThrowsNonFatalExceptionDummyTest.DESCRIPTIVE_TEXT, ex.getXMPPError().getDescriptiveText());
|
assertEquals(ThrowsNonFatalExceptionDummyTest.DESCRIPTIVE_TEXT, ex.getStanzaError().getDescriptiveText());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class ThrowsNonFatalExceptionDummyTest extends AbstractSmackIntegrationTest {
|
public static class ThrowsNonFatalExceptionDummyTest extends AbstractSmackIntegrationTest {
|
||||||
|
|
|
@ -467,7 +467,7 @@ public abstract class OmemoService<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey,
|
||||||
|
|
||||||
} catch (XMPPException.XMPPErrorException e) {
|
} catch (XMPPException.XMPPErrorException e) {
|
||||||
|
|
||||||
if (e.getXMPPError().getCondition() == StanzaError.Condition.item_not_found) {
|
if (e.getStanzaError().getCondition() == StanzaError.Condition.item_not_found) {
|
||||||
LOGGER.log(Level.WARNING, "Could not refresh own deviceList, because the node did not exist: "
|
LOGGER.log(Level.WARNING, "Could not refresh own deviceList, because the node did not exist: "
|
||||||
+ e.getMessage());
|
+ e.getMessage());
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -211,7 +211,7 @@ public class StreamManagement {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public StanzaError.Condition getXMPPErrorCondition() {
|
public StanzaError.Condition getStanzaErrorCondition() {
|
||||||
return condition;
|
return condition;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -228,7 +228,7 @@ public class StreamManagement {
|
||||||
if (condition != null) {
|
if (condition != null) {
|
||||||
xml.rightAngleBracket();
|
xml.rightAngleBracket();
|
||||||
xml.append(condition.toString());
|
xml.append(condition.toString());
|
||||||
xml.xmlnsAttribute(StanzaError.NAMESPACE);
|
xml.xmlnsAttribute(StanzaError.ERROR_CONDITION_AND_TEXT_NAMESPACE);
|
||||||
xml.closeEmptyElement();
|
xml.closeEmptyElement();
|
||||||
}
|
}
|
||||||
xml.append(textElements);
|
xml.append(textElements);
|
||||||
|
|
|
@ -58,7 +58,7 @@ public class ParseStreamManagement {
|
||||||
case XmlPullParser.START_TAG:
|
case XmlPullParser.START_TAG:
|
||||||
name = parser.getName();
|
name = parser.getName();
|
||||||
String namespace = parser.getNamespace();
|
String namespace = parser.getNamespace();
|
||||||
if (StanzaError.NAMESPACE.equals(namespace)) {
|
if (StanzaError.ERROR_CONDITION_AND_TEXT_NAMESPACE.equals(namespace)) {
|
||||||
if (name.equals(AbstractTextElement.ELEMENT)) {
|
if (name.equals(AbstractTextElement.ELEMENT)) {
|
||||||
String lang = ParserUtils.getXmlLang(parser);
|
String lang = ParserUtils.getXmlLang(parser);
|
||||||
String text = parser.nextText();
|
String text = parser.nextText();
|
||||||
|
|
|
@ -1139,7 +1139,7 @@ public class XMPPTCPConnection extends AbstractXMPPConnection {
|
||||||
break;
|
break;
|
||||||
case Failed.ELEMENT:
|
case Failed.ELEMENT:
|
||||||
Failed failed = ParseStreamManagement.failed(parser);
|
Failed failed = ParseStreamManagement.failed(parser);
|
||||||
FailedNonzaException xmppException = new FailedNonzaException(failed, failed.getXMPPErrorCondition());
|
FailedNonzaException xmppException = new FailedNonzaException(failed, failed.getStanzaErrorCondition());
|
||||||
// If only XEP-198 would specify different failure elements for the SM
|
// If only XEP-198 would specify different failure elements for the SM
|
||||||
// enable and SM resume failure case. But this is not the case, so we
|
// enable and SM resume failure case. But this is not the case, so we
|
||||||
// need to determine if this is a 'Failed' response for either 'Enable'
|
// need to determine if this is a 'Failed' response for either 'Enable'
|
||||||
|
|
|
@ -85,7 +85,7 @@ public class ParseStreamManagementTest {
|
||||||
PacketParserUtils.getParserFor(failedStanza));
|
PacketParserUtils.getParserFor(failedStanza));
|
||||||
|
|
||||||
assertThat(failedPacket, is(notNullValue()));
|
assertThat(failedPacket, is(notNullValue()));
|
||||||
assertTrue(failedPacket.getXMPPErrorCondition() == null);
|
assertTrue(failedPacket.getStanzaErrorCondition() == null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -94,14 +94,14 @@ public class ParseStreamManagementTest {
|
||||||
|
|
||||||
String failedStanza = XMLBuilder.create("failed")
|
String failedStanza = XMLBuilder.create("failed")
|
||||||
.a("xmlns", "urn:xmpp:sm:3")
|
.a("xmlns", "urn:xmpp:sm:3")
|
||||||
.element(errorCondition.toString(), StanzaError.NAMESPACE)
|
.element(errorCondition.toString(), StanzaError.ERROR_CONDITION_AND_TEXT_NAMESPACE)
|
||||||
.asString(outputProperties);
|
.asString(outputProperties);
|
||||||
|
|
||||||
StreamManagement.Failed failedPacket = ParseStreamManagement.failed(
|
StreamManagement.Failed failedPacket = ParseStreamManagement.failed(
|
||||||
PacketParserUtils.getParserFor(failedStanza));
|
PacketParserUtils.getParserFor(failedStanza));
|
||||||
|
|
||||||
assertThat(failedPacket, is(notNullValue()));
|
assertThat(failedPacket, is(notNullValue()));
|
||||||
assertTrue(failedPacket.getXMPPErrorCondition() == errorCondition);
|
assertTrue(failedPacket.getStanzaErrorCondition() == errorCondition);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -118,7 +118,7 @@ public class ParseStreamManagementTest {
|
||||||
|
|
||||||
StreamManagement.Failed failed = ParseStreamManagement.failed(parser);
|
StreamManagement.Failed failed = ParseStreamManagement.failed(parser);
|
||||||
|
|
||||||
assertEquals(StanzaError.Condition.item_not_found, failed.getXMPPErrorCondition());
|
assertEquals(StanzaError.Condition.item_not_found, failed.getStanzaErrorCondition());
|
||||||
|
|
||||||
List<StanzaErrorTextElement> textElements = failed.getTextElements();
|
List<StanzaErrorTextElement> textElements = failed.getTextElements();
|
||||||
assertEquals(1, textElements.size());
|
assertEquals(1, textElements.size());
|
||||||
|
|
Loading…
Reference in a new issue