From 93dedbc1c6ef25ac4eac9eff7e3292de97910bb6 Mon Sep 17 00:00:00 2001 From: Javen O'Neal Date: Sun, 17 Apr 2016 08:06:30 +0000 Subject: [PATCH] add junit test classes for combined testing of XML-specific functionality of (S)XSSF Workbook, Sheet, and Row git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1739550 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/poi/ss/usermodel/BaseTestXRow.java | 35 +++++++++++++++++++ .../poi/ss/usermodel/BaseTestXSheet.java | 35 +++++++++++++++++++ .../poi/ss/usermodel/BaseTestXWorkbook.java | 35 +++++++++++++++++++ .../poi/xssf/streaming/TestSXSSFRow.java | 6 ++-- .../poi/xssf/streaming/TestSXSSFSheet.java | 6 ++-- .../poi/xssf/streaming/TestSXSSFWorkbook.java | 13 +++---- .../poi/xssf/usermodel/TestXSSFRow.java | 4 +-- .../poi/xssf/usermodel/TestXSSFSheet.java | 5 ++- .../poi/xssf/usermodel/TestXSSFWorkbook.java | 7 ++-- .../apache/poi/ss/usermodel/BaseTestRow.java | 2 +- .../poi/ss/usermodel/BaseTestSheet.java | 4 +-- .../poi/ss/usermodel/BaseTestWorkbook.java | 4 +-- 12 files changed, 127 insertions(+), 29 deletions(-) create mode 100644 src/ooxml/testcases/org/apache/poi/ss/usermodel/BaseTestXRow.java create mode 100644 src/ooxml/testcases/org/apache/poi/ss/usermodel/BaseTestXSheet.java create 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 new file mode 100644 index 0000000000..369dbcc9cb --- /dev/null +++ b/src/ooxml/testcases/org/apache/poi/ss/usermodel/BaseTestXRow.java @@ -0,0 +1,35 @@ +/* ==================================================================== + 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.SXSSFRow; +import org.apache.poi.xssf.usermodel.XSSFRow; + +/** + * 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); + } +} diff --git a/src/ooxml/testcases/org/apache/poi/ss/usermodel/BaseTestXSheet.java b/src/ooxml/testcases/org/apache/poi/ss/usermodel/BaseTestXSheet.java new file mode 100644 index 0000000000..f6e1bffde8 --- /dev/null +++ b/src/ooxml/testcases/org/apache/poi/ss/usermodel/BaseTestXSheet.java @@ -0,0 +1,35 @@ +/* ==================================================================== + 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 new file mode 100644 index 0000000000..9c7fe3a09a --- /dev/null +++ b/src/ooxml/testcases/org/apache/poi/ss/usermodel/BaseTestXWorkbook.java @@ -0,0 +1,35 @@ +/* ==================================================================== + 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 3ebedd6fae..6281402007 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestSXSSFRow.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestSXSSFRow.java @@ -22,7 +22,7 @@ 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; @@ -30,7 +30,7 @@ import org.junit.Test; /** * Tests for XSSFRow */ -public final class TestSXSSFRow extends BaseTestRow { +public final class TestSXSSFRow extends BaseTestXRow { public TestSXSSFRow() { super(SXSSFITestDataProvider.instance); @@ -39,7 +39,7 @@ public final class TestSXSSFRow extends BaseTestRow { @After public void tearDown() { - SXSSFITestDataProvider.instance.cleanup(); + ((SXSSFITestDataProvider) _testDataProvider).cleanup(); } @Test 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 fbe14f1067..2092f5c35b 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestSXSSFSheet.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestSXSSFSheet.java @@ -23,11 +23,9 @@ 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.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; @@ -36,7 +34,7 @@ import org.junit.After; import org.junit.Test; -public class TestSXSSFSheet extends BaseTestSheet { +public final class TestSXSSFSheet extends BaseTestXSheet { public TestSXSSFSheet() { super(SXSSFITestDataProvider.instance); 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 f8816a4066..27a9096cdf 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestSXSSFWorkbook.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestSXSSFWorkbook.java @@ -32,11 +32,9 @@ 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.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; @@ -52,16 +50,15 @@ import org.junit.Assume; 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(); } /** 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 67b5038576..0d5399a1ea 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFRow.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFRow.java @@ -24,7 +24,7 @@ import static org.junit.Assert.assertSame; 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; @@ -35,7 +35,7 @@ import org.junit.Test; /** * Tests for XSSFRow */ -public final class TestXSSFRow extends BaseTestRow { +public final class TestXSSFRow extends BaseTestXRow { public TestXSSFRow() { super(XSSFITestDataProvider.instance); 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 1e641c64e7..b3ac6991a5 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java @@ -26,7 +26,6 @@ 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; @@ -43,7 +42,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.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; @@ -82,7 +81,7 @@ import org.openxmlformats.schemas.spreadsheetml.x2006.main.STCalcMode; 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); 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 b0266ee4e6..0171edb42d 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.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; @@ -77,11 +77,10 @@ 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 BaseTestWorkbook { - private static final XSSFITestDataProvider _testDataProvider = XSSFITestDataProvider.instance; +public final class TestXSSFWorkbook extends BaseTestXWorkbook { public TestXSSFWorkbook() { - super(_testDataProvider); + super(XSSFITestDataProvider.instance); } /** diff --git a/src/testcases/org/apache/poi/ss/usermodel/BaseTestRow.java b/src/testcases/org/apache/poi/ss/usermodel/BaseTestRow.java index 6801695399..8810cc953d 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 { - private final ITestDataProvider _testDataProvider; + protected final ITestDataProvider _testDataProvider; protected BaseTestRow(ITestDataProvider testDataProvider) { _testDataProvider = testDataProvider; diff --git a/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheet.java b/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheet.java index 830298181c..f1beee2f9a 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(); - private final ITestDataProvider _testDataProvider; + protected final ITestDataProvider _testDataProvider; protected BaseTestSheet(ITestDataProvider testDataProvider) { - _testDataProvider = testDataProvider; + _testDataProvider = testDataProvider; } protected void trackColumnsForAutoSizingIfSXSSF(Sheet sheet) { diff --git a/src/testcases/org/apache/poi/ss/usermodel/BaseTestWorkbook.java b/src/testcases/org/apache/poi/ss/usermodel/BaseTestWorkbook.java index 2169db3d59..097dddfcf9 100644 --- a/src/testcases/org/apache/poi/ss/usermodel/BaseTestWorkbook.java +++ b/src/testcases/org/apache/poi/ss/usermodel/BaseTestWorkbook.java @@ -39,10 +39,10 @@ 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 -- 2.39.5