/*
 * Copyright 2012 The Netty Project
 *
 * The Netty Project licenses this file to you under the Apache License,
 * version 2.0 (the "License"); you may not use this file except in compliance
 * with the License. You may obtain a copy of the License at:
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations
 * under the License.
 */
package io.netty.channel.nio;

import io.netty.channel.AbstractEventLoopTest;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.socket.ServerSocketChannel;
import io.netty.channel.socket.nio.NioServerSocketChannel;

public class NioEventLoopTest extends AbstractEventLoopTest {

    @Override
    protected EventLoopGroup newEventLoopGroup() {
        return new NioEventLoopGroup();
    }

    @Override
    protected Class<? extends ServerSocketChannel> newChannel() {
        return NioServerSocketChannel.class;
    }
}

@@ -706,16 +706,49 @@
 opTest;%0A
+import io.netty.channel.Channel;%0A
 import i
@@ -779,16 +779,16 @@
 pGroup;%0A
-
 import i
@@ -889,16 +889,110 @@
 Channel;
+%0Aimport org.junit.Test;%0A%0Aimport java.nio.channels.Selector;%0A%0Aimport static org.junit.Assert.*;
 %0A%0Apublic
@@ -1236,24 +1236,24 @@
 Channel() %7B%0A
-
         retu
@@ -1290,11 +1290,1188 @@
 s;%0A    %7D
+%0A%0A    @Test%0A    public void testRebuildSelector() throws Exception %7B%0A        EventLoopGroup group = new NioEventLoopGroup(1);%0A        final NioEventLoop loop = (NioEventLoop) group.next();%0A        try %7B%0A            Channel channel = new NioServerSocketChannel();%0A            loop.register(channel).syncUninterruptibly();%0A%0A            Selector selector = loop.unwrappedSelector();%0A            assertSame(selector, ((NioEventLoop) channel.eventLoop()).unwrappedSelector());%0A            assertTrue(selector.isOpen());%0A%0A            // Submit to the EventLoop so we are sure its really executed in a non-async manner.%0A            loop.submit(new Runnable() %7B%0A                @Override%0A                public void run() %7B%0A                    loop.rebuildSelector();%0A                %7D%0A            %7D).syncUninterruptibly();%0A%0A            Selector newSelector = ((NioEventLoop) channel.eventLoop()).unwrappedSelector();%0A            assertTrue(newSelector.isOpen());%0A            assertNotSame(selector, newSelector);%0A            assertFalse(selector.isOpen());%0A%0A            channel.close().syncUninterruptibly();%0A        %7D finally %7B%0A            group.shutdownGracefully();%0A        %7D%0A    %7D
 %0A%7D%0A

Add testcase to ensure NioEventLoop.rebuildSelector() works correctly.