### Question:
GameClient extends IoHandlerAdapter { public boolean connectToServer() { try { resourceLock.lock(); if ( log.isInfoEnabled() ) { log.info("Connect to message server : " + remoteHost + ":" + remotePort); } connector = new NioSocketConnector(); connector.getFilterChain().addLast("codec", new GameProtocolCodecFilter()); connector.setHandler(this.handler); int heartBeatSecond = GlobalConfig.getInstance().getIntProperty("message.heartbeat.second"); if ( log.isDebugEnabled() ) { log.debug("heartBeatSecond : " + heartBeatSecond); } connector.getSessionConfig().setBothIdleTime(heartBeatSecond); ConnectFuture connectFuture = connector.connect(new InetSocketAddress(remoteHost, remotePort)); connectFuture.awaitUninterruptibly(CONNECT_TIMEOUT); try { session = connectFuture.getSession(); if ( log.isInfoEnabled() ) { log.info("connect to " + remoteHost + ":" + remotePort); } return true; } catch (Throwable e) { disconnectFromServer(); return false; } } finally { resourceLock.unlock(); } } GameClient(String remoteHost, int remotePort);  GameClient(String remoteHost, int remotePort, IoHandler handler); boolean connectToServer(); boolean disconnectFromServer(); @Override void sessionOpened(IoSession session); @Override void sessionClosed(IoSession session); @Override void sessionIdle(IoSession session, IdleStatus status); @Override void exceptionCaught(IoSession session, Throwable cause); @Override void messageReceived(IoSession session, Object message); void sendMessageToServer(XinqiMessage msg); Object getLastMessage(); ArrayList getLastMessages(); void clearLastMessages(); void clearLastMessage(); static final int CONNECT_TIMEOUT; }### Answer:
@Test public void testConnectToServer() { try { GameClient client = new GameClient(host, port); assertTrue(client.connectToServer()); } catch (Exception e) { e.printStackTrace(); } }