Package org.apache.vysper.xmpp.stanza

Examples of org.apache.vysper.xmpp.stanza.IQStanza


        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
       
        // get the query Element
        XMLElement query = response.getFirstInnerElement();
        List<XMLElement> inner = query.getInnerElements();

        assertEquals("query", query.getName());
        assertEquals("news", query.getAttributeValue("node"));
       
View Full Code Here


        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
       
        // get the query Element
        XMLElement query = response.getFirstInnerElement();
        List<XMLElement> inner = query.getInnerElements();

        assertEquals("query", query.getName());
        assertEquals("news", query.getAttributeValue("node"));
       
View Full Code Here

       
        AbstractStanzaGenerator sg = getDefaultStanzaGenerator();
        Stanza stanza = sg.getStanza(client, pubsubService, "id123", testNode);
        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
       
        LeafNode n = root.find(testNode);
        assertEquals(testNode, n.getName());
    }
View Full Code Here

       
        AbstractStanzaGenerator sg = getDefaultStanzaGenerator();
        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.getInnerElements().get(1); // jump over the original request
        XMLElement conflict = error.getFirstInnerElement();
       
        assertEquals("error", error.getName());
        assertEquals("cancel", error.getAttributeValue("type"));
       
View Full Code Here

        AbstractStanzaGenerator sg = getDefaultStanzaGenerator();

        node.subscribe("id", client);
        ResponseStanzaContainer result = sendStanza(sg.getStanza(client, pubsubService, "id123", "news"), true);
        assertTrue(result.hasResponse());
        IQStanza response = new IQStanza(result.getResponseStanza());
        assertEquals(IQStanzaType.RESULT.value(),response.getType());

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

        // get the subscription Element
        XMLElement pub = response.getFirstInnerElement().getFirstInnerElement();
        XMLElement item = pub.getFirstInnerElement();

        assertEquals("publish", pub.getName());
        assertEquals("news", pub.getAttributeValue("node"));
        assertNotNull(item); // should be present
View Full Code Here

        ResponseStanzaContainer result = sendStanza(sg.getStanza(client, pubsubService, "id1", "news"), true);

        // verify response
        assertTrue(result.hasResponse());
       
        IQStanza response = new IQStanza(result.getResponseStanza());

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

        assertEquals("id1", response.getAttributeValue("id")); // IDs must match
       
        // get the query Element
        XMLElement pubsub = response.getFirstInnerElement();
        XMLElement publish = pubsub.getFirstInnerElement();
        XMLElement item = publish.getFirstInnerElement();

        assertEquals("pubsub", pubsub.getName());
        assertEquals(NamespaceURIs.XEP0060_PUBSUB, pubsub.getNamespaceURI());
View Full Code Here

            @SpecCompliant(spec = "rfc3920", section = "9.2.3", status = FINISHED, coverage = PARTIAL, comment = "covers points 1, 2, 5 and 6"),
            @SpecCompliant(spec = "rfc3920bis-09", section = "9.2.3", status = FINISHED, coverage = PARTIAL, comment = "covers points 1, 2, 5 and 6") })
    @Override
    protected Stanza executeCore(XMPPCoreStanza coreStanza, ServerRuntimeContext serverRuntimeContext,
            boolean isOutboundStanza, SessionContext sessionContext) {
        IQStanza stanza = (IQStanza) coreStanza;

        // rfc3920/9.2.3/1.
        String id = stanza.getID();
        if (id == null) {
            return ServerErrorResponses.getInstance().getStanzaError(StanzaErrorCondition.BAD_REQUEST, stanza,
                    StanzaErrorType.MODIFY, "iq-stanza requires 'id' attribute to be present",
                    getErrorLanguage(serverRuntimeContext, sessionContext), null);
        }

        // rfc3920/9.2.3/2.
        IQStanzaType iqType = stanza.getIQType();
        if (iqType == null) {
            // missing or unknown type
            return ServerErrorResponses.getInstance().getStanzaError(StanzaErrorCondition.BAD_REQUEST, stanza,
                    StanzaErrorType.MODIFY, "iq-stanza requires a valid 'type' attribute to be present",
                    getErrorLanguage(serverRuntimeContext, sessionContext), null);
View Full Code Here

        builder.addAttribute("from", CLIENT_JID);
        builder.startInnerElement("ping", NamespaceURIs.URN_XMPP_PING);
        builder.endInnerElement();

        Stanza request = builder.build();
        IQStanza requestIq = new IQStanza(request);

        ServerErrorResponses serverErrorResponses = ServerErrorResponses.getInstance();

        Stanza errorReply = serverErrorResponses.getStanzaError(StanzaErrorCondition.SERVICE_UNAVAILABLE, requestIq,
                StanzaErrorType.CANCEL, "Test", "en", null);
View Full Code Here

    protected boolean checkRosterPush(Stanza stanza, Entity entity, Entity contact, SubscriptionType subscriptionType,
            AskSubscriptionType askSubscriptionType) {
        if (stanza == null)
            return false;
        IQStanza rosterPush = (IQStanza) XMPPCoreStanza.getWrapper(stanza);
        rosterPush.getInnerElementsNamed("query");

        RosterItem rosterItem = null;
        try {
            rosterItem = RosterUtils.parseRosterItemForTesting(rosterPush);
        } catch (Exception e) {
            fail(e.toString());
        }
        assertEquals(rosterPush.getTo().getFullQualifiedName(), entity.getFullQualifiedName());
        assertEquals(contact.getFullQualifiedName(), rosterItem.getJid().getFullQualifiedName());
        assertEquals(subscriptionType, rosterItem.getSubscriptionType());
        assertEquals(subscriptionType, rosterItem.getSubscriptionType());
        assertEquals(askSubscriptionType, rosterItem.getAskSubscriptionType());
View Full Code Here

        DiscoInfoIQHandler infoIQHandler = new DiscoInfoIQHandler();

        StanzaBuilder request = StanzaBuilder.createIQStanza(EntityImpl.parse("user@vysper.org"), EntityImpl
                .parse("info@vysper.org"), IQStanzaType.GET, "1");

        IQStanza finalStanza = (IQStanza) XMPPCoreStanza.getWrapper(request.build());

        Stanza resultStanza = infoIQHandler.handleGet(finalStanza, runtimeContext, new TestSessionContext(
                runtimeContext, new SessionStateHolder()));

        assertTrue(resultStanza.getVerifier().onlySubelementEquals("query",
View Full Code Here

TOP

Related Classes of org.apache.vysper.xmpp.stanza.IQStanza

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.