Package org.apache.vysper.xmpp.stanza

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


       
        SessionStateHolder sessionStateHolder = new SessionStateHolder();
        sessionStateHolder.setState(SessionState.AUTHENTICATED);

        // pres 1
        XMPPCoreStanza initialPresence1 = sendInitialPresence(sessionStateHolder, initiatingUser);
        PresenceStanza presenceStanza1 = getCache().get(initiatingUser.getEntityFQ());
        assertSame(initialPresence1, presenceStanza1);
        assertSame(initialPresence1, getCache().getForBareJID(initiatingUser.getEntity().getBareJID()));

        // pres 2, same user
        XMPPCoreStanza initialPresence2 = sendInitialPresence(sessionStateHolder, anotherInterestedUser);
        PresenceStanza presenceStanza2 = getCache().get(anotherInterestedUser.getEntityFQ());
        assertSame(initialPresence2, presenceStanza2);
        assertSame(initialPresence2, getCache().getForBareJID(anotherInterestedUser.getEntity().getBareJID()));

        // re-retrieve the pres 1, still there
        PresenceStanza presenceStanza1_again = getCache().get(initiatingUser.getEntityFQ());
        assertSame(initialPresence1, presenceStanza1_again);
        assertSame(initialPresence2, getCache().getForBareJID(initiatingUser.getEntity().getBareJID()));

        // replace pres 1
        XMPPCoreStanza initialPresence1_1 = sendInitialPresence(sessionStateHolder, initiatingUser);
        PresenceStanza presenceStanza1_1 = getCache().get(initiatingUser.getEntityFQ());
        assertSame(initialPresence1_1, presenceStanza1_1);
        assertSame(initialPresence1_1, getCache().getForBareJID(initiatingUser.getEntity().getBareJID()));
       
    }
View Full Code Here


        assertSame(initialPresence1_1, getCache().getForBareJID(initiatingUser.getEntity().getBareJID()));
       
    }

    public XMPPCoreStanza sendInitialPresence(SessionStateHolder sessionStateHolder, TestUser user) {
        XMPPCoreStanza initialPresence = XMPPCoreStanza.getWrapper(StanzaBuilder.createPresenceStanza(user.getEntityFQ(), null, null, null, null, null).build());
        handler.execute(initialPresence, sessionContext.getServerRuntimeContext(), true, sessionContext, sessionStateHolder);
        return initialPresence;
    }
View Full Code Here

                sessionContext.getXMLLang(), "could not process incoming stanza", receivedStanza);
        writeErrorAndClose(sessionContext, errorStanza);
    }

    public void handleWrongFromJID(SessionContext sessionContext, Stanza receivedStanza) {
        XMPPCoreStanza receivedCoreStanza = XMPPCoreStanza.getWrapper(receivedStanza);
        if (receivedCoreStanza == null) {
            handleNotAuthorized(sessionContext, receivedStanza);
            return;
        }
View Full Code Here

            stanza = XMPPCoreStanza.getWrapper(stanza);
        }
        if (stanza == null)
            throw new IllegalArgumentException("cannot coerce into a message, iq or presence stanza");

        XMPPCoreStanza coreStanza = (XMPPCoreStanza) stanza;
        Stanza errorStanza = ServerErrorResponses.getInstance().getStanzaError(
                StanzaErrorCondition.SERVICE_UNAVAILABLE, coreStanza, StanzaErrorType.CANCEL,
                "namespace not supported", null, null);
        return new ResponseStanzaContainerImpl(errorStanza);
    }
View Full Code Here

        return true;
    }

    public ResponseStanzaContainer execute(Stanza anyStanza, ServerRuntimeContext serverRuntimeContext,
            boolean isOutboundStanza, SessionContext sessionContext, SessionStateHolder sessionStateHolder) {
        XMPPCoreStanza stanza = XMPPCoreStanza.getWrapper(anyStanza);
        if (stanza == null)
            throw new IllegalArgumentException("can only handle core XMPP stanzas (iq, message, presence)");

        // type="error" is common to all stanza, check here some prerequisites
        Attribute typeAttribute = stanza.getAttribute("type");
        XMPPCoreStanza xmppCoreStanza = XMPPCoreStanza.getWrapper(stanza);
        if (xmppCoreStanza != null && typeAttribute != null) {
            String errorDescription = null;
            String type = typeAttribute.getValue();
            if (IQStanzaType.ERROR.value().equals(type)) {
                // assure, result contains zero or one element
View Full Code Here

        responseStanzaContainer = messageHandler.execute(failureMessageStanza, senderSessionContext
                .getServerRuntimeContext(), true, senderSessionContext, null);
        assertNull(receiverQueue.getNext());
        Stanza rejectionStanza = senderQueue.getNext();
        assertNotNull(rejectionStanza);
        XMPPCoreStanza rejectionCoreStanza = XMPPCoreStanza.getWrapper(rejectionStanza);
        assertEquals("error", rejectionCoreStanza.getType());

    }
View Full Code Here

    public void testUpdatedPresence() throws BindException, EntityFormatException {
        StanzaReceiverRelay receiverRelay = (StanzaReceiverRelay) sessionContext.getServerRuntimeContext()
                .getStanzaRelay();

        // at first, initial presence
        XMPPCoreStanza initialPresence = XMPPCoreStanza.getWrapper(StanzaBuilder.createPresenceStanza(
                initiatingUser.getEntityFQ(), null, null, null, null, null).build());
        handler.executeCore(initialPresence, sessionContext.getServerRuntimeContext(), true, sessionContext);
        assertTrue(0 < receiverRelay.getCountDelivered());
        resetRecordedStanzas(); // purge recorded
        assertTrue(0 == receiverRelay.getCountDelivered());

        // send update now
        final String showValue = "chatty";

        XMPPCoreStanza updatePresence = XMPPCoreStanza.getWrapper(StanzaBuilder.createPresenceStanza(
                initiatingUser.getEntityFQ(), null, null, null, showValue, null).build());
        handler.executeCore(updatePresence, sessionContext.getServerRuntimeContext(), true, sessionContext);
        // check resource state
        assertEquals(ResourceState.AVAILABLE, getResourceState());
View Full Code Here

        requestSubscribeToUnrelated_Outbound();
        assertStanzasDeliveredAndRelayed(0);

        // now entity 'unrelated' approves the subscription

        XMPPCoreStanza requestApproval = XMPPCoreStanza.getWrapper(StanzaBuilder.createPresenceStanza(
                unrelatedUser.getEntityFQ(), initiatingUser.getEntity(), null, PresenceStanzaType.SUBSCRIBED, null,
                null).build());
        handler.executeCore(requestApproval, sessionContext.getServerRuntimeContext(), false, sessionContext);

        // 3 roster pushes but...
View Full Code Here

    private void requestSubscribeToUnrelated_Outbound() {
        setResourceState(initiatingUser.getBoundResourceId(), ResourceState.AVAILABLE_INTERESTED);

        // SUBSCRIBE FROM
        XMPPCoreStanza initialPresence = XMPPCoreStanza.getWrapper(StanzaBuilder
                .createPresenceStanza(initiatingUser.getEntityFQ(), unrelatedUser.getEntity(), null,
                        PresenceStanzaType.SUBSCRIBE, null, null).build());

        handler.executeCore(initialPresence, sessionContext.getServerRuntimeContext(), true, sessionContext);
        assertEquals(ResourceState.AVAILABLE_INTERESTED, getResourceState());
View Full Code Here

    public void testWithFROM() throws BindException, EntityFormatException {

        setResourceState(initiatingUser.getBoundResourceId(), ResourceState.AVAILABLE_INTERESTED);

        // SUBSCRIBE FROM
        XMPPCoreStanza initialPresence = XMPPCoreStanza.getWrapper(StanzaBuilder.createPresenceStanza(
                initiatingUser.getEntityFQ(), subscribed_FROM.getEntity(), null, PresenceStanzaType.SUBSCRIBE, null,
                null).build());

        handler.executeCore(initialPresence, sessionContext.getServerRuntimeContext(), true, sessionContext);
        assertEquals(ResourceState.AVAILABLE_INTERESTED, getResourceState());
View Full Code Here

TOP

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

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.