Package org.apache.vysper.xmpp.delivery

Examples of org.apache.vysper.xmpp.delivery.StanzaReceiverRelay


     * @param serverContext
     * @return
     */
    public static TestSessionContext createWithStanzaReceiverRelay(SessionStateHolder sessionStateHolder,
            ServerRuntimeContext serverContext) {
        StanzaReceiverRelay relay = (StanzaReceiverRelay) serverContext.getStanzaRelay();
        relay.setServerRuntimeContext(serverContext);
        return new TestSessionContext(serverContext, sessionStateHolder);
    }
View Full Code Here


        return true;
    }

    protected void resetRecordedStanzas() {
        StanzaReceiverRelay receiverRelay = (StanzaReceiverRelay) sessionContext.getServerRuntimeContext()
                .getStanzaRelay();
        receiverRelay.resetAll();
    }
View Full Code Here

    public void testStanzaReceiverUnavailable() throws EntityFormatException, DeliveryException {
        Entity sender = EntityImpl.parse("from@example.com/resID");
        Entity receiver = EntityImpl.parse("to_exist@example.com");
        Entity noReceiver = EntityImpl.parse("to_unavail@example.com");

        StanzaReceiverRelay stanzaRelay = (StanzaReceiverRelay) senderSessionContext.getServerRuntimeContext()
                .getStanzaRelay();
        StanzaReceiverQueue senderQueue = new StanzaReceiverQueue();
        StanzaReceiverQueue receiverQueue = new StanzaReceiverQueue();
        stanzaRelay.add(sender, senderQueue);
        stanzaRelay.add(receiver, receiverQueue);

        Stanza successfulMessageStanza = StanzaBuilder.createMessageStanza(sender, receiver, "en", "info").build();
        ResponseStanzaContainer responseStanzaContainer = messageHandler.execute(successfulMessageStanza,
                senderSessionContext.getServerRuntimeContext(), true, senderSessionContext, null);
        assertEquals(successfulMessageStanza, receiverQueue.getNext());
View Full Code Here

public class PresenceAvailUpdateOutHandlerTestCase extends PresenceHandlerBaseTestCase {

    protected PresenceHandler handler = new PresenceHandler();

    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(
View Full Code Here

public class DirectedPresenceHandlerTestCase extends PresenceHandlerBaseTestCase {

    protected PresenceHandler handler = new PresenceHandler();

    public void testUpdatedPresence() throws BindException, EntityFormatException {
        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());

        // directed presence has been recorded internally
        map = (Set<Entity>) sessionContext.getAttribute("DIRECTED_PRESENCE_MAP_" + initiatingUser.getBoundResourceId());
        assertTrue(map.size() == 0);
        ResourceState resourceState = sessionContext.getServerRuntimeContext().getResourceRegistry().getResourceState(
View Full Code Here

        assertEquals(PresenceStanzaType.UNAVAILABLE, presenceStanza.getPresenceType());

    }

    public void testUnavailableForDirectedPresences() throws BindException, EntityFormatException {
        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());
        assertFalse(ResourceState.isAvailable(resourceState));

        // directed presence has been recorded internally
View Full Code Here

    protected void setUp() throws Exception {
        super.setUp();

        protocolWorker = new ProtocolWorker();
        namespaceHandlerDictionary = new NamespaceHandlerDictionary("testNSURI");
        StanzaReceiverRelay receiverRelay = new StanzaReceiverRelay();
        serverRuntimeContext = new DefaultServerRuntimeContext(serverEnitity, receiverRelay);
        receiverRelay.setServerRuntimeContext(serverRuntimeContext);
        serverRuntimeContext.addDictionary(namespaceHandlerDictionary);
        sessionStateHolder = new SessionStateHolder();
        sessionContext = new TestSessionContext(serverRuntimeContext, sessionStateHolder);
    }
View Full Code Here

        super.setUp();

        protocolWorker = new ProtocolWorker();
        sessionStateHolder = new SessionStateHolder();
        Entity serverEnitity = new EntityImpl(null, "vysper-server.org", null);
        StanzaReceiverRelay receiverRelay = new StanzaReceiverRelay();
        DefaultServerRuntimeContext serverRuntimeContext = new DefaultServerRuntimeContext(serverEnitity, receiverRelay);
        receiverRelay.setServerRuntimeContext(serverRuntimeContext);
        serverRuntimeContext.addDictionary(new BaseStreamStanzaDictionary());
        sessionStateHolder = new SessionStateHolder();
        sessionContext = new TestSessionContext(serverRuntimeContext, sessionStateHolder);
    }
View Full Code Here

    @Override
    protected void setUp() throws Exception {
        super.setUp();

        protocolWorker = new ProtocolWorker();
        StanzaReceiverRelay receiverRelay = new StanzaReceiverRelay();
        serverRuntimeContext = new DefaultServerRuntimeContext(serverEnitity, receiverRelay);
        receiverRelay.setServerRuntimeContext(serverRuntimeContext);
        serverRuntimeContext.addDictionary(new BaseStreamStanzaDictionary());
        sessionStateHolder = new SessionStateHolder();
        sessionContext = new TestSessionContext(serverRuntimeContext, sessionStateHolder);
        sessionContext.setSessionState(getDefaultState());
    }
View Full Code Here

     * creates a session and also creates a fresh runtime context for it
     * @param sessionStateHolder
     * @return
     */
    public static TestSessionContext createWithStanzaReceiverRelay(SessionStateHolder sessionStateHolder) {
        StanzaReceiverRelay relay = new org.apache.vysper.xmpp.delivery.StanzaReceiverRelay();
        DefaultServerRuntimeContext serverContext = new DefaultServerRuntimeContext(new EntityImpl(null, "test", null),
                relay);
        relay.setServerRuntimeContext(serverContext);
        return new TestSessionContext(serverContext, sessionStateHolder);
    }
View Full Code Here

TOP

Related Classes of org.apache.vysper.xmpp.delivery.StanzaReceiverRelay

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.