Package org.apache.vysper.xmpp.protocol

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


        stanzaBuilder.addAttribute("id", "1");
        stanzaBuilder.addAttribute("type", "get");
        stanzaBuilder.startInnerElement("getRequest", NamespaceURIs.JABBER_CLIENT).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


        if (stanzaHandler == null) {
            unhandledStanza(stanza);
            return;
        }

        ResponseStanzaContainer responseStanzaContainer = null;
        try {
            responseStanzaContainer = stanzaHandler.execute(stanza, serverRuntimeContext, false, sessionContext,
                    sessionStateHolder);
        } catch (ProtocolException e) {
            e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
        }

        if (responseStanzaContainer != null && responseStanzaContainer.getResponseStanza() != null) {
            Stanza responseStanza = responseStanzaContainer.getResponseStanza();
            try {
                IgnoreFailureStrategy failureStrategy = new IgnoreFailureStrategy(); // TODO call back module
                serverRuntimeContext.getStanzaRelay().relay(responseStanza.getTo(), responseStanza, failureStrategy);
            } catch (DeliveryException e) {
                throw new RuntimeException(e);
View Full Code Here

        Entity client2 = new EntityImpl("yoda", "starwars.com", null);

        AbstractStanzaGenerator sg = new DefaultModifyAffiliationsStanzaGenerator("Node1", client,
                PubSubAffiliation.MEMBER);
        Stanza stanza = sg.getStanza(client2, pubsubService, "id123", null);
        ResponseStanzaContainer result = sendStanza(stanza, true);

        assertTrue(result.hasResponse());

        IQStanza response = new IQStanza(result.getResponseStanza());
        assertEquals(IQStanzaType.ERROR.value(), response.getType());

        assertEquals("id123", response.getAttributeValue("id")); // IDs must match

        XMLElement error = response.getInnerElementsNamed("error").get(0); //jump directly to the error part
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

        assertNull(root.find(testNode));

        AbstractStanzaGenerator sg = new DefaultModifyAffiliationsStanzaGenerator("test", client,
                PubSubAffiliation.MEMBER);
        Stanza stanza = sg.getStanza(client, pubsubService, "id123", testNode);
        ResponseStanzaContainer result = sendStanza(stanza, true);
        assertTrue(result.hasResponse());
        IQStanza response = new IQStanza(result.getResponseStanza());
        assertEquals(IQStanzaType.ERROR.value(), response.getType());

        assertEquals("id123", response.getAttributeValue("id")); // IDs must match

        XMLElement error = response.getInnerElementsNamed("error").get(0); //jump directly to the error part
View Full Code Here

        root.add(new LeafNode(serviceConfiguration, "blogs", "Blogs", client));

        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

        assertEquals(PubSubAffiliation.NONE, n1.getAffiliation(client3));

        AbstractStanzaGenerator sg = getDefaultStanzaGenerator();

        Stanza stanza = sg.getStanza(client, pubsubService, "4711", null);
        ResponseStanzaContainer result = sendStanza(stanza, true);

        assertTrue(result.hasResponse());

        IQStanza response = new IQStanza(result.getResponseStanza());
        assertEquals(IQStanzaType.RESULT.value(), response.getType());
        assertEquals("4711", response.getAttributeValue("id")); // IDs must match

        assertEquals(PubSubAffiliation.OWNER, n1.getAffiliation(client));
        assertEquals(PubSubAffiliation.MEMBER, n1.getAffiliation(client2));
View Full Code Here

        DefaultModifyAffiliationsStanzaGenerator sg = new DefaultModifyAffiliationsStanzaGenerator(n1.getName(),
                client2, PubSubAffiliation.NONE);

        Stanza stanza = sg.getStanza(client, pubsubService, "4711", null);
        ResponseStanzaContainer result = sendStanza(stanza, true);

        assertTrue(result.hasResponse());

        IQStanza response = new IQStanza(result.getResponseStanza());
        assertEquals(IQStanzaType.RESULT.value(), response.getType());
        assertEquals("4711", response.getAttributeValue("id")); // IDs must match

        assertEquals(PubSubAffiliation.OWNER, n1.getAffiliation(client));
        assertEquals(PubSubAffiliation.NONE, n1.getAffiliation(client2));
View Full Code Here

        root.add(new LeafNode(serviceConfiguration, "news", "News", client));

        DefaultDiscoInfoStanzaGenerator sg = (DefaultDiscoInfoStanzaGenerator) getDefaultStanzaGenerator();
        Stanza stanza = sg.getStanza(client, pubsubService.getBareJID(), "id123", "news");

        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

        node.publish(client, relay, "itemid3", item3);

        DefaultDiscoInfoStanzaGenerator sg = (DefaultDiscoInfoStanzaGenerator) getDefaultStanzaGenerator();
        Stanza stanza = sg.getStanza(client, pubsubService.getBareJID(), "id123", "news");

        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.