Package com.google.code.yanf4j.nio.impl

Examples of com.google.code.yanf4j.nio.impl.Reactor


    @Test
    public void testNextReactor() {
        long start = System.currentTimeMillis();
        for (int i = 0; i < 10000; i++) {
            Reactor reactor = this.selectorManager.nextReactor();
            Assert.assertNotNull(reactor);
            Assert.assertTrue(reactor.getReactorIndex() > 0);
        }
        System.out.println(System.currentTimeMillis() - start);
    }
View Full Code Here


    @Test
    public void testRegisterOpenChannel() throws Exception {
        MockSelectableChannel channel = new MockSelectableChannel();
        channel.selectionKey = new MockSelectionKey();
        Reactor reactor = this.selectorManager.registerChannel(channel, 1, "hello");
        Thread.sleep(Reactor.DEFAULT_WAIT * 3);
        Assert.assertSame(reactor.getSelector(), channel.selector);
        Assert.assertSame(reactor.getSelector(), channel.selectionKey.selector);
        Assert.assertEquals(1, channel.ops);
        Assert.assertEquals("hello", channel.attch);
    }
View Full Code Here

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

TOP

Related Classes of com.google.code.yanf4j.nio.impl.Reactor

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.