mirror of https://github.com/apache/poi.git
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:
parent
2ffd1d9dd5
commit
865bf1d24f
|
@ -95,13 +95,6 @@ public final class SXSSFITestDataProvider implements ITestDataProvider {
|
||||||
return wb;
|
return wb;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void trackColumnsForAutosizing(Sheet sheet, int...columns) {
|
|
||||||
for (int cn : columns) {
|
|
||||||
((SXSSFSheet)sheet).trackColumnForAutoSizing(cn);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void trackAllColumnsForAutosizing(Sheet sheet) {
|
public void trackAllColumnsForAutosizing(Sheet sheet) {
|
||||||
((SXSSFSheet)sheet).trackAllColumnsForAutoSizing();
|
((SXSSFSheet)sheet).trackAllColumnsForAutoSizing();
|
||||||
|
|
|
@ -60,8 +60,6 @@ public final class XSSFITestDataProvider implements ITestDataProvider {
|
||||||
return createWorkbook();
|
return createWorkbook();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void trackColumnsForAutosizing(Sheet sheet, int...columns) {}
|
|
||||||
@Override
|
@Override
|
||||||
public void trackAllColumnsForAutosizing(Sheet sheet) {}
|
public void trackAllColumnsForAutosizing(Sheet sheet) {}
|
||||||
//************ End SXSSF-specific methods ***************//
|
//************ End SXSSF-specific methods ***************//
|
||||||
|
|
|
@ -34,12 +34,6 @@ public final class TestSXSSFBugs extends BaseTestBugzillaIssues {
|
||||||
super(SXSSFITestDataProvider.instance);
|
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 some tests which do not work for SXSSF
|
||||||
@Override @Ignore("cloneSheet() not implemented") @Test public void bug18800() { /* cloneSheet() not implemented */ }
|
@Override @Ignore("cloneSheet() not implemented") @Test public void bug18800() { /* cloneSheet() not implemented */ }
|
||||||
@Override @Ignore("cloneSheet() not implemented") @Test public void bug22720() { /* cloneSheet() not implemented */ }
|
@Override @Ignore("cloneSheet() not implemented") @Test public void bug22720() { /* cloneSheet() not implemented */ }
|
||||||
|
|
|
@ -66,8 +66,6 @@ public final class HSSFITestDataProvider implements ITestDataProvider {
|
||||||
return createWorkbook();
|
return createWorkbook();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void trackColumnsForAutosizing(Sheet sheet, int...columns) {}
|
|
||||||
@Override
|
@Override
|
||||||
public void trackAllColumnsForAutosizing(Sheet sheet) {}
|
public void trackAllColumnsForAutosizing(Sheet sheet) {}
|
||||||
//************ End SXSSF-specific methods ***************//
|
//************ End SXSSF-specific methods ***************//
|
||||||
|
|
|
@ -60,7 +60,6 @@ public interface ITestDataProvider {
|
||||||
* Only matters for SXSSF - enables tracking of the column
|
* Only matters for SXSSF - enables tracking of the column
|
||||||
* widths so that autosizing can work. No-op on others.
|
* widths so that autosizing can work. No-op on others.
|
||||||
*/
|
*/
|
||||||
void trackColumnsForAutosizing(Sheet sheet, int...columns);
|
|
||||||
void trackAllColumnsForAutosizing(Sheet sheet);
|
void trackAllColumnsForAutosizing(Sheet sheet);
|
||||||
//************ End SXSSF-specific methods ***************//
|
//************ End SXSSF-specific methods ***************//
|
||||||
|
|
||||||
|
|
|
@ -56,10 +56,6 @@ public abstract class BaseTestBugzillaIssues {
|
||||||
_testDataProvider = 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),
|
* Unlike org.junit.Assert.assertEquals(double expected, double actual, double delta),
|
||||||
* where delta is an absolute error value, this function's factor is a relative error,
|
* where delta is an absolute error value, this function's factor is a relative error,
|
||||||
|
@ -377,7 +373,7 @@ public abstract class BaseTestBugzillaIssues {
|
||||||
Workbook wb = _testDataProvider.createWorkbook();
|
Workbook wb = _testDataProvider.createWorkbook();
|
||||||
BaseTestSheetAutosizeColumn.fixFonts(wb);
|
BaseTestSheetAutosizeColumn.fixFonts(wb);
|
||||||
Sheet sheet = wb.createSheet("Sheet1");
|
Sheet sheet = wb.createSheet("Sheet1");
|
||||||
trackColumnsForAutoSizingIfSXSSF(sheet);
|
_testDataProvider.trackAllColumnsForAutosizing(sheet);
|
||||||
Row row = sheet.createRow(0);
|
Row row = sheet.createRow(0);
|
||||||
Cell cell0 = row.createCell(0);
|
Cell cell0 = row.createCell(0);
|
||||||
|
|
||||||
|
@ -434,7 +430,7 @@ public abstract class BaseTestBugzillaIssues {
|
||||||
Workbook wb = _testDataProvider.createWorkbook();
|
Workbook wb = _testDataProvider.createWorkbook();
|
||||||
BaseTestSheetAutosizeColumn.fixFonts(wb);
|
BaseTestSheetAutosizeColumn.fixFonts(wb);
|
||||||
Sheet sheet = wb.createSheet();
|
Sheet sheet = wb.createSheet();
|
||||||
trackColumnsForAutoSizingIfSXSSF(sheet);
|
_testDataProvider.trackAllColumnsForAutosizing(sheet);
|
||||||
Row row = sheet.createRow(0);
|
Row row = sheet.createRow(0);
|
||||||
Cell cell0 = row.createCell(0);
|
Cell cell0 = row.createCell(0);
|
||||||
Cell cell1 = row.createCell(1);
|
Cell cell1 = row.createCell(1);
|
||||||
|
@ -670,7 +666,7 @@ public abstract class BaseTestBugzillaIssues {
|
||||||
d2Percent.setDataFormat(format.getFormat("0.00%"));
|
d2Percent.setDataFormat(format.getFormat("0.00%"));
|
||||||
|
|
||||||
Sheet s = wb.createSheet();
|
Sheet s = wb.createSheet();
|
||||||
trackColumnsForAutoSizingIfSXSSF(s);
|
_testDataProvider.trackAllColumnsForAutosizing(s);
|
||||||
Row r1 = s.createRow(0);
|
Row r1 = s.createRow(0);
|
||||||
|
|
||||||
for (int i=0; i<3; i++) {
|
for (int i=0; i<3; i++) {
|
||||||
|
@ -1393,7 +1389,7 @@ public abstract class BaseTestBugzillaIssues {
|
||||||
cell.setCellValue((String)null);
|
cell.setCellValue((String)null);
|
||||||
assertEquals(Cell.CELL_TYPE_BLANK, cell.getCellType());
|
assertEquals(Cell.CELL_TYPE_BLANK, cell.getCellType());
|
||||||
|
|
||||||
_testDataProvider.trackColumnsForAutosizing(s, 0);
|
_testDataProvider.trackAllColumnsForAutosizing(s);
|
||||||
|
|
||||||
s.autoSizeColumn(0);
|
s.autoSizeColumn(0);
|
||||||
assertEquals(2048, s.getColumnWidth(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();
|
final long currentTime = System.currentTimeMillis();
|
||||||
return currentTime;
|
return currentTime;
|
||||||
}
|
}
|
||||||
public double delta(long startTimeMillis) {
|
protected double delta(long startTimeMillis) {
|
||||||
return time() - startTimeMillis;
|
return time() - startTimeMillis;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue