aboutsummaryrefslogtreecommitdiffstats
path: root/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheetUpdateArrayFormulas.java
diff options
context:
space:
mode:
authorAndreas Beeker <kiwiwings@apache.org>2015-10-06 00:04:12 +0000
committerAndreas Beeker <kiwiwings@apache.org>2015-10-06 00:04:12 +0000
commit72bae7a1e66f911a631b8b6cfc7aa69125babcac (patch)
tree806aa447084f640ddffee6c53f781aea565c8e7c /src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheetUpdateArrayFormulas.java
parent0e05a940822986a3cc206b613e4195f23a6d41d8 (diff)
downloadpoi-72bae7a1e66f911a631b8b6cfc7aa69125babcac.tar.gz
poi-72bae7a1e66f911a631b8b6cfc7aa69125babcac.zip
sonar fixes and closing resources after use
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1706937 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheetUpdateArrayFormulas.java')
-rw-r--r--src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheetUpdateArrayFormulas.java28
1 files changed, 20 insertions, 8 deletions
diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheetUpdateArrayFormulas.java b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheetUpdateArrayFormulas.java
index 6f3cdad920..dfa2bae701 100644
--- a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheetUpdateArrayFormulas.java
+++ b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheetUpdateArrayFormulas.java
@@ -17,7 +17,12 @@
package org.apache.poi.hssf.usermodel;
-import junit.framework.AssertionFailedError;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.io.IOException;
import org.apache.poi.hssf.HSSFITestDataProvider;
import org.apache.poi.hssf.record.ArrayRecord;
@@ -27,8 +32,10 @@ import org.apache.poi.hssf.record.aggregates.FormulaRecordAggregate;
import org.apache.poi.hssf.record.aggregates.RowRecordsAggregate;
import org.apache.poi.hssf.record.aggregates.SharedValueManager;
import org.apache.poi.hssf.record.aggregates.TestSharedValueManager;
-import org.apache.poi.ss.usermodel.*;
+import org.apache.poi.ss.usermodel.BaseTestSheetUpdateArrayFormulas;
+import org.apache.poi.ss.usermodel.CellRange;
import org.apache.poi.ss.util.CellRangeAddress;
+import org.junit.Test;
/**
* Test array formulas in HSSF
@@ -44,8 +51,8 @@ public final class TestHSSFSheetUpdateArrayFormulas extends BaseTestSheetUpdateA
// Test methods common with XSSF are in superclass
// Local methods here test HSSF-specific details of updating array formulas
-
- public void testHSSFSetArrayFormula_singleCell() {
+ @Test
+ public void testHSSFSetArrayFormula_singleCell() throws IOException {
HSSFWorkbook workbook = new HSSFWorkbook();
HSSFSheet sheet = workbook.createSheet("Sheet1");
@@ -65,12 +72,15 @@ public final class TestHSSFSheetUpdateArrayFormulas extends BaseTestSheetUpdateA
FormulaRecordAggregate agg = (FormulaRecordAggregate)cell.getCellValueRecord();
assertEquals(range.formatAsString(), agg.getArrayFormulaRange().formatAsString());
assertTrue(agg.isPartOfArrayFormula());
+
+ workbook.close();
}
/**
* Makes sure the internal state of HSSFSheet is consistent after removing array formulas
*/
- public void testAddRemoveArrayFormulas_recordUpdates() {
+ @Test
+ public void testAddRemoveArrayFormulas_recordUpdates() throws IOException {
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet s = wb.createSheet("Sheet1");
@@ -96,14 +106,16 @@ public final class TestHSSFSheetUpdateArrayFormulas extends BaseTestSheetUpdateA
RowRecordsAggregate rra = s.getSheet().getRowsAggregate();
SharedValueManager svm = TestSharedValueManager.extractFromRRA(rra);
if (svm.getArrayRecord(4, 1) != null) {
- throw new AssertionFailedError("Array record was not cleaned up properly.");
+ fail("Array record was not cleaned up properly.");
}
+
+ wb.close();
}
private static void confirmRecordClass(Record[] recs, int index, Class<? extends Record> cls) {
if (recs.length <= index) {
- throw new AssertionFailedError("Expected (" + cls.getName() + ") at index "
- + index + " but array length is " + recs.length + ".");
+ fail("Expected (" + cls.getName() + ") at index "
+ + index + " but array length is " + recs.length + ".");
}
assertEquals(cls, recs[index].getClass());
}