aboutsummaryrefslogtreecommitdiffstats
path: root/src/ooxml/testcases/org/apache/poi/TestDetectAsOOXML.java
diff options
context:
space:
mode:
authorYegor Kozlov <yegor@apache.org>2009-08-19 18:51:44 +0000
committerYegor Kozlov <yegor@apache.org>2009-08-19 18:51:44 +0000
commit8b283b14b10c01f6b7247555ac0098258d7f0164 (patch)
treec5186589a87b7e5c49b3394a6d750a8c09e1b686 /src/ooxml/testcases/org/apache/poi/TestDetectAsOOXML.java
parentbb7b42c1265efe711303c4f38b25bc0a1eb92247 (diff)
downloadpoi-8b283b14b10c01f6b7247555ac0098258d7f0164.tar.gz
poi-8b283b14b10c01f6b7247555ac0098258d7f0164.zip
Centralize logic for finding/opening sample files
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@805928 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/ooxml/testcases/org/apache/poi/TestDetectAsOOXML.java')
-rw-r--r--src/ooxml/testcases/org/apache/poi/TestDetectAsOOXML.java19
1 files changed, 7 insertions, 12 deletions
diff --git a/src/ooxml/testcases/org/apache/poi/TestDetectAsOOXML.java b/src/ooxml/testcases/org/apache/poi/TestDetectAsOOXML.java
index dca593c3c7..2461f463dd 100644
--- a/src/ooxml/testcases/org/apache/poi/TestDetectAsOOXML.java
+++ b/src/ooxml/testcases/org/apache/poi/TestDetectAsOOXML.java
@@ -22,23 +22,18 @@ package org.apache.poi;
import junit.framework.TestCase;
import java.io.*;
+import org.apache.poi.hssf.HSSFTestDataSamples;
+import org.apache.poi.openxml4j.opc.OPCPackage;
+
/**
* Class to test that HXF correctly detects OOXML
* documents
*/
public class TestDetectAsOOXML extends TestCase
{
- public String dirname;
-
- public void setUp() {
- dirname = System.getProperty("HSSF.testdata.path");
- }
-
public void testOpensProperly() throws Exception
{
- File f = new File(dirname + "/sample.xlsx");
-
- POIXMLDocument.openPackage(f.toString());
+ OPCPackage.open(HSSFTestDataSamples.openSampleFileStream("sample.xlsx"));
}
public void testDetectAsPOIFS() throws Exception {
@@ -46,19 +41,19 @@ public class TestDetectAsOOXML extends TestCase
// ooxml file is
in = new PushbackInputStream(
- new FileInputStream(dirname + "/SampleSS.xlsx"), 10
+ HSSFTestDataSamples.openSampleFileStream("SampleSS.xlsx"), 10
);
assertTrue(POIXMLDocument.hasOOXMLHeader(in));
// xls file isn't
in = new PushbackInputStream(
- new FileInputStream(dirname + "/SampleSS.xls"), 10
+ HSSFTestDataSamples.openSampleFileStream("SampleSS.xls"), 10
);
assertFalse(POIXMLDocument.hasOOXMLHeader(in));
// text file isn't
in = new PushbackInputStream(
- new FileInputStream(dirname + "/SampleSS.txt"), 10
+ HSSFTestDataSamples.openSampleFileStream("SampleSS.txt"), 10
);
assertFalse(POIXMLDocument.hasOOXMLHeader(in));
}