Package org.apache.vysper.xmpp.stanza

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


        Stanza iqStanza = StanzaBuilder.createIQStanza(initiatingUser.getEntityFQ(), unrelatedUser.getEntityFQ(),
                IQStanzaType.GET, "test").startInnerElement("mandatory", NamespaceURIs.JABBER_CLIENT).build();

        ResponseStanzaContainer stanzaContainer = relayingIQHandler.execute(iqStanza, sessionContext
                .getServerRuntimeContext(), true, sessionContext, null /*don't we have as sessionStateHolder?*/);
        XMPPCoreStanza response = XMPPCoreStanza.getWrapper(stanzaContainer.getResponseStanza());
        assertNotNull(response);
        assertTrue(response.isError());
    }
View Full Code Here


    public void testWithTO() throws BindException, EntityFormatException {

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

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

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

        Stanza iqStanza = StanzaBuilder.createIQStanza(subscribed_FROM.getEntityFQ(), initiatingUser.getEntityFQ(),
                IQStanzaType.GET, "test").startInnerElement("mandatory", NamespaceURIs.JABBER_CLIENT).build();

        ResponseStanzaContainer stanzaContainer = relayingIQHandler.execute(iqStanza, sessionContext
                .getServerRuntimeContext(), false, sessionContext, null /*don't we have as sessionStateHolder?*/);
        XMPPCoreStanza response = XMPPCoreStanza.getWrapper(stanzaContainer.getResponseStanza());
        assertNotNull(response);
        assertTrue(response.isError());
    }
View Full Code Here

    public void testWithBOTH() throws BindException, EntityFormatException {

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

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

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

        StanzaReceiverRelay receiverRelay = (StanzaReceiverRelay) sessionContext.getServerRuntimeContext()
                .getStanzaRelay();
        setResourceState(initiatingUser.getBoundResourceId(), ResourceState.AVAILABLE_INTERESTED);

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

        // directed presence has been recorded internally
        Set<Entity> map = (Set<Entity>) sessionContext.getAttribute("DIRECTED_PRESENCE_MAP_"
                + initiatingUser.getBoundResourceId());
        assertNotNull(map);
        assertEquals(map.iterator().next(), unrelatedUser.getEntityFQ());

        Stanza directedPresence = unrelatedUser.getNextStanza();
        assertNotNull(directedPresence);
        assertTrue(PresenceStanza.isOfType(directedPresence)); // is presence
        PresenceStanza presenceStanza = new PresenceStanza(directedPresence);
        assertEquals(initiatingUser.getEntityFQ(), presenceStanza.getFrom());

        resetRecordedStanzas(); // purge recorded

        // directed unavailable presence
        XMPPCoreStanza directedUnvailPresence = XMPPCoreStanza.getWrapper(StanzaBuilder.createPresenceStanza(
                initiatingUser.getEntityFQ(), unrelatedUser.getEntityFQ(), null, PresenceStanzaType.UNAVAILABLE, null,
                null).build());
        handler.executeCore(directedUnvailPresence, sessionContext.getServerRuntimeContext(), true, sessionContext);
        assertTrue(0 < receiverRelay.getCountDelivered());
View Full Code Here

        StanzaReceiverRelay receiverRelay = (StanzaReceiverRelay) sessionContext.getServerRuntimeContext()
                .getStanzaRelay();
        setResourceState(initiatingUser.getBoundResourceId(), ResourceState.AVAILABLE_INTERESTED);

        // at first, initial presence
        XMPPCoreStanza initialPresence = XMPPCoreStanza.getWrapper(StanzaBuilder.createPresenceStanza(
                initiatingUser.getEntityFQ(), unrelatedUser.getEntityFQ(), null, null, null, null).build());
        handler.executeCore(initialPresence, sessionContext.getServerRuntimeContext(), true, sessionContext);

        // directed presence has been recorded internally
        Set<Entity> map = (Set<Entity>) sessionContext.getAttribute("DIRECTED_PRESENCE_MAP_"
                + initiatingUser.getBoundResourceId());
        assertEquals(map.iterator().next(), unrelatedUser.getEntityFQ());

        resetRecordedStanzas(); // purge recorded

        // GENERAL unavailable presence
        XMPPCoreStanza generalUnavailable = XMPPCoreStanza.getWrapper(StanzaBuilder.createPresenceStanza(
                initiatingUser.getEntityFQ(), null, null, PresenceStanzaType.UNAVAILABLE, null, null).build());
        handler.executeCore(generalUnavailable, sessionContext.getServerRuntimeContext(), true, sessionContext);
        assertTrue(0 < receiverRelay.getCountDelivered());
        ResourceState resourceState = sessionContext.getServerRuntimeContext().getResourceRegistry().getResourceState(
                initiatingUser.getBoundResourceId());
View Full Code Here

public class PresenceAvailInitialOutHandlerTestCase extends PresenceHandlerBaseTestCase {

    protected PresenceHandler handler = new PresenceHandler();

    public void testInitialPresence() throws BindException, EntityFormatException {
        XMPPCoreStanza initialPresence = XMPPCoreStanza.getWrapper(StanzaBuilder.createPresenceStanza(
                initiatingUser.getEntityFQ(), null, null, null, null, null).build());

        assertEquals(ResourceState.CONNECTED, getResourceState());
        handler.executeCore(initialPresence, sessionContext.getServerRuntimeContext(), true, sessionContext);
        // check resource state change, do not override interested
View Full Code Here

    }

    public void testInitialPresenceWithoutFrom() throws BindException, EntityFormatException, XMLSemanticError {
        // after setUp(), there is more than one bound resource
        // so, if leaving from == null, the handler will not know from which resource the presence really comes...
        XMPPCoreStanza initialPresence = XMPPCoreStanza.getWrapper(StanzaBuilder.createPresenceStanza(null, null, null,
                null, null, null).build());

        Stanza stanza = handler.executeCore(initialPresence, sessionContext.getServerRuntimeContext(), true,
                sessionContext);
        // ... and will give an error:
View Full Code Here

     *
     * @param user  User whose Presence Information is to be created
     * @return  Presence Information of the User
     */
    protected PresenceStanza getPresenceStanza(TestUser user) {
        XMPPCoreStanza initialPresence = XMPPCoreStanza.getWrapper(StanzaBuilder.createPresenceStanza(
                user.getEntityFQ(), null, null, null, null, null).build());
        return (PresenceStanza) initialPresence;
    }
View Full Code Here

        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

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.