Fix JDK 1.4 compilation (after r682511 /bug 45538)

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@683023 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Josh Micich 2008-08-05 23:03:33 +00:00
parent 9d70190dab
commit 1746dea8b1
1 changed files with 11 additions and 14 deletions

View File

@ -32,7 +32,7 @@ import org.apache.poi.poifs.filesystem.POIFSFileSystem;
*/ */
public final class TestExcelExtractor extends TestCase { public final class TestExcelExtractor extends TestCase {
private static final ExcelExtractor createExtractor(String sampleFileName) { private static ExcelExtractor createExtractor(String sampleFileName) {
InputStream is = HSSFTestDataSamples.openSampleFileStream(sampleFileName); InputStream is = HSSFTestDataSamples.openSampleFileStream(sampleFileName);
@ -192,18 +192,16 @@ public final class TestExcelExtractor extends TestCase {
* Embded in a non-excel file * Embded in a non-excel file
*/ */
public void testWithEmbeded() throws Exception { public void testWithEmbeded() throws Exception {
// TODO - encapsulate sys prop 'POIFS.testdata.path' similar to HSSFTestDataSamples
String pdirname = System.getProperty("POIFS.testdata.path"); String pdirname = System.getProperty("POIFS.testdata.path");
String filename = pdirname + "/word_with_embeded.doc"; String filename = pdirname + "/word_with_embeded.doc";
POIFSFileSystem fs = new POIFSFileSystem( POIFSFileSystem fs = new POIFSFileSystem(
new FileInputStream(filename) new FileInputStream(filename)
); );
DirectoryNode objPool = (DirectoryNode) DirectoryNode objPool = (DirectoryNode) fs.getRoot().getEntry("ObjectPool");
fs.getRoot().getEntry("ObjectPool"); DirectoryNode dirA = (DirectoryNode) objPool.getEntry("_1269427460");
DirectoryNode dirA = (DirectoryNode) DirectoryNode dirB = (DirectoryNode) objPool.getEntry("_1269427461");
objPool.getEntry("_1269427460");
DirectoryNode dirB = (DirectoryNode)
objPool.getEntry("_1269427461");
HSSFWorkbook wbA = new HSSFWorkbook(dirA, fs, true); HSSFWorkbook wbA = new HSSFWorkbook(dirA, fs, true);
HSSFWorkbook wbB = new HSSFWorkbook(dirB, fs, true); HSSFWorkbook wbB = new HSSFWorkbook(dirB, fs, true);
@ -224,16 +222,15 @@ public final class TestExcelExtractor extends TestCase {
* Excel embeded in excel * Excel embeded in excel
*/ */
public void testWithEmbededInOwn() throws Exception { public void testWithEmbededInOwn() throws Exception {
// TODO - encapsulate sys prop 'POIFS.testdata.path' similar to HSSFTestDataSamples
String pdirname = System.getProperty("POIFS.testdata.path"); String pdirname = System.getProperty("POIFS.testdata.path");
String filename = pdirname + "/excel_with_embeded.xls"; String filename = pdirname + "/excel_with_embeded.xls";
POIFSFileSystem fs = new POIFSFileSystem( POIFSFileSystem fs = new POIFSFileSystem(
new FileInputStream(filename) new FileInputStream(filename)
); );
DirectoryNode dirA = (DirectoryNode) DirectoryNode dirA = (DirectoryNode) fs.getRoot().getEntry("MBD0000A3B5");
fs.getRoot().getEntry("MBD0000A3B5"); DirectoryNode dirB = (DirectoryNode) fs.getRoot().getEntry("MBD0000A3B4");
DirectoryNode dirB = (DirectoryNode)
fs.getRoot().getEntry("MBD0000A3B4");
HSSFWorkbook wbA = new HSSFWorkbook(dirA, fs, true); HSSFWorkbook wbA = new HSSFWorkbook(dirA, fs, true);
HSSFWorkbook wbB = new HSSFWorkbook(dirB, fs, true); HSSFWorkbook wbB = new HSSFWorkbook(dirB, fs, true);
@ -260,15 +257,15 @@ public final class TestExcelExtractor extends TestCase {
* Test that we get text from headers and footers * Test that we get text from headers and footers
*/ */
public void test45538() throws Exception { public void test45538() throws Exception {
String[] files = new String[] { String[] files = {
"45538_classic_Footer.xls", "45538_form_Footer.xls", "45538_classic_Footer.xls", "45538_form_Footer.xls",
"45538_classic_Header.xls", "45538_form_Header.xls" "45538_classic_Header.xls", "45538_form_Header.xls"
}; };
for(int i=0; i<files.length; i++) { for(int i=0; i<files.length; i++) {
ExcelExtractor extractor = createExtractor(files[i]); ExcelExtractor extractor = createExtractor(files[i]);
String text = extractor.getText(); String text = extractor.getText();
assertTrue("Unable to find expected word in text\n" + text, text.contains("testdoc")); assertTrue("Unable to find expected word in text\n" + text, text.indexOf("testdoc") >=0);
assertTrue("Unable to find expected word in text\n" + text, text.contains("test phrase")); assertTrue("Unable to find expected word in text\n" + text, text.indexOf("test phrase") >= 0);
} }
} }
} }