aboutsummaryrefslogtreecommitdiffstats
path: root/src/ooxml
diff options
context:
space:
mode:
authorDominik Stadler <centic@apache.org>2015-01-02 21:04:50 +0000
committerDominik Stadler <centic@apache.org>2015-01-02 21:04:50 +0000
commit943af49680b038ea13981d1cff3cb7ef88260f33 (patch)
tree4ae855824dcc0e15cac4d03528d60182d17ed367 /src/ooxml
parent906a9177963862ec7cf5de8eb91105426c5de0e8 (diff)
downloadpoi-943af49680b038ea13981d1cff3cb7ef88260f33.tar.gz
poi-943af49680b038ea13981d1cff3cb7ef88260f33.zip
Bug 46898: Convert unit tests for circular references to also run for XSSF
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1649122 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/ooxml')
-rw-r--r--src/ooxml/testcases/org/apache/poi/ss/formula/eval/TestXSSFCircularReferences.java31
-rw-r--r--src/ooxml/testcases/org/apache/poi/xssf/SXSSFITestDataProvider.java23
-rw-r--r--src/ooxml/testcases/org/apache/poi/xssf/XSSFITestDataProvider.java12
3 files changed, 60 insertions, 6 deletions
diff --git a/src/ooxml/testcases/org/apache/poi/ss/formula/eval/TestXSSFCircularReferences.java b/src/ooxml/testcases/org/apache/poi/ss/formula/eval/TestXSSFCircularReferences.java
new file mode 100644
index 0000000000..0b8c9fcb1e
--- /dev/null
+++ b/src/ooxml/testcases/org/apache/poi/ss/formula/eval/TestXSSFCircularReferences.java
@@ -0,0 +1,31 @@
+/* ====================================================================
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+==================================================================== */
+
+package org.apache.poi.ss.formula.eval;
+
+import org.apache.poi.xssf.XSSFITestDataProvider;
+
+/**
+ * Tests XSSFFormulaEvaluator for its handling of cell formula circular references.
+ *
+ * @author Josh Micich
+ */
+public final class TestXSSFCircularReferences extends BaseTestCircularReferences {
+ public TestXSSFCircularReferences() {
+ super(XSSFITestDataProvider.instance);
+ }
+}
diff --git a/src/ooxml/testcases/org/apache/poi/xssf/SXSSFITestDataProvider.java b/src/ooxml/testcases/org/apache/poi/xssf/SXSSFITestDataProvider.java
index a8ca27fdef..cb3660af0d 100644
--- a/src/ooxml/testcases/org/apache/poi/xssf/SXSSFITestDataProvider.java
+++ b/src/ooxml/testcases/org/apache/poi/xssf/SXSSFITestDataProvider.java
@@ -19,19 +19,21 @@
package org.apache.poi.xssf;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+
import org.apache.poi.POIDataSamples;
import org.apache.poi.ss.ITestDataProvider;
import org.apache.poi.ss.SpreadsheetVersion;
+import org.apache.poi.ss.usermodel.FormulaEvaluator;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
+import org.apache.poi.xssf.usermodel.XSSFFormulaEvaluator;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.ArrayList;
-
/**
* @author Yegor Kozlov
*/
@@ -43,6 +45,7 @@ public final class SXSSFITestDataProvider implements ITestDataProvider {
private SXSSFITestDataProvider() {
// enforce singleton
}
+
public Workbook openSampleWorkbook(String sampleFileName) {
XSSFWorkbook xssfWorkbook = XSSFITestDataProvider.instance.openSampleWorkbook(sampleFileName);
SXSSFWorkbook swb = new SXSSFWorkbook(xssfWorkbook);
@@ -66,17 +69,25 @@ public final class SXSSFITestDataProvider implements ITestDataProvider {
}
return result;
}
+
public SXSSFWorkbook createWorkbook(){
SXSSFWorkbook wb = new SXSSFWorkbook();
instances.add(wb);
return wb;
}
+
+ public FormulaEvaluator createFormulaEvaluator(Workbook wb) {
+ return new XSSFFormulaEvaluator(((SXSSFWorkbook) wb).getXSSFWorkbook());
+ }
+
public byte[] getTestDataFileContent(String fileName) {
return POIDataSamples.getSpreadSheetInstance().readFile(fileName);
}
+
public SpreadsheetVersion getSpreadsheetVersion(){
return SpreadsheetVersion.EXCEL2007;
}
+
public String getStandardFileNameExtension() {
return "xlsx";
}
diff --git a/src/ooxml/testcases/org/apache/poi/xssf/XSSFITestDataProvider.java b/src/ooxml/testcases/org/apache/poi/xssf/XSSFITestDataProvider.java
index b08403b240..cacf8376ad 100644
--- a/src/ooxml/testcases/org/apache/poi/xssf/XSSFITestDataProvider.java
+++ b/src/ooxml/testcases/org/apache/poi/xssf/XSSFITestDataProvider.java
@@ -20,7 +20,9 @@ package org.apache.poi.xssf;
import org.apache.poi.POIDataSamples;
import org.apache.poi.ss.ITestDataProvider;
import org.apache.poi.ss.SpreadsheetVersion;
+import org.apache.poi.ss.usermodel.FormulaEvaluator;
import org.apache.poi.ss.usermodel.Workbook;
+import org.apache.poi.xssf.usermodel.XSSFFormulaEvaluator;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
/**
@@ -32,24 +34,34 @@ public final class XSSFITestDataProvider implements ITestDataProvider {
private XSSFITestDataProvider() {
// enforce singleton
}
+
public XSSFWorkbook openSampleWorkbook(String sampleFileName) {
return XSSFTestDataSamples.openSampleWorkbook(sampleFileName);
}
+
public XSSFWorkbook writeOutAndReadBack(Workbook original) {
if(!(original instanceof XSSFWorkbook)) {
throw new IllegalArgumentException("Expected an instance of XSSFWorkbook");
}
return XSSFTestDataSamples.writeOutAndReadBack((XSSFWorkbook)original);
}
+
public XSSFWorkbook createWorkbook(){
return new XSSFWorkbook();
}
+
+ public FormulaEvaluator createFormulaEvaluator(Workbook wb) {
+ return new XSSFFormulaEvaluator((XSSFWorkbook) wb);
+ }
+
public byte[] getTestDataFileContent(String fileName) {
return POIDataSamples.getSpreadSheetInstance().readFile(fileName);
}
+
public SpreadsheetVersion getSpreadsheetVersion(){
return SpreadsheetVersion.EXCEL2007;
}
+
public String getStandardFileNameExtension() {
return "xlsx";
}