### Question:
IdleAwareSocketWrapper extends SocketWrapper { public boolean hasData(long inactiveClientTimeOut) throws IOException { if (isClosed()) { throw new IOException("Socket is closed"); } final InputStream inputStream = getInputStream(); synchronized (inputStream) { if (inputStream.available() > 0) { m_idleStart = -1; return true; } final long now = m_timeAuthority.getTimeInMilliseconds(); if (m_idleStart == -1) { m_idleStart = now; } else if (m_idleStart + inactiveClientTimeOut < now) { close(); } return false; } } IdleAwareSocketWrapper(Socket socket,
                                TimeAuthority timeAuthority); boolean hasData(long inactiveClientTimeOut);  }### Answer:
@Test public void testHasDataNoData() throws Exception { final IdleAwareSocketWrapper socketWrapper = new IdleAwareSocketWrapper(m_socket, m_timeAuthority); assertFalse(socketWrapper.hasData(99)); }
@Test(expected = IOException.class) public void testHasDataSocketClosed() throws Exception { final IdleAwareSocketWrapper socketWrapper = new IdleAwareSocketWrapper(m_socket, m_timeAuthority); socketWrapper.close(); socketWrapper.hasData(99); }
@Test public void testHasDataTimeOut() throws Exception { final IdleAwareSocketWrapper socketWrapper = new IdleAwareSocketWrapper(m_socket, m_timeAuthority); when(m_timeAuthority.getTimeInMilliseconds()) .thenReturn(1000L) .thenReturn(2000L); assertFalse(socketWrapper.hasData(123)); assertFalse(m_socket.isClosed()); assertFalse(socketWrapper.hasData(123)); assertTrue(m_socket.isClosed()); }