Program: 127251
Project: 127251
Buggy source:
/** 
 * DOC ggu Comment method "testReturnColumns4reCreateConnection". test when the dontCreateClose is true
 * @throws Exception
 */
@Test public void testReturnColumns4reCreateConnection() throws Exception {
  Assert.assertNotNull(getExtractManger());
  Connection conn=mockConnection4ReturnColumns4reCreateConnection();
  extractMeta.setConn(conn);
  IMetadataConnection metadataConn=mockMetadataConnection4ReturnColumns4reCreateConnection();
  DatabaseMetaData dbMetadata=mockDatabaseMetaData4ReturnColumns4reCreateConnection();
  when(conn.getMetaData()).thenReturn(dbMetadata);
  ResultSet getColumnsResultSet=mockGetColumnsResultSet4ReturnColumns4reCreateConnection();
  doReturn(getColumnsResultSet).when(dbMetadata).getColumns(anyString(),anyString(),anyString(),anyString());
  TableNode tableNode=mockTableNode4ReturnColumns4reCreateConnection();
  TdTable tdTable=mockTable4ReturnColumns4reCreateConnection();
  when(tableNode.getTable()).thenReturn(tdTable);
  List conList=new ArrayList();
  conList.add(conn);
  DriverShim wapperDriver=mock(DriverShim.class);
  conList.add(wapperDriver);
  when(extractMeta.getConnection(anyString(),anyString(),anyString(),anyString(),anyString(),anyString(),anyString(),anyString(),anyString(),anyString())).thenReturn(conList);
  when(extractMeta.getDatabaseMetaData(conn,metadataConn.getDbType(),metadataConn.isSqlMode(),metadataConn.getDatabase())).thenReturn(dbMetadata);
  List<TdColumn> columns=getExtractManger().returnColumns(metadataConn,tableNode,false);
  Assert.assertNotNull(columns);
  Assert.assertTrue(columns.isEmpty());
  extractMeta.setConn(null);
}

Fixed version (ground truth):
/** 
 * DOC ggu Comment method "testReturnColumns4reCreateConnection". test when the dontCreateClose is true
 * @throws Exception
 */
@Test public void testReturnColumns4reCreateConnection() throws Exception {
  Assert.assertNotNull(getExtractManger());
  Connection conn=mockConnection4ReturnColumns4reCreateConnection();
  extractMeta.setConn(conn);
  extractMeta.setReconnect(false);
  IMetadataConnection metadataConn=mockMetadataConnection4ReturnColumns4reCreateConnection();
  DatabaseMetaData dbMetadata=mockDatabaseMetaData4ReturnColumns4reCreateConnection();
  when(conn.getMetaData()).thenReturn(dbMetadata);
  ResultSet getColumnsResultSet=mockGetColumnsResultSet4ReturnColumns4reCreateConnection();
  doReturn(getColumnsResultSet).when(dbMetadata).getColumns(anyString(),anyString(),anyString(),anyString());
  TableNode tableNode=mockTableNode4ReturnColumns4reCreateConnection();
  TdTable tdTable=mockTable4ReturnColumns4reCreateConnection();
  when(tableNode.getTable()).thenReturn(tdTable);
  List list=extractMeta.getConnection(metadataConn.getDbType(),metadataConn.getUrl(),metadataConn.getUsername(),metadataConn.getPassword(),metadataConn.getDatabase(),metadataConn.getSchema(),metadataConn.getDriverClass(),metadataConn.getDriverJarPath(),metadataConn.getDbVersionString(),metadataConn.getAdditionalParams());
  assertTrue(list.size() == 0);
  list.add(conn);
  assertTrue(list.size() != 0);
  List conMockList=mock(List.class);
  conMockList.add(conn);
  DriverShim wapperDriver=mock(DriverShim.class);
  conMockList.add(wapperDriver);
  when(conMockList.get(0)).thenReturn(conn);
  when(conMockList.get(1)).thenReturn(wapperDriver);
  when(conMockList.get(2)).thenThrow(new RuntimeException());
  verify(conMockList,times(1)).add(conn);
  verify(conMockList,times(1)).add(wapperDriver);
  List<TdColumn> columns=getExtractManger().returnColumns(metadataConn,tableNode,false);
  Assert.assertNotNull(columns);
  Assert.assertTrue(columns.isEmpty());
  extractMeta.setConn(null);
}