JdbcEndpointAdapterController implements JdbcController, EndpointAdapter { @Override public void closeConnection() throws JdbcServerException { if (!endpointConfiguration.isAutoConnect()) { handleMessageAndCheckResponse(JdbcMessage.closeConnection()); } if (connections.decrementAndGet() < 0) { connections.set(0); } } JdbcEndpointAdapterController(
            JdbcEndpointConfiguration endpointConfiguration,
            EndpointAdapter delegate);   JdbcEndpointAdapterController(
            JdbcEndpointConfiguration endpointConfiguration,
            EndpointAdapter delegate,
            DataSetCreator dataSetCreator); @Override Message handleMessage(Message request); @Override void openConnection(Map<String, String> properties); @Override void closeConnection(); @Override void createPreparedStatement(String stmt); @Override void createStatement(); @Override DataSet executeQuery(String query); @Override DataSet executeStatement(String stmt); @Override int executeUpdate(String updateSql); @Override void closeStatement(); @Override void setTransactionState(boolean transactionState); @Override boolean getTransactionState(); @Override void commitStatements(); @Override void rollbackStatements(); @Override void createCallableStatement(String sql); @Override Endpoint getEndpoint(); @Override EndpointConfiguration getEndpointConfiguration();  }
@Test public void testCloseConnection(){ final JdbcEndpointAdapterController jdbcEndpointAdapterController = spy(this.jdbcEndpointAdapterController); when(jdbcEndpointConfiguration.isAutoConnect()).thenReturn(true); jdbcEndpointAdapterController.getConnections().set(1); final int before = jdbcEndpointAdapterController.getConnections().get(); jdbcEndpointAdapterController.closeConnection(); final int after = jdbcEndpointAdapterController.getConnections().get(); verify(jdbcEndpointAdapterController, never()).handleMessage(any()); assertEquals(before -1 , after); }