Package org.apache.vysper.xmpp.protocol

Examples of org.apache.vysper.xmpp.protocol.ResponseStanzaContainer


        TestSessionContext sessionContext = this.sessionContext;
        sessionContext.setServerToServer();

        TestIQHandler iqHandler = new TestIQHandler();
        ResponseStanzaContainer responseStanzaContainer = iqHandler.execute(stanzaBuilder.build(), sessionContext.getServerRuntimeContext(), true, sessionContext, null);
        Stanza responseStanza = responseStanzaContainer.getResponseStanza();
        XMLElementVerifier verifier = responseStanza.getVerifier();
        assertTrue("error", verifier.nameEquals("error"));
    }
View Full Code Here


        StanzaBuilder stanzaBuilder = new StanzaBuilder("iq", NamespaceURIs.JABBER_CLIENT);
        stanzaBuilder.addAttribute("type", "error");
        Stanza stanza = stanzaBuilder.build(); // this stanza has no ID

        IQHandler iqHandler = new IQHandler();
        ResponseStanzaContainer responseStanzaContainer = iqHandler.execute(stanza, sessionContext.getServerRuntimeContext(), true, sessionContext, null);
        Stanza responseStanza = responseStanzaContainer.getResponseStanza();
        XMLElementVerifier verifier = responseStanza.getVerifier();
        assertTrue("error", verifier.nameEquals("error")); // response is _not_ IQ stanza
    }
View Full Code Here

        assertTrue("error", verifier.nameEquals("error")); // response is _not_ IQ stanza
    }

    private void assertIQError(Stanza stanza) {
        TestIQHandler iqHandler = new TestIQHandler();
        ResponseStanzaContainer responseStanzaContainer = iqHandler.execute(stanza, sessionContext.getServerRuntimeContext(), true, sessionContext, null);
        Stanza responseStanza = responseStanzaContainer.getResponseStanza();
        XMLElementVerifier verifier = responseStanza.getVerifier();
        assertTrue("iq", verifier.nameEquals("iq"));
        assertTrue("error type", verifier.attributeEquals("type", IQStanzaType.ERROR.value()));
        assertTrue("iq-error", verifier.subElementPresent("error"));
    }
View Full Code Here

        stanzaBuilder.addAttribute("id", "1");
        stanzaBuilder.addAttribute("type", "get");
        stanzaBuilder.startInnerElement("getRequest").endInnerElement();

        TestIQHandler iqHandler = new TestIQHandler();
        ResponseStanzaContainer responseStanzaContainer = iqHandler.execute(stanzaBuilder.build(), sessionContext.getServerRuntimeContext(), true, sessionContext, null);
        IQStanza incomingStanza = iqHandler.getIncomingStanza();

        XMPPCoreStanzaVerifier verifier = incomingStanza.getCoreVerifier();
        assertTrue("iq", verifier.nameEquals("iq"));
        assertTrue("iq-id", verifier.attributeEquals("id", "1"));
        assertTrue("iq-type-get", verifier.attributeEquals("type", "get"));

        // response is "result"
        Stanza responseStanza = responseStanzaContainer.getResponseStanza();
        XMLElementVerifier responseVerifier = responseStanza.getVerifier();
        assertTrue("iq", responseVerifier.nameEquals("iq"));
        assertTrue("iq-id", responseVerifier.attributeEquals("id", "1"));
        assertTrue("iq-type-result", responseVerifier.attributeEquals("type", "result"));
    }
View Full Code Here

       
        StanzaBuilder stanzaBuilder = StanzaBuilder.createIQStanza(boundClient, server, IQStanzaType.GET, IQ_ID);
        stanzaBuilder.startInnerElement("ping", NamespaceURIs.URN_XMPP_PING).endInnerElement();

        Stanza requestStanza = stanzaBuilder.build();
        ResponseStanzaContainer resp = handler.execute(requestStanza, sessionContext.getServerRuntimeContext(), true, sessionContext, null);

        // we should always get a response
        assertTrue(resp.hasResponse());
       
        Stanza respStanza = resp.getResponseStanza();

        assertEquals("iq", respStanza.getName());
        assertEquals(boundClient, respStanza.getTo());
        assertEquals(server, respStanza.getFrom());
        assertEquals(IQ_ID, respStanza.getAttributeValue("id"));
View Full Code Here

        assertTrue("tls init", sessionContext.isSwitchToTLSCalled());
    }

    private Stanza executeStartTLSHandler(Stanza starttlsStanza, TestSessionContext sessionContext) {
        StartTLSHandler startTLSHandler = new StartTLSHandler();
        ResponseStanzaContainer responseStanzaContainer = startTLSHandler.execute(starttlsStanza, sessionContext.getServerRuntimeContext(), true, sessionContext, sessionStateHolder);
        Stanza responseStanza = responseStanzaContainer.getResponseStanza();
        return responseStanza;
    }
View Full Code Here

        StanzaBuilder stanzaBuilder = StanzaBuilder.createIQStanza(new EntityImpl("test", "vysper.org", null), null, IQStanzaType.GET, "id1");
        stanzaBuilder.startInnerElement("query").endInnerElement();
        Stanza iqStanza = stanzaBuilder.build();

        ResponseStanzaContainer container = asyncIQGetHandler.execute(iqStanza, sessionContext.getServerRuntimeContext(), true, sessionContext, sessionStateHolder);
        assertTrue(container == null || container.hasNoResponse());

        TriggeredRunnableFuture runnableFuture = asyncIQGetHandler.getWaitingRunnableFuture();
        assertNotNull("future has been created", runnableFuture);
        assertFalse("not done", runnableFuture.isDone());
       
View Full Code Here

    public void processStanza(SessionContext sessionContext, SessionStateHolder sessionStateHolder, Stanza stanza, StanzaHandler stanzaHandler) {
        boolean proceed = checkState(sessionContext, sessionStateHolder, stanza, stanzaHandler);
        if (!proceed) return; // TODO close stream?

        ResponseStanzaContainer responseStanzaContainer = executeHandler(sessionContext, sessionStateHolder, stanza, stanzaHandler);

        writeResponse(sessionContext, responseStanzaContainer);
    }
View Full Code Here

            ResponseWriter.writeResponse(sessionContext, responseStanzaContainer);
        }
    }

    protected ResponseStanzaContainer executeHandler(SessionContext sessionContext, SessionStateHolder sessionStateHolder, Stanza stanza, StanzaHandler stanzaHandler) {
        ResponseStanzaContainer responseStanzaContainer = null;
        try {
            responseStanzaContainer = stanzaHandler.execute(stanza, sessionContext.getServerRuntimeContext(), isProcessingOutboundStanzas(), sessionContext, sessionStateHolder);
        } catch (ProtocolException e) {
            ResponseWriter.handleProtocolError(e, sessionContext, stanza);
            return null;
View Full Code Here

   
    public void testNoItems() {
        DefaultDiscoInfoStanzaGenerator sg = (DefaultDiscoInfoStanzaGenerator)getDefaultStanzaGenerator();
        Stanza stanza = sg.getStanza(client, pubsubService.getBareJID(), "id123");

        ResponseStanzaContainer result = sendStanza(stanza, true);
        assertTrue(result.hasResponse());
        IQStanza response = new IQStanza(result.getResponseStanza());

        assertEquals(IQStanzaType.RESULT.value(),response.getType());

        assertEquals("id123", response.getAttributeValue("id")); // IDs must match
View Full Code Here

TOP

Related Classes of org.apache.vysper.xmpp.protocol.ResponseStanzaContainer

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.