@Test
public void testInternalReleaseConnectionWhereConnectionIsExpired() throws InterruptedException, SQLException {

    // Test case where connection is expired
    reset(mockConnection, mockPartition, mockConnectionHandles);
    Connection mockRealConnection = EasyMock.createNiceMock(Connection.class);
    expect(mockConnection.getInternalConnection()).andReturn(mockRealConnection).anyTimes();
    // return a partition
    expect(mockConnection.getOriginatingPartition()).andReturn(mockPartition).anyTimes();
    // break out from this method, we're not interested in it
    expect(mockPartition.isUnableToCreateMoreTransactions()).andReturn(true).once();
    expect(mockConnection.isExpired()).andReturn(true).anyTimes();
    mockConnection.internalClose();
    expectLastCall();
    replay(mockPartition, mockConnection, mockRealConnection);
    testClass.internalReleaseConnection(mockConnection);
    verify(mockPartition, mockConnection, mockRealConnection);
}