Examples of NioSession


Examples of com.google.code.hs4j.network.nio.NioSession

  }

  protected NioSession buildSession(SocketChannel sc) {
    Queue<WriteMessage> queue = buildQueue();
    NioSessionConfig sessionConfig = buildSessionConfig(sc, queue);
    NioSession session = new NioTCPSession(sessionConfig,
        this.configuration.getSessionReadBufferSize());
    return session;
  }
View Full Code Here

Examples of com.google.code.yanf4j.nio.NioSession


    @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);
        Thread.sleep(Reactor.DEFAULT_WAIT * 3);
        control.verify();
View Full Code Here

Examples of com.google.code.yanf4j.nio.NioSession


    @Test
    public void testRegisterCloseSession() throws Exception {
        IMocksControl control = EasyMock.createControl();
        NioSession session = control.createMock(NioSession.class);
        EasyMock.expect(session.isClosed()).andReturn(true);
        control.replay();
        this.reactor.registerSession(session, EventType.ENABLE_READ);
        Thread.sleep(Reactor.DEFAULT_WAIT * 3);
        control.verify();
    }
View Full Code Here

Examples of com.google.code.yanf4j.nio.NioSession

    }


    private void addTimeoutKey(IMocksControl mocksControl, Set<SelectionKey> allKeys) {
        MockSelectionKey key = new MockSelectionKey();
        NioSession session = mocksControl.createMock(NioSession.class);
        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

Examples of com.google.code.yanf4j.nio.NioSession

    }


    private void addIdleKey(IMocksControl mocksControl, Set<SelectionKey> allKeys) {
        MockSelectionKey key = new MockSelectionKey();
        NioSession session = mocksControl.createMock(NioSession.class);
        key.attach(session);
        // �ж�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

Examples of com.google.code.yanf4j.nio.NioSession


    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

Examples of com.google.code.yanf4j.nio.NioSession


    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

Examples of com.google.code.yanf4j.nio.NioSession


    @Test
    public void testRegisterOpenSession() throws Exception {
        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);

        control.replay();
        this.selectorManager.registerSession(session, EventType.ENABLE_READ);
        Thread.sleep(Reactor.DEFAULT_WAIT * 3);
        control.verify();
View Full Code Here

Examples of com.google.code.yanf4j.nio.NioSession


    @Test
    public void testRegisterCloseSession() throws Exception {
        IMocksControl control = EasyMock.createControl();
        NioSession session = control.createMock(NioSession.class);
        EasyMock.expect(session.isClosed()).andReturn(true);
        control.replay();
        this.selectorManager.registerSession(session, EventType.ENABLE_READ);
        Thread.sleep(Reactor.DEFAULT_WAIT * 3);
        control.verify();
    }
View Full Code Here

Examples of com.google.code.yanf4j.nio.NioSession

  }

  protected NioSession buildSession(SocketChannel sc) {
    Queue<WriteMessage> queue = buildQueue();
    NioSessionConfig sessionConfig = buildSessionConfig(sc, queue);
    NioSession session = new NioTCPSession(sessionConfig,
        this.configuration.getSessionReadBufferSize());
    return session;
  }
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.