aboutsummaryrefslogtreecommitdiffstats
path: root/src/testcases/org/apache/poi/ss
diff options
context:
space:
mode:
authorAndreas Beeker <kiwiwings@apache.org>2015-10-05 00:28:54 +0000
committerAndreas Beeker <kiwiwings@apache.org>2015-10-05 00:28:54 +0000
commit461375359cb24e15591f414a6c05b63729268a7b (patch)
tree96d512e055f759be9766462d65f774de56776963 /src/testcases/org/apache/poi/ss
parent43db87198bb1374bda4d3c58af26561174566023 (diff)
downloadpoi-461375359cb24e15591f414a6c05b63729268a7b.tar.gz
poi-461375359cb24e15591f414a6c05b63729268a7b.zip
fixed sonar issues and eclipse warnings
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1706742 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/testcases/org/apache/poi/ss')
-rw-r--r--src/testcases/org/apache/poi/ss/usermodel/BaseTestCellComment.java74
-rw-r--r--src/testcases/org/apache/poi/ss/usermodel/BaseTestConditionalFormatting.java131
-rw-r--r--src/testcases/org/apache/poi/ss/usermodel/BaseTestFormulaEvaluator.java56
-rw-r--r--src/testcases/org/apache/poi/ss/usermodel/BaseTestSheet.java191
4 files changed, 303 insertions, 149 deletions
diff --git a/src/testcases/org/apache/poi/ss/usermodel/BaseTestCellComment.java b/src/testcases/org/apache/poi/ss/usermodel/BaseTestCellComment.java
index d5b8a8c515..1b93c22a11 100644
--- a/src/testcases/org/apache/poi/ss/usermodel/BaseTestCellComment.java
+++ b/src/testcases/org/apache/poi/ss/usermodel/BaseTestCellComment.java
@@ -24,7 +24,6 @@ import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
-import java.io.FileOutputStream;
import java.io.IOException;
import org.apache.poi.hssf.usermodel.HSSFSheet;
@@ -45,7 +44,7 @@ public abstract class BaseTestCellComment {
}
@Test
- public final void find() {
+ public final void find() throws IOException {
Workbook book = _testDataProvider.createWorkbook();
Sheet sheet = book.createSheet();
assertNull(sheet.getCellComment(0, 0));
@@ -54,20 +53,21 @@ public abstract class BaseTestCellComment {
Cell cell = row.createCell(0);
assertNull(sheet.getCellComment(0, 0));
assertNull(cell.getCellComment());
+ book.close();
}
@Test
- public final void create() {
+ public final void create() throws IOException {
String cellText = "Hello, World";
String commentText = "We can set comments in POI";
String commentAuthor = "Apache Software Foundation";
int cellRow = 3;
int cellColumn = 1;
- Workbook wb = _testDataProvider.createWorkbook();
- CreationHelper factory = wb.getCreationHelper();
+ Workbook wb1 = _testDataProvider.createWorkbook();
+ CreationHelper factory = wb1.getCreationHelper();
- Sheet sheet = wb.createSheet();
+ Sheet sheet = wb1.createSheet();
assertNull(sheet.getCellComment(cellRow, cellColumn));
Cell cell = sheet.createRow(cellRow).createCell(cellColumn);
@@ -98,8 +98,10 @@ public abstract class BaseTestCellComment {
assertEquals(cellRow, comment.getRow());
assertEquals(cellColumn, comment.getColumn());
- wb = _testDataProvider.writeOutAndReadBack(wb);
- sheet = wb.getSheetAt(0);
+ Workbook wb2 = _testDataProvider.writeOutAndReadBack(wb1);
+ wb1.close();
+
+ sheet = wb2.getSheetAt(0);
cell = sheet.getRow(cellRow).getCell(cellColumn);
comment = cell.getCellComment();
@@ -114,9 +116,10 @@ public abstract class BaseTestCellComment {
comment.setString(factory.createRichTextString("New Comment Text"));
comment.setVisible(false);
- wb = _testDataProvider.writeOutAndReadBack(wb);
+ Workbook wb3 = _testDataProvider.writeOutAndReadBack(wb2);
+ wb2.close();
- sheet = wb.getSheetAt(0);
+ sheet = wb3.getSheetAt(0);
cell = sheet.getRow(cellRow).getCell(cellColumn);
comment = cell.getCellComment();
@@ -126,13 +129,15 @@ public abstract class BaseTestCellComment {
assertEquals(cellRow, comment.getRow());
assertEquals(cellColumn, comment.getColumn());
assertFalse(comment.isVisible());
+
+ wb3.close();
}
/**
* test that we can read cell comments from an existing workbook.
*/
@Test
- public final void readComments() {
+ public final void readComments() throws IOException {
Workbook wb = _testDataProvider.openSampleWorkbook("SimpleWithComments." + _testDataProvider.getStandardFileNameExtension());
@@ -163,18 +168,20 @@ public abstract class BaseTestCellComment {
assertEquals(rownum, comment.getRow());
assertEquals(cell.getColumnIndex(), comment.getColumn());
}
+
+ wb.close();
}
/**
* test that we can modify existing cell comments
*/
@Test
- public final void modifyComments() {
+ public final void modifyComments() throws IOException {
- Workbook wb = _testDataProvider.openSampleWorkbook("SimpleWithComments." + _testDataProvider.getStandardFileNameExtension());
- CreationHelper factory = wb.getCreationHelper();
+ Workbook wb1 = _testDataProvider.openSampleWorkbook("SimpleWithComments." + _testDataProvider.getStandardFileNameExtension());
+ CreationHelper factory = wb1.getCreationHelper();
- Sheet sheet = wb.getSheetAt(0);
+ Sheet sheet = wb1.getSheetAt(0);
Cell cell;
Row row;
@@ -188,8 +195,9 @@ public abstract class BaseTestCellComment {
comment.setString(factory.createRichTextString("Modified comment at row " + rownum));
}
- wb = _testDataProvider.writeOutAndReadBack(wb);
- sheet = wb.getSheetAt(0);
+ Workbook wb2 = _testDataProvider.writeOutAndReadBack(wb1);
+ wb1.close();
+ sheet = wb2.getSheetAt(0);
for (int rownum = 0; rownum < 3; rownum++) {
row = sheet.getRow(rownum);
@@ -199,12 +207,14 @@ public abstract class BaseTestCellComment {
assertEquals("Mofified[" + rownum + "] by Yegor", comment.getAuthor());
assertEquals("Modified comment at row " + rownum, comment.getString().getString());
}
+
+ wb2.close();
}
@Test
- public final void deleteComments() {
- Workbook wb = _testDataProvider.openSampleWorkbook("SimpleWithComments." + _testDataProvider.getStandardFileNameExtension());
- Sheet sheet = wb.getSheetAt(0);
+ public final void deleteComments() throws IOException {
+ Workbook wb1 = _testDataProvider.openSampleWorkbook("SimpleWithComments." + _testDataProvider.getStandardFileNameExtension());
+ Sheet sheet = wb1.getSheetAt(0);
// Zap from rows 1 and 3
assertNotNull(sheet.getRow(0).getCell(1).getCellComment());
@@ -220,24 +230,27 @@ public abstract class BaseTestCellComment {
assertNull(sheet.getRow(2).getCell(1).getCellComment());
// Save and re-load
- wb = _testDataProvider.writeOutAndReadBack(wb);
- sheet = wb.getSheetAt(0);
+ Workbook wb2 = _testDataProvider.writeOutAndReadBack(wb1);
+ wb1.close();
+ sheet = wb2.getSheetAt(0);
// Check
assertNull(sheet.getRow(0).getCell(1).getCellComment());
assertNotNull(sheet.getRow(1).getCell(1).getCellComment());
assertNull(sheet.getRow(2).getCell(1).getCellComment());
+
+ wb2.close();
}
/**
* code from the quick guide
*/
@Test
- public void quickGuide(){
- Workbook wb = _testDataProvider.createWorkbook();
+ public void quickGuide() throws IOException {
+ Workbook wb1 = _testDataProvider.createWorkbook();
- CreationHelper factory = wb.getCreationHelper();
+ CreationHelper factory = wb1.getCreationHelper();
- Sheet sheet = wb.createSheet();
+ Sheet sheet = wb1.createSheet();
Cell cell = sheet.createRow(3).createCell(5);
cell.setCellValue("F4");
@@ -252,8 +265,9 @@ public abstract class BaseTestCellComment {
//assign the comment to the cell
cell.setCellComment(comment);
- wb = _testDataProvider.writeOutAndReadBack(wb);
- sheet = wb.getSheetAt(0);
+ Workbook wb2 = _testDataProvider.writeOutAndReadBack(wb1);
+ wb1.close();
+ sheet = wb2.getSheetAt(0);
cell = sheet.getRow(3).getCell(5);
comment = cell.getCellComment();
assertNotNull(comment);
@@ -261,6 +275,8 @@ public abstract class BaseTestCellComment {
assertEquals("Apache POI", comment.getAuthor());
assertEquals(3, comment.getRow());
assertEquals(5, comment.getColumn());
+
+ wb2.close();
}
@Test
@@ -334,5 +350,7 @@ public abstract class BaseTestCellComment {
assertEquals( 3, anchor.getRow2());
assertEquals(16*EMU_PER_PIXEL, anchor.getDy2());
}
+
+ wb.close();
}
}
diff --git a/src/testcases/org/apache/poi/ss/usermodel/BaseTestConditionalFormatting.java b/src/testcases/org/apache/poi/ss/usermodel/BaseTestConditionalFormatting.java
index a12dbc13d9..de7b298609 100644
--- a/src/testcases/org/apache/poi/ss/usermodel/BaseTestConditionalFormatting.java
+++ b/src/testcases/org/apache/poi/ss/usermodel/BaseTestConditionalFormatting.java
@@ -19,7 +19,14 @@
package org.apache.poi.ss.usermodel;
-import junit.framework.TestCase;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.io.IOException;
import org.apache.poi.hssf.usermodel.HSSFConditionalFormatting;
import org.apache.poi.hssf.usermodel.HSSFConditionalFormattingRule;
@@ -27,11 +34,12 @@ import org.apache.poi.ss.ITestDataProvider;
import org.apache.poi.ss.usermodel.ConditionalFormattingThreshold.RangeType;
import org.apache.poi.ss.usermodel.IconMultiStateFormatting.IconSet;
import org.apache.poi.ss.util.CellRangeAddress;
+import org.junit.Test;
/**
* Base tests for Conditional Formatting, for both HSSF and XSSF
*/
-public abstract class BaseTestConditionalFormatting extends TestCase {
+public abstract class BaseTestConditionalFormatting {
private final ITestDataProvider _testDataProvider;
public BaseTestConditionalFormatting(ITestDataProvider testDataProvider){
@@ -40,7 +48,8 @@ public abstract class BaseTestConditionalFormatting extends TestCase {
protected abstract void assertColour(String hexExpected, Color actual);
- public void testBasic() {
+ @Test
+ public void testBasic() throws IOException {
Workbook wb = _testDataProvider.createWorkbook();
Sheet sh = wb.createSheet();
SheetConditionalFormatting sheetCF = sh.getSheetConditionalFormatting();
@@ -96,13 +105,15 @@ public abstract class BaseTestConditionalFormatting extends TestCase {
} catch (IllegalArgumentException e) {
assertTrue(e.getMessage().startsWith("Number of rules must not exceed 3"));
}
+ wb.close();
}
/**
* Test format conditions based on a boolean formula
*/
+ @Test
@SuppressWarnings("deprecation")
- public void testBooleanFormulaConditions() {
+ public void testBooleanFormulaConditions() throws IOException {
Workbook wb = _testDataProvider.createWorkbook();
Sheet sh = wb.createSheet();
SheetConditionalFormatting sheetCF = sh.getSheetConditionalFormatting();
@@ -135,10 +146,12 @@ public abstract class BaseTestConditionalFormatting extends TestCase {
CellRangeAddress[] ranges2 = sheetCF.getConditionalFormattingAt(formatIndex2).getFormattingRanges();
assertEquals(1, ranges2.length);
assertEquals("B1:B3", ranges2[0].formatAsString());
+ wb.close();
}
+ @Test
@SuppressWarnings("deprecation")
- public void testSingleFormulaConditions() {
+ public void testSingleFormulaConditions() throws IOException {
Workbook wb = _testDataProvider.createWorkbook();
Sheet sh = wb.createSheet();
SheetConditionalFormatting sheetCF = sh.getSheetConditionalFormatting();
@@ -207,10 +220,13 @@ public abstract class BaseTestConditionalFormatting extends TestCase {
assertEquals("0", rule9.getFormula1());
assertEquals("5", rule9.getFormula2());
assertEquals(ComparisonOperator.NOT_BETWEEN, rule9.getComparisonOperation());
+
+ wb.close();
}
+ @Test
@SuppressWarnings("deprecation")
- public void testCopy() {
+ public void testCopy() throws IOException {
Workbook wb = _testDataProvider.createWorkbook();
Sheet sheet1 = wb.createSheet();
Sheet sheet2 = wb.createSheet();
@@ -246,9 +262,12 @@ public abstract class BaseTestConditionalFormatting extends TestCase {
assertEquals("15", sheet2cf.getRule(1).getFormula1());
assertEquals(ComparisonOperator.NOT_EQUAL, sheet2cf.getRule(1).getComparisonOperation());
assertEquals(ConditionalFormattingRule.CONDITION_TYPE_CELL_VALUE_IS, sheet2cf.getRule(1).getConditionType());
+
+ wb.close();
}
- public void testRemove() {
+ @Test
+ public void testRemove() throws IOException {
Workbook wb = _testDataProvider.createWorkbook();
Sheet sheet1 = wb.createSheet();
SheetConditionalFormatting sheetCF = sheet1.getSheetConditionalFormatting();
@@ -287,9 +306,12 @@ public abstract class BaseTestConditionalFormatting extends TestCase {
} catch (IllegalArgumentException e) {
assertTrue(e.getMessage().startsWith("Specified CF index 0 is outside the allowable range"));
}
+
+ wb.close();
}
- public void testCreateCF() {
+ @Test
+ public void testCreateCF() throws IOException {
Workbook workbook = _testDataProvider.createWorkbook();
Sheet sheet = workbook.createSheet();
String formula = "7";
@@ -366,9 +388,12 @@ public abstract class BaseTestConditionalFormatting extends TestCase {
rule2 = cf.getRule(1);
assertEquals("2",rule2.getFormula2());
assertEquals("1",rule2.getFormula1());
+
+ workbook.close();
}
- public void testClone() {
+ @Test
+ public void testClone() throws IOException {
Workbook wb = _testDataProvider.createWorkbook();
Sheet sheet = wb.createSheet();
@@ -399,16 +424,19 @@ public abstract class BaseTestConditionalFormatting extends TestCase {
try {
wb.cloneSheet(0);
+ assertEquals(2, wb.getNumberOfSheets());
} catch (RuntimeException e) {
if (e.getMessage().indexOf("needs to define a clone method") > 0) {
fail("Indentified bug 45682");
}
throw e;
+ } finally {
+ wb.close();
}
- assertEquals(2, wb.getNumberOfSheets());
}
- public void testShiftRows() {
+ @Test
+ public void testShiftRows() throws IOException {
Workbook wb = _testDataProvider.createWorkbook();
Sheet sheet = wb.createSheet();
@@ -457,9 +485,11 @@ public abstract class BaseTestConditionalFormatting extends TestCase {
cf2 = sheetCF.getConditionalFormattingAt(1);
assertEquals("SUM(A10:A21)", cf2.getRule(0).getFormula1());
assertEquals("1+SUM(#REF!)", cf2.getRule(0).getFormula2());
+
+ wb.close();
}
- protected void testRead(String filename){
+ protected void testRead(String filename) throws IOException {
Workbook wb = _testDataProvider.openSampleWorkbook(filename);
Sheet sh = wb.getSheet("CF");
SheetConditionalFormatting sheetCF = sh.getSheetConditionalFormatting();
@@ -542,9 +572,11 @@ public abstract class BaseTestConditionalFormatting extends TestCase {
assertEquals(ComparisonOperator.BETWEEN, rule5.getComparisonOperation());
assertEquals("\"A\"", rule5.getFormula1());
assertEquals("\"AAA\"", rule5.getFormula2());
+
+ wb.close();
}
- public void testReadOffice2007(String filename) {
+ public void testReadOffice2007(String filename) throws IOException {
Workbook wb = _testDataProvider.openSampleWorkbook(filename);
Sheet s = wb.getSheet("CF");
ConditionalFormatting cf = null;
@@ -768,6 +800,8 @@ public abstract class BaseTestConditionalFormatting extends TestCase {
// Mixed icons - Column U
// TODO Support EXT formattings
+
+ wb.close();
}
private void assertDataBar(ConditionalFormatting cf, String color) {
@@ -869,7 +903,8 @@ public abstract class BaseTestConditionalFormatting extends TestCase {
}
}
- public void testCreateFontFormatting() {
+ @Test
+ public void testCreateFontFormatting() throws IOException {
Workbook workbook = _testDataProvider.createWorkbook();
Sheet sheet = workbook.createSheet();
@@ -934,9 +969,11 @@ public abstract class BaseTestConditionalFormatting extends TestCase {
assertEquals(FontFormatting.U_DOUBLE, r1fp.getUnderlineType());
assertEquals(IndexedColors.BLUE.index, r1fp.getFontColorIndex());
+ workbook.close();
}
- public void testCreatePatternFormatting() {
+ @Test
+ public void testCreatePatternFormatting() throws IOException {
Workbook workbook = _testDataProvider.createWorkbook();
Sheet sheet = workbook.createSheet();
@@ -979,9 +1016,12 @@ public abstract class BaseTestConditionalFormatting extends TestCase {
assertEquals(IndexedColors.RED.index, r1fp.getFillBackgroundColor());
assertEquals(IndexedColors.BLUE.index, r1fp.getFillForegroundColor());
assertEquals(PatternFormatting.BRICKS, r1fp.getFillPattern());
+
+ workbook.close();
}
- public void testCreateBorderFormatting() {
+ @Test
+ public void testCreateBorderFormatting() throws IOException {
Workbook workbook = _testDataProvider.createWorkbook();
Sheet sheet = workbook.createSheet();
@@ -1040,11 +1080,14 @@ public abstract class BaseTestConditionalFormatting extends TestCase {
assertEquals(BorderFormatting.BORDER_THICK, r1fp.getBorderTop());
assertEquals(BorderFormatting.BORDER_THIN, r1fp.getBorderLeft());
assertEquals(BorderFormatting.BORDER_HAIR, r1fp.getBorderRight());
+
+ workbook.close();
}
- public void testCreateIconFormatting() {
- Workbook workbook = _testDataProvider.createWorkbook();
- Sheet sheet = workbook.createSheet();
+ @Test
+ public void testCreateIconFormatting() throws IOException {
+ Workbook wb1 = _testDataProvider.createWorkbook();
+ Sheet sheet = wb1.createSheet();
SheetConditionalFormatting sheetCF = sheet.getSheetConditionalFormatting();
ConditionalFormattingRule rule1 =
@@ -1066,9 +1109,11 @@ public abstract class BaseTestConditionalFormatting extends TestCase {
CellRangeAddress [] regions = { CellRangeAddress.valueOf("A1:A5") };
sheetCF.addConditionalFormatting(regions, rule1);
-
+
// Save, re-load and re-check
- workbook = _testDataProvider.writeOutAndReadBack(workbook);
+ Workbook wb2 = _testDataProvider.writeOutAndReadBack(wb1);
+ wb1.close();
+ sheet = wb2.getSheetAt(0);
sheetCF = sheet.getSheetConditionalFormatting();
assertEquals(1, sheetCF.getNumConditionalFormattings());
@@ -1088,14 +1133,17 @@ public abstract class BaseTestConditionalFormatting extends TestCase {
assertEquals(RangeType.PERCENT,iconFmt.getThresholds()[2].getRangeType());
assertEquals(RangeType.MAX, iconFmt.getThresholds()[3].getRangeType());
assertEquals(null, iconFmt.getThresholds()[0].getValue());
- assertEquals(10d, iconFmt.getThresholds()[1].getValue());
- assertEquals(75d, iconFmt.getThresholds()[2].getValue());
+ assertEquals(10d, iconFmt.getThresholds()[1].getValue(), 0);
+ assertEquals(75d, iconFmt.getThresholds()[2].getValue(), 0);
assertEquals(null, iconFmt.getThresholds()[3].getValue());
+
+ wb2.close();
}
- public void testCreateColorScaleFormatting() {
- Workbook workbook = _testDataProvider.createWorkbook();
- Sheet sheet = workbook.createSheet();
+ @Test
+ public void testCreateColorScaleFormatting() throws IOException {
+ Workbook wb1 = _testDataProvider.createWorkbook();
+ Sheet sheet = wb1.createSheet();
SheetConditionalFormatting sheetCF = sheet.getSheetConditionalFormatting();
ConditionalFormattingRule rule1 =
@@ -1115,7 +1163,9 @@ public abstract class BaseTestConditionalFormatting extends TestCase {
sheetCF.addConditionalFormatting(regions, rule1);
// Save, re-load and re-check
- workbook = _testDataProvider.writeOutAndReadBack(workbook);
+ Workbook wb2 = _testDataProvider.writeOutAndReadBack(wb1);
+ wb1.close();
+ sheet = wb2.getSheetAt(0);
sheetCF = sheet.getSheetConditionalFormatting();
assertEquals(1, sheetCF.getNumConditionalFormattings());
@@ -1133,16 +1183,19 @@ public abstract class BaseTestConditionalFormatting extends TestCase {
assertEquals(RangeType.NUMBER, clrFmt.getThresholds()[1].getRangeType());
assertEquals(RangeType.MAX, clrFmt.getThresholds()[2].getRangeType());
assertEquals(null, clrFmt.getThresholds()[0].getValue());
- assertEquals(10d, clrFmt.getThresholds()[1].getValue());
+ assertEquals(10d, clrFmt.getThresholds()[1].getValue(), 0);
assertEquals(null, clrFmt.getThresholds()[2].getValue());
+
+ wb2.close();
}
- public void testCreateDataBarFormatting() {
- Workbook workbook = _testDataProvider.createWorkbook();
- Sheet sheet = workbook.createSheet();
+ @Test
+ public void testCreateDataBarFormatting() throws IOException {
+ Workbook wb1 = _testDataProvider.createWorkbook();
+ Sheet sheet = wb1.createSheet();
String colorHex = "FFFFEB84";
- ExtendedColor color = workbook.getCreationHelper().createExtendedColor();
+ ExtendedColor color = wb1.getCreationHelper().createExtendedColor();
color.setARGBHex(colorHex);
SheetConditionalFormatting sheetCF = sheet.getSheetConditionalFormatting();
ConditionalFormattingRule rule1 =
@@ -1162,7 +1215,9 @@ public abstract class BaseTestConditionalFormatting extends TestCase {
sheetCF.addConditionalFormatting(regions, rule1);
// Save, re-load and re-check
- workbook = _testDataProvider.writeOutAndReadBack(workbook);
+ Workbook wb2 = _testDataProvider.writeOutAndReadBack(wb1);
+ wb1.close();
+ sheet = wb2.getSheetAt(0);
sheetCF = sheet.getSheetConditionalFormatting();
assertEquals(1, sheetCF.getNumConditionalFormattings());
@@ -1182,15 +1237,19 @@ public abstract class BaseTestConditionalFormatting extends TestCase {
assertEquals(RangeType.MAX, dbFmt.getMaxThreshold().getRangeType());
assertEquals(null, dbFmt.getMinThreshold().getValue());
assertEquals(null, dbFmt.getMaxThreshold().getValue());
+
+ wb2.close();
}
- public void testBug55380() {
+ @Test
+ public void testBug55380() throws IOException {
Workbook wb = _testDataProvider.createWorkbook();
Sheet sheet = wb.createSheet();
CellRangeAddress[] ranges = new CellRangeAddress[] {
CellRangeAddress.valueOf("C9:D30"), CellRangeAddress.valueOf("C7:C31")
};
ConditionalFormattingRule rule = sheet.getSheetConditionalFormatting().createConditionalFormattingRule("$A$1>0");
- sheet.getSheetConditionalFormatting().addConditionalFormatting(ranges, rule);
+ sheet.getSheetConditionalFormatting().addConditionalFormatting(ranges, rule);
+ wb.close();
}
-}
+} \ No newline at end of file
diff --git a/src/testcases/org/apache/poi/ss/usermodel/BaseTestFormulaEvaluator.java b/src/testcases/org/apache/poi/ss/usermodel/BaseTestFormulaEvaluator.java
index 1542c36098..998555cc7e 100644
--- a/src/testcases/org/apache/poi/ss/usermodel/BaseTestFormulaEvaluator.java
+++ b/src/testcases/org/apache/poi/ss/usermodel/BaseTestFormulaEvaluator.java
@@ -17,17 +17,21 @@
package org.apache.poi.ss.usermodel;
-import junit.framework.AssertionFailedError;
-import junit.framework.TestCase;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.fail;
+
+import java.io.IOException;
import org.apache.poi.ss.ITestDataProvider;
+import org.junit.Test;
/**
* Common superclass for testing implementatiosn of{@link FormulaEvaluator}
*
* @author Yegor Kozlov
*/
-public abstract class BaseTestFormulaEvaluator extends TestCase {
+public abstract class BaseTestFormulaEvaluator {
protected final ITestDataProvider _testDataProvider;
@@ -38,7 +42,8 @@ public abstract class BaseTestFormulaEvaluator extends TestCase {
_testDataProvider = testDataProvider;
}
- public void testSimpleArithmetic() {
+ @Test
+ public void testSimpleArithmetic() throws IOException {
Workbook wb = _testDataProvider.createWorkbook();
Sheet s = wb.createSheet();
Row r = s.createRow(0);
@@ -58,9 +63,12 @@ public abstract class BaseTestFormulaEvaluator extends TestCase {
assertEquals(6.0, c1.getNumericCellValue(), 0.0001);
assertEquals(5.0, c2.getNumericCellValue(), 0.0001);
+
+ wb.close();
}
- public void testSumCount() {
+ @Test
+ public void testSumCount() throws IOException {
Workbook wb = _testDataProvider.createWorkbook();
Sheet s = wb.createSheet();
Row r = s.createRow(0);
@@ -100,9 +108,11 @@ public abstract class BaseTestFormulaEvaluator extends TestCase {
assertEquals(17.5, c2.getNumericCellValue(), 0.0001);
assertEquals(1, c3.getNumericCellValue(), 0.0001);
assertEquals(4, c4.getNumericCellValue(), 0.0001);
+
+ wb.close();
}
- public void baseTestSharedFormulas(String sampleFile){
+ public void baseTestSharedFormulas(String sampleFile) throws IOException {
Workbook wb = _testDataProvider.openSampleWorkbook(sampleFile);
Sheet sheet = wb.getSheetAt(0);
@@ -125,12 +135,15 @@ public abstract class BaseTestFormulaEvaluator extends TestCase {
cell = sheet.getRow(4).getCell(0);
assertEquals("B5", cell.getCellFormula());
assertEquals("UniqueDocumentNumberID", evaluator.evaluate(cell).getStringValue());
+
+ wb.close();
}
/**
* Test creation / evaluation of formulas with sheet-level names
*/
- public void testSheetLevelFormulas(){
+ @Test
+ public void testSheetLevelFormulas() throws IOException {
Workbook wb = _testDataProvider.createWorkbook();
Row row;
@@ -161,9 +174,12 @@ public abstract class BaseTestFormulaEvaluator extends TestCase {
assertEquals(5.0, evaluator.evaluate(sh2.getRow(0).getCell(1)).getNumberValue(), 0.0);
assertEquals(15.0, evaluator.evaluate(sh2.getRow(0).getCell(2)).getNumberValue(), 0.0);
+
+ wb.close();
}
- public void testFullColumnRefs() {
+ @Test
+ public void testFullColumnRefs() throws IOException {
Workbook wb = _testDataProvider.createWorkbook();
Sheet sheet = wb.createSheet("Sheet1");
Row row = sheet.createRow(0);
@@ -192,9 +208,12 @@ public abstract class BaseTestFormulaEvaluator extends TestCase {
FormulaEvaluator fe = wb.getCreationHelper().createFormulaEvaluator();
assertEquals(26.0, fe.evaluate(cell0).getNumberValue(), 0.0);
assertEquals(56.0, fe.evaluate(cell1).getNumberValue(), 0.0);
+
+ wb.close();
}
- public void testRepeatedEvaluation() {
+ @Test
+ public void testRepeatedEvaluation() throws IOException {
Workbook wb = _testDataProvider.createWorkbook();
FormulaEvaluator fe = wb.getCreationHelper().createFormulaEvaluator();
Sheet sheet = wb.createSheet("Sheet1");
@@ -230,6 +249,8 @@ public abstract class BaseTestFormulaEvaluator extends TestCase {
fe.clearAllCachedResultValues();
cellValue = fe.evaluate(c);
assertEquals(40455.0, cellValue.getNumberValue(), 0.0);
+
+ wb.close();
}
private static void setValue(Sheet sheet, int rowIndex, int colIndex, double value) {
@@ -244,19 +265,22 @@ public abstract class BaseTestFormulaEvaluator extends TestCase {
* {@link FormulaEvaluator#evaluate(org.apache.poi.ss.usermodel.Cell)} should behave the same whether the cell
* is <code>null</code> or blank.
*/
- public void testEvaluateBlank() {
+ @Test
+ public void testEvaluateBlank() throws IOException {
Workbook wb = _testDataProvider.createWorkbook();
FormulaEvaluator fe = wb.getCreationHelper().createFormulaEvaluator();
assertNull(fe.evaluate(null));
Sheet sheet = wb.createSheet("Sheet1");
Cell cell = sheet.createRow(0).createCell(0);
assertNull(fe.evaluate(cell));
+ wb.close();
}
/**
* Test for bug due to attempt to convert a cached formula error result to a boolean
*/
- public void testUpdateCachedFormulaResultFromErrorToNumber_bug46479() {
+ @Test
+ public void testUpdateCachedFormulaResultFromErrorToNumber_bug46479() throws IOException {
Workbook wb = _testDataProvider.createWorkbook();
Sheet sheet = wb.createSheet("Sheet1");
@@ -275,14 +299,16 @@ public abstract class BaseTestFormulaEvaluator extends TestCase {
fe.evaluateInCell(cellB1);
} catch (IllegalStateException e) {
if (e.getMessage().equals("Cannot get a numeric value from a error formula cell")) {
- throw new AssertionFailedError("Identified bug 46479a");
+ fail("Identified bug 46479a");
}
}
assertEquals(3.5, cellB1.getNumericCellValue(), 0.0);
+
+ wb.close();
}
-
- public void testRounding_bug51339() {
+ @Test
+ public void testRounding_bug51339() throws IOException {
Workbook wb = _testDataProvider.createWorkbook();
Sheet sheet = wb.createSheet("Sheet1");
Row row = sheet.createRow(0);
@@ -299,5 +325,7 @@ public abstract class BaseTestFormulaEvaluator extends TestCase {
assertEquals(2162.62, fe.evaluateInCell(cellB1).getNumericCellValue(), 0.0);
assertEquals(2162.62, fe.evaluateInCell(cellC1).getNumericCellValue(), 0.0);
assertEquals(2162.61, fe.evaluateInCell(cellD1).getNumericCellValue(), 0.0);
+
+ wb.close();
}
} \ No newline at end of file
diff --git a/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheet.java b/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheet.java
index 1608006852..5c1df69dac 100644
--- a/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheet.java
+++ b/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheet.java
@@ -49,7 +49,7 @@ public abstract class BaseTestSheet {
}
@Test
- public void createRow() {
+ public void createRow() throws IOException {
Workbook workbook = _testDataProvider.createWorkbook();
Sheet sheet = workbook.createSheet();
assertEquals(0, sheet.getPhysicalNumberOfRows());
@@ -86,36 +86,38 @@ public abstract class BaseTestSheet {
Row row2_ovrewritten_ref = it2.next();
assertSame(row2_ovrewritten, row2_ovrewritten_ref);
assertEquals(100.0, row2_ovrewritten_ref.getCell(0).getNumericCellValue(), 0.0);
+
+ workbook.close();
}
- @Test
- public void createRowBeforeFirstRow() {
+ @Test(expected=IllegalArgumentException.class)
+ public void createRowBeforeFirstRow() throws IOException {
final Workbook workbook = _testDataProvider.createWorkbook();
final Sheet sh = workbook.createSheet();
sh.createRow(0);
try {
+ // Negative rows not allowed
sh.createRow(-1);
- fail("Negative rows not allowed");
- } catch (final IllegalArgumentException e) {
- // expected
+ } finally {
+ workbook.close();
}
}
- protected void createRowAfterLastRow(SpreadsheetVersion version) {
+ protected void createRowAfterLastRow(SpreadsheetVersion version) throws IOException {
final Workbook workbook = _testDataProvider.createWorkbook();
final Sheet sh = workbook.createSheet();
sh.createRow(version.getLastRowIndex());
try {
+ // Row number must be between 0 and last row
sh.createRow(version.getLastRowIndex() + 1);
- fail("Row number must be between 0 and " + version.getLastColumnIndex());
- } catch (final IllegalArgumentException e) {
- // expected
+ } finally {
+ workbook.close();
}
}
@Test
- public void removeRow() {
+ public void removeRow() throws IOException {
Workbook workbook = _testDataProvider.createWorkbook();
Sheet sheet1 = workbook.createSheet();
assertEquals(0, sheet1.getPhysicalNumberOfRows());
@@ -152,10 +154,12 @@ public abstract class BaseTestSheet {
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("Specified row does not belong to this sheet");
sheet2.removeRow(row3);
+
+ workbook.close();
}
@Test
- public void cloneSheet() {
+ public void cloneSheet() throws IOException {
Workbook workbook = _testDataProvider.createWorkbook();
CreationHelper factory = workbook.getCreationHelper();
Sheet sheet = workbook.createSheet("Test Clone");
@@ -182,13 +186,15 @@ public abstract class BaseTestSheet {
}
assertEquals(clonedRow.getCell(0).getRichStringCellValue().getString(), "clone_test");
assertEquals(clonedRow.getCell(1).getCellFormula(), "SIN(1)");
+
+ workbook.close();
}
/** tests that the sheet name for multiple clones of the same sheet is unique
* BUG 37416
*/
@Test
- public void cloneSheetMultipleTimes() {
+ public void cloneSheetMultipleTimes() throws IOException {
Workbook workbook = _testDataProvider.createWorkbook();
CreationHelper factory = workbook.getCreationHelper();
Sheet sheet = workbook.createSheet("Test Clone");
@@ -210,16 +216,18 @@ public abstract class BaseTestSheet {
workbook.createSheet("abc ( 123)");
workbook.cloneSheet(0);
assertEquals("abc (124)", workbook.getSheetName(1));
+
+ workbook.close();
}
/**
* Setting landscape and portrait stuff on new sheets
*/
@Test
- public void printSetupLandscapeNew() {
- Workbook workbook = _testDataProvider.createWorkbook();
- Sheet sheetL = workbook.createSheet("LandscapeS");
- Sheet sheetP = workbook.createSheet("LandscapeP");
+ public void printSetupLandscapeNew() throws IOException {
+ Workbook wb1 = _testDataProvider.createWorkbook();
+ Sheet sheetL = wb1.createSheet("LandscapeS");
+ Sheet sheetP = wb1.createSheet("LandscapeP");
// Check two aspects of the print setup
assertFalse(sheetL.getPrintSetup().getLandscape());
@@ -238,14 +246,16 @@ public abstract class BaseTestSheet {
assertEquals(3, sheetP.getPrintSetup().getCopies());
// Save and re-load, and check still there
- workbook = _testDataProvider.writeOutAndReadBack(workbook);
- sheetL = workbook.getSheet("LandscapeS");
- sheetP = workbook.getSheet("LandscapeP");
+ Workbook wb2 = _testDataProvider.writeOutAndReadBack(wb1);
+ wb1.close();
+ sheetL = wb2.getSheet("LandscapeS");
+ sheetP = wb2.getSheet("LandscapeP");
assertTrue(sheetL.getPrintSetup().getLandscape());
assertFalse(sheetP.getPrintSetup().getLandscape());
assertEquals(1, sheetL.getPrintSetup().getCopies());
assertEquals(3, sheetP.getPrintSetup().getCopies());
+ wb2.close();
}
/**
@@ -254,7 +264,7 @@ public abstract class BaseTestSheet {
*
*/
@Test
- public void addMerged() {
+ public void addMerged() throws IOException {
Workbook wb = _testDataProvider.createWorkbook();
Sheet sheet = wb.createSheet();
assertEquals(0, sheet.getNumMergedRegions());
@@ -286,6 +296,8 @@ public abstract class BaseTestSheet {
assertEquals("Maximum row number is " + ssVersion.getLastRowIndex(), e.getMessage());
}
assertEquals(1, sheet.getNumMergedRegions());
+
+ wb.close();
}
/**
@@ -293,7 +305,7 @@ public abstract class BaseTestSheet {
*
*/
@Test
- public void removeMerged() {
+ public void removeMerged() throws IOException {
Workbook wb = _testDataProvider.createWorkbook();
Sheet sheet = wb.createSheet();
CellRangeAddress region = new CellRangeAddress(0, 1, 0, 1);
@@ -325,10 +337,12 @@ public abstract class BaseTestSheet {
assertTrue("there isn't more than one merged region in there", 1 <= sheet.getNumMergedRegions());
region = sheet.getMergedRegion(0);
assertEquals("the merged row to doesnt match the one we put in ", 4, region.getLastRow());
+
+ wb.close();
}
@Test
- public void shiftMerged() {
+ public void shiftMerged() throws IOException {
Workbook wb = _testDataProvider.createWorkbook();
CreationHelper factory = wb.getCreationHelper();
Sheet sheet = wb.createSheet();
@@ -347,16 +361,17 @@ public abstract class BaseTestSheet {
region = sheet.getMergedRegion(0);
assertEquals("Merged region not moved over to row 2", 2, region.getFirstRow());
+
+ wb.close();
}
/**
* Tests the display of gridlines, formulas, and rowcolheadings.
- * @author Shawn Laubach (slaubach at apache dot org)
*/
@Test
- public void displayOptions() {
- Workbook wb = _testDataProvider.createWorkbook();
- Sheet sheet = wb.createSheet();
+ public void displayOptions() throws IOException {
+ Workbook wb1 = _testDataProvider.createWorkbook();
+ Sheet sheet = wb1.createSheet();
assertEquals(sheet.isDisplayGridlines(), true);
assertEquals(sheet.isDisplayRowColHeadings(), true);
@@ -368,19 +383,22 @@ public abstract class BaseTestSheet {
sheet.setDisplayFormulas(true);
sheet.setDisplayZeros(false);
- wb = _testDataProvider.writeOutAndReadBack(wb);
- sheet = wb.getSheetAt(0);
+ Workbook wb2 = _testDataProvider.writeOutAndReadBack(wb1);
+ wb1.close();
+ sheet = wb2.getSheetAt(0);
assertEquals(sheet.isDisplayGridlines(), false);
assertEquals(sheet.isDisplayRowColHeadings(), false);
assertEquals(sheet.isDisplayFormulas(), true);
assertEquals(sheet.isDisplayZeros(), false);
+
+ wb2.close();
}
@Test
- public void columnWidth() {
- Workbook wb = _testDataProvider.createWorkbook();
- Sheet sheet = wb.createSheet();
+ public void columnWidth() throws IOException {
+ Workbook wb1 = _testDataProvider.createWorkbook();
+ Sheet sheet = wb1.createSheet();
//default column width measured in characters
sheet.setDefaultColumnWidth(10);
@@ -421,9 +439,10 @@ public abstract class BaseTestSheet {
}
//serialize and read again
- wb = _testDataProvider.writeOutAndReadBack(wb);
+ Workbook wb2 = _testDataProvider.writeOutAndReadBack(wb1);
+ wb1.close();
- sheet = wb.getSheetAt(0);
+ sheet = wb2.getSheetAt(0);
assertEquals(20, sheet.getDefaultColumnWidth());
//columns A-C have default width
assertEquals(256*20, sheet.getColumnWidth(0));
@@ -435,11 +454,13 @@ public abstract class BaseTestSheet {
assertEquals(w, sheet.getColumnWidth(i));
}
assertEquals(40000, sheet.getColumnWidth(10));
+
+ wb2.close();
}
@Test
- public void defaultRowHeight() {
+ public void defaultRowHeight() throws IOException {
Workbook workbook = _testDataProvider.createWorkbook();
Sheet sheet = workbook.createSheet();
sheet.setDefaultRowHeightInPoints(15);
@@ -464,11 +485,13 @@ public abstract class BaseTestSheet {
sheet.setDefaultRowHeightInPoints(17.5f);
assertEquals(17.5f, sheet.getDefaultRowHeightInPoints(), 0F);
assertEquals((short)(17.5f*20), sheet.getDefaultRowHeight());
+
+ workbook.close();
}
/** cell with formula becomes null on cloning a sheet*/
@Test
- public void bug35084() {
+ public void bug35084() throws IOException {
Workbook wb = _testDataProvider.createWorkbook();
Sheet s = wb.createSheet("Sheet1");
Row r = s.createRow(0);
@@ -479,11 +502,12 @@ public abstract class BaseTestSheet {
assertEquals("double", r.getCell(0).getNumericCellValue(), 1, 0); // sanity check
assertNotNull(r.getCell(1));
assertEquals("formula", r.getCell(1).getCellFormula(), "A1*2");
+ wb.close();
}
/** test that new default column styles get applied */
@Test
- public void defaultColumnStyle() {
+ public void defaultColumnStyle() throws IOException {
Workbook wb = _testDataProvider.createWorkbook();
CellStyle style = wb.createCellStyle();
Sheet sheet = wb.createSheet();
@@ -496,13 +520,14 @@ public abstract class BaseTestSheet {
CellStyle style2 = cell.getCellStyle();
assertNotNull(style2);
assertEquals("style should match", style.getIndex(), style2.getIndex());
+ wb.close();
}
@Test
- public void outlineProperties() {
- Workbook wb = _testDataProvider.createWorkbook();
+ public void outlineProperties() throws IOException {
+ Workbook wb1 = _testDataProvider.createWorkbook();
- Sheet sheet = wb.createSheet();
+ Sheet sheet = wb1.createSheet();
//TODO defaults are different in HSSF and XSSF
//assertTrue(sheet.getRowSumsBelow());
@@ -520,17 +545,19 @@ public abstract class BaseTestSheet {
assertTrue(sheet.getRowSumsBelow());
assertTrue(sheet.getRowSumsRight());
- wb = _testDataProvider.writeOutAndReadBack(wb);
- sheet = wb.getSheetAt(0);
+ Workbook wb2 = _testDataProvider.writeOutAndReadBack(wb1);
+ wb1.close();
+ sheet = wb2.getSheetAt(0);
assertTrue(sheet.getRowSumsBelow());
assertTrue(sheet.getRowSumsRight());
+ wb2.close();
}
/**
* Test basic display properties
*/
@Test
- public void sheetProperties() {
+ public void sheetProperties() throws IOException {
Workbook wb = _testDataProvider.createWorkbook();
Sheet sheet = wb.createSheet();
@@ -580,9 +607,11 @@ public abstract class BaseTestSheet {
assertTrue(sheet.getFitToPage());
sheet.setFitToPage(false);
assertFalse(sheet.getFitToPage());
+
+ wb.close();
}
- public void baseTestGetSetMargin(double[] defaultMargins) {
+ public void baseTestGetSetMargin(double[] defaultMargins) throws IOException {
double marginLeft = defaultMargins[0];
double marginRight = defaultMargins[1];
double marginTop = defaultMargins[2];
@@ -615,10 +644,12 @@ public abstract class BaseTestSheet {
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("Unknown margin constant: 65");
sheet.setMargin((short) 65, 15);
+
+ workbook.close();
}
@Test
- public void rowBreaks() {
+ public void rowBreaks() throws IOException {
Workbook workbook = _testDataProvider.createWorkbook();
Sheet sheet = workbook.createSheet();
//Sheet#getRowBreaks() returns an empty array if no row breaks are defined
@@ -644,10 +675,12 @@ public abstract class BaseTestSheet {
assertFalse(sheet.isRowBroken(1));
assertFalse(sheet.isRowBroken(15));
+
+ workbook.close();
}
@Test
- public void columnBreaks() {
+ public void columnBreaks() throws IOException {
Workbook workbook = _testDataProvider.createWorkbook();
Sheet sheet = workbook.createSheet();
assertNotNull(sheet.getColumnBreaks());
@@ -672,10 +705,11 @@ public abstract class BaseTestSheet {
assertFalse(sheet.isColumnBroken(11));
assertFalse(sheet.isColumnBroken(12));
+ workbook.close();
}
@Test
- public void getFirstLastRowNum() {
+ public void getFirstLastRowNum() throws IOException {
Workbook workbook = _testDataProvider.createWorkbook();
Sheet sheet = workbook.createSheet("Sheet 1");
sheet.createRow(9);
@@ -683,27 +717,30 @@ public abstract class BaseTestSheet {
sheet.createRow(1);
assertEquals(0, sheet.getFirstRowNum());
assertEquals(9, sheet.getLastRowNum());
+ workbook.close();
}
@Test
- public void getFooter() {
+ public void getFooter() throws IOException {
Workbook workbook = _testDataProvider.createWorkbook();
Sheet sheet = workbook.createSheet("Sheet 1");
assertNotNull(sheet.getFooter());
sheet.getFooter().setCenter("test center footer");
assertEquals("test center footer", sheet.getFooter().getCenter());
+ workbook.close();
}
@Test
- public void getSetColumnHidden() {
+ public void getSetColumnHidden() throws IOException {
Workbook workbook = _testDataProvider.createWorkbook();
Sheet sheet = workbook.createSheet("Sheet 1");
sheet.setColumnHidden(2, true);
assertTrue(sheet.isColumnHidden(2));
+ workbook.close();
}
@Test
- public void protectSheet() {
+ public void protectSheet() throws IOException {
Workbook wb = _testDataProvider.createWorkbook();
Sheet sheet = wb.createSheet();
assertFalse(sheet.getProtect());
@@ -711,11 +748,11 @@ public abstract class BaseTestSheet {
assertTrue(sheet.getProtect());
sheet.protectSheet(null);
assertFalse(sheet.getProtect());
-
+ wb.close();
}
@Test
- public void createFreezePane() {
+ public void createFreezePane() throws IOException {
Workbook wb = _testDataProvider.createWorkbook();
// create a workbook
Sheet sheet = wb.createSheet();
@@ -762,11 +799,13 @@ public abstract class BaseTestSheet {
sheet.createFreezePane(0, 0);
// If both colSplit and rowSplit are zero then the existing freeze pane is removed
assertNull(sheet.getPaneInformation());
+
+ wb.close();
}
@Test
- public void getRepeatingRowsAndColumns() {
+ public void getRepeatingRowsAndColumns() throws IOException {
Workbook wb = _testDataProvider.openSampleWorkbook(
"RepeatingRowsCols."
+ _testDataProvider.getStandardFileNameExtension());
@@ -775,11 +814,12 @@ public abstract class BaseTestSheet {
checkRepeatingRowsAndColumns(wb.getSheetAt(1), "1:1", null);
checkRepeatingRowsAndColumns(wb.getSheetAt(2), null, "A:A");
checkRepeatingRowsAndColumns(wb.getSheetAt(3), "2:3", "A:B");
+ wb.close();
}
@Test
- public void setRepeatingRowsAndColumnsBug47294(){
+ public void setRepeatingRowsAndColumnsBug47294() throws IOException {
Workbook wb = _testDataProvider.createWorkbook();
Sheet sheet1 = wb.createSheet();
sheet1.setRepeatingRows(CellRangeAddress.valueOf("1:4"));
@@ -789,14 +829,15 @@ public abstract class BaseTestSheet {
Sheet sheet2 = wb.createSheet("My' Sheet");
sheet2.setRepeatingRows(CellRangeAddress.valueOf("1:4"));
assertEquals("1:4", sheet2.getRepeatingRows().formatAsString());
+ wb.close();
}
@Test
- public void setRepeatingRowsAndColumns() {
- Workbook wb = _testDataProvider.createWorkbook();
- Sheet sheet1 = wb.createSheet("Sheet1");
- Sheet sheet2 = wb.createSheet("Sheet2");
- Sheet sheet3 = wb.createSheet("Sheet3");
+ public void setRepeatingRowsAndColumns() throws IOException {
+ Workbook wb1 = _testDataProvider.createWorkbook();
+ Sheet sheet1 = wb1.createSheet("Sheet1");
+ Sheet sheet2 = wb1.createSheet("Sheet2");
+ Sheet sheet3 = wb1.createSheet("Sheet3");
checkRepeatingRowsAndColumns(sheet1, null, null);
@@ -810,10 +851,11 @@ public abstract class BaseTestSheet {
checkRepeatingRowsAndColumns(sheet3, "1:4", "A:A");
// write out, read back, and test refrain...
- wb = _testDataProvider.writeOutAndReadBack(wb);
- sheet1 = wb.getSheetAt(0);
- sheet2 = wb.getSheetAt(1);
- sheet3 = wb.getSheetAt(2);
+ Workbook wb2 = _testDataProvider.writeOutAndReadBack(wb1);
+ wb1.close();
+ sheet1 = wb2.getSheetAt(0);
+ sheet2 = wb2.getSheetAt(1);
+ sheet3 = wb2.getSheetAt(2);
checkRepeatingRowsAndColumns(sheet1, "4:5", null);
checkRepeatingRowsAndColumns(sheet2, null, "A:C");
@@ -825,6 +867,7 @@ public abstract class BaseTestSheet {
sheet3.setRepeatingColumns(null);
checkRepeatingRowsAndColumns(sheet3, null, null);
+ wb2.close();
}
private void checkRepeatingRowsAndColumns(
@@ -842,23 +885,25 @@ public abstract class BaseTestSheet {
}
@Test
- public void baseZoom() {
+ public void baseZoom() throws IOException {
Workbook wb = _testDataProvider.createWorkbook();
Sheet sheet = wb.createSheet();
// here we can only verify that setting some zoom values works, range-checking is different between the implementations
sheet.setZoom(3,4);
+ wb.close();
}
@Test
- public void baseShowInPane() {
+ public void baseShowInPane() throws IOException {
Workbook wb = _testDataProvider.createWorkbook();
Sheet sheet = wb.createSheet();
sheet.showInPane(2, 3);
+ wb.close();
}
@Test
- public void bug55723(){
+ public void bug55723() throws IOException {
Workbook wb = _testDataProvider.createWorkbook();
Sheet sheet = wb.createSheet();
@@ -871,6 +916,7 @@ public abstract class BaseTestSheet {
filter = sheet.setAutoFilter(range);
assertNotNull(filter);
// there seems to be currently no generic way to check the setting...
+ wb.close();
}
@Test
@@ -956,9 +1002,9 @@ public abstract class BaseTestSheet {
}
@Test
- public void showInPaneManyRowsBug55248() {
- Workbook workbook = _testDataProvider.createWorkbook();
- Sheet sheet = workbook.createSheet("Sheet 1");
+ public void showInPaneManyRowsBug55248() throws IOException {
+ Workbook wb1 = _testDataProvider.createWorkbook();
+ Sheet sheet = wb1.createSheet("Sheet 1");
sheet.showInPane(0, 0);
@@ -971,8 +1017,11 @@ public abstract class BaseTestSheet {
int i = 0;
sheet.showInPane(i, i);
- Workbook wb = _testDataProvider.writeOutAndReadBack(workbook);
- checkRowCount(wb);
+ Workbook wb2 = _testDataProvider.writeOutAndReadBack(wb1);
+ checkRowCount(wb2);
+
+ wb2.close();
+ wb1.close();
}
private void checkRowCount(Workbook wb) {