mirror of
https://github.com/vanitasvitae/Smack.git
synced 2025-09-09 17:19:39 +02:00
Rename XMPPError to StanzaError
Fixes SMACK-769.
This commit is contained in:
parent
609f4243d9
commit
2efec89050
53 changed files with 205 additions and 208 deletions
|
@ -74,9 +74,9 @@ import org.jivesoftware.smack.packet.Nonza;
|
|||
import org.jivesoftware.smack.packet.Presence;
|
||||
import org.jivesoftware.smack.packet.Session;
|
||||
import org.jivesoftware.smack.packet.Stanza;
|
||||
import org.jivesoftware.smack.packet.StanzaError;
|
||||
import org.jivesoftware.smack.packet.StartTls;
|
||||
import org.jivesoftware.smack.packet.StreamError;
|
||||
import org.jivesoftware.smack.packet.XMPPError;
|
||||
import org.jivesoftware.smack.parsing.ParsingExceptionCallback;
|
||||
import org.jivesoftware.smack.provider.ExtensionElementProvider;
|
||||
import org.jivesoftware.smack.provider.ProviderManager;
|
||||
|
@ -1087,15 +1087,15 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
|
|||
throw new IllegalStateException("Should only encounter IQ type 'get' or 'set'");
|
||||
}
|
||||
if (iqRequestHandler == null) {
|
||||
XMPPError.Condition replyCondition;
|
||||
StanzaError.Condition replyCondition;
|
||||
switch (unknownIqRequestReplyMode) {
|
||||
case doNotReply:
|
||||
return;
|
||||
case replyFeatureNotImplemented:
|
||||
replyCondition = XMPPError.Condition.feature_not_implemented;
|
||||
replyCondition = StanzaError.Condition.feature_not_implemented;
|
||||
break;
|
||||
case replyServiceUnavailable:
|
||||
replyCondition = XMPPError.Condition.service_unavailable;
|
||||
replyCondition = StanzaError.Condition.service_unavailable;
|
||||
break;
|
||||
default:
|
||||
throw new AssertionError();
|
||||
|
@ -1103,7 +1103,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
|
|||
|
||||
// If the IQ stanza is of type "get" or "set" with no registered IQ request handler, then answer an
|
||||
// IQ of type 'error' with condition 'service-unavailable'.
|
||||
ErrorIQ errorIQ = IQ.createErrorResponse(iq, XMPPError.getBuilder((
|
||||
ErrorIQ errorIQ = IQ.createErrorResponse(iq, StanzaError.getBuilder((
|
||||
replyCondition)));
|
||||
try {
|
||||
sendStanza(errorIQ);
|
||||
|
|
|
@ -19,8 +19,8 @@ package org.jivesoftware.smack;
|
|||
|
||||
import org.jivesoftware.smack.packet.Nonza;
|
||||
import org.jivesoftware.smack.packet.Stanza;
|
||||
import org.jivesoftware.smack.packet.StanzaError;
|
||||
import org.jivesoftware.smack.packet.StreamError;
|
||||
import org.jivesoftware.smack.packet.XMPPError;
|
||||
|
||||
import org.jxmpp.jid.Jid;
|
||||
|
||||
|
@ -35,7 +35,7 @@ import org.jxmpp.jid.Jid;
|
|||
* is sent to the client an XMPPException will be thrown containing the StreamError sent
|
||||
* by the server.
|
||||
*
|
||||
* @see XMPPError
|
||||
* @see StanzaError
|
||||
* @author Matt Tucker
|
||||
*/
|
||||
public abstract class XMPPException extends Exception {
|
||||
|
@ -74,17 +74,17 @@ public abstract class XMPPException extends Exception {
|
|||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 212790389529249604L;
|
||||
private final XMPPError error;
|
||||
private final StanzaError error;
|
||||
private final Stanza stanza;
|
||||
|
||||
/**
|
||||
* Creates a new XMPPErrorException with the given builder.
|
||||
*
|
||||
* @param xmppErrorBuilder
|
||||
* @deprecated Use {@link #XMPPErrorException(Stanza, XMPPError)} instead.
|
||||
* @deprecated Use {@link #XMPPErrorException(Stanza, StanzaError)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public XMPPErrorException(XMPPError.Builder xmppErrorBuilder) {
|
||||
public XMPPErrorException(StanzaError.Builder xmppErrorBuilder) {
|
||||
this(null, xmppErrorBuilder.build());
|
||||
}
|
||||
|
||||
|
@ -94,7 +94,7 @@ public abstract class XMPPException extends Exception {
|
|||
* @param stanza stanza that contained the exception.
|
||||
* @param error the root cause of the exception.
|
||||
*/
|
||||
public XMPPErrorException(Stanza stanza, XMPPError error) {
|
||||
public XMPPErrorException(Stanza stanza, StanzaError error) {
|
||||
super();
|
||||
this.error = error;
|
||||
this.stanza = stanza;
|
||||
|
@ -106,7 +106,7 @@ public abstract class XMPPException extends Exception {
|
|||
*
|
||||
* @return the XMPPError associated with this exception.
|
||||
*/
|
||||
public XMPPError getXMPPError() {
|
||||
public StanzaError getXMPPError() {
|
||||
return error;
|
||||
}
|
||||
|
||||
|
@ -127,7 +127,7 @@ public abstract class XMPPException extends Exception {
|
|||
}
|
||||
|
||||
public static void ifHasErrorThenThrow(Stanza packet) throws XMPPErrorException {
|
||||
XMPPError xmppError = packet.getError();
|
||||
StanzaError xmppError = packet.getError();
|
||||
if (xmppError != null) {
|
||||
throw new XMPPErrorException(packet, xmppError);
|
||||
}
|
||||
|
@ -141,16 +141,16 @@ public abstract class XMPPException extends Exception {
|
|||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private final XMPPError.Condition condition;
|
||||
private final StanzaError.Condition condition;
|
||||
|
||||
private final Nonza nonza;
|
||||
|
||||
public FailedNonzaException(Nonza nonza, XMPPError.Condition condition) {
|
||||
public FailedNonzaException(Nonza nonza, StanzaError.Condition condition) {
|
||||
this.condition = condition;
|
||||
this.nonza = nonza;
|
||||
}
|
||||
|
||||
public XMPPError.Condition getCondition() {
|
||||
public StanzaError.Condition getCondition() {
|
||||
return condition;
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ import org.jivesoftware.smack.util.Objects;
|
|||
|
||||
public class ErrorIQ extends SimpleIQ {
|
||||
|
||||
public static final String ELEMENT = XMPPError.ERROR;
|
||||
public static final String ELEMENT = StanzaError.ERROR;
|
||||
|
||||
/**
|
||||
* Constructs a new error IQ.
|
||||
|
@ -29,7 +29,7 @@ public class ErrorIQ extends SimpleIQ {
|
|||
* </p>
|
||||
* @param xmppErrorBuilder the XMPPError builder (required).
|
||||
*/
|
||||
public ErrorIQ(XMPPError.Builder xmppErrorBuilder) {
|
||||
public ErrorIQ(StanzaError.Builder xmppErrorBuilder) {
|
||||
super(ELEMENT, null);
|
||||
Objects.requireNonNull(xmppErrorBuilder, "xmppErrorBuilder must not be null");
|
||||
setType(IQ.Type.error);
|
||||
|
|
|
@ -263,7 +263,7 @@ public abstract class IQ extends Stanza {
|
|||
* <li>The type set to {@link Type#error IQ.Type.error}.
|
||||
* <li>The id set to the id of the originating IQ.
|
||||
* <li>The child element contained in the associated originating IQ.
|
||||
* <li>The provided {@link XMPPError XMPPError}.
|
||||
* <li>The provided {@link StanzaError XMPPError}.
|
||||
* </ul>
|
||||
*
|
||||
* @param request the {@link Type#get IQ.Type.get} or {@link Type#set IQ.Type.set} IQ packet.
|
||||
|
@ -272,7 +272,7 @@ public abstract class IQ extends Stanza {
|
|||
* {@link Type#get IQ.Type.get} or {@link Type#set IQ.Type.set}.
|
||||
* @return a new {@link Type#error IQ.Type.error} IQ based on the originating IQ.
|
||||
*/
|
||||
public static ErrorIQ createErrorResponse(final IQ request, final XMPPError.Builder error) {
|
||||
public static ErrorIQ createErrorResponse(final IQ request, final StanzaError.Builder error) {
|
||||
if (!(request.getType() == Type.get || request.getType() == Type.set)) {
|
||||
throw new IllegalArgumentException(
|
||||
"IQ must be of type 'set' or 'get'. Original IQ: " + request.toXML());
|
||||
|
@ -287,8 +287,8 @@ public abstract class IQ extends Stanza {
|
|||
return result;
|
||||
}
|
||||
|
||||
public static ErrorIQ createErrorResponse(final IQ request, final XMPPError.Condition condition) {
|
||||
return createErrorResponse(request, XMPPError.getBuilder(condition));
|
||||
public static ErrorIQ createErrorResponse(final IQ request, final StanzaError.Condition condition) {
|
||||
return createErrorResponse(request, StanzaError.getBuilder(condition));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -300,7 +300,7 @@ public abstract class IQ extends Stanza {
|
|||
* <li>The type set to {@link Type#error IQ.Type.error}.
|
||||
* <li>The id set to the id of the originating IQ.
|
||||
* <li>The child element contained in the associated originating IQ.
|
||||
* <li>The provided {@link XMPPError XMPPError}.
|
||||
* <li>The provided {@link StanzaError XMPPError}.
|
||||
* </ul>
|
||||
*
|
||||
* @param request the {@link Type#get IQ.Type.get} or {@link Type#set IQ.Type.set} IQ packet.
|
||||
|
@ -309,8 +309,8 @@ public abstract class IQ extends Stanza {
|
|||
* {@link Type#get IQ.Type.get} or {@link Type#set IQ.Type.set}.
|
||||
* @return a new {@link Type#error IQ.Type.error} IQ based on the originating IQ.
|
||||
*/
|
||||
public static ErrorIQ createErrorResponse(final IQ request, final XMPPError error) {
|
||||
return createErrorResponse(request, XMPPError.getBuilder(error));
|
||||
public static ErrorIQ createErrorResponse(final IQ request, final StanzaError error) {
|
||||
return createErrorResponse(request, StanzaError.getBuilder(error));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -105,13 +105,13 @@ public interface Packet extends TopLevelStreamElement {
|
|||
*
|
||||
* @return the error sub-packet or <tt>null</tt> if there isn't an error.
|
||||
*/
|
||||
XMPPError getError();
|
||||
StanzaError getError();
|
||||
/**
|
||||
* Sets the error for this packet.
|
||||
*
|
||||
* @param error the error to associate with this packet.
|
||||
*/
|
||||
void setError(XMPPError error);
|
||||
void setError(StanzaError error);
|
||||
|
||||
/**
|
||||
* Returns the xml:lang of this Stanza, or null if one has not been set.
|
||||
|
|
|
@ -61,7 +61,7 @@ public abstract class Stanza implements TopLevelStreamElement {
|
|||
private String id = null;
|
||||
private Jid to;
|
||||
private Jid from;
|
||||
private XMPPError error = null;
|
||||
private StanzaError error = null;
|
||||
|
||||
/**
|
||||
* Optional value of the 'xml:lang' attribute of the outermost element of
|
||||
|
@ -254,7 +254,7 @@ public abstract class Stanza implements TopLevelStreamElement {
|
|||
*
|
||||
* @return the error sub-packet or <tt>null</tt> if there isn't an error.
|
||||
*/
|
||||
public XMPPError getError() {
|
||||
public StanzaError getError() {
|
||||
return error;
|
||||
}
|
||||
|
||||
|
@ -262,10 +262,10 @@ public abstract class Stanza implements TopLevelStreamElement {
|
|||
* Sets the error for this packet.
|
||||
*
|
||||
* @param error the error to associate with this packet.
|
||||
* @deprecated use {@link #setError(org.jivesoftware.smack.packet.XMPPError.Builder)} instead.
|
||||
* @deprecated use {@link #setError(org.jivesoftware.smack.packet.StanzaError.Builder)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public void setError(XMPPError error) {
|
||||
public void setError(StanzaError error) {
|
||||
this.error = error;
|
||||
}
|
||||
|
||||
|
@ -274,7 +274,7 @@ public abstract class Stanza implements TopLevelStreamElement {
|
|||
*
|
||||
* @param xmppErrorBuilder the error to associate with this stanza.
|
||||
*/
|
||||
public void setError(XMPPError.Builder xmppErrorBuilder) {
|
||||
public void setError(StanzaError.Builder xmppErrorBuilder) {
|
||||
if (xmppErrorBuilder == null) {
|
||||
return;
|
||||
}
|
||||
|
@ -534,7 +534,7 @@ public abstract class Stanza implements TopLevelStreamElement {
|
|||
* @param xml the XmlStringBuilder to append the error to.
|
||||
*/
|
||||
protected void appendErrorIfExists(XmlStringBuilder xml) {
|
||||
XMPPError error = getError();
|
||||
StanzaError error = getError();
|
||||
if (error != null) {
|
||||
xml.append(error.toXML());
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2003-2007 Jive Software, 2015-2017 Florian Schmaus
|
||||
* Copyright 2003-2007 Jive Software, 2015-2018 Florian Schmaus
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -61,14 +61,13 @@ import org.jivesoftware.smack.util.XmlStringBuilder;
|
|||
* @author Matt Tucker
|
||||
* @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 Rename this class to StanzaError (RFC 6120 § 8.3) in Smack 4.3, as this is what this class actually is. SMACK-769
|
||||
// TODO Use StanzaErrorTextElement here.
|
||||
public class XMPPError extends AbstractError {
|
||||
public class StanzaError extends AbstractError {
|
||||
|
||||
public static final String NAMESPACE = "urn:ietf:params:xml:ns:xmpp-stanzas";
|
||||
public static final String ERROR = "error";
|
||||
|
||||
private static final Logger LOGGER = Logger.getLogger(XMPPError.class.getName());
|
||||
private static final Logger LOGGER = Logger.getLogger(StanzaError.class.getName());
|
||||
static final Map<Condition, Type> CONDITION_TO_TYPE = new HashMap<Condition, Type>();
|
||||
|
||||
static {
|
||||
|
@ -116,7 +115,7 @@ public class XMPPError extends AbstractError {
|
|||
* @param extensions list of stanza extensions
|
||||
* @param stanza the stanza carrying this XMPP error.
|
||||
*/
|
||||
public XMPPError(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) {
|
||||
super(descriptiveTexts, NAMESPACE, extensions);
|
||||
this.condition = Objects.requireNonNull(condition, "condition must not be null");
|
||||
|
@ -227,8 +226,8 @@ public class XMPPError extends AbstractError {
|
|||
return xml;
|
||||
}
|
||||
|
||||
public static XMPPError.Builder from(Condition condition, String descriptiveText) {
|
||||
XMPPError.Builder builder = getBuilder().setCondition(condition);
|
||||
public static StanzaError.Builder from(Condition condition, String descriptiveText) {
|
||||
StanzaError.Builder builder = getBuilder().setCondition(condition);
|
||||
if (descriptiveText != null) {
|
||||
Map<String, String> descriptiveTexts = new HashMap<>();
|
||||
descriptiveTexts.put("en", descriptiveText);
|
||||
|
@ -245,7 +244,7 @@ public class XMPPError extends AbstractError {
|
|||
return getBuilder().setCondition(condition);
|
||||
}
|
||||
|
||||
public static Builder getBuilder(XMPPError xmppError) {
|
||||
public static Builder getBuilder(StanzaError xmppError) {
|
||||
return getBuilder().copyFrom(xmppError);
|
||||
}
|
||||
|
||||
|
@ -284,7 +283,7 @@ public class XMPPError extends AbstractError {
|
|||
return this;
|
||||
}
|
||||
|
||||
public Builder copyFrom(XMPPError xmppError) {
|
||||
public Builder copyFrom(StanzaError xmppError) {
|
||||
setCondition(xmppError.getCondition());
|
||||
setType(xmppError.getType());
|
||||
setConditionText(xmppError.getConditionText());
|
||||
|
@ -296,8 +295,8 @@ public class XMPPError extends AbstractError {
|
|||
return this;
|
||||
}
|
||||
|
||||
public XMPPError build() {
|
||||
return new XMPPError(condition, conditionText, errorGenerator, type, descriptiveTexts,
|
||||
public StanzaError build() {
|
||||
return new StanzaError(condition, conditionText, errorGenerator, type, descriptiveTexts,
|
||||
extensions, stanza);
|
||||
}
|
||||
|
|
@ -18,7 +18,7 @@ package org.jivesoftware.smack.packet;
|
|||
|
||||
public class StanzaErrorTextElement extends AbstractTextElement {
|
||||
|
||||
public static final String NAMESPACE = XMPPError.NAMESPACE;
|
||||
public static final String NAMESPACE = StanzaError.NAMESPACE;
|
||||
|
||||
public StanzaErrorTextElement(String text, String lang) {
|
||||
super(text, lang);
|
||||
|
|
|
@ -37,10 +37,10 @@ import org.jivesoftware.smack.packet.Message;
|
|||
import org.jivesoftware.smack.packet.Presence;
|
||||
import org.jivesoftware.smack.packet.Session;
|
||||
import org.jivesoftware.smack.packet.Stanza;
|
||||
import org.jivesoftware.smack.packet.StanzaError;
|
||||
import org.jivesoftware.smack.packet.StartTls;
|
||||
import org.jivesoftware.smack.packet.StreamError;
|
||||
import org.jivesoftware.smack.packet.UnparsedIQ;
|
||||
import org.jivesoftware.smack.packet.XMPPError;
|
||||
import org.jivesoftware.smack.parsing.StandardExtensionElementProvider;
|
||||
import org.jivesoftware.smack.provider.ExtensionElementProvider;
|
||||
import org.jivesoftware.smack.provider.IQProvider;
|
||||
|
@ -607,7 +607,7 @@ public class PacketParserUtils {
|
|||
ParserUtils.assertAtStartTag(parser);
|
||||
final int initialDepth = parser.getDepth();
|
||||
IQ iqPacket = null;
|
||||
XMPPError.Builder error = null;
|
||||
StanzaError.Builder error = null;
|
||||
|
||||
final String id = parser.getAttributeValue("", "id");
|
||||
final Jid to = ParserUtils.getJidAttribute(parser, "to");
|
||||
|
@ -854,15 +854,15 @@ public class PacketParserUtils {
|
|||
* @return an error sub-packet.
|
||||
* @throws Exception
|
||||
*/
|
||||
public static XMPPError.Builder parseError(XmlPullParser parser)
|
||||
public static StanzaError.Builder parseError(XmlPullParser parser)
|
||||
throws Exception {
|
||||
final int initialDepth = parser.getDepth();
|
||||
Map<String, String> descriptiveTexts = null;
|
||||
List<ExtensionElement> extensions = new ArrayList<>();
|
||||
XMPPError.Builder builder = XMPPError.getBuilder();
|
||||
StanzaError.Builder builder = StanzaError.getBuilder();
|
||||
|
||||
// Parse the error header
|
||||
builder.setType(XMPPError.Type.fromString(parser.getAttributeValue("", "type")));
|
||||
builder.setType(StanzaError.Type.fromString(parser.getAttributeValue("", "type")));
|
||||
builder.setErrorGenerator(parser.getAttributeValue("", "by"));
|
||||
|
||||
outerloop: while (true) {
|
||||
|
@ -872,13 +872,13 @@ public class PacketParserUtils {
|
|||
String name = parser.getName();
|
||||
String namespace = parser.getNamespace();
|
||||
switch (namespace) {
|
||||
case XMPPError.NAMESPACE:
|
||||
case StanzaError.NAMESPACE:
|
||||
switch (name) {
|
||||
case Stanza.TEXT:
|
||||
descriptiveTexts = parseDescriptiveTexts(parser, descriptiveTexts);
|
||||
break;
|
||||
default:
|
||||
builder.setCondition(XMPPError.Condition.fromString(name));
|
||||
builder.setCondition(StanzaError.Condition.fromString(name));
|
||||
if (!parser.isEmptyElementTag()) {
|
||||
builder.setConditionText(parser.nextText());
|
||||
}
|
||||
|
|
|
@ -62,7 +62,7 @@ public class IQResponseTest {
|
|||
*/
|
||||
@Test
|
||||
public void testGeneratingValidErrorResponse() throws XmppStringprepException {
|
||||
final XMPPError.Builder error = XMPPError.getBuilder(XMPPError.Condition.bad_request);
|
||||
final StanzaError.Builder error = StanzaError.getBuilder(StanzaError.Condition.bad_request);
|
||||
final IQ request = new TestIQ(ELEMENT, NAMESPACE);
|
||||
|
||||
request.setType(IQ.Type.set);
|
||||
|
@ -110,7 +110,7 @@ public class IQResponseTest {
|
|||
*/
|
||||
@Test
|
||||
public void testGeneratingErrorBasedOnError() throws XmppStringprepException {
|
||||
final XMPPError.Builder error = XMPPError.getBuilder(XMPPError.Condition.bad_request);
|
||||
final StanzaError.Builder error = StanzaError.getBuilder(StanzaError.Condition.bad_request);
|
||||
final IQ request = new TestIQ(ELEMENT, NAMESPACE);
|
||||
|
||||
request.setType(IQ.Type.error);
|
||||
|
|
|
@ -16,8 +16,8 @@
|
|||
*/
|
||||
package org.jivesoftware.smack.packet;
|
||||
|
||||
import static org.jivesoftware.smack.packet.XMPPError.Condition;
|
||||
import static org.jivesoftware.smack.packet.XMPPError.Type;
|
||||
import static org.jivesoftware.smack.packet.StanzaError.Condition;
|
||||
import static org.jivesoftware.smack.packet.StanzaError.Type;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.util.Map;
|
||||
|
@ -27,7 +27,7 @@ import org.junit.Test;
|
|||
public class XMPPErrorTest {
|
||||
@Test
|
||||
public void testConditionHasDefaultTypeMapping() throws NoSuchFieldException, IllegalAccessException {
|
||||
Map<Condition, Type> conditionToTypeMap = XMPPError.CONDITION_TO_TYPE;
|
||||
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());
|
||||
|
|
|
@ -37,7 +37,7 @@ import javax.xml.transform.TransformerException;
|
|||
import org.jivesoftware.smack.packet.Message;
|
||||
import org.jivesoftware.smack.packet.Presence;
|
||||
import org.jivesoftware.smack.packet.Stanza;
|
||||
import org.jivesoftware.smack.packet.XMPPError;
|
||||
import org.jivesoftware.smack.packet.StanzaError;
|
||||
import org.jivesoftware.smack.sasl.SASLError;
|
||||
import org.jivesoftware.smack.sasl.packet.SaslStreamElements;
|
||||
import org.jivesoftware.smack.sasl.packet.SaslStreamElements.SASLFailure;
|
||||
|
@ -875,8 +875,8 @@ public class PacketParserUtilsTest {
|
|||
final String text = "Dummy descriptive text";
|
||||
Map<String, String> texts = new HashMap<>();
|
||||
texts.put(null, text);
|
||||
XMPPError
|
||||
.getBuilder(XMPPError.Condition.internal_server_error)
|
||||
StanzaError
|
||||
.getBuilder(StanzaError.Condition.internal_server_error)
|
||||
.setDescriptiveTexts(texts)
|
||||
.build();
|
||||
}
|
||||
|
@ -886,14 +886,14 @@ public class PacketParserUtilsTest {
|
|||
final String text = "Dummy descriptive text";
|
||||
Map<String, String> texts = new HashMap<>();
|
||||
texts.put("", text);
|
||||
XMPPError error = XMPPError
|
||||
.getBuilder(XMPPError.Condition.internal_server_error)
|
||||
StanzaError error = StanzaError
|
||||
.getBuilder(StanzaError.Condition.internal_server_error)
|
||||
.setDescriptiveTexts(texts)
|
||||
.build();
|
||||
final String errorXml = XMLBuilder
|
||||
.create(XMPPError.ERROR).a("type", "cancel").up()
|
||||
.element("internal-server-error", XMPPError.NAMESPACE).up()
|
||||
.element("text", XMPPError.NAMESPACE).t(text).up()
|
||||
.create(StanzaError.ERROR).a("type", "cancel").up()
|
||||
.element("internal-server-error", StanzaError.NAMESPACE).up()
|
||||
.element("text", StanzaError.NAMESPACE).t(text).up()
|
||||
.asString();
|
||||
XmlUnitUtils.assertSimilar(errorXml, error.toXML());
|
||||
}
|
||||
|
@ -902,12 +902,12 @@ public class PacketParserUtilsTest {
|
|||
public void ensureNoNullLangInParsedDescriptiveTexts() throws Exception {
|
||||
final String text = "Dummy descriptive text";
|
||||
final String errorXml = XMLBuilder
|
||||
.create(XMPPError.ERROR).a("type", "cancel").up()
|
||||
.element("internal-server-error", XMPPError.NAMESPACE).up()
|
||||
.element("text", XMPPError.NAMESPACE).t(text).up()
|
||||
.create(StanzaError.ERROR).a("type", "cancel").up()
|
||||
.element("internal-server-error", StanzaError.NAMESPACE).up()
|
||||
.element("text", StanzaError.NAMESPACE).t(text).up()
|
||||
.asString();
|
||||
XmlPullParser parser = TestUtils.getParser(errorXml);
|
||||
XMPPError error = PacketParserUtils.parseError(parser).build();
|
||||
StanzaError error = PacketParserUtils.parseError(parser).build();
|
||||
assertEquals(text, error.getDescriptiveText());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue