From 7dfcd6c684508d60c9500525b0f3b2b836a5c239 Mon Sep 17 00:00:00 2001 From: Dominik Stadler Date: Fri, 27 Feb 2015 09:52:57 +0000 Subject: [PATCH] Adjust tests and fix small typo git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1662650 13f79535-47bb-0310-9956-ffa450edef68 --- .../poi/xssf/streaming/SXSSFWorkbook.java | 2 +- .../poi/xssf/streaming/TestSXSSFWorkbook.java | 26 +++++++++++-------- .../poi/hssf/usermodel/TestHSSFCell.java | 3 +-- 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFWorkbook.java b/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFWorkbook.java index 87d8847bd..79d2cc83b 100644 --- a/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFWorkbook.java +++ b/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFWorkbook.java @@ -831,7 +831,7 @@ public class SXSSFWorkbook implements Workbook /** * Closes the underlying {@link XSSFWorkbook} and {@link OPCPackage} - * on which this Workbook is based, if any. Has no effect on Worbooks + * on which this Workbook is based, if any. Has no effect on Workbooks * created from scratch. */ @Override 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 ce217e234..7aa9422a6 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestSXSSFWorkbook.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestSXSSFWorkbook.java @@ -88,19 +88,23 @@ public final class TestSXSSFWorkbook extends BaseTestWorkbook { } @Test - public void existingWorkbook() { + public void existingWorkbook() throws IOException { XSSFWorkbook xssfWorkbook = new XSSFWorkbook(); xssfWorkbook.createSheet("S1"); SXSSFWorkbook wb = new SXSSFWorkbook(xssfWorkbook); - xssfWorkbook = (XSSFWorkbook) SXSSFITestDataProvider.instance.writeOutAndReadBack(wb); - assertTrue(wb.dispose()); - - wb = new SXSSFWorkbook(xssfWorkbook); - assertEquals(1, wb.getNumberOfSheets()); - Sheet sheet = wb.getSheetAt(0); - assertNotNull(sheet); - assertEquals("S1", sheet.getSheetName()); - assertTrue(wb.dispose()); + try { + xssfWorkbook = (XSSFWorkbook) SXSSFITestDataProvider.instance.writeOutAndReadBack(wb); + assertTrue(wb.dispose()); + + wb = new SXSSFWorkbook(xssfWorkbook); + assertEquals(1, wb.getNumberOfSheets()); + Sheet sheet = wb.getSheetAt(0); + assertNotNull(sheet); + assertEquals("S1", sheet.getSheetName()); + } finally { + assertTrue(wb.dispose()); + wb.close(); + } } @@ -123,7 +127,7 @@ public final class TestSXSSFWorkbook extends BaseTestWorkbook { XSSFWorkbook xssfWorkbook = (XSSFWorkbook) SXSSFITestDataProvider.instance.writeOutAndReadBack(wb); sss = (SharedStringsTable)f.get(wb); assertEquals(2, sss.getUniqueCount()); - wb.dispose(); + assertTrue(wb.dispose()); Sheet sheet1 = xssfWorkbook.getSheetAt(0); assertEquals("S1", sheet1.getSheetName()); diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFCell.java b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFCell.java index 36a48f46f..066c12e7f 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFCell.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFCell.java @@ -33,7 +33,6 @@ import org.apache.poi.hssf.record.StringRecord; import org.apache.poi.ss.SpreadsheetVersion; import org.apache.poi.ss.usermodel.BaseTestCell; import org.apache.poi.ss.usermodel.Cell; -import org.apache.poi.ss.usermodel.ErrorConstants; import org.apache.poi.ss.usermodel.FormulaError; import org.apache.poi.ss.usermodel.RichTextString; import org.apache.poi.ss.usermodel.Row; @@ -330,7 +329,7 @@ public final class TestHSSFCell extends BaseTestCell { // string to error code cell.setCellValue("abc"); confirmStringRecord(sheet, true); - cell.setCellErrorValue((byte)ErrorConstants.ERROR_REF); + cell.setCellErrorValue(FormulaError.REF.getCode()); confirmStringRecord(sheet, false); // string to boolean