Examples of IQ

@author Matt Tucker
  • org.xmpp.packet.IQ
    IQ (Info/Query) packet. IQ packets are used to get and set information on the server, including authentication, roster operations, and creating accounts. Each IQ packet has a specific type that indicates what type of action is being taken: "get", "set", "result", or "error".

    IQ packets can contain a single child element that exists in a extended XML namespace.

  • rocks.xmpp.core.stanza.model.client.IQ
    The implementation of the {@code } element for the client namespace ('jabber:client'). @author Christian Schudt

  • Examples of org.xmpp.packet.IQ

      public void testPacketTimeout() throws Exception {
        int TIMEOUT_DELAY = 0;
        int TIMEOUT_WAIT = 5;

        // Send a valid packet, so it is received by the remote Disco mock, but not processed.
        IQ packet = new IQ();
        packet.setFrom(server1.jid);
        packet.setID("disco");
        packet.setTo(server2.jid);
        packet.setType(IQ.Type.get);
        packet.setChildElement("query", XmppNamespace.NAMESPACE_DISCO_ITEMS);

        PacketCallback callback = mock(PacketCallback.class);
        final CountDownLatch finished = new CountDownLatch(1);

        Mockito.doAnswer(new Answer<Void>() {
    View Full Code Here

    Examples of org.xmpp.packet.IQ

        FederationError.Code TEST_CODE = FederationError.Code.NOT_AUTHORIZED;
        PacketError.Condition TEST_CONDITION = PacketError.Condition.not_authorized;

        // Send a valid packet, so it is received by the remote Disco mock, but not
        // explicitly processed.
        IQ packet = new IQ();
        packet.setFrom(server1.jid);
        packet.setID("disco");
        packet.setTo(server2.jid);
        packet.setType(IQ.Type.get);
        packet.setChildElement("query", XmppNamespace.NAMESPACE_DISCO_ITEMS);

        PacketCallback callback = mock(PacketCallback.class);
        server1.manager.send(packet, callback, PACKET_TIMEOUT);

        // Accept the disco request and return TEST_CODE error.
        ArgumentCaptor<PacketCallback> server2Callback = ArgumentCaptor.forClass(PacketCallback.class);
        verify(server2.disco).processDiscoItemsGet(eq(packet), server2Callback.capture());
        server2Callback.getValue().error(FederationErrors.newFederationError(TEST_CODE));

        // Try to then complete the message, but cause an IllegalStateException.
        IQ fakeResponse = IQ.createResultIQ(packet);
        try {
          server2Callback.getValue().run(fakeResponse);
          fail("Should not be able to invoke callback twice");
        } catch (IllegalStateException e) {
          // pass
        }

        // Check the outgoing packet log.
        assertEquals(1, server2.transport.packets.size());
        Packet errorResponse = server2.transport.packets.peek();
        PacketError error = errorResponse.getError();
        assertNotNull(error);
        assertEquals(TEST_CONDITION, error.getCondition());

        // Assert that the error response does *not* include the original packet.
        assertTrue(errorResponse instanceof IQ);
        IQ errorIQ = (IQ) errorResponse;
        assertEquals(null, errorIQ.getChildElement());

        // Confirm that the error is received properly on the first server.
        ArgumentCaptor<FederationError> returnedError = ArgumentCaptor.forClass(FederationError.class);
        verify(callback).error(returnedError.capture());
        verify(callback, never()).run(any(Packet.class));
    View Full Code Here

    Examples of org.xmpp.packet.IQ

      /**
       * Test that an unhandled error (e.g. <forbidden>) is translated to
       * UNDEFINED_CONDITION before being returned to the mocked callback.
       */
      public void testUnhandledErrorResponse() {
        IQ packet = new IQ();
        packet.setFrom(server1.jid);
        packet.setID("foo");
        packet.setTo(server2.jid);

        // Disable routing so we can intercept the packet.
        server1.transport.router = null;
        PacketCallback callback = mock(PacketCallback.class);
        server1.manager.send(packet, callback, PACKET_TIMEOUT);

        // Generate an explicit error <forbidden>.
        IQ errorPacket = IQ.createResultIQ(packet);
        errorPacket.setError(PacketError.Condition.forbidden);
        server1.manager.receivePacket(errorPacket);

        // Confirm that <forbidden> is transformed to UNDEFINED_CONDITION.
        ArgumentCaptor<FederationError> returnedError = ArgumentCaptor.forClass(FederationError.class);
        verify(callback).error(returnedError.capture());
    View Full Code Here

    Examples of rocks.xmpp.core.stanza.model.client.IQ

                            }
                        }

                        for (StanzaEntry entry : stanzaTableView.getItems()) {
                            if (newValue.getStanza() instanceof IQ && entry.getStanza() instanceof IQ) {
                                IQ selectedIQ = (IQ) newValue.getStanza();
                                IQ otherIQ = (IQ) entry.getStanza();
                                if (otherIQ.getId() != null && otherIQ.getId().equals(selectedIQ.getId())
                                        && ((selectedIQ.isRequest() && otherIQ.isResponse())
                                        || selectedIQ.isResponse() && otherIQ.isRequest())) {
                                    // Add the highlighted items.
                                    viewModel.highlightedItems.add(entry);
                                }
                            }
                        }
    View Full Code Here
    TOP
    Copyright © 2018 www.massapi.com. 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.