Package com.google.code.yanf4j.nio

Examples of com.google.code.yanf4j.nio.NioSession.onEvent()


    @Test
    public void testRegisterOpenSession() throws Exception {
        IMocksControl control = EasyMock.createControl();
        NioSession session = control.createMock(NioSession.class);
        session.onEvent(EventType.ENABLE_READ, this.reactor.getSelector());
        EasyMock.expectLastCall();
        EasyMock.expect(session.isClosed()).andReturn(false);

        control.replay();
        this.reactor.registerSession(session, EventType.ENABLE_READ);
View Full Code Here


        key.attach(session);
        // �ж�session�Ƿ���ڣ�����Ϊ����
        EasyMock.expect(session.isExpired()).andReturn(true);
        // ���ھͻ����onSessionExpired�����ر�����
        // ͬʱ��expired��session�����ж�idle
        session.onEvent(EventType.EXPIRED, this.reactor.getSelector());
        EasyMock.expectLastCall();
        session.close();
        EasyMock.expectLastCall();

        allKeys.add(key);
View Full Code Here

        // �ж�session�Ƿ���ڣ�������
        EasyMock.expect(session.isExpired()).andReturn(false);
        // �����ھͻ��ж�session�Ƿ�idle������idleΪ��
        EasyMock.expect(session.isIdle()).andReturn(true);
        // ���idle����Ϊ�棬��ô�����onSessionIdle
        session.onEvent(EventType.IDLE, this.reactor.getSelector());
        EasyMock.expectLastCall();

        allKeys.add(key);
    }
View Full Code Here

    private void addReadableKey(Set<SelectionKey> keySet, IMocksControl control, Selector selector) {
        MockSelectionKey key = new MockSelectionKey();
        key.interestOps = SelectionKey.OP_READ;
        NioSession session = control.createMock(NioSession.class);
        session.onEvent(EventType.READABLE, selector);
        EasyMock.expectLastCall();
        key.attach(session);
        key.selector = selector;
        keySet.add(key);
    }
View Full Code Here

    private void addWritableKey(Set<SelectionKey> keySet, IMocksControl control, Selector selector) {
        MockSelectionKey key = new MockSelectionKey();
        key.interestOps = SelectionKey.OP_WRITE;
        NioSession session = control.createMock(NioSession.class);
        session.onEvent(EventType.WRITEABLE, selector);
        EasyMock.expectLastCall();
        key.attach(session);
        key.selector = selector;
        keySet.add(key);
    }
View Full Code Here

        IMocksControl control = EasyMock.createControl();
        NioSession session = control.createMock(NioSession.class);
        EasyMock.makeThreadSafe(session, true);
        // next reactor��index=2
        Reactor nextReactor = this.selectorManager.getReactorByIndex(2);
        session.onEvent(EventType.ENABLE_READ, nextReactor.getSelector());
        EasyMock.expectLastCall();
        EasyMock.expect(session.isClosed()).andReturn(false).times(2);
        EasyMock.expect(session.getAttribute(SelectorManager.REACTOR_ATTRIBUTE)).andReturn(null);
        EasyMock.expect(session.setAttributeIfAbsent(SelectorManager.REACTOR_ATTRIBUTE, nextReactor)).andReturn(null);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.