aboutsummaryrefslogtreecommitdiffstats
path: root/src/scratchpad
diff options
context:
space:
mode:
authorNick Burch <nick@apache.org>2008-01-08 11:54:26 +0000
committerNick Burch <nick@apache.org>2008-01-08 11:54:26 +0000
commit7b8ac5e4c63cfaf3bd004789974fa53934c73b82 (patch)
tree74d113c1ec0ff6e22d55f0fa3ed82ca68d5830fb /src/scratchpad
parent95b15d00c752ad8d4cd5f1fc381b4a1915b3aaee (diff)
downloadpoi-7b8ac5e4c63cfaf3bd004789974fa53934c73b82.tar.gz
poi-7b8ac5e4c63cfaf3bd004789974fa53934c73b82.zip
Add a (disabled, as broken) test to show that HXFExcelExtractor and ExcelExtractor basically agree on extracting text from the same file (which they do not quite do yet!)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@609941 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/scratchpad')
-rw-r--r--src/scratchpad/ooxml-testcases/org/apache/poi/hssf/extractor/TestHXFExcelExtractor.java55
1 files changed, 53 insertions, 2 deletions
diff --git a/src/scratchpad/ooxml-testcases/org/apache/poi/hssf/extractor/TestHXFExcelExtractor.java b/src/scratchpad/ooxml-testcases/org/apache/poi/hssf/extractor/TestHXFExcelExtractor.java
index 94123dac77..d7fc4dc3a5 100644
--- a/src/scratchpad/ooxml-testcases/org/apache/poi/hssf/extractor/TestHXFExcelExtractor.java
+++ b/src/scratchpad/ooxml-testcases/org/apache/poi/hssf/extractor/TestHXFExcelExtractor.java
@@ -17,13 +17,16 @@
package org.apache.poi.hssf.extractor;
import java.io.File;
+import java.io.FileInputStream;
+import junit.framework.TestCase;
+
+import org.apache.poi.POITextExtractor;
import org.apache.poi.hssf.HSSFXML;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.hssf.usermodel.HSSFXMLWorkbook;
import org.apache.poi.hxf.HXFDocument;
-import junit.framework.TestCase;
-
/**
* Tests for HXFExcelExtractor
*/
@@ -36,6 +39,15 @@ public class TestHXFExcelExtractor extends TestCase {
* A fairly complex file
*/
private HSSFXML xmlB;
+
+ /**
+ * A fairly simple file - ooxml
+ */
+ private HSSFXML simpleXLSX;
+ /**
+ * A fairly simple file - ole2
+ */
+ private HSSFWorkbook simpleXLS;
protected void setUp() throws Exception {
super.setUp();
@@ -49,8 +61,20 @@ public class TestHXFExcelExtractor extends TestCase {
File.separator + "AverageTaxRates.xlsx"
);
+ File fileSOOXML = new File(
+ System.getProperty("HSSF.testdata.path") +
+ File.separator + "SampleSS.xlsx"
+ );
+ File fileSOLE2 = new File(
+ System.getProperty("HSSF.testdata.path") +
+ File.separator + "SampleSS.xls"
+ );
+
xmlA = new HSSFXML(HXFDocument.openPackage(fileA));
xmlB = new HSSFXML(HXFDocument.openPackage(fileB));
+
+ simpleXLSX = new HSSFXML(HXFDocument.openPackage(fileSOOXML));
+ simpleXLS = new HSSFWorkbook(new FileInputStream(fileSOLE2));
}
/**
@@ -140,4 +164,31 @@ public class TestHXFExcelExtractor extends TestCase {
"3\t13\t3\t2\t2\t3\t2\t"
));
}
+
+ /**
+ * Test that we return pretty much the same as
+ * ExcelExtractor does, when we're both passed
+ * the same file, just saved as xls and xlsx
+ */
+ public void BROKENtestComparedToOLE2() throws Exception {
+ HXFExcelExtractor ooxmlExtractor =
+ new HXFExcelExtractor(simpleXLSX.getPackage());
+ ExcelExtractor ole2Extractor =
+ new ExcelExtractor(simpleXLS);
+
+ POITextExtractor[] extractors =
+ new POITextExtractor[] { ooxmlExtractor, ole2Extractor };
+ for (int i = 0; i < extractors.length; i++) {
+ POITextExtractor extractor = extractors[i];
+
+ String text = extractor.getText().replace("\r", "");
+ System.out.println(text.length());
+ System.out.println(text);
+ assertTrue(text.startsWith("First Sheet\nTest spreadsheet\t\n2nd row\t2nd row 2nd column\n"));
+ assertTrue(text.endsWith("13.0\nSheet3\n"));
+
+ assertTrue(text.length() >= 214);
+ assertTrue(text.length() <= 214);
+ }
+ }
}