use of org.jivesoftware.smack.packet.XMPPError in project Smack by igniterealtime.
the class XMPPErrorTest method testCancel.
/**
* Check the parser with an xml with the 404 error.
*/
public void testCancel() {
// Make the XML to test
String xml = "<error type='cancel'>" + "<conflict xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>" + "</error>";
try {
// Create the xml parser
XmlPullParser parser = getParserFromXML(xml);
// Create a packet from the xml
XMPPError error = parseError(parser);
assertNotNull(error);
} catch (Exception e) {
e.printStackTrace();
fail(e.getMessage());
}
}
use of org.jivesoftware.smack.packet.XMPPError in project Smack by igniterealtime.
the class XMPPErrorTest method testLocalErrorCreation.
/**
* Check the creation of a new xmppError locally.
*/
public void testLocalErrorCreation() {
XMPPError error = new XMPPError(XMPPError.Condition.item_not_found);
error.toXML();
assertEquals(error.getCondition(), "item-not-found");
assertEquals(error.getCode(), 404);
assertEquals(error.getType(), XMPPError.Type.CANCEL);
assertNull(error.getMessage());
}
use of org.jivesoftware.smack.packet.XMPPError in project Smack by igniterealtime.
the class XMPPErrorTest method testLocalErrorWithCommentCreation.
/**
* Check the creation of a new xmppError locally.
*/
public void testLocalErrorWithCommentCreation() {
String message = "Error Message";
XMPPError error = new XMPPError(XMPPError.Condition.item_not_found, message);
error.toXML();
assertEquals(error.getCondition(), "item-not-found");
assertEquals(error.getCode(), 404);
assertEquals(error.getType(), XMPPError.Type.CANCEL);
assertEquals(error.getMessage(), message);
}
use of org.jivesoftware.smack.packet.XMPPError in project Smack by igniterealtime.
the class XMPPErrorTest method testCancelWithMessageAndApplicationError.
/**
* Check the parser with an xml with the 404 error.
*/
public void testCancelWithMessageAndApplicationError() {
// Make the XML to test
String xml = "<error type='cancel' code='10'>" + "<conflict xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>" + "<text xml:lang='en' xmlns='urn:ietf:params:xml:ns:xmpp-streams'>" + "Some special application diagnostic information!" + "</text>" + "<application-defined-error xmlns='application-ns'/>" + "</error>";
try {
// Create the xml parser
XmlPullParser parser = getParserFromXML(xml);
// Create a packet from the xml
XMPPError error = parseError(parser);
assertNotNull(error);
} catch (Exception e) {
e.printStackTrace();
fail(e.getMessage());
}
}
use of org.jivesoftware.smack.packet.XMPPError in project Smack by igniterealtime.
the class IBBPacketUtils method createErrorIQ.
/**
* Returns an error IQ.
*
* @param from the senders JID
* @param to the recipients JID
* @param condition the XMPP error condition
* @return an error IQ
*/
public static IQ createErrorIQ(Jid from, Jid to, XMPPError.Condition condition) {
XMPPError.Builder xmppError = XMPPError.getBuilder(condition);
IQ errorIQ = new ErrorIQ(xmppError);
errorIQ.setType(IQ.Type.error);
errorIQ.setFrom(from);
errorIQ.setTo(to);
return errorIQ;
}
Aggregations