aboutsummaryrefslogtreecommitdiffstats
path: root/src/testcases/org/apache/poi/hssf/extractor
diff options
context:
space:
mode:
authorNick Burch <nick@apache.org>2014-11-30 14:36:01 +0000
committerNick Burch <nick@apache.org>2014-11-30 14:36:01 +0000
commit6d1c6f391b852bca97d3c4e181445ae00218b762 (patch)
tree622e9eedbc180430448b48859007b03b80a50963 /src/testcases/org/apache/poi/hssf/extractor
parent37f001274abe9cf19683a7005912d81766878b78 (diff)
downloadpoi-6d1c6f391b852bca97d3c4e181445ae00218b762.tar.gz
poi-6d1c6f391b852bca97d3c4e181445ae00218b762.zip
Switch to POITestCase / assertContains
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1642549 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/testcases/org/apache/poi/hssf/extractor')
-rw-r--r--src/testcases/org/apache/poi/hssf/extractor/TestOldExcelExtractor.java66
1 files changed, 39 insertions, 27 deletions
diff --git a/src/testcases/org/apache/poi/hssf/extractor/TestOldExcelExtractor.java b/src/testcases/org/apache/poi/hssf/extractor/TestOldExcelExtractor.java
index 8c58f9e4f3..1558a50e02 100644
--- a/src/testcases/org/apache/poi/hssf/extractor/TestOldExcelExtractor.java
+++ b/src/testcases/org/apache/poi/hssf/extractor/TestOldExcelExtractor.java
@@ -17,17 +17,17 @@
package org.apache.poi.hssf.extractor;
+import java.io.File;
import java.io.InputStream;
-import junit.framework.TestCase;
-
+import org.apache.poi.POITestCase;
import org.apache.poi.hssf.HSSFTestDataSamples;
/**
* Unit tests for the Excel 5/95 and Excel 4 (and older) text
* extractor
*/
-public final class TestOldExcelExtractor extends TestCase {
+public final class TestOldExcelExtractor extends POITestCase {
private static OldExcelExtractor createExtractor(String sampleFileName) {
InputStream is = HSSFTestDataSamples.openSampleFileStream(sampleFileName);
@@ -37,7 +37,7 @@ public final class TestOldExcelExtractor extends TestCase {
throw new RuntimeException(e);
}
}
-
+
public void testSimpleExcel4() {
OldExcelExtractor extractor = createExtractor("testEXCEL_4.xls");
@@ -45,12 +45,12 @@ public final class TestOldExcelExtractor extends TestCase {
String text = extractor.getText();
// Check we find a few words we expect in there
- assertTrue(text, text.contains("Size"));
- assertTrue(text, text.contains("Returns"));
+ assertContains(text, "Size");
+ assertContains(text, "Returns");
// Check we find a few numbers we expect in there
- assertTrue(text, text.contains("11"));
- assertTrue(text, text.contains("784"));
+ assertContains(text, "11");
+ assertContains(text, "784");
}
public void DISABLEDtestSimpleExcel5() {
for (String ver : new String[] {"5", "95"}) {
@@ -60,12 +60,12 @@ public final class TestOldExcelExtractor extends TestCase {
String text = extractor.getText();
// Check we find a few words we expect in there
- assertTrue(text, text.contains("Sample Excel"));
- assertTrue(text, text.contains("Written and saved"));
+ assertContains(text, "Sample Excel");
+ assertContains(text, "Written and saved");
// Check we find a few numbers we expect in there
- assertTrue(text, text.contains("15"));
- assertTrue(text, text.contains("169"));
+ assertContains(text, "15");
+ assertContains(text, "169");
}
}
@@ -74,15 +74,15 @@ public final class TestOldExcelExtractor extends TestCase {
String text = extractor.getText();
// Simple strings
- assertTrue(text, text.contains("Table 10 -- Examination Coverage:"));
- assertTrue(text, text.contains("Recommended and Average Recommended Additional Tax After"));
- assertTrue(text, text.contains("Individual income tax returns, total"));
+ assertContains(text, "Table 10 -- Examination Coverage:");
+ assertContains(text, "Recommended and Average Recommended Additional Tax After");
+ assertContains(text, "Individual income tax returns, total");
// More complicated strings
- assertTrue(text, text.contains("$100,000 or more"));
- assertTrue(text, text.contains("S corporation returns, Form 1120S [10,15]"));
+ assertContains(text, "$100,000 or more");
+ assertContains(text, "S corporation returns, Form 1120S [10,15]");
// TODO Get these quotes working correctly
-// assertTrue(text, text.contains("individual income tax return \u201Cshort forms.\u201D"));
+// assertContains(text, "individual income tax return \u201Cshort forms.\u201D");
// Formula based strings
// TODO Find some then test
@@ -93,17 +93,17 @@ public final class TestOldExcelExtractor extends TestCase {
String text = extractor.getText();
// Simple numbers
- assertTrue(text, text.contains("151"));
- assertTrue(text, text.contains("784"));
+ assertContains(text, "151");
+ assertContains(text, "784");
// Numbers which come from formulas
- assertTrue(text, text.contains("0.398")); // TODO Rounding
- assertTrue(text, text.contains("624"));
+ assertContains(text, "0.398"); // TODO Rounding
+ assertContains(text, "624");
// Formatted numbers
// TODO
-// assertTrue(text, text.contains("55,624"));
-// assertTrue(text, text.contains("11,743,477"));
+// assertContains(text, "55,624");
+// assertContains(text, "11,743,477");
}
public void DISABLEDtestFormattedNumbersExcel5() {
for (String ver : new String[] {"5", "95"}) {
@@ -111,11 +111,23 @@ public final class TestOldExcelExtractor extends TestCase {
String text = extractor.getText();
// Simple numbers
- assertTrue(text, text.contains("1"));
+ assertContains(text, "1");
// Numbers which come from formulas
- assertTrue(text, text.contains("13"));
- assertTrue(text, text.contains("169"));
+ assertContains(text, "13");
+ assertContains(text, "169");
+ }
+ }
+
+ public void testFromFile() throws Exception {
+ for (String ver : new String[] {"4", "5", "95"}) {
+ String filename = "testEXCEL_"+ver+".xls";
+ File f = HSSFTestDataSamples.getSampleFile(filename);
+
+ OldExcelExtractor extractor = new OldExcelExtractor(f);
+ String text = extractor.getText();
+ assertNotNull(text);
+ assertTrue(text.length() > 100);
}
}
}