ASF Bugzilla – Attachment 34954 Details for
Bug 61033
[PATCH] Add Workbook.setCellFormulaValidation to control whether formulas are validated during Cell.setCellFormula or not
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
0002-Unit-tests-for-XSSFWorkbook.setCellFormulaValidation.patch
0002-Unit-tests-for-XSSFWorkbook.setCellFormulaValidation.patch (text/plain), 2.94 KB, created by
Travis Burtrum
on 2017-04-26 18:17:50 UTC
(
hide
)
Description:
0002-Unit-tests-for-XSSFWorkbook.setCellFormulaValidation.patch
Filename:
MIME Type:
Creator:
Travis Burtrum
Created:
2017-04-26 18:17:50 UTC
Size:
2.94 KB
patch
obsolete
>From 935b7783ae2ec1dce4d239e69a3730f9845e98b5 Mon Sep 17 00:00:00 2001 >From: moparisthebest <admin@moparisthebest.com> >Date: Wed, 26 Apr 2017 14:09:24 -0400 >Subject: [PATCH 2/2] Unit tests for XSSFWorkbook.setCellFormulaValidation > >--- > .../apache/poi/xssf/usermodel/TestXSSFCell.java | 38 ++++++++++++++++++++++ > 1 file changed, 38 insertions(+) > >diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCell.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCell.java >index bbca6625e..76e477298 100644 >--- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCell.java >+++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCell.java >@@ -23,6 +23,7 @@ import static org.junit.Assert.assertNotNull; > import static org.junit.Assert.assertNull; > import static org.junit.Assert.assertSame; > import static org.junit.Assert.assertTrue; >+import static org.junit.Assert.assertFalse; > > import java.io.IOException; > import java.util.List; >@@ -30,6 +31,7 @@ import java.util.List; > import org.apache.poi.common.usermodel.HyperlinkType; > import org.apache.poi.hssf.HSSFITestDataProvider; > import org.apache.poi.ss.SpreadsheetVersion; >+import org.apache.poi.ss.formula.FormulaParseException; > import org.apache.poi.ss.usermodel.BaseTestXCell; > import org.apache.poi.ss.usermodel.BorderStyle; > import org.apache.poi.ss.usermodel.Cell; >@@ -179,6 +181,42 @@ public final class TestXSSFCell extends BaseTestXCell { > assertEquals(CellType.BLANK, cell.getCellTypeEnum()); > assertEquals(STCellType.N, ctCell.getT()); > assertEquals("", cell.getStringCellValue()); >+ >+ // check behavior with setCellFormulaValidation >+ final String invalidFormula = "A", validFormula = "A2"; >+ FormulaParseException fpe = null; >+ // check that default is true >+ assertTrue(wb.getCellFormulaValidation()); >+ >+ // check that valid formula does not throw exception >+ try { >+ cell.setCellFormula(validFormula); >+ } catch(FormulaParseException e) { >+ fpe = e; >+ } >+ assertNull(fpe); >+ >+ // check that invalid formula does throw exception >+ try { >+ cell.setCellFormula(invalidFormula); >+ } catch(FormulaParseException e) { >+ fpe = e; >+ } >+ assertNotNull(fpe); >+ fpe = null; >+ >+ // set cell formula validation to false >+ wb.setCellFormulaValidation(false); >+ assertFalse(wb.getCellFormulaValidation()); >+ >+ // check that neither valid nor invalid formula throw an exception >+ try { >+ cell.setCellFormula(validFormula); >+ cell.setCellFormula(invalidFormula); >+ } catch(FormulaParseException e) { >+ fpe = e; >+ } >+ assertNull(fpe); > } finally { > wb.close(); > } >-- >2.12.2 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 61033
:
34946
|
34953
| 34954