### Question:
ImapConnection { public void close() { open = false; stacktraceForClose = new Exception(); untagQuietly(socket); IOUtils.closeQuietly(inputStream); IOUtils.closeQuietly(outputStream); IOUtils.closeQuietly(socket); inputStream = null; outputStream = null; socket = null; } ImapConnection(ImapSettings settings, TrustedSocketFactory socketFactory,
            ConnectivityManager connectivityManager, OAuth2TokenProvider oauthTokenProvider);   ImapConnection(ImapSettings settings, TrustedSocketFactory socketFactory,
            ConnectivityManager connectivityManager, OAuth2TokenProvider oauthTokenProvider,
            int socketConnectTimeout, int socketReadTimeout); void open(); boolean isConnected(); void close(); OutputStream getOutputStream(); List<ImapResponse> executeSimpleCommand(String command); List<ImapResponse> executeSimpleCommand(String command, boolean sensitive); List<ImapResponse> readStatusResponse(String tag, String commandToLog, UntaggedHandler untaggedHandler); String sendSaslIrCommand(String command, String initialClientResponse, boolean sensitive); String sendCommand(String command, boolean sensitive); void sendContinuation(String continuation); ImapResponse readResponse(); ImapResponse readResponse(ImapResponseCallback callback);  }### Answer:
@Test public void close_withoutOpen_shouldNotThrow() throws Exception { ImapConnection imapConnection = createImapConnection( settings, socketFactory, connectivityManager, oAuth2TokenProvider); imapConnection.close(); }
@Test public void close_afterOpen_shouldCloseConnection() throws Exception { MockImapServer server = new MockImapServer(); ImapConnection imapConnection = simpleOpen(server); imapConnection.close(); server.verifyConnectionClosed(); server.shutdown(); }