### Question:
ClientHandler extends Connection { @Override public void shutdown() { if (getUser() != null) { try { server.getAuthenticator().logOutUser(user.getUsername()); } catch (LoginException e) { LOGGER.log(Level.WARNING, "Unable to perform emergency logout.", e); } } getServer().removeClient(this); } ClientHandler(AuthServer s, MessageIO messageIO); void setHandlerId(int id); void update(); @Override void shutdown(); ServerMessageFactory getMessageFactory(); AuthServer getServer(); void sendLogoutStatus(boolean success); long getLoggedInTime(); void setLoggedInTime(long loggedInTime); int getHandlerId(); User getUser(); void setUser(User user);  }### Answer:
@Test public void testShutDown() throws Exception { Authenticator authenticator = mock(Authenticator.class); User user = mock(User.class); AuthServer server = mock(AuthServer.class); MessageInputStream mis = mock(MessageInputStream.class); MessageOutputStream mos = mock(MessageOutputStream.class); MessageIO messageIO = new MessageIO(mis, mos); when(server.getAuthenticator()).thenReturn(authenticator); ClientHandler clientHandler = new ClientHandler(server, messageIO); clientHandler.setUser(user); clientHandler.shutdown(); verify(authenticator).logOutUser(anyString()); verify(server).removeClient(clientHandler); }