aboutsummaryrefslogtreecommitdiffstats
path: root/src/testcases/org/apache/poi/hssf/extractor
diff options
context:
space:
mode:
authorJosh Micich <josh@apache.org>2008-04-07 03:02:03 +0000
committerJosh Micich <josh@apache.org>2008-04-07 03:02:03 +0000
commitbf756d96784b527c3cb77d455d9f0c322311d091 (patch)
tree08b9b03e4820164076827a8cbd0de2aca09275bf /src/testcases/org/apache/poi/hssf/extractor
parentb938b6c97f47f085757b330d1bce90293c863afb (diff)
downloadpoi-bf756d96784b527c3cb77d455d9f0c322311d091.tar.gz
poi-bf756d96784b527c3cb77d455d9f0c322311d091.zip
refactored all hssf junits to get test sample data in the in one place
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@645348 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/TestExcelExtractor.java57
1 files changed, 32 insertions, 25 deletions
diff --git a/src/testcases/org/apache/poi/hssf/extractor/TestExcelExtractor.java b/src/testcases/org/apache/poi/hssf/extractor/TestExcelExtractor.java
index 0aef5c765a..80611e6e67 100644
--- a/src/testcases/org/apache/poi/hssf/extractor/TestExcelExtractor.java
+++ b/src/testcases/org/apache/poi/hssf/extractor/TestExcelExtractor.java
@@ -14,21 +14,36 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-package org.apache.poi.hssf.extractor;
-import java.io.File;
-import java.io.FileInputStream;
+package org.apache.poi.hssf.extractor;
-import org.apache.poi.poifs.filesystem.POIFSFileSystem;
+import java.io.IOException;
+import java.io.InputStream;
import junit.framework.TestCase;
-public class TestExcelExtractor extends TestCase {
- public void testSimple() throws Exception {
- String path = System.getProperty("HSSF.testdata.path");
- FileInputStream fin = new FileInputStream(path + File.separator + "Simple.xls");
+import org.apache.poi.hssf.HSSFTestDataSamples;
+import org.apache.poi.poifs.filesystem.POIFSFileSystem;
+/**
+ *
+ */
+public final class TestExcelExtractor extends TestCase {
+
+ private static final ExcelExtractor createExtractor(String sampleFileName) {
+
+ InputStream is = HSSFTestDataSamples.openSampleFileStream(sampleFileName);
+
+ try {
+ return new ExcelExtractor(new POIFSFileSystem(is));
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+
+ public void testSimple() {
- ExcelExtractor extractor = new ExcelExtractor(new POIFSFileSystem(fin));
+ ExcelExtractor extractor = createExtractor("Simple.xls");
assertEquals("Sheet1\nreplaceMe\nSheet2\nSheet3\n", extractor.getText());
@@ -37,11 +52,9 @@ public class TestExcelExtractor extends TestCase {
assertEquals("replaceMe\n", extractor.getText());
}
- public void testNumericFormula() throws Exception {
- String path = System.getProperty("HSSF.testdata.path");
- FileInputStream fin = new FileInputStream(path + File.separator + "sumifformula.xls");
+ public void testNumericFormula() {
- ExcelExtractor extractor = new ExcelExtractor(new POIFSFileSystem(fin));
+ ExcelExtractor extractor = createExtractor("sumifformula.xls");
assertEquals(
"Sheet1\n" +
@@ -68,11 +81,9 @@ public class TestExcelExtractor extends TestCase {
);
}
- public void testwithContinueRecords() throws Exception {
- String path = System.getProperty("HSSF.testdata.path");
- FileInputStream fin = new FileInputStream(path + File.separator + "StringContinueRecords.xls");
+ public void testwithContinueRecords() {
- ExcelExtractor extractor = new ExcelExtractor(new POIFSFileSystem(fin));
+ ExcelExtractor extractor = createExtractor("StringContinueRecords.xls");
extractor.getText();
@@ -82,11 +93,9 @@ public class TestExcelExtractor extends TestCase {
assertTrue(extractor.getText().length() > 40960);
}
- public void testStringConcat() throws Exception {
- String path = System.getProperty("HSSF.testdata.path");
- FileInputStream fin = new FileInputStream(path + File.separator + "SimpleWithFormula.xls");
+ public void testStringConcat() {
- ExcelExtractor extractor = new ExcelExtractor(new POIFSFileSystem(fin));
+ ExcelExtractor extractor = createExtractor("SimpleWithFormula.xls");
// Comes out as NaN if treated as a number
// And as XYZ if treated as a string
@@ -97,11 +106,9 @@ public class TestExcelExtractor extends TestCase {
assertEquals("Sheet1\nreplaceme\nreplaceme\nCONCATENATE(A1,A2)\nSheet2\nSheet3\n", extractor.getText());
}
- public void testStringFormula() throws Exception {
- String path = System.getProperty("HSSF.testdata.path");
- FileInputStream fin = new FileInputStream(path + File.separator + "StringFormulas.xls");
+ public void testStringFormula() {
- ExcelExtractor extractor = new ExcelExtractor(new POIFSFileSystem(fin));
+ ExcelExtractor extractor = createExtractor("StringFormulas.xls");
// Comes out as NaN if treated as a number
// And as XYZ if treated as a string