### Question:
GameClient extends IoHandlerAdapter { @Override public void sessionIdle(IoSession session, IdleStatus status) throws Exception { try { resourceLock.lock(); if ( log.isDebugEnabled() ) { log.debug("session has been idle for a while. Send a heartbeat message."); } sendMessageToServer(HEART_BEAT_MSG); Stat.getInstance().messageHearbeatSent++; } 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 testSessionIdle() throws Exception { GlobalConfig.getInstance().overrideProperty("message.heartbeat.second", "1"); GameClient client = new GameClient(host, port); assertTrue(client.connectToServer()); Thread.sleep(2000); assertTrue(Stat.getInstance().messageHearbeatSent>=1); }