Package org.apache.vysper.xmpp.stanza

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


        String timeZone = new SimpleDateFormat("Z").format(now);
        timeZone = timeZone.substring(0, 3) + ":" + timeZone.substring(3, 5); // adjust to required formatting "-00:08"

        String utcTime = DateTimeProfile.getInstance().getDateTimeInUTC(now);

        StanzaBuilder stanzaBuilder = StanzaBuilder.createIQStanza(stanza.getTo(), stanza.getFrom(), IQStanzaType.RESULT, stanza.getID()).
            startInnerElement("time", NamespaceURIs.URN_XMPP_TIME).

            startInnerElement("tzo", NamespaceURIs.URN_XMPP_TIME).addText(timeZone).endInnerElement().
            startInnerElement("utc", NamespaceURIs.URN_XMPP_TIME).addText(utcTime).endInnerElement().

        endInnerElement();

        return stanzaBuilder.build();
    }
View Full Code Here


    }

    @Override
    protected Stanza handleGet(IQStanza stanza, ServerRuntimeContext serverRuntimeContext, SessionContext sessionContext) {

        StanzaBuilder stanzaBuilder = StanzaBuilder.createIQStanza(stanza.getTo(), stanza.getFrom(), IQStanzaType.RESULT, stanza.getID());

        return stanzaBuilder.build();
    }
View Full Code Here

    }

    @Override
    protected Stanza handleGet(IQStanza stanza, ServerRuntimeContext serverRuntimeContext, SessionContext sessionContext) {

        StanzaBuilder stanzaBuilder = StanzaBuilder.createIQStanza(stanza.getTo(), stanza.getFrom(), IQStanzaType.RESULT, stanza.getID()).
            startInnerElement("query", NamespaceURIs.JABBER_IQ_VERSION).

            startInnerElement("name", NamespaceURIs.JABBER_IQ_VERSION).addText("Apache Vysper XMPP Server").endInnerElement().
            startInnerElement("version", NamespaceURIs.JABBER_IQ_VERSION).addText("0.1 beta").endInnerElement().
            startInnerElement("os", NamespaceURIs.JABBER_IQ_VERSION).addText(OS_VERSION).endInnerElement().

        endInnerElement();

        return stanzaBuilder.build();
    }
View Full Code Here

public class PlainTestCase extends TestCase {
    protected SessionStateHolder stateHolder;

    public void testPlainEmpty() throws XMLSemanticError {

        Stanza stanza = new StanzaBuilder("plain", NamespaceURIs.URN_IETF_PARAMS_XML_NS_XMPP_SASL).build();

        Stanza response = startMechanism(stanza);
        assertResponse(response, "malformed-request");
    }
View Full Code Here

        assertResponse(response, "malformed-request");
    }

    public void testPlainNonBASE64() throws XMLSemanticError {

        Stanza stanza = new StanzaBuilder("plain", NamespaceURIs.URN_IETF_PARAMS_XML_NS_XMPP_SASL)
                .addText("aEflkejidkj==")
                .build();

        Stanza response = startMechanism(stanza);
        assertResponse(response, "malformed-request");
View Full Code Here

        assertResponse(response, "malformed-request");
    }

    public void testPlainNonExistingUser() throws XMLSemanticError {

        Stanza stanza = new StanzaBuilder("plain", NamespaceURIs.URN_IETF_PARAMS_XML_NS_XMPP_SASL)
                .addText(encode("dieter", "schluppkoweit"))
                .build();

        Stanza response = startMechanism(stanza);
        assertResponse(response, "not-authorized");
View Full Code Here

        assertResponse(response, "not-authorized");
    }

    public void testPlainNotExistingUser() throws XMLSemanticError {

        Stanza stanza = new StanzaBuilder("plain", NamespaceURIs.URN_IETF_PARAMS_XML_NS_XMPP_SASL)
                .addText(encode("dieter", "schluppkoweit"))
                .build();

        Stanza response = startMechanism(stanza);
        assertResponse(response, "not-authorized");
View Full Code Here

    public void testPlainNoUserPasswordCombination() throws XMLSemanticError {

        String innerText = new String(Base64.encodeBase64("continuous".getBytes()));

        Stanza stanza = new StanzaBuilder("plain", NamespaceURIs.URN_IETF_PARAMS_XML_NS_XMPP_SASL)
                .addText(innerText).build();

        Stanza response = startMechanism(stanza);
        assertResponse(response, "malformed-request");
    }
View Full Code Here

        handler = new RosterIQHandler();
    }

    public void testRosterGet() {

        StanzaBuilder stanzaBuilder = createRosterGet();

        assertEquals(ResourceState.CONNECTED, getResourceState());
        handler.execute(stanzaBuilder.build(), sessionContext.getServerRuntimeContext(), true, sessionContext, null);
        assertEquals(ResourceState.CONNECTED_INTERESTED, getResourceState());
       
//        C: <iq from='juliet@example.com/balcony'
//               type='get'
//               id='roster_get'>
View Full Code Here

       
    }

    public void testRosterState_WithRosterGetAfterInitialPresence() {

        StanzaBuilder stanzaBuilder = createRosterGet();

        // mock intial presence resource state change
        sessionContext.getServerRuntimeContext().getResourceRegistry().setResourceState(boundResourceId, ResourceState.AVAILABLE);
       
        handler.execute(stanzaBuilder.build(), sessionContext.getServerRuntimeContext(), true, sessionContext, null);
        assertEquals(ResourceState.AVAILABLE_INTERESTED, getResourceState());
    }
View Full Code Here

TOP

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

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.