move trackColumnsForAutoSizingIfSXSSF into ITestDataProvider, replace ITestDataProvider.trackColumnsForAutosizing(Sheet, int...) with ITestDataProvider.trackAllColumnsForAutosizing(Sheet) to avoid cluttering unit tests with specific columns that will be autosized

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1730999 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Javen O'Neal 2016-02-18 04:05:45 +00:00
parent 2ffd1d9dd5
commit 865bf1d24f
6 changed files with 6 additions and 28 deletions

View File

@ -95,13 +95,6 @@ public final class SXSSFITestDataProvider implements ITestDataProvider {
return wb;
}
@Override
public void trackColumnsForAutosizing(Sheet sheet, int...columns) {
for (int cn : columns) {
((SXSSFSheet)sheet).trackColumnForAutoSizing(cn);
}
}
@Override
public void trackAllColumnsForAutosizing(Sheet sheet) {
((SXSSFSheet)sheet).trackAllColumnsForAutoSizing();

View File

@ -60,8 +60,6 @@ public final class XSSFITestDataProvider implements ITestDataProvider {
return createWorkbook();
}
@Override
public void trackColumnsForAutosizing(Sheet sheet, int...columns) {}
@Override
public void trackAllColumnsForAutosizing(Sheet sheet) {}
//************ End SXSSF-specific methods ***************//

View File

@ -33,12 +33,6 @@ public final class TestSXSSFBugs extends BaseTestBugzillaIssues {
public TestSXSSFBugs() {
super(SXSSFITestDataProvider.instance);
}
@Override
protected void trackColumnsForAutoSizingIfSXSSF(Sheet sheet) {
SXSSFSheet sxSheet = (SXSSFSheet) sheet;
sxSheet.trackAllColumnsForAutoSizing();
}
// override some tests which do not work for SXSSF
@Override @Ignore("cloneSheet() not implemented") @Test public void bug18800() { /* cloneSheet() not implemented */ }

View File

@ -66,8 +66,6 @@ public final class HSSFITestDataProvider implements ITestDataProvider {
return createWorkbook();
}
@Override
public void trackColumnsForAutosizing(Sheet sheet, int...columns) {}
@Override
public void trackAllColumnsForAutosizing(Sheet sheet) {}
//************ End SXSSF-specific methods ***************//

View File

@ -60,7 +60,6 @@ public interface ITestDataProvider {
* Only matters for SXSSF - enables tracking of the column
* widths so that autosizing can work. No-op on others.
*/
void trackColumnsForAutosizing(Sheet sheet, int...columns);
void trackAllColumnsForAutosizing(Sheet sheet);
//************ End SXSSF-specific methods ***************//

View File

@ -55,10 +55,6 @@ public abstract class BaseTestBugzillaIssues {
protected BaseTestBugzillaIssues(ITestDataProvider testDataProvider) {
_testDataProvider = testDataProvider;
}
protected void trackColumnsForAutoSizingIfSXSSF(Sheet sheet) {
// do nothing for Sheet base class. This will be overridden for SXSSFSheets.
}
/**
* Unlike org.junit.Assert.assertEquals(double expected, double actual, double delta),
@ -377,7 +373,7 @@ public abstract class BaseTestBugzillaIssues {
Workbook wb = _testDataProvider.createWorkbook();
BaseTestSheetAutosizeColumn.fixFonts(wb);
Sheet sheet = wb.createSheet("Sheet1");
trackColumnsForAutoSizingIfSXSSF(sheet);
_testDataProvider.trackAllColumnsForAutosizing(sheet);
Row row = sheet.createRow(0);
Cell cell0 = row.createCell(0);
@ -434,7 +430,7 @@ public abstract class BaseTestBugzillaIssues {
Workbook wb = _testDataProvider.createWorkbook();
BaseTestSheetAutosizeColumn.fixFonts(wb);
Sheet sheet = wb.createSheet();
trackColumnsForAutoSizingIfSXSSF(sheet);
_testDataProvider.trackAllColumnsForAutosizing(sheet);
Row row = sheet.createRow(0);
Cell cell0 = row.createCell(0);
Cell cell1 = row.createCell(1);
@ -670,7 +666,7 @@ public abstract class BaseTestBugzillaIssues {
d2Percent.setDataFormat(format.getFormat("0.00%"));
Sheet s = wb.createSheet();
trackColumnsForAutoSizingIfSXSSF(s);
_testDataProvider.trackAllColumnsForAutosizing(s);
Row r1 = s.createRow(0);
for (int i=0; i<3; i++) {
@ -1393,7 +1389,7 @@ public abstract class BaseTestBugzillaIssues {
cell.setCellValue((String)null);
assertEquals(Cell.CELL_TYPE_BLANK, cell.getCellType());
_testDataProvider.trackColumnsForAutosizing(s, 0);
_testDataProvider.trackAllColumnsForAutosizing(s);
s.autoSizeColumn(0);
assertEquals(2048, s.getColumnWidth(0));
@ -1480,11 +1476,11 @@ public abstract class BaseTestBugzillaIssues {
}
}
public long time() {
protected long time() {
final long currentTime = System.currentTimeMillis();
return currentTime;
}
public double delta(long startTimeMillis) {
protected double delta(long startTimeMillis) {
return time() - startTimeMillis;
}
}