From 01bd0b4a3987865c6f1305ff47d7ad617696b9b5 Mon Sep 17 00:00:00 2001 From: Javen O'Neal Date: Sun, 17 Apr 2016 11:25:35 +0000 Subject: [PATCH] revert r1739548 and r1739550. I could not figure out how to add BaseTestXWorkbook|Sheet|Row.java without causing junit to complain about 'Test class should have exactly one public constructor' git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1739580 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/poi/ss/usermodel/BaseTestXRow.java | 48 ------------------- .../poi/ss/usermodel/BaseTestXSheet.java | 35 -------------- .../poi/ss/usermodel/BaseTestXWorkbook.java | 35 -------------- .../poi/xssf/streaming/TestSXSSFRow.java | 19 ++++++-- .../poi/xssf/streaming/TestSXSSFSheet.java | 12 ++++- .../poi/xssf/streaming/TestSXSSFWorkbook.java | 23 ++++++--- .../poi/xssf/usermodel/TestXSSFRow.java | 18 +++++-- .../poi/xssf/usermodel/TestXSSFSheet.java | 12 +++-- .../poi/xssf/usermodel/TestXSSFWorkbook.java | 19 +++++--- .../poi/hssf/usermodel/TestHSSFSheet.java | 6 +++ .../poi/hssf/usermodel/TestHSSFWorkbook.java | 8 ++++ .../apache/poi/ss/usermodel/BaseTestRow.java | 13 ++--- .../poi/ss/usermodel/BaseTestSheet.java | 9 ++-- .../poi/ss/usermodel/BaseTestWorkbook.java | 13 +++-- 14 files changed, 106 insertions(+), 164 deletions(-) delete mode 100644 src/ooxml/testcases/org/apache/poi/ss/usermodel/BaseTestXRow.java delete mode 100644 src/ooxml/testcases/org/apache/poi/ss/usermodel/BaseTestXSheet.java delete mode 100644 src/ooxml/testcases/org/apache/poi/ss/usermodel/BaseTestXWorkbook.java diff --git a/src/ooxml/testcases/org/apache/poi/ss/usermodel/BaseTestXRow.java b/src/ooxml/testcases/org/apache/poi/ss/usermodel/BaseTestXRow.java deleted file mode 100644 index a4b21001e5..0000000000 --- a/src/ooxml/testcases/org/apache/poi/ss/usermodel/BaseTestXRow.java +++ /dev/null @@ -1,48 +0,0 @@ -/* ==================================================================== - Licensed to the Apache Software Foundation (ASF) under one or more - contributor license agreements. See the NOTICE file distributed with - this work for additional information regarding copyright ownership. - The ASF licenses this file to You under the Apache License, Version 2.0 - (the "License"); you may not use this file except in compliance with - the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -==================================================================== */ - -package org.apache.poi.ss.usermodel; - -import java.io.IOException; - -import org.apache.poi.ss.ITestDataProvider; -import org.apache.poi.xssf.streaming.SXSSFRow; -import org.apache.poi.xssf.usermodel.XSSFRow; -import org.junit.Test; - -/** - * Class for combined testing of XML-specific functionality of - * {@link XSSFRow} and {@link SXSSFRow}. - * - * Any test that is applicable for {@link org.apache.poi.hssf.usermodel.HSSFRow} as well should go into - * the common base class {@link BaseTestRow}. - */ -public abstract class BaseTestXRow extends BaseTestRow { - protected BaseTestXRow(ITestDataProvider testDataProvider) { - super(testDataProvider); - } - - @Test - public void testRowBounds() throws IOException { - baseTestRowBounds(_testDataProvider.getSpreadsheetVersion().getLastRowIndex()); - } - - @Test - public void testCellBounds() throws IOException { - baseTestCellBounds(_testDataProvider.getSpreadsheetVersion().getLastColumnIndex()); - } -} diff --git a/src/ooxml/testcases/org/apache/poi/ss/usermodel/BaseTestXSheet.java b/src/ooxml/testcases/org/apache/poi/ss/usermodel/BaseTestXSheet.java deleted file mode 100644 index f6e1bffde8..0000000000 --- a/src/ooxml/testcases/org/apache/poi/ss/usermodel/BaseTestXSheet.java +++ /dev/null @@ -1,35 +0,0 @@ -/* ==================================================================== - Licensed to the Apache Software Foundation (ASF) under one or more - contributor license agreements. See the NOTICE file distributed with - this work for additional information regarding copyright ownership. - The ASF licenses this file to You under the Apache License, Version 2.0 - (the "License"); you may not use this file except in compliance with - the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -==================================================================== */ - -package org.apache.poi.ss.usermodel; - -import org.apache.poi.ss.ITestDataProvider; -import org.apache.poi.xssf.streaming.SXSSFSheet; -import org.apache.poi.xssf.usermodel.XSSFSheet; - -/** - * Class for combined testing of XML-specific functionality of - * {@link XSSFSheet} and {@link SXSSFSheet}. - * - * Any test that is applicable for {@link org.apache.poi.hssf.usermodel.HSSFSheet} as well should go into - * the common base class {@link BaseTestSheet}. - */ -public abstract class BaseTestXSheet extends BaseTestSheet { - protected BaseTestXSheet(ITestDataProvider testDataProvider) { - super(testDataProvider); - } -} diff --git a/src/ooxml/testcases/org/apache/poi/ss/usermodel/BaseTestXWorkbook.java b/src/ooxml/testcases/org/apache/poi/ss/usermodel/BaseTestXWorkbook.java deleted file mode 100644 index 9c7fe3a09a..0000000000 --- a/src/ooxml/testcases/org/apache/poi/ss/usermodel/BaseTestXWorkbook.java +++ /dev/null @@ -1,35 +0,0 @@ -/* ==================================================================== - Licensed to the Apache Software Foundation (ASF) under one or more - contributor license agreements. See the NOTICE file distributed with - this work for additional information regarding copyright ownership. - The ASF licenses this file to You under the Apache License, Version 2.0 - (the "License"); you may not use this file except in compliance with - the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -==================================================================== */ - -package org.apache.poi.ss.usermodel; - -import org.apache.poi.ss.ITestDataProvider; -import org.apache.poi.xssf.streaming.SXSSFWorkbook; -import org.apache.poi.xssf.usermodel.XSSFWorkbook; - -/** - * Class for combined testing of XML-specific functionality of - * {@link XSSFWorkbook} and {@link SXSSFWorkbook}. - * - * Any test that is applicable for {@link org.apache.poi.hssf.usermodel.HSSFWorkbook} as well should go into - * the common base class {@link BaseTestWorkbook}. - */ -public abstract class BaseTestXWorkbook extends BaseTestWorkbook { - protected BaseTestXWorkbook(ITestDataProvider testDataProvider) { - super(testDataProvider); - } -} diff --git a/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestSXSSFRow.java b/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestSXSSFRow.java index c9a113711f..3ebedd6fae 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestSXSSFRow.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestSXSSFRow.java @@ -19,7 +19,10 @@ package org.apache.poi.xssf.streaming; -import org.apache.poi.ss.usermodel.BaseTestXRow; +import java.io.IOException; + +import org.apache.poi.ss.SpreadsheetVersion; +import org.apache.poi.ss.usermodel.BaseTestRow; import org.apache.poi.xssf.SXSSFITestDataProvider; import org.junit.After; import org.junit.Test; @@ -27,7 +30,7 @@ import org.junit.Test; /** * Tests for XSSFRow */ -public final class TestSXSSFRow extends BaseTestXRow { +public final class TestSXSSFRow extends BaseTestRow { public TestSXSSFRow() { super(SXSSFITestDataProvider.instance); @@ -36,7 +39,17 @@ public final class TestSXSSFRow extends BaseTestXRow { @After public void tearDown() { - ((SXSSFITestDataProvider) _testDataProvider).cleanup(); + SXSSFITestDataProvider.instance.cleanup(); + } + + @Test + public void testRowBounds() throws IOException { + baseTestRowBounds(SpreadsheetVersion.EXCEL2007.getLastRowIndex()); + } + + @Test + public void testCellBounds() throws IOException { + baseTestCellBounds(SpreadsheetVersion.EXCEL2007.getLastColumnIndex()); } } diff --git a/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestSXSSFSheet.java b/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestSXSSFSheet.java index 07b80c43eb..fbe14f1067 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestSXSSFSheet.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestSXSSFSheet.java @@ -23,8 +23,11 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; import java.io.IOException; +import java.util.SortedSet; +import java.util.TreeSet; -import org.apache.poi.ss.usermodel.BaseTestXSheet; +import org.apache.poi.ss.SpreadsheetVersion; +import org.apache.poi.ss.usermodel.BaseTestSheet; import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.xssf.SXSSFITestDataProvider; @@ -33,7 +36,7 @@ import org.junit.After; import org.junit.Test; -public final class TestSXSSFSheet extends BaseTestXSheet { +public class TestSXSSFSheet extends BaseTestSheet { public TestSXSSFSheet() { super(SXSSFITestDataProvider.instance); @@ -154,4 +157,9 @@ public final class TestSXSSFSheet extends BaseTestXSheet { template.close(); } } + + @Test(expected=IllegalArgumentException.class) + public void createRowAfterLastRow() throws IOException { + createRowAfterLastRow(SpreadsheetVersion.EXCEL2007); + } } diff --git a/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestSXSSFWorkbook.java b/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestSXSSFWorkbook.java index 3eb5a29beb..f8816a4066 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestSXSSFWorkbook.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestSXSSFWorkbook.java @@ -32,8 +32,11 @@ import java.io.IOException; import org.apache.poi.POIDataSamples; import org.apache.poi.POITestCase; +import org.apache.poi.hssf.HSSFTestDataSamples; import org.apache.poi.openxml4j.exceptions.InvalidFormatException; -import org.apache.poi.ss.usermodel.BaseTestXWorkbook; +import org.apache.poi.openxml4j.opc.OPCPackage; +import org.apache.poi.ss.SpreadsheetVersion; +import org.apache.poi.ss.usermodel.BaseTestWorkbook; import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.Row; import org.apache.poi.ss.usermodel.Sheet; @@ -49,15 +52,16 @@ import org.junit.Assume; import org.junit.Ignore; import org.junit.Test; -public final class TestSXSSFWorkbook extends BaseTestXWorkbook { +public final class TestSXSSFWorkbook extends BaseTestWorkbook { + private static final SXSSFITestDataProvider _testDataProvider = SXSSFITestDataProvider.instance; public TestSXSSFWorkbook() { - super(SXSSFITestDataProvider.instance); - } + super(_testDataProvider); + } @After public void tearDown(){ - ((SXSSFITestDataProvider)_testDataProvider).cleanup(); + _testDataProvider.cleanup(); } /** @@ -306,7 +310,7 @@ public final class TestSXSSFWorkbook extends BaseTestXWorkbook { xwb.close(); } - protected static void assertWorkbookDispose(SXSSFWorkbook wb) + static void assertWorkbookDispose(SXSSFWorkbook wb) { int rowNum = 1000; int sheetNum = 5; @@ -454,7 +458,12 @@ public final class TestSXSSFWorkbook extends BaseTestXWorkbook { workBook.close(); } - + @Test + @Override + public void getSpreadsheetVersion() throws IOException { + verifySpreadsheetVersion(SpreadsheetVersion.EXCEL2007); + } + @Test public void closeDoesNotModifyWorkbook() throws IOException, InvalidFormatException { final String filename = "SampleSS.xlsx"; diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFRow.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFRow.java index c83336b7d6..67b5038576 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFRow.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFRow.java @@ -23,7 +23,8 @@ import static org.junit.Assert.assertSame; import java.io.IOException; -import org.apache.poi.ss.usermodel.BaseTestXRow; +import org.apache.poi.ss.SpreadsheetVersion; +import org.apache.poi.ss.usermodel.BaseTestRow; import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.CellCopyPolicy; import org.apache.poi.ss.usermodel.Row; @@ -34,13 +35,22 @@ import org.junit.Test; /** * Tests for XSSFRow */ -public final class TestXSSFRow extends BaseTestXRow { +public final class TestXSSFRow extends BaseTestRow { public TestXSSFRow() { super(XSSFITestDataProvider.instance); } - + + @Test + public void testRowBounds() throws IOException { + baseTestRowBounds(SpreadsheetVersion.EXCEL2007.getLastRowIndex()); + } + @Test + public void testCellBounds() throws IOException { + baseTestCellBounds(SpreadsheetVersion.EXCEL2007.getLastColumnIndex()); + } + public void testCopyRowFrom() throws IOException { final XSSFWorkbook workbook = new XSSFWorkbook(); final XSSFSheet sheet = workbook.createSheet("test"); @@ -55,7 +65,6 @@ public final class TestXSSFRow extends BaseTestXRow { workbook.close(); } - @Test public void testCopyRowFromExternalSheet() throws IOException { final XSSFWorkbook workbook = new XSSFWorkbook(); final Sheet srcSheet = workbook.createSheet("src"); @@ -150,7 +159,6 @@ public final class TestXSSFRow extends BaseTestXRow { workbook.close(); } - @Test public void testCopyRowOverwritesExistingRow() throws IOException { final XSSFWorkbook workbook = new XSSFWorkbook(); final XSSFSheet sheet1 = workbook.createSheet("Sheet1"); diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java index 6b1eebe652..1e641c64e7 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java @@ -26,6 +26,7 @@ import static org.junit.Assert.assertNotSame; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertSame; import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; import java.io.IOException; import java.util.Arrays; @@ -42,7 +43,7 @@ import org.apache.poi.poifs.crypt.CryptoFunctions; import org.apache.poi.poifs.crypt.HashAlgorithm; import org.apache.poi.ss.SpreadsheetVersion; import org.apache.poi.ss.usermodel.AutoFilter; -import org.apache.poi.ss.usermodel.BaseTestXSheet; +import org.apache.poi.ss.usermodel.BaseTestSheet; import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.CellCopyPolicy; import org.apache.poi.ss.usermodel.ClientAnchor; @@ -81,7 +82,7 @@ import org.openxmlformats.schemas.spreadsheetml.x2006.main.STCalcMode; import org.openxmlformats.schemas.spreadsheetml.x2006.main.STPane; -public final class TestXSSFSheet extends BaseTestXSheet { +public final class TestXSSFSheet extends BaseTestSheet { public TestXSSFSheet() { super(XSSFITestDataProvider.instance); @@ -1054,6 +1055,11 @@ public final class TestXSSFSheet extends BaseTestXSheet { wb2.close(); } + + @Test(expected=IllegalArgumentException.class) + public void createRowAfterLastRow() throws IOException { + createRowAfterLastRow(SpreadsheetVersion.EXCEL2007); + } @Test public void setAutoFilter() throws IOException { @@ -1598,7 +1604,7 @@ public final class TestXSSFSheet extends BaseTestXSheet { wb.close(); } - protected void testCopyMultipleRows(String copyRowsTestWorkbook) throws IOException { + public void testCopyMultipleRows(String copyRowsTestWorkbook) throws IOException { final double FLOAT_PRECISION = 1e-9; final XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook(copyRowsTestWorkbook); final XSSFSheet sheet = wb.getSheetAt(0); diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFWorkbook.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFWorkbook.java index 8d3eb852c1..b0266ee4e6 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFWorkbook.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFWorkbook.java @@ -53,7 +53,7 @@ import org.apache.poi.openxml4j.opc.internal.FileHelper; import org.apache.poi.openxml4j.opc.internal.MemoryPackagePart; import org.apache.poi.openxml4j.opc.internal.PackagePropertiesPart; import org.apache.poi.ss.SpreadsheetVersion; -import org.apache.poi.ss.usermodel.BaseTestXWorkbook; +import org.apache.poi.ss.usermodel.BaseTestWorkbook; import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.CellStyle; import org.apache.poi.ss.usermodel.Font; @@ -77,10 +77,11 @@ import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorkbook; import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorkbookPr; import org.openxmlformats.schemas.spreadsheetml.x2006.main.STCalcMode; -public final class TestXSSFWorkbook extends BaseTestXWorkbook { +public final class TestXSSFWorkbook extends BaseTestWorkbook { + private static final XSSFITestDataProvider _testDataProvider = XSSFITestDataProvider.instance; public TestXSSFWorkbook() { - super(XSSFITestDataProvider.instance); + super(_testDataProvider); } /** @@ -773,7 +774,7 @@ public final class TestXSSFWorkbook extends BaseTestXWorkbook { } } - protected void setPivotData(XSSFWorkbook wb){ + public void setPivotData(XSSFWorkbook wb){ XSSFSheet sheet = wb.createSheet(); Row row1 = sheet.createRow(0); @@ -948,6 +949,8 @@ public final class TestXSSFWorkbook extends BaseTestXWorkbook { workbook.close(); } + @SuppressWarnings("unchecked") + @Test /** * Iterator XSSFWorkbook.iterator was committed in r700472 on 2008-09-30 * and has been replaced with Iterator XSSFWorkbook.iterator @@ -963,8 +966,6 @@ public final class TestXSSFWorkbook extends BaseTestXWorkbook { * upgrade their code with either of the following options presented in this test case. * */ - @SuppressWarnings("unchecked") - @Test public void bug58245_XSSFSheetIterator() throws IOException { final XSSFWorkbook wb = new XSSFWorkbook(); wb.createSheet(); @@ -1065,6 +1066,12 @@ public final class TestXSSFWorkbook extends BaseTestXWorkbook { } } + @Test + @Override + public void getSpreadsheetVersion() throws IOException { + verifySpreadsheetVersion(SpreadsheetVersion.EXCEL2007); + } + @Test public void closeDoesNotModifyWorkbook() throws IOException, InvalidFormatException { final String filename = "SampleSS.xlsx"; diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheet.java b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheet.java index 65a5f21dbf..ed43b4264c 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheet.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheet.java @@ -56,6 +56,7 @@ import org.apache.poi.hssf.record.WSBoolRecord; import org.apache.poi.hssf.record.WindowTwoRecord; import org.apache.poi.hssf.record.aggregates.WorksheetProtectionBlock; import org.apache.poi.hssf.usermodel.RecordInspector.RecordCollector; +import org.apache.poi.ss.SpreadsheetVersion; import org.apache.poi.ss.formula.ptg.Area3DPtg; import org.apache.poi.ss.formula.ptg.Ptg; import org.apache.poi.ss.usermodel.AutoFilter; @@ -82,6 +83,11 @@ public final class TestHSSFSheet extends BaseTestSheet { public TestHSSFSheet() { super(HSSFITestDataProvider.instance); } + + @Test(expected=IllegalArgumentException.class) + public void createRowAfterLastRow() throws IOException { + createRowAfterLastRow(SpreadsheetVersion.EXCEL97); + } /** * Test for Bugzilla #29747. diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFWorkbook.java b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFWorkbook.java index 65a6422cf7..167e41adf6 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFWorkbook.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFWorkbook.java @@ -53,6 +53,7 @@ import org.apache.poi.poifs.filesystem.DirectoryEntry; import org.apache.poi.poifs.filesystem.DirectoryNode; import org.apache.poi.poifs.filesystem.NPOIFSFileSystem; import org.apache.poi.poifs.filesystem.POIFSFileSystem; +import org.apache.poi.ss.SpreadsheetVersion; import org.apache.poi.ss.formula.ptg.Area3DPtg; import org.apache.poi.ss.usermodel.*; import org.apache.poi.ss.util.CellRangeAddress; @@ -215,6 +216,7 @@ public final class TestHSSFWorkbook extends BaseTestWorkbook { wb.close(); } + @SuppressWarnings("unused") @Test public void selectMultiple() throws IOException { HSSFWorkbook wb=new HSSFWorkbook(); @@ -1192,6 +1194,12 @@ public final class TestHSSFWorkbook extends BaseTestWorkbook { } + @Test + @Override + public void getSpreadsheetVersion() throws IOException { + verifySpreadsheetVersion(SpreadsheetVersion.EXCEL97); + } + @Test public void closeDoesNotModifyWorkbook() throws IOException { final String filename = "SampleSS.xls"; diff --git a/src/testcases/org/apache/poi/ss/usermodel/BaseTestRow.java b/src/testcases/org/apache/poi/ss/usermodel/BaseTestRow.java index 5b22f82792..6801695399 100644 --- a/src/testcases/org/apache/poi/ss/usermodel/BaseTestRow.java +++ b/src/testcases/org/apache/poi/ss/usermodel/BaseTestRow.java @@ -36,7 +36,7 @@ import org.junit.Test; */ public abstract class BaseTestRow { - protected final ITestDataProvider _testDataProvider; + private final ITestDataProvider _testDataProvider; protected BaseTestRow(ITestDataProvider testDataProvider) { _testDataProvider = testDataProvider; @@ -72,7 +72,6 @@ public abstract class BaseTestRow { * Make sure that there is no cross-talk between rows especially with getFirstCellNum and getLastCellNum * This test was added in response to bug report 44987. */ - @Test public void testBoundsInMultipleRows() throws IOException { Workbook workbook = _testDataProvider.createWorkbook(); Sheet sheet = workbook.createSheet(); @@ -98,7 +97,6 @@ public abstract class BaseTestRow { workbook.close(); } - @Test public void testRemoveCell() throws IOException { Workbook wb1 = _testDataProvider.createWorkbook(); { @@ -141,7 +139,7 @@ public abstract class BaseTestRow { wb2.close(); } - protected void baseTestRowBounds(int maxRowNum) throws IOException { + public void baseTestRowBounds(int maxRowNum) throws IOException { Workbook workbook = _testDataProvider.createWorkbook(); Sheet sheet = workbook.createSheet(); //Test low row bound @@ -170,7 +168,7 @@ public abstract class BaseTestRow { workbook.close(); } - protected void baseTestCellBounds(int maxCellNum) throws IOException { + public void baseTestCellBounds(int maxCellNum) throws IOException { Workbook wb1 = _testDataProvider.createWorkbook(); Sheet sheet = wb1.createSheet(); @@ -213,7 +211,6 @@ public abstract class BaseTestRow { * Prior to patch 43901, POI was producing files with the wrong last-column * number on the row */ - @Test public void testLastCellNumIsCorrectAfterAddCell_bug43901() throws IOException { Workbook workbook = _testDataProvider.createWorkbook(); Sheet sheet = workbook.createSheet("test"); @@ -237,7 +234,6 @@ public abstract class BaseTestRow { /** * Tests for the missing/blank cell policy stuff */ - @Test public void testGetCellPolicy() throws IOException { Workbook workbook = _testDataProvider.createWorkbook(); Sheet sheet = workbook.createSheet("test"); @@ -309,7 +305,6 @@ public abstract class BaseTestRow { workbook.close(); } - @Test public void testRowHeight() throws IOException { Workbook wb1 = _testDataProvider.createWorkbook(); Sheet sheet = wb1.createSheet(); @@ -365,7 +360,6 @@ public abstract class BaseTestRow { /** * Test adding cells to a row in various places and see if we can find them again. */ - @Test public void testCellIterator() throws IOException { Workbook wb = _testDataProvider.createWorkbook(); Sheet sheet = wb.createSheet(); @@ -423,7 +417,6 @@ public abstract class BaseTestRow { wb.close(); } - @Test public void testRowStyle() throws IOException { Workbook wb1 = _testDataProvider.createWorkbook(); Sheet sheet = wb1.createSheet("test"); diff --git a/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheet.java b/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheet.java index 6d81606383..830298181c 100644 --- a/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheet.java +++ b/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheet.java @@ -51,10 +51,10 @@ public abstract class BaseTestSheet { @Rule public ExpectedException thrown = ExpectedException.none(); - protected final ITestDataProvider _testDataProvider; + private final ITestDataProvider _testDataProvider; protected BaseTestSheet(ITestDataProvider testDataProvider) { - _testDataProvider = testDataProvider; + _testDataProvider = testDataProvider; } protected void trackColumnsForAutoSizingIfSXSSF(Sheet sheet) { @@ -116,9 +116,7 @@ public abstract class BaseTestSheet { } } - @Test(expected=IllegalArgumentException.class) - public void createRowAfterLastRow() throws IOException { - final SpreadsheetVersion version = _testDataProvider.getSpreadsheetVersion(); + protected void createRowAfterLastRow(SpreadsheetVersion version) throws IOException { final Workbook workbook = _testDataProvider.createWorkbook(); final Sheet sh = workbook.createSheet(); sh.createRow(version.getLastRowIndex()); @@ -130,6 +128,7 @@ public abstract class BaseTestSheet { } } + @Test public void removeRow() throws IOException { Workbook workbook = _testDataProvider.createWorkbook(); diff --git a/src/testcases/org/apache/poi/ss/usermodel/BaseTestWorkbook.java b/src/testcases/org/apache/poi/ss/usermodel/BaseTestWorkbook.java index 6290119f51..2169db3d59 100644 --- a/src/testcases/org/apache/poi/ss/usermodel/BaseTestWorkbook.java +++ b/src/testcases/org/apache/poi/ss/usermodel/BaseTestWorkbook.java @@ -33,15 +33,16 @@ import java.util.Iterator; import org.apache.poi.hssf.HSSFTestDataSamples; import org.apache.poi.ss.ITestDataProvider; +import org.apache.poi.ss.SpreadsheetVersion; import org.apache.poi.ss.util.CellRangeAddress; import org.junit.Test; public abstract class BaseTestWorkbook { - protected final ITestDataProvider _testDataProvider; + private final ITestDataProvider _testDataProvider; protected BaseTestWorkbook(ITestDataProvider testDataProvider) { - _testDataProvider = testDataProvider; + _testDataProvider = testDataProvider; } @Test @@ -742,7 +743,7 @@ public abstract class BaseTestWorkbook { wb2.close(); } - protected void changeSheetNameWithSharedFormulas(String sampleFile) throws IOException { + public void changeSheetNameWithSharedFormulas(String sampleFile) throws IOException { Workbook wb = _testDataProvider.openSampleWorkbook(sampleFile); FormulaEvaluator evaluator = wb.getCreationHelper().createFormulaEvaluator(); @@ -826,9 +827,11 @@ public abstract class BaseTestWorkbook { } @Test - public void getSpreadsheetVersion() throws IOException { + public abstract void getSpreadsheetVersion() throws IOException; + + protected void verifySpreadsheetVersion(SpreadsheetVersion expected) throws IOException { final Workbook wb = _testDataProvider.createWorkbook(); - assertEquals(_testDataProvider.getSpreadsheetVersion(), wb.getSpreadsheetVersion()); + assertEquals(expected, wb.getSpreadsheetVersion()); wb.close(); } -- 2.39.5