Package org.jivesoftware.smack.packet

Examples of org.jivesoftware.smack.packet.XMPPError


         "</error>";
       try {
         // Create the xml parser
         XmlPullParser parser = getParserFromXML(xml);
         // Create a packet from the xml
         XMPPError error = parseError(parser);
        
         String sendingXML = error.toXML();
        
       assertNotNull(error);
       assertNotNull(sendingXML);
       } catch (Exception e) {
           e.printStackTrace();
View Full Code Here


          "</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());
View Full Code Here

          "</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());
View Full Code Here

            try {
                muc3.join("MyNick");
                fail("Other user was able to join with other user's reserved nickname");
            }
            catch (XMPPException e) {
                XMPPError xmppError = e.getXMPPError();
                assertNotNull(
                    "No XMPPError was received when joining with other user's reserved nickname",
                    xmppError);
                assertEquals(
                    "Different error code was received while joining with other user's reserved nickname",
                    409,
                    xmppError.getCode());
            }

            // Check that user3 can join the room using his own nickname (not reserved)
            muc3.join("MyNotReservedNick");
            muc3.leave();

            // Check that another user cannot reserve an already reserved nickname
            registrationForm = muc3.getRegistrationForm();
            answerForm = registrationForm.createAnswerForm();
            answerForm.setAnswer("muc#register_first", "MyFirstName 2");
            answerForm.setAnswer("muc#register_last", "MyLastName 2");
            answerForm.setAnswer("muc#register_roomnick", "MyNick");
            try {
                muc3.sendRegistrationForm(answerForm);
            }
            catch (XMPPException e) {
                XMPPError xmppError = e.getXMPPError();
                assertNotNull(
                    "No XMPPError was received when reserving an already reserved nickname",
                    xmppError);
                assertEquals(
                    "Different error code was received while reserving an already reserved nickname",
                    409,
                    xmppError.getCode());
            }

            // Check that another user can reserve a new nickname
            registrationForm = muc3.getRegistrationForm();
            answerForm = registrationForm.createAnswerForm();
View Full Code Here

            try {
                muc2.changeSubject("New Subject2");
                fail("User2 was allowed to change the room's subject");
            }
            catch (XMPPException e) {
                XMPPError xmppError = e.getXMPPError();
                assertNotNull(
                    "No XMPPError was received when changing the room's subject",
                    xmppError);
                assertEquals(
                    "Different error code was received while changing the room's subject",
                    403,
                    xmppError.getCode());
            }

            // Check that every MUC updates its subject when an allowed user changes the subject
            // in a room
            muc.changeSubject("New Subject1");
View Full Code Here

                // Check whether a simple participant can kick a room owner or not
                muc2.kickParticipant("testbot", "Because I'm bad");
                fail("User2 was able to kick a room owner");
            }
            catch (XMPPException e) {
                XMPPError xmppError = e.getXMPPError();
                assertNotNull("No XMPPError was received when kicking a room owner", xmppError);
                assertEquals(
                    "A simple participant was able to kick another participant from the room",
                    403,
                    xmppError.getCode());
            }

            // Check that the room's owner can kick a simple participant
            muc.kickParticipant("testbot2", "Because I'm the owner");
            Thread.sleep(300);
View Full Code Here

                // Check whether a simple participant can ban a room owner or not
                muc2.banUser(getBareJID(0), "Because I'm bad");
                fail("User2 was able to ban a room owner");
            }
            catch (XMPPException e) {
                XMPPError xmppError = e.getXMPPError();
                assertNotNull("No XMPPError was received when banning a room owner", xmppError);
                assertEquals(
                    "A simple participant was able to ban another participant from the room",
                    403,
                    xmppError.getCode());
            }

            // Check that the room's owner can ban a simple participant
            muc.banUser(getBareJID(1), "Because I'm the owner");
            Thread.sleep(300);
View Full Code Here

    {
      node.send(new Item());
      fail("Exception should be thrown when there is no payload");
    }
    catch (XMPPException e) {
      XMPPError err = e.getXMPPError();
      assertTrue(err.getType().equals(XMPPError.Type.MODIFY));
      assertTrue(err.getCondition().equals(Condition.bad_request.toString()));
      assertNotNull(err.getExtension("payload-required", PubSubNamespace.ERROR.getXmlns()));
    }

    try
    {
      node.send(new Item("test" + System.currentTimeMillis()));
      fail("Exception should be thrown when there is no payload");
    }
    catch (XMPPException e) {
      XMPPError err = e.getXMPPError();
      assertTrue(err.getType().equals(XMPPError.Type.MODIFY));
      assertTrue(err.getCondition().equals(Condition.bad_request.toString()));
      assertNotNull(err.getExtension("payload-required", PubSubNamespace.ERROR.getXmlns()));
    }
  }
View Full Code Here

                // Check whether a visitor can grant voice to another visitor
                muc2.grantVoice("testbot3");
                fail("User2 was able to grant voice");
            }
            catch (XMPPException e) {
                XMPPError xmppError = e.getXMPPError();
                assertNotNull("No XMPPError was received granting voice", xmppError);
                assertEquals(
                    "A visitor was able to grant voice to another visitor",
                    403,
                    xmppError.getCode());
            }

            // Check that the room's owner can grant voice to a participant
            muc.grantVoice("testbot2");
            Thread.sleep(300);
View Full Code Here

                // Check whether a visitor can grant moderator privileges to another visitor
                muc2.grantModerator("testbot3");
                fail("User2 was able to grant moderator privileges");
            }
            catch (XMPPException e) {
                XMPPError xmppError = e.getXMPPError();
                assertNotNull("No XMPPError was received granting moderator privileges", xmppError);
                assertEquals(
                    "A visitor was able to grant moderator privileges to another visitor",
                    403,
                    xmppError.getCode());
            }

            // Check that the room's owner can grant moderator privileges to a visitor
            muc.grantModerator("testbot2");
            Thread.sleep(300);
View Full Code Here

TOP

Related Classes of org.jivesoftware.smack.packet.XMPPError

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.