From 865bf1d24f910178167aef05a91dfc75cb9ae738 Mon Sep 17 00:00:00 2001 From: Javen O'Neal Date: Thu, 18 Feb 2016 04:05:45 +0000 Subject: [PATCH] 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 --- .../apache/poi/xssf/SXSSFITestDataProvider.java | 7 ------- .../apache/poi/xssf/XSSFITestDataProvider.java | 2 -- .../apache/poi/xssf/usermodel/TestSXSSFBugs.java | 6 ------ .../apache/poi/hssf/HSSFITestDataProvider.java | 2 -- .../org/apache/poi/ss/ITestDataProvider.java | 1 - .../poi/ss/usermodel/BaseTestBugzillaIssues.java | 16 ++++++---------- 6 files changed, 6 insertions(+), 28 deletions(-) diff --git a/src/ooxml/testcases/org/apache/poi/xssf/SXSSFITestDataProvider.java b/src/ooxml/testcases/org/apache/poi/xssf/SXSSFITestDataProvider.java index 5b5fe3f447..4f2eb40f91 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/SXSSFITestDataProvider.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/SXSSFITestDataProvider.java @@ -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(); diff --git a/src/ooxml/testcases/org/apache/poi/xssf/XSSFITestDataProvider.java b/src/ooxml/testcases/org/apache/poi/xssf/XSSFITestDataProvider.java index b8eb9ebb1c..e0ba6617ca 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/XSSFITestDataProvider.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/XSSFITestDataProvider.java @@ -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 ***************// diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestSXSSFBugs.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestSXSSFBugs.java index 8c67676d0c..0f37da3ba4 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestSXSSFBugs.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestSXSSFBugs.java @@ -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 */ } diff --git a/src/testcases/org/apache/poi/hssf/HSSFITestDataProvider.java b/src/testcases/org/apache/poi/hssf/HSSFITestDataProvider.java index 58e6327eb4..5d80a26d53 100644 --- a/src/testcases/org/apache/poi/hssf/HSSFITestDataProvider.java +++ b/src/testcases/org/apache/poi/hssf/HSSFITestDataProvider.java @@ -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 ***************// diff --git a/src/testcases/org/apache/poi/ss/ITestDataProvider.java b/src/testcases/org/apache/poi/ss/ITestDataProvider.java index c88794854e..e258e1a4a2 100644 --- a/src/testcases/org/apache/poi/ss/ITestDataProvider.java +++ b/src/testcases/org/apache/poi/ss/ITestDataProvider.java @@ -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 ***************// diff --git a/src/testcases/org/apache/poi/ss/usermodel/BaseTestBugzillaIssues.java b/src/testcases/org/apache/poi/ss/usermodel/BaseTestBugzillaIssues.java index e5991adf9a..99c07c0c6c 100644 --- a/src/testcases/org/apache/poi/ss/usermodel/BaseTestBugzillaIssues.java +++ b/src/testcases/org/apache/poi/ss/usermodel/BaseTestBugzillaIssues.java @@ -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; } } -- 2.39.5