aboutsummaryrefslogtreecommitdiffstats
path: root/src/ooxml/testcases/org/apache/poi
diff options
context:
space:
mode:
authorAndreas Beeker <kiwiwings@apache.org>2021-01-09 18:24:51 +0000
committerAndreas Beeker <kiwiwings@apache.org>2021-01-09 18:24:51 +0000
commita4ed4359cce220abe549f870df84b0cd4895b881 (patch)
treee2d349b2aba0486b74f23ec7b02e60a40be418e6 /src/ooxml/testcases/org/apache/poi
parent1d676a098d667f7132f7d62cd76f3f33fb1b17fe (diff)
downloadpoi-a4ed4359cce220abe549f870df84b0cd4895b881.tar.gz
poi-a4ed4359cce220abe549f870df84b0cd4895b881.zip
Sonar fixes
JUnit5 test classes and methods should have default package visibility git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1885308 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/ooxml/testcases/org/apache/poi')
-rw-r--r--src/ooxml/testcases/org/apache/poi/xssf/streaming/TestDeferredSXSSFWorkbook.java13
-rw-r--r--src/ooxml/testcases/org/apache/poi/xssf/streaming/TestSXSSFCell.java18
-rw-r--r--src/ooxml/testcases/org/apache/poi/xssf/streaming/TestSXSSFSheet.java19
-rw-r--r--src/ooxml/testcases/org/apache/poi/xssf/streaming/TestSXSSFWorkbook.java8
-rw-r--r--src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestMissingWorkbookOnXSSF.java2
-rw-r--r--src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestSXSSFBugs.java12
-rw-r--r--src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java202
7 files changed, 131 insertions, 143 deletions
diff --git a/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestDeferredSXSSFWorkbook.java b/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestDeferredSXSSFWorkbook.java
index f0d27d85ce..02d46600e2 100644
--- a/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestDeferredSXSSFWorkbook.java
+++ b/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestDeferredSXSSFWorkbook.java
@@ -58,8 +58,8 @@ public final class TestDeferredSXSSFWorkbook extends BaseTestXWorkbook {
*/
@Override
@Test
- public void cloneSheet() throws IOException {
- RuntimeException e = assertThrows(RuntimeException.class, super::cloneSheet);
+ protected void cloneSheet() throws IOException {
+ RuntimeException e = assertThrows(RuntimeException.class, () -> super.cloneSheet());
assertEquals("Not Implemented", e.getMessage());
}
@@ -68,8 +68,8 @@ public final class TestDeferredSXSSFWorkbook extends BaseTestXWorkbook {
*/
@Override
@Test
- public void sheetClone() throws IOException {
- RuntimeException e = assertThrows(RuntimeException.class, super::sheetClone);
+ protected void sheetClone() throws IOException {
+ RuntimeException e = assertThrows(RuntimeException.class, () -> super.sheetClone());
assertEquals("Not Implemented", e.getMessage());
}
@@ -78,17 +78,14 @@ public final class TestDeferredSXSSFWorkbook extends BaseTestXWorkbook {
*/
@Override
@Disabled("SXSSF doesn't update formulas on sheet name changes, as most cells probably aren't in memory at the time")
- @Test
- public void setSheetName() {}
+ protected void setSheetName() {}
@Override
@Disabled("DeferredSXSSF code disposes rows in a way that breaks this test")
- @Test
public void parentReferences() {}
@Override
@Disabled("DeferredSXSSF code disposes rows in a way that breaks this test")
- @Test
public void unicodeInAll() {}
@Test
diff --git a/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestSXSSFCell.java b/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestSXSSFCell.java
index ebf0f2c134..c9f8612a71 100644
--- a/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestSXSSFCell.java
+++ b/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestSXSSFCell.java
@@ -138,7 +138,7 @@ public class TestSXSSFCell extends BaseTestXCell {
*/
@Override
@Disabled
- public void setBlank_removesArrayFormula_ifCellIsPartOfAnArrayFormulaGroupContainingOnlyThisCell() {
+ protected void setBlank_removesArrayFormula_ifCellIsPartOfAnArrayFormulaGroupContainingOnlyThisCell() {
}
/**
@@ -147,33 +147,29 @@ public class TestSXSSFCell extends BaseTestXCell {
*/
@Override
@Disabled
- @Test // <- annotation is necessary to override expected exception
- public void setBlank_throwsISE_ifCellIsPartOfAnArrayFormulaGroupContainingOtherCells() {
+ protected void setBlank_throwsISE_ifCellIsPartOfAnArrayFormulaGroupContainingOtherCells() {
}
@Override
@Disabled
- @Test
- public void setCellFormula_throwsISE_ifCellIsPartOfAnArrayFormulaGroupContainingOtherCells() {
+ protected void setCellFormula_throwsISE_ifCellIsPartOfAnArrayFormulaGroupContainingOtherCells() {
}
@Override
@Disabled
- public void removeFormula_turnsCellToBlank_whenFormulaWasASingleCellArrayFormula() {
+ protected void removeFormula_turnsCellToBlank_whenFormulaWasASingleCellArrayFormula() {
}
@Override
@Disabled
- public void setCellFormula_onASingleCellArrayFormulaCell_preservesTheValue() {
+ protected void setCellFormula_onASingleCellArrayFormulaCell_preservesTheValue() {
}
- @Test
@Disabled
- public void setCellFormula_isExceptionSafe_onBlankCell() {
+ protected void setCellFormula_isExceptionSafe_onBlankCell() {
}
- @Test
@Disabled
- public void setCellType_FORMULA_onAnArrayFormulaCell_doesNothing() {
+ protected void setCellType_FORMULA_onAnArrayFormulaCell_doesNothing() {
}
}
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 b6c7f54e17..d161e77a32 100644
--- a/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestSXSSFSheet.java
+++ b/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestSXSSFSheet.java
@@ -58,15 +58,15 @@ public final class TestSXSSFSheet extends BaseTestXSheet {
*/
@Override
@Test
- public void cloneSheet() {
- RuntimeException ex = assertThrows(RuntimeException.class, super::cloneSheet);
+ protected void cloneSheet() {
+ RuntimeException ex = assertThrows(RuntimeException.class, () -> super.cloneSheet());
assertEquals("Not Implemented", ex.getMessage());
}
@Override
@Test
- public void cloneSheetMultipleTimes() {
- RuntimeException ex = assertThrows(RuntimeException.class, super::cloneSheetMultipleTimes);
+ protected void cloneSheetMultipleTimes() {
+ RuntimeException ex = assertThrows(RuntimeException.class, () -> super.cloneSheetMultipleTimes());
assertEquals("Not Implemented", ex.getMessage());
}
@@ -75,8 +75,8 @@ public final class TestSXSSFSheet extends BaseTestXSheet {
*/
@Override
@Test
- public void shiftMerged() {
- RuntimeException ex = assertThrows(RuntimeException.class, super::shiftMerged);
+ protected void shiftMerged() {
+ RuntimeException ex = assertThrows(RuntimeException.class, () -> super.shiftMerged());
assertEquals("Not Implemented", ex.getMessage());
}
@@ -87,14 +87,13 @@ public final class TestSXSSFSheet extends BaseTestXSheet {
*/
@Override
@Test
- public void bug35084() {
- RuntimeException ex = assertThrows(RuntimeException.class, super::bug35084);
+ protected void bug35084() {
+ RuntimeException ex = assertThrows(RuntimeException.class, () -> super.bug35084());
assertEquals("Not Implemented", ex.getMessage());
}
@Override
- @Test
- public void getCellComment() {
+ protected void getCellComment() {
// TODO: reading cell comments via Sheet does not work currently as it tries
// to access the underlying sheet for this, but comments are stored as
// properties on Cells...
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 c50e29abf8..2676c623b0 100644
--- a/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestSXSSFWorkbook.java
+++ b/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestSXSSFWorkbook.java
@@ -72,8 +72,8 @@ public final class TestSXSSFWorkbook extends BaseTestXWorkbook {
*/
@Override
@Test
- public void cloneSheet() throws IOException {
- RuntimeException e = assertThrows(RuntimeException.class, super::cloneSheet);
+ protected void cloneSheet() throws IOException {
+ RuntimeException e = assertThrows(RuntimeException.class, () -> super.cloneSheet());
assertEquals("Not Implemented", e.getMessage());
}
@@ -82,8 +82,8 @@ public final class TestSXSSFWorkbook extends BaseTestXWorkbook {
*/
@Override
@Test
- public void sheetClone() throws IOException {
- RuntimeException e = assertThrows(RuntimeException.class, super::sheetClone);
+ protected void sheetClone() {
+ RuntimeException e = assertThrows(RuntimeException.class, () -> super.sheetClone());
assertEquals("Not Implemented", e.getMessage());
}
diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestMissingWorkbookOnXSSF.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestMissingWorkbookOnXSSF.java
index 55790fde8d..bac2e49688 100644
--- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestMissingWorkbookOnXSSF.java
+++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestMissingWorkbookOnXSSF.java
@@ -34,7 +34,7 @@ public final class TestMissingWorkbookOnXSSF extends BaseTestMissingWorkbook {
@Override
@BeforeEach
- public void setUp() {
+ protected void setUp() {
mainWorkbook = XSSFTestDataSamples.openSampleWorkbook(MAIN_WORKBOOK_FILENAME);
sourceWorkbook = HSSFTestDataSamples.openSampleWorkbook(SOURCE_WORKBOOK_FILENAME);
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 4cb0991d5c..e7b8a9ea25 100644
--- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestSXSSFBugs.java
+++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestSXSSFBugs.java
@@ -54,15 +54,15 @@ public final class TestSXSSFBugs extends BaseTestBugzillaIssues {
// override some tests which do not work for SXSSF
@Override @Disabled("cloneSheet() not implemented") @Test
- public void bug18800() { /* cloneSheet() not implemented */ }
+ protected void bug18800() { /* cloneSheet() not implemented */ }
@Override @Disabled("cloneSheet() not implemented") @Test
- public void bug22720() { /* cloneSheet() not implemented */ }
+ protected void bug22720() { /* cloneSheet() not implemented */ }
@Override @Disabled("Evaluation is not fully supported") @Test
- public void bug47815() { /* Evaluation is not supported */ }
+ protected void bug47815() { /* Evaluation is not supported */ }
@Override @Disabled("Evaluation is not fully supported") @Test
- public void bug46729_testMaxFunctionArguments() { /* Evaluation is not supported */ }
+ protected void bug46729_testMaxFunctionArguments() { /* Evaluation is not supported */ }
@Override @Disabled("Reading data is not supported") @Test
- public void bug57798() { /* Reading data is not supported */ }
+ protected void bug57798() { /* Reading data is not supported */ }
/**
* Setting repeating rows and columns shouldn't break
@@ -105,7 +105,7 @@ public final class TestSXSSFBugs extends BaseTestBugzillaIssues {
// bug 60197: setSheetOrder should update sheet-scoped named ranges to maintain references to the sheets before the re-order
@Test
@Override
- public void bug60197_NamedRangesReferToCorrectSheetWhenSheetOrderIsChanged() throws Exception {
+ protected void bug60197_NamedRangesReferToCorrectSheetWhenSheetOrderIsChanged() throws Exception {
try {
super.bug60197_NamedRangesReferToCorrectSheetWhenSheetOrderIsChanged();
} catch (final RuntimeException e) {
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 733372554d..4cbbbb807f 100644
--- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java
+++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java
@@ -96,125 +96,121 @@ public final class TestXSSFSheet extends BaseTestXSheet {
//TODO column styles are not yet supported by XSSF
@Override
- @Test
- public void defaultColumnStyle() {
+ protected void defaultColumnStyle() {
//super.defaultColumnStyle();
}
@Test
public void existingHeaderFooter() throws IOException {
- XSSFWorkbook wb1 = XSSFTestDataSamples.openSampleWorkbook("45540_classic_Header.xlsx");
- XSSFOddHeader hdr;
- XSSFOddFooter ftr;
-
- // Sheet 1 has a header with center and right text
- XSSFSheet s1 = wb1.getSheetAt(0);
- assertNotNull(s1.getHeader());
- assertNotNull(s1.getFooter());
- hdr = (XSSFOddHeader) s1.getHeader();
- ftr = (XSSFOddFooter) s1.getFooter();
-
- assertEquals("&Ctestdoc&Rtest phrase", hdr.getText());
- assertNull(ftr.getText());
-
- assertEquals("", hdr.getLeft());
- assertEquals("testdoc", hdr.getCenter());
- assertEquals("test phrase", hdr.getRight());
-
- assertEquals("", ftr.getLeft());
- assertEquals("", ftr.getCenter());
- assertEquals("", ftr.getRight());
-
- // Sheet 2 has a footer, but it's empty
- XSSFSheet s2 = wb1.getSheetAt(1);
- assertNotNull(s2.getHeader());
- assertNotNull(s2.getFooter());
- hdr = (XSSFOddHeader) s2.getHeader();
- ftr = (XSSFOddFooter) s2.getFooter();
-
- assertNull(hdr.getText());
- assertEquals("&L&F", ftr.getText());
-
- assertEquals("", hdr.getLeft());
- assertEquals("", hdr.getCenter());
- assertEquals("", hdr.getRight());
-
- assertEquals("&F", ftr.getLeft());
- assertEquals("", ftr.getCenter());
- assertEquals("", ftr.getRight());
-
- // Save and reload
- XSSFWorkbook wb2 = XSSFTestDataSamples.writeOutAndReadBack(wb1);
- wb1.close();
-
- hdr = (XSSFOddHeader) wb2.getSheetAt(0).getHeader();
- ftr = (XSSFOddFooter) wb2.getSheetAt(0).getFooter();
-
- assertEquals("", hdr.getLeft());
- assertEquals("testdoc", hdr.getCenter());
- assertEquals("test phrase", hdr.getRight());
+ try (XSSFWorkbook wb1 = XSSFTestDataSamples.openSampleWorkbook("45540_classic_Header.xlsx")) {
+ XSSFOddHeader hdr;
+ XSSFOddFooter ftr;
+
+ // Sheet 1 has a header with center and right text
+ XSSFSheet s1 = wb1.getSheetAt(0);
+ assertNotNull(s1.getHeader());
+ assertNotNull(s1.getFooter());
+ hdr = (XSSFOddHeader) s1.getHeader();
+ ftr = (XSSFOddFooter) s1.getFooter();
+
+ assertEquals("&Ctestdoc&Rtest phrase", hdr.getText());
+ assertNull(ftr.getText());
+
+ assertEquals("", hdr.getLeft());
+ assertEquals("testdoc", hdr.getCenter());
+ assertEquals("test phrase", hdr.getRight());
+
+ assertEquals("", ftr.getLeft());
+ assertEquals("", ftr.getCenter());
+ assertEquals("", ftr.getRight());
+
+ // Sheet 2 has a footer, but it's empty
+ XSSFSheet s2 = wb1.getSheetAt(1);
+ assertNotNull(s2.getHeader());
+ assertNotNull(s2.getFooter());
+ hdr = (XSSFOddHeader) s2.getHeader();
+ ftr = (XSSFOddFooter) s2.getFooter();
+
+ assertNull(hdr.getText());
+ assertEquals("&L&F", ftr.getText());
+
+ assertEquals("", hdr.getLeft());
+ assertEquals("", hdr.getCenter());
+ assertEquals("", hdr.getRight());
+
+ assertEquals("&F", ftr.getLeft());
+ assertEquals("", ftr.getCenter());
+ assertEquals("", ftr.getRight());
+
+ // Save and reload
+ try (XSSFWorkbook wb2 = XSSFTestDataSamples.writeOutAndReadBack(wb1)) {
+ hdr = (XSSFOddHeader) wb2.getSheetAt(0).getHeader();
+ ftr = (XSSFOddFooter) wb2.getSheetAt(0).getFooter();
- assertEquals("", ftr.getLeft());
- assertEquals("", ftr.getCenter());
- assertEquals("", ftr.getRight());
+ assertEquals("", hdr.getLeft());
+ assertEquals("testdoc", hdr.getCenter());
+ assertEquals("test phrase", hdr.getRight());
- wb2.close();
+ assertEquals("", ftr.getLeft());
+ assertEquals("", ftr.getCenter());
+ assertEquals("", ftr.getRight());
+ }
+ }
}
@Test
public void getAllHeadersFooters() throws IOException {
- XSSFWorkbook workbook = new XSSFWorkbook();
- XSSFSheet sheet = workbook.createSheet("Sheet 1");
- assertNotNull(sheet.getOddFooter());
- assertNotNull(sheet.getEvenFooter());
- assertNotNull(sheet.getFirstFooter());
- assertNotNull(sheet.getOddHeader());
- assertNotNull(sheet.getEvenHeader());
- assertNotNull(sheet.getFirstHeader());
-
- assertEquals("", sheet.getOddFooter().getLeft());
- sheet.getOddFooter().setLeft("odd footer left");
- assertEquals("odd footer left", sheet.getOddFooter().getLeft());
-
- assertEquals("", sheet.getEvenFooter().getLeft());
- sheet.getEvenFooter().setLeft("even footer left");
- assertEquals("even footer left", sheet.getEvenFooter().getLeft());
-
- assertEquals("", sheet.getFirstFooter().getLeft());
- sheet.getFirstFooter().setLeft("first footer left");
- assertEquals("first footer left", sheet.getFirstFooter().getLeft());
-
- assertEquals("", sheet.getOddHeader().getLeft());
- sheet.getOddHeader().setLeft("odd header left");
- assertEquals("odd header left", sheet.getOddHeader().getLeft());
-
- assertEquals("", sheet.getOddHeader().getRight());
- sheet.getOddHeader().setRight("odd header right");
- assertEquals("odd header right", sheet.getOddHeader().getRight());
-
- assertEquals("", sheet.getOddHeader().getCenter());
- sheet.getOddHeader().setCenter("odd header center");
- assertEquals("odd header center", sheet.getOddHeader().getCenter());
-
- // Defaults are odd
- assertEquals("odd footer left", sheet.getFooter().getLeft());
- assertEquals("odd header center", sheet.getHeader().getCenter());
-
- workbook.close();
+ try (XSSFWorkbook workbook = new XSSFWorkbook()) {
+ XSSFSheet sheet = workbook.createSheet("Sheet 1");
+ assertNotNull(sheet.getOddFooter());
+ assertNotNull(sheet.getEvenFooter());
+ assertNotNull(sheet.getFirstFooter());
+ assertNotNull(sheet.getOddHeader());
+ assertNotNull(sheet.getEvenHeader());
+ assertNotNull(sheet.getFirstHeader());
+
+ assertEquals("", sheet.getOddFooter().getLeft());
+ sheet.getOddFooter().setLeft("odd footer left");
+ assertEquals("odd footer left", sheet.getOddFooter().getLeft());
+
+ assertEquals("", sheet.getEvenFooter().getLeft());
+ sheet.getEvenFooter().setLeft("even footer left");
+ assertEquals("even footer left", sheet.getEvenFooter().getLeft());
+
+ assertEquals("", sheet.getFirstFooter().getLeft());
+ sheet.getFirstFooter().setLeft("first footer left");
+ assertEquals("first footer left", sheet.getFirstFooter().getLeft());
+
+ assertEquals("", sheet.getOddHeader().getLeft());
+ sheet.getOddHeader().setLeft("odd header left");
+ assertEquals("odd header left", sheet.getOddHeader().getLeft());
+
+ assertEquals("", sheet.getOddHeader().getRight());
+ sheet.getOddHeader().setRight("odd header right");
+ assertEquals("odd header right", sheet.getOddHeader().getRight());
+
+ assertEquals("", sheet.getOddHeader().getCenter());
+ sheet.getOddHeader().setCenter("odd header center");
+ assertEquals("odd header center", sheet.getOddHeader().getCenter());
+
+ // Defaults are odd
+ assertEquals("odd footer left", sheet.getFooter().getLeft());
+ assertEquals("odd header center", sheet.getHeader().getCenter());
+ }
}
@Test
public void autoSizeColumn() throws IOException {
- XSSFWorkbook workbook = new XSSFWorkbook();
- XSSFSheet sheet = workbook.createSheet("Sheet 1");
- sheet.createRow(0).createCell(13).setCellValue("test");
+ try (XSSFWorkbook workbook = new XSSFWorkbook()) {
+ XSSFSheet sheet = workbook.createSheet("Sheet 1");
+ sheet.createRow(0).createCell(13).setCellValue("test");
- sheet.autoSizeColumn(13);
+ sheet.autoSizeColumn(13);
- ColumnHelper columnHelper = sheet.getColumnHelper();
- CTCol col = columnHelper.getColumn(13, false);
- assertTrue(col.getBestFit());
- workbook.close();
+ ColumnHelper columnHelper = sheet.getColumnHelper();
+ CTCol col = columnHelper.getColumn(13, false);
+ assertTrue(col.getBestFit());
+ }
}
@@ -925,7 +921,7 @@ public final class TestXSSFSheet extends BaseTestXSheet {
*/
@Override
@Test
- public void createRow() throws IOException {
+ protected void createRow() throws IOException {
XSSFWorkbook wb1 = new XSSFWorkbook();
XSSFSheet sheet = wb1.createSheet();
CTWorksheet wsh = sheet.getCTWorksheet();