Source:
<code>public void testClientHandshakeTimeout() throws Exception { EmbeddedChannel serverChannel = createServerChannel(new SimpleChannelInboundHandler<Object>() { @Override public void userEventTriggered(ChannelHandlerContext ctx, Object evt) { if (evt == ServerHandshakeStateEvent.HANDSHAKE_COMPLETE) { serverReceivedHandshake = true; ctx.writeAndFlush(new TextWebSocketFrame("abc")); } else if (evt instanceof WebSocketServerProtocolHandler.HandshakeComplete) { serverHandshakeComplete = (WebSocketServerProtocolHandler.HandshakeComplete) evt; } } @Override protected void channelRead0(ChannelHandlerContext ctx, Object msg) throws Exception { } }); EmbeddedChannel clientChannel = createClientChannel(new SimpleChannelInboundHandler<Object>() { @Override public void userEventTriggered(ChannelHandlerContext ctx, Object evt) { if (evt == ClientHandshakeStateEvent.HANDSHAKE_COMPLETE) { clientReceivedHandshake = true; } if (evt == ClientHandshakeStateEvent.HANDSHAKE_TIMEOUT) { clientHandshakeTimeout = true; } } @Override protected void channelRead0(ChannelHandlerContext ctx, Object msg) throws Exception { if (msg instanceof TextWebSocketFrame) { clientReceivedMessage = true; } } }, 100); transferAllDataWithMerge(clientChannel, serverChannel); WebSocketClientProtocolHandshakeHandler handshakeHandler = (WebSocketClientProtocolHandshakeHandler) clientChannel .pipeline().get(WebSocketClientProtocolHandshakeHandler.class.getName()); while (!handshakeHandler.getHandshakeFuture().isDone()) { Thread.sleep(10); <START> clientChannel.runScheduledPendingTasks(); <END> } assertTrue(clientHandshakeTimeout); assertFalse(clientReceivedHandshake); assertFalse(clientReceivedMessage); try { handshakeHandler.getHandshakeFuture().syncUninterruptibly(); } finally { cleanChannelData(serverChannel); } }</code><technical_language>this else if</technical_language>

Target:
public void testClientHandshakeTimeout() throws Exception { EmbeddedChannel serverChannel = createServerChannel(new SimpleChannelInboundHandler<Object>() { @Override public void userEventTriggered(ChannelHandlerContext ctx, Object evt) { if (evt == ServerHandshakeStateEvent.HANDSHAKE_COMPLETE) { serverReceivedHandshake = true; ctx.writeAndFlush(new TextWebSocketFrame("abc")); } else if (evt instanceof WebSocketServerProtocolHandler.HandshakeComplete) { serverHandshakeComplete = (WebSocketServerProtocolHandler.HandshakeComplete) evt; } } @Override protected void channelRead0(ChannelHandlerContext ctx, Object msg) throws Exception { } }); EmbeddedChannel clientChannel = createClientChannel(new SimpleChannelInboundHandler<Object>() { @Override public void userEventTriggered(ChannelHandlerContext ctx, Object evt) { if (evt == ClientHandshakeStateEvent.HANDSHAKE_COMPLETE) { clientReceivedHandshake = true; } else if (evt == ClientHandshakeStateEvent.HANDSHAKE_TIMEOUT) { clientHandshakeTimeout = true; } } @Override protected void channelRead0(ChannelHandlerContext ctx, Object msg) throws Exception { if (msg instanceof TextWebSocketFrame) { clientReceivedMessage = true; } } }, 100); transferAllDataWithMerge(clientChannel, serverChannel); WebSocketClientProtocolHandshakeHandler handshakeHandler = (WebSocketClientProtocolHandshakeHandler) clientChannel .pipeline().get(WebSocketClientProtocolHandshakeHandler.class.getName()); while (!handshakeHandler.getHandshakeFuture().isDone()) { Thread.sleep(10); clientChannel.runScheduledPendingTasks(); } assertTrue(clientHandshakeTimeout); assertFalse(clientReceivedHandshake); assertFalse(clientReceivedMessage); try { handshakeHandler.getHandshakeFuture().syncUninterruptibly(); } finally { serverChannel.finishAndReleaseAll(); } }