ConnectionHandle implements Connection,Serializable { public void refreshConnection() throws SQLException{ this.connection.close(); try{ this.connection = this.pool.obtainRawInternalConnection(); } catch(SQLException e){ throw markPossiblyBroken(e); } } protected  ConnectionHandle(Connection connection, ConnectionPartition partition, BoneCP pool, boolean recreating); private  ConnectionHandle(); ConnectionHandle recreateConnectionHandle(); void sendInitSQL(); void clearWarnings(); void close(); void commit(); Properties getClientInfo(); String getClientInfo(String name); boolean isValid(int timeout); boolean isWrapperFor(Class<?> iface); T unwrap(Class<T> iface); void setClientInfo(Properties properties); void setClientInfo(String name, String value); Struct createStruct(String typeName, Object[] attributes); Array createArrayOf(String typeName, Object[] elements); Blob createBlob(); Clob createClob(); NClob createNClob(); SQLXML createSQLXML(); void setSchema(String schema); String getSchema(); void abort(Executor executor); void setNetworkTimeout(Executor executor, int milliseconds); int getNetworkTimeout(); Statement createStatement(); Statement createStatement(int resultSetType, int resultSetConcurrency); Statement createStatement(int resultSetType,
			int resultSetConcurrency, int resultSetHoldability); boolean getAutoCommit(); String getCatalog(); int getHoldability(); DatabaseMetaData getMetaData(); int getTransactionIsolation(); Map<String, Class<?>> getTypeMap(); SQLWarning getWarnings(); boolean isClosed(); boolean isReadOnly(); String nativeSQL(String sql); CallableStatement prepareCall(String sql); CallableStatement prepareCall(String sql, int resultSetType,	int resultSetConcurrency); CallableStatement prepareCall(String sql, int resultSetType,
			int resultSetConcurrency, int resultSetHoldability); PreparedStatement prepareStatement(String sql); PreparedStatement prepareStatement(String sql, int autoGeneratedKeys); PreparedStatement prepareStatement(String sql, int[] columnIndexes); PreparedStatement prepareStatement(String sql, String[] columnNames); PreparedStatement prepareStatement(String sql, int resultSetType,  int resultSetConcurrency); PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability); void releaseSavepoint(Savepoint savepoint); void rollback(); void rollback(Savepoint savepoint); void setAutoCommit(boolean autoCommit); void setCatalog(String catalog); void setHoldability(int holdability); void setReadOnly(boolean readOnly); Savepoint setSavepoint(); Savepoint setSavepoint(String name); void setTransactionIsolation(int level); void setTypeMap(Map<String, Class<?>> map); long getConnectionLastUsedInMs(); @Deprecated long getConnectionLastUsed(); long getConnectionLastResetInMs(); @Deprecated long getConnectionLastReset(); boolean isPossiblyBroken(); ConnectionPartition getOriginatingPartition(); Object getDebugHandle(); void setDebugHandle(Object debugHandle); @Deprecated Connection getRawConnection(); Connection getInternalConnection(); ConnectionHook getConnectionHook(); boolean isLogStatementsEnabled(); void setLogStatementsEnabled(boolean logStatementsEnabled); boolean isConnectionAlive(); void setInternalConnection(Connection rawConnection); BoneCP getPool(); List<ReplayLog> getReplayLog(); Object getProxyTarget(); Thread getThreadUsingConnection(); @Deprecated long getConnectionCreationTime(); long getConnectionCreationTimeInMs(); boolean isExpired(); Thread getThreadWatch(); void refreshConnection(); String getUrl(); String toString();  }
@Test public void testRefreshConnection() throws SQLException{ Connection mockInternalConnection = createNiceMock(Connection.class); this.testClass.connection = mockInternalConnection; mockInternalConnection.close(); expectLastCall().once(); replay(mockInternalConnection); this.testClass.refreshConnection(); assertNotSame(mockInternalConnection, this.testClass.getInternalConnection()); verify(mockInternalConnection); this.testClass.connection = mockInternalConnection; reset(this.mockPool, mockInternalConnection); mockInternalConnection.close(); expectLastCall().once(); expect(this.mockPool.obtainRawInternalConnection()).andThrow(new SQLException("foo", "1234")).once(); replay(this.mockPool, mockInternalConnection); try{ this.testClass.refreshConnection(); fail("Should throw exception"); } catch(SQLException e){ } }