Fix a bug where DefaultChannelPipelineTest.testFireChannelRegistered() triggers channelRegistered() twice

This commit is contained in:
Trustin Lee 2014-01-13 23:25:32 +09:00
parent 1a54ff843c
commit 9c1b9492d5

View File

@ -189,8 +189,9 @@ public class DefaultChannelPipelineTest {
@Test @Test
public void testFireChannelRegistered() throws Exception { public void testFireChannelRegistered() throws Exception {
ChannelPipeline pipeline = new LocalChannel(group.next()).pipeline();
final CountDownLatch latch = new CountDownLatch(1); final CountDownLatch latch = new CountDownLatch(1);
Channel ch = new LocalChannel(group.next());
ChannelPipeline pipeline = ch.pipeline();
pipeline.addLast(new ChannelInitializer<Channel>() { pipeline.addLast(new ChannelInitializer<Channel>() {
@Override @Override
protected void initChannel(Channel ch) throws Exception { protected void initChannel(Channel ch) throws Exception {
@ -202,7 +203,7 @@ public class DefaultChannelPipelineTest {
}); });
} }
}); });
pipeline.fireChannelRegistered(); ch.unsafe().register(ch.newPromise());
assertTrue(latch.await(2, TimeUnit.SECONDS)); assertTrue(latch.await(2, TimeUnit.SECONDS));
} }