]> source.dussan.org Git - poi.git/commitdiff
Fix JDK 1.4 compilation (after r682511 /bug 45538)
authorJosh Micich <josh@apache.org>
Tue, 5 Aug 2008 23:03:33 +0000 (23:03 +0000)
committerJosh Micich <josh@apache.org>
Tue, 5 Aug 2008 23:03:33 +0000 (23:03 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@683023 13f79535-47bb-0310-9956-ffa450edef68

src/testcases/org/apache/poi/hssf/extractor/TestExcelExtractor.java

index 0913ab7250ce009d887a12ce30ff2cc1f6876c73..cb028edfa56c9b705e6c3b400b8c63b3e19a0416 100644 (file)
@@ -32,7 +32,7 @@ import org.apache.poi.poifs.filesystem.POIFSFileSystem;
  */
 public final class TestExcelExtractor extends TestCase {
 
-       private static final ExcelExtractor createExtractor(String sampleFileName) {
+       private static ExcelExtractor createExtractor(String sampleFileName) {
                
                InputStream is = HSSFTestDataSamples.openSampleFileStream(sampleFileName);
                
@@ -192,18 +192,16 @@ public final class TestExcelExtractor extends TestCase {
         * Embded in a non-excel file
         */
        public void testWithEmbeded() throws Exception {
+               // TODO - encapsulate sys prop 'POIFS.testdata.path' similar to HSSFTestDataSamples
                String pdirname = System.getProperty("POIFS.testdata.path");
                String filename = pdirname + "/word_with_embeded.doc";
                POIFSFileSystem fs = new POIFSFileSystem(
                                new FileInputStream(filename)
                );
                
-               DirectoryNode objPool = (DirectoryNode)
-                       fs.getRoot().getEntry("ObjectPool");
-               DirectoryNode dirA = (DirectoryNode)
-                       objPool.getEntry("_1269427460");
-               DirectoryNode dirB = (DirectoryNode)
-                       objPool.getEntry("_1269427461");
+               DirectoryNode objPool = (DirectoryNode) fs.getRoot().getEntry("ObjectPool");
+               DirectoryNode dirA = (DirectoryNode) objPool.getEntry("_1269427460");
+               DirectoryNode dirB = (DirectoryNode) objPool.getEntry("_1269427461");
 
                HSSFWorkbook wbA = new HSSFWorkbook(dirA, fs, true);
                HSSFWorkbook wbB = new HSSFWorkbook(dirB, fs, true);
@@ -224,16 +222,15 @@ public final class TestExcelExtractor extends TestCase {
         * Excel embeded in excel
         */
        public void testWithEmbededInOwn() throws Exception {
+               // TODO - encapsulate sys prop 'POIFS.testdata.path' similar to HSSFTestDataSamples
                String pdirname = System.getProperty("POIFS.testdata.path");
                String filename = pdirname + "/excel_with_embeded.xls";
                POIFSFileSystem fs = new POIFSFileSystem(
                                new FileInputStream(filename)
                );
                
-       DirectoryNode dirA = (DirectoryNode)
-                       fs.getRoot().getEntry("MBD0000A3B5");
-               DirectoryNode dirB = (DirectoryNode)
-                       fs.getRoot().getEntry("MBD0000A3B4");
+               DirectoryNode dirA = (DirectoryNode) fs.getRoot().getEntry("MBD0000A3B5");
+               DirectoryNode dirB = (DirectoryNode) fs.getRoot().getEntry("MBD0000A3B4");
                
                HSSFWorkbook wbA = new HSSFWorkbook(dirA, 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
         */
        public void test45538() throws Exception {
-               String[] files = new String[] {
+               String[] files = {
                        "45538_classic_Footer.xls", "45538_form_Footer.xls",    
                        "45538_classic_Header.xls", "45538_form_Header.xls"
                };
                for(int i=0; i<files.length; i++) {
                        ExcelExtractor extractor = createExtractor(files[i]);
                        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.contains("test phrase"));
+                       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.indexOf("test phrase") >= 0);
                }
        }
 }