From: PJ Fanning Date: Tue, 9 Nov 2021 19:45:03 +0000 (+0000) Subject: [bug-65675] add regression test X-Git-Tag: REL_5_2_0~244 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=02f36cf4fdf608c95afbb8875deb26e857f1978d;p=poi.git [bug-65675] add regression test git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1894884 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/poi-examples/src/main/java/org/apache/poi/examples/xssf/usermodel/CalendarDemo.java b/poi-examples/src/main/java/org/apache/poi/examples/xssf/usermodel/CalendarDemo.java index 9f0da5e740..60ce9b91ee 100644 --- a/poi-examples/src/main/java/org/apache/poi/examples/xssf/usermodel/CalendarDemo.java +++ b/poi-examples/src/main/java/org/apache/poi/examples/xssf/usermodel/CalendarDemo.java @@ -41,7 +41,7 @@ import org.apache.poi.xssf.usermodel.XSSFWorkbook; /** * A monthly calendar created using Apache POI. Each month is on a separate sheet. * This is a version of org.apache.poi.ss.examples.CalendarDemo that demonstrates - * some XSSF features not avaiable when using common HSSF-XSSF interfaces. + * some XSSF features not available when using common HSSF-XSSF interfaces. * *
  * Usage:
diff --git a/poi-examples/src/main/java/org/apache/poi/examples/xssf/usermodel/WorkingWithPageSetup.java b/poi-examples/src/main/java/org/apache/poi/examples/xssf/usermodel/WorkingWithPageSetup.java
index a43c5125a3..f05f6ff8d1 100644
--- a/poi-examples/src/main/java/org/apache/poi/examples/xssf/usermodel/WorkingWithPageSetup.java
+++ b/poi-examples/src/main/java/org/apache/poi/examples/xssf/usermodel/WorkingWithPageSetup.java
@@ -25,7 +25,7 @@ import org.apache.poi.ss.util.CellRangeAddress;
 import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 
 /**
- * Demonstrates various settings avaiable in the Page Setup dialog
+ * Demonstrates various settings available in the Page Setup dialog
  */
 public class WorkingWithPageSetup {
 
diff --git a/poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestXSSFEvaluationSheet.java b/poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestXSSFEvaluationSheet.java
index 431f585b60..4c9eba60f9 100644
--- a/poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestXSSFEvaluationSheet.java
+++ b/poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestXSSFEvaluationSheet.java
@@ -16,22 +16,22 @@
 ==================================================================== */
 package org.apache.poi.xssf.usermodel;
 
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertNull;
-
+import java.io.IOException;
 import java.util.AbstractMap;
 import java.util.Map;
 
 import org.apache.poi.ss.formula.EvaluationSheet;
 import org.apache.poi.ss.usermodel.BaseTestXEvaluationSheet;
+import org.apache.poi.ss.usermodel.CellType;
 import org.apache.poi.ss.usermodel.Sheet;
 import org.junit.jupiter.api.Test;
 
+import static org.junit.jupiter.api.Assertions.*;
+
 class TestXSSFEvaluationSheet extends BaseTestXEvaluationSheet {
 
     @Test
-    void test() throws Exception {
+    void testSheetEval() throws Exception {
         XSSFWorkbook wb = new XSSFWorkbook();
         XSSFSheet sheet = wb.createSheet("test");
         XSSFRow row = sheet.createRow(0);
@@ -61,6 +61,26 @@ class TestXSSFEvaluationSheet extends BaseTestXEvaluationSheet {
         assertEquals(sheet, evalsheet.getXSSFSheet());
     }
 
+    @Test
+    void testBug65675() throws IOException  {
+        try (XSSFWorkbook workbook = new XSSFWorkbook()) {
+            XSSFFormulaEvaluator evaluator = workbook.getCreationHelper().createFormulaEvaluator();
+            evaluator.setIgnoreMissingWorkbooks(true);
+
+            XSSFSheet sheet = workbook.createSheet("sheet");
+            XSSFRow row = sheet.createRow(0);
+            XSSFCell cell = row.createCell(0, CellType.FORMULA);
+
+            try {
+                cell.setCellFormula("[some-workbook-that-does-not-yet-exist.xlsx]main!B:D");
+                //it might be better if this succeeded but just adding this regression test for now
+                fail("expected exception");
+            } catch (RuntimeException re) {
+                assertEquals("Book not linked for filename some-workbook-that-does-not-yet-exist.xlsx", re.getMessage());
+            }
+        }
+    }
+
     @Override
     protected Map.Entry getInstance() {
         XSSFSheet sheet = new XSSFWorkbook().createSheet();
diff --git a/poi/src/main/java/org/apache/poi/ss/formula/WorkbookEvaluator.java b/poi/src/main/java/org/apache/poi/ss/formula/WorkbookEvaluator.java
index f1beee7569..79aa8dc374 100644
--- a/poi/src/main/java/org/apache/poi/ss/formula/WorkbookEvaluator.java
+++ b/poi/src/main/java/org/apache/poi/ss/formula/WorkbookEvaluator.java
@@ -926,7 +926,7 @@ public final class WorkbookEvaluator {
      * Whether to ignore missing references to external workbooks and
      * use cached formula results in the main workbook instead.
      * 

- * In some cases exetrnal workbooks referenced by formulas in the main workbook are not avaiable. + * In some cases external workbooks referenced by formulas in the main workbook are not available. * With this method you can control how POI handles such missing references: *

    *
  • by default ignoreMissingWorkbooks=false and POI throws {@link WorkbookNotFoundException} diff --git a/poi/src/main/java/org/apache/poi/ss/formula/ptg/RefPtgBase.java b/poi/src/main/java/org/apache/poi/ss/formula/ptg/RefPtgBase.java index e73093a716..c7b55780f6 100644 --- a/poi/src/main/java/org/apache/poi/ss/formula/ptg/RefPtgBase.java +++ b/poi/src/main/java/org/apache/poi/ss/formula/ptg/RefPtgBase.java @@ -33,8 +33,8 @@ import org.apache.poi.util.LittleEndianOutput; public abstract class RefPtgBase extends OperandPtg { /** - * YK: subclasses of RefPtgBase are used by the FormulaParser and FormulaEvaluator accross HSSF and XSSF. - * The bit mask should accommodate the maximum number of avaiable columns, i.e. 0x3FFF. + * YK: subclasses of RefPtgBase are used by the FormulaParser and FormulaEvaluator across HSSF and XSSF. + * The bit mask should accommodate the maximum number of available columns, i.e. 0x3FFF. * * @see org.apache.poi.ss.SpreadsheetVersion */ diff --git a/poi/src/test/java/org/apache/poi/ss/usermodel/BaseTestXEvaluationSheet.java b/poi/src/test/java/org/apache/poi/ss/usermodel/BaseTestXEvaluationSheet.java index 08fbae584e..c1a02f3aaa 100644 --- a/poi/src/test/java/org/apache/poi/ss/usermodel/BaseTestXEvaluationSheet.java +++ b/poi/src/test/java/org/apache/poi/ss/usermodel/BaseTestXEvaluationSheet.java @@ -46,4 +46,5 @@ public abstract class BaseTestXEvaluationSheet { underlyingSheet.removeRow(underlyingSheet.getRow(2)); assertEquals(1, instance.getLastRowNum()); } + }