List<Class<?>> lst = new ArrayList<Class<?>>();
//collect unit tests
String exclude = StringUtil.join("|",
+ "BaseTestXWorkbook",
+ "BaseTestXSheet",
+ "BaseTestXRow",
"BaseTestXCell",
"TestSXSSFWorkbook\\$\\d",
"TestSXSSFWorkbook\\$NullOutputStream",
--- /dev/null
+/* ====================================================================
+ 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());
+ }
+}
--- /dev/null
+/* ====================================================================
+ 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);
+ }
+}
--- /dev/null
+/* ====================================================================
+ 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);
+ }
+}
package org.apache.poi.xssf.streaming;
-import java.io.IOException;
-
-import org.apache.poi.ss.SpreadsheetVersion;
-import org.apache.poi.ss.usermodel.BaseTestRow;
+import org.apache.poi.ss.usermodel.BaseTestXRow;
import org.apache.poi.xssf.SXSSFITestDataProvider;
import org.junit.After;
import org.junit.Test;
/**
* Tests for XSSFRow
*/
-public final class TestSXSSFRow extends BaseTestRow {
+public final class TestSXSSFRow extends BaseTestXRow {
public TestSXSSFRow() {
super(SXSSFITestDataProvider.instance);
@After
public void tearDown() {
- SXSSFITestDataProvider.instance.cleanup();
- }
-
- @Test
- public void testRowBounds() throws IOException {
- baseTestRowBounds(SpreadsheetVersion.EXCEL2007.getLastRowIndex());
- }
-
- @Test
- public void testCellBounds() throws IOException {
- baseTestCellBounds(SpreadsheetVersion.EXCEL2007.getLastColumnIndex());
+ ((SXSSFITestDataProvider) _testDataProvider).cleanup();
}
}
import static org.junit.Assert.fail;
import java.io.IOException;
-import java.util.SortedSet;
-import java.util.TreeSet;
-import org.apache.poi.ss.SpreadsheetVersion;
-import org.apache.poi.ss.usermodel.BaseTestSheet;
+import org.apache.poi.ss.usermodel.BaseTestXSheet;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.SXSSFITestDataProvider;
import org.junit.Test;
-public class TestSXSSFSheet extends BaseTestSheet {
+public final class TestSXSSFSheet extends BaseTestXSheet {
public TestSXSSFSheet() {
super(SXSSFITestDataProvider.instance);
template.close();
}
}
-
- @Test(expected=IllegalArgumentException.class)
- public void createRowAfterLastRow() throws IOException {
- createRowAfterLastRow(SpreadsheetVersion.EXCEL2007);
- }
}
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.openxml4j.opc.OPCPackage;
-import org.apache.poi.ss.SpreadsheetVersion;
-import org.apache.poi.ss.usermodel.BaseTestWorkbook;
+import org.apache.poi.ss.usermodel.BaseTestXWorkbook;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.junit.Ignore;
import org.junit.Test;
-public final class TestSXSSFWorkbook extends BaseTestWorkbook {
- private static final SXSSFITestDataProvider _testDataProvider = SXSSFITestDataProvider.instance;
+public final class TestSXSSFWorkbook extends BaseTestXWorkbook {
public TestSXSSFWorkbook() {
- super(_testDataProvider);
- }
+ super(SXSSFITestDataProvider.instance);
+ }
@After
public void tearDown(){
- _testDataProvider.cleanup();
+ ((SXSSFITestDataProvider)_testDataProvider).cleanup();
}
/**
xwb.close();
}
- static void assertWorkbookDispose(SXSSFWorkbook wb)
+ protected static void assertWorkbookDispose(SXSSFWorkbook wb)
{
int rowNum = 1000;
int sheetNum = 5;
workBook.close();
}
- @Test
- @Override
- public void getSpreadsheetVersion() throws IOException {
- verifySpreadsheetVersion(SpreadsheetVersion.EXCEL2007);
- }
-
+
@Test
public void closeDoesNotModifyWorkbook() throws IOException, InvalidFormatException {
final String filename = "SampleSS.xlsx";
import java.io.IOException;
-import org.apache.poi.ss.SpreadsheetVersion;
-import org.apache.poi.ss.usermodel.BaseTestRow;
+import org.apache.poi.ss.usermodel.BaseTestXRow;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellCopyPolicy;
import org.apache.poi.ss.usermodel.Row;
/**
* Tests for XSSFRow
*/
-public final class TestXSSFRow extends BaseTestRow {
+public final class TestXSSFRow extends BaseTestXRow {
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());
- }
+ @Test
public void testCopyRowFrom() throws IOException {
final XSSFWorkbook workbook = new XSSFWorkbook();
final XSSFSheet sheet = workbook.createSheet("test");
workbook.close();
}
+ @Test
public void testCopyRowFromExternalSheet() throws IOException {
final XSSFWorkbook workbook = new XSSFWorkbook();
final Sheet srcSheet = workbook.createSheet("src");
workbook.close();
}
+ @Test
public void testCopyRowOverwritesExistingRow() throws IOException {
final XSSFWorkbook workbook = new XSSFWorkbook();
final XSSFSheet sheet1 = workbook.createSheet("Sheet1");
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;
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.BaseTestSheet;
+import org.apache.poi.ss.usermodel.BaseTestXSheet;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellCopyPolicy;
import org.apache.poi.ss.usermodel.ClientAnchor;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.STPane;
-public final class TestXSSFSheet extends BaseTestSheet {
+public final class TestXSSFSheet extends BaseTestXSheet {
public TestXSSFSheet() {
super(XSSFITestDataProvider.instance);
wb2.close();
}
-
- @Test(expected=IllegalArgumentException.class)
- public void createRowAfterLastRow() throws IOException {
- createRowAfterLastRow(SpreadsheetVersion.EXCEL2007);
- }
@Test
public void setAutoFilter() throws IOException {
wb.close();
}
- public void testCopyMultipleRows(String copyRowsTestWorkbook) throws IOException {
+ protected void testCopyMultipleRows(String copyRowsTestWorkbook) throws IOException {
final double FLOAT_PRECISION = 1e-9;
final XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook(copyRowsTestWorkbook);
final XSSFSheet sheet = wb.getSheetAt(0);
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.BaseTestWorkbook;
+import org.apache.poi.ss.usermodel.BaseTestXWorkbook;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.Font;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorkbookPr;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.STCalcMode;
-public final class TestXSSFWorkbook extends BaseTestWorkbook {
- private static final XSSFITestDataProvider _testDataProvider = XSSFITestDataProvider.instance;
+public final class TestXSSFWorkbook extends BaseTestXWorkbook {
public TestXSSFWorkbook() {
- super(_testDataProvider);
+ super(XSSFITestDataProvider.instance);
}
/**
}
}
- public void setPivotData(XSSFWorkbook wb){
+ protected void setPivotData(XSSFWorkbook wb){
XSSFSheet sheet = wb.createSheet();
Row row1 = sheet.createRow(0);
workbook.close();
}
- @SuppressWarnings("unchecked")
- @Test
/**
* Iterator<XSSFSheet> XSSFWorkbook.iterator was committed in r700472 on 2008-09-30
* and has been replaced with Iterator<Sheet> XSSFWorkbook.iterator
* 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();
}
}
- @Test
- @Override
- public void getSpreadsheetVersion() throws IOException {
- verifySpreadsheetVersion(SpreadsheetVersion.EXCEL2007);
- }
-
@Test
public void closeDoesNotModifyWorkbook() throws IOException, InvalidFormatException {
final String filename = "SampleSS.xlsx";
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;
public TestHSSFSheet() {
super(HSSFITestDataProvider.instance);
}
-
- @Test(expected=IllegalArgumentException.class)
- public void createRowAfterLastRow() throws IOException {
- createRowAfterLastRow(SpreadsheetVersion.EXCEL97);
- }
/**
* Test for Bugzilla #29747.
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;
wb.close();
}
- @SuppressWarnings("unused")
@Test
public void selectMultiple() throws IOException {
HSSFWorkbook wb=new HSSFWorkbook();
}
- @Test
- @Override
- public void getSpreadsheetVersion() throws IOException {
- verifySpreadsheetVersion(SpreadsheetVersion.EXCEL97);
- }
-
@Test
public void closeDoesNotModifyWorkbook() throws IOException {
final String filename = "SampleSS.xls";
*/
public abstract class BaseTestRow {
- private final ITestDataProvider _testDataProvider;
+ protected final ITestDataProvider _testDataProvider;
protected BaseTestRow(ITestDataProvider testDataProvider) {
_testDataProvider = testDataProvider;
* 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();
workbook.close();
}
+ @Test
public void testRemoveCell() throws IOException {
Workbook wb1 = _testDataProvider.createWorkbook();
{
wb2.close();
}
- public void baseTestRowBounds(int maxRowNum) throws IOException {
+ protected void baseTestRowBounds(int maxRowNum) throws IOException {
Workbook workbook = _testDataProvider.createWorkbook();
Sheet sheet = workbook.createSheet();
//Test low row bound
workbook.close();
}
- public void baseTestCellBounds(int maxCellNum) throws IOException {
+ protected void baseTestCellBounds(int maxCellNum) throws IOException {
Workbook wb1 = _testDataProvider.createWorkbook();
Sheet sheet = wb1.createSheet();
* 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");
/**
* Tests for the missing/blank cell policy stuff
*/
+ @Test
public void testGetCellPolicy() throws IOException {
Workbook workbook = _testDataProvider.createWorkbook();
Sheet sheet = workbook.createSheet("test");
workbook.close();
}
+ @Test
public void testRowHeight() throws IOException {
Workbook wb1 = _testDataProvider.createWorkbook();
Sheet sheet = wb1.createSheet();
/**
* 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();
wb.close();
}
+ @Test
public void testRowStyle() throws IOException {
Workbook wb1 = _testDataProvider.createWorkbook();
Sheet sheet = wb1.createSheet("test");
@Rule
public ExpectedException thrown = ExpectedException.none();
- private final ITestDataProvider _testDataProvider;
+ protected final ITestDataProvider _testDataProvider;
protected BaseTestSheet(ITestDataProvider testDataProvider) {
- _testDataProvider = testDataProvider;
+ _testDataProvider = testDataProvider;
}
protected void trackColumnsForAutoSizingIfSXSSF(Sheet sheet) {
}
}
- protected void createRowAfterLastRow(SpreadsheetVersion version) throws IOException {
+ @Test(expected=IllegalArgumentException.class)
+ public void createRowAfterLastRow() throws IOException {
+ final SpreadsheetVersion version = _testDataProvider.getSpreadsheetVersion();
final Workbook workbook = _testDataProvider.createWorkbook();
final Sheet sh = workbook.createSheet();
sh.createRow(version.getLastRowIndex());
}
}
-
@Test
public void removeRow() throws IOException {
Workbook workbook = _testDataProvider.createWorkbook();
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 {
- private final ITestDataProvider _testDataProvider;
+ protected final ITestDataProvider _testDataProvider;
protected BaseTestWorkbook(ITestDataProvider testDataProvider) {
- _testDataProvider = testDataProvider;
+ _testDataProvider = testDataProvider;
}
@Test
wb2.close();
}
- public void changeSheetNameWithSharedFormulas(String sampleFile) throws IOException {
+ protected void changeSheetNameWithSharedFormulas(String sampleFile) throws IOException {
Workbook wb = _testDataProvider.openSampleWorkbook(sampleFile);
FormulaEvaluator evaluator = wb.getCreationHelper().createFormulaEvaluator();
}
@Test
- public abstract void getSpreadsheetVersion() throws IOException;
-
- protected void verifySpreadsheetVersion(SpreadsheetVersion expected) throws IOException {
+ public void getSpreadsheetVersion() throws IOException {
final Workbook wb = _testDataProvider.createWorkbook();
- assertEquals(expected, wb.getSpreadsheetVersion());
+ assertEquals(_testDataProvider.getSpreadsheetVersion(), wb.getSpreadsheetVersion());
wb.close();
}