aboutsummaryrefslogtreecommitdiffstats
path: root/src/testcases/org/apache
diff options
context:
space:
mode:
authorDominik Stadler <centic@apache.org>2021-01-07 06:52:57 +0000
committerDominik Stadler <centic@apache.org>2021-01-07 06:52:57 +0000
commit4bc450ef5f7544d9918d0f560e7b5f4356ae1b81 (patch)
tree9c10a255995e8d58e764c6eca91508cb8a7b7ad8 /src/testcases/org/apache
parent1882dc74c992997994860899e32900a79deab002 (diff)
downloadpoi-4bc450ef5f7544d9918d0f560e7b5f4356ae1b81.tar.gz
poi-4bc450ef5f7544d9918d0f560e7b5f4356ae1b81.zip
Properly close file handles in extractors and when handling password-protected files
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1885229 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/testcases/org/apache')
-rw-r--r--src/testcases/org/apache/poi/ss/usermodel/BaseTestSheetAutosizeColumn.java24
1 files changed, 13 insertions, 11 deletions
diff --git a/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheetAutosizeColumn.java b/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheetAutosizeColumn.java
index c7584ef978..849f656d1c 100644
--- a/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheetAutosizeColumn.java
+++ b/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheetAutosizeColumn.java
@@ -20,6 +20,7 @@ package org.apache.poi.ss.usermodel;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
+import java.io.IOException;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;
@@ -345,19 +346,20 @@ public abstract class BaseTestSheetAutosizeColumn {
@Test
- public void testExcelExporter() {
- final Workbook wb = _testDataProvider.createWorkbook();
- final Sheet sheet = wb.createSheet("test");
- trackColumnsForAutoSizingIfSXSSF(sheet);
- final Row row = sheet.createRow(0);
- final Cell cell = row.createCell(0);
+ public void testExcelExporter() throws IOException {
+ try (final Workbook wb = _testDataProvider.createWorkbook()) {
+ final Sheet sheet = wb.createSheet("test");
+ trackColumnsForAutoSizingIfSXSSF(sheet);
+ final Row row = sheet.createRow(0);
+ final Cell cell = row.createCell(0);
- CellStyle csDateTime = wb.createCellStyle();
- csDateTime.setAlignment(HorizontalAlignment.LEFT);
+ CellStyle csDateTime = wb.createCellStyle();
+ csDateTime.setAlignment(HorizontalAlignment.LEFT);
- cell.setCellValue(new Date(Long.parseLong("1439800763994")));
- cell.setCellStyle(csDateTime);
+ cell.setCellValue(new Date(Long.parseLong("1439800763994")));
+ cell.setCellStyle(csDateTime);
- sheet.autoSizeColumn(0);
+ sheet.autoSizeColumn(0);
+ }
}
} \ No newline at end of file