Search in sources :

Example 16 with XMPPError

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());
    }
}
Also used : XmlPullParser(org.xmlpull.v1.XmlPullParser) XMPPError(org.jivesoftware.smack.packet.XMPPError) XmlPullParserException(org.xmlpull.v1.XmlPullParserException)

Example 17 with XMPPError

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());
}
Also used : XMPPError(org.jivesoftware.smack.packet.XMPPError)

Example 18 with XMPPError

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);
}
Also used : XMPPError(org.jivesoftware.smack.packet.XMPPError)

Example 19 with XMPPError

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());
    }
}
Also used : XmlPullParser(org.xmlpull.v1.XmlPullParser) XMPPError(org.jivesoftware.smack.packet.XMPPError) XmlPullParserException(org.xmlpull.v1.XmlPullParserException)

Example 20 with XMPPError

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;
}
Also used : ErrorIQ(org.jivesoftware.smack.packet.ErrorIQ) ErrorIQ(org.jivesoftware.smack.packet.ErrorIQ) EmptyResultIQ(org.jivesoftware.smack.packet.EmptyResultIQ) IQ(org.jivesoftware.smack.packet.IQ) XMPPError(org.jivesoftware.smack.packet.XMPPError)

Aggregations

XMPPError (org.jivesoftware.smack.packet.XMPPError)36 XMPPException (org.jivesoftware.smack.XMPPException)11 IQ (org.jivesoftware.smack.packet.IQ)10 XmlPullParserException (org.xmlpull.v1.XmlPullParserException)6 SmackException (org.jivesoftware.smack.SmackException)5 XmlPullParser (org.xmlpull.v1.XmlPullParser)5 AdHocCommandData (org.jivesoftware.smackx.packet.AdHocCommandData)3 NetworkException (com.xabber.android.data.NetworkException)2 IOException (java.io.IOException)2 UnknownHostException (java.net.UnknownHostException)2 Form (org.jivesoftware.smackx.Form)2 Action (org.jivesoftware.smackx.commands.AdHocCommand.Action)2 MultiUserChat (org.jivesoftware.smackx.muc.MultiUserChat)2 StreamInitiation (org.jivesoftware.smackx.packet.StreamInitiation)2 AccountItem (com.xabber.android.data.account.AccountItem)1 ConnectionThread (com.xabber.android.data.connection.ConnectionThread)1 MessageItem (com.xabber.android.data.database.messagerealm.MessageItem)1 UserJid (com.xabber.android.data.entity.UserJid)1 Realm (io.realm.Realm)1 BufferedImage (java.awt.image.BufferedImage)1