JDBCCertRecordStoreConnection implements CertRecordStoreConnection { @Override public void close() { if (con == null) { return; } try { con.close(); con = null; } catch (SQLException ex) { LOGGER.error("Failed to close connection: state - {}, code - {}, message - {}", ex.getSQLState(), ex.getErrorCode(), ex.getMessage()); } } JDBCCertRecordStoreConnection(Connection con); @Override void setOperationTimeout(int queryTimeout); @Override void close(); @Override X509CertRecord getX509CertRecord(String provider, String instanceId, String service); @Override boolean updateX509CertRecord(X509CertRecord certRecord); @Override boolean insertX509CertRecord(X509CertRecord certRecord); @Override boolean deleteX509CertRecord(String provider, String instanceId, String service); @Override int deleteExpiredX509CertRecords(int expiryTimeMins); @Override List<X509CertRecord> updateUnrefreshedCertificatesNotificationTimestamp(String lastNotifiedServer,
                                                                      long lastNotifiedTime,
                                                                      String provider); static final String DB_COLUMN_INSTANCE_ID; static final String DB_COLUMN_INSTANCE_PROVIDER; static final String DB_COLUMN_SERVICE; static final String DB_COLUMN_CURRENT_IP; static final String DB_COLUMN_CURRENT_SERIAL; static final String DB_COLUMN_CURRENT_TIME; static final String DB_COLUMN_PREV_IP; static final String DB_COLUMN_PREV_SERIAL; static final String DB_COLUMN_PREV_TIME; static final String DB_COLUMN_CLIENT_CERT; static final String DB_COLUMN_LAST_NOTIFIED_TIME; static final String DB_COLUMN_LAST_NOTIFIED_SERVER; static final String DB_COLUMN_EXPIRY_TIME; static final String DB_COLUMN_HOSTNAME; }
@Test public void testConnectionNullClose() throws SQLException { JDBCCertRecordStoreConnection jdbcConn = new JDBCCertRecordStoreConnection(mockConn); jdbcConn.con = null; jdbcConn.close(); }
@Test public void testConnectionCloseException() throws SQLException { Mockito.doThrow(new SQLException()).when(mockConn).close(); JDBCCertRecordStoreConnection jdbcConn = new JDBCCertRecordStoreConnection(mockConn); jdbcConn.close(); }