]> source.dussan.org Git - poi.git/commitdiff
removed test document referenced in Bug 51524 because it cannot be distributed with...
authorYegor Kozlov <yegor@apache.org>
Sun, 21 Aug 2011 15:01:23 +0000 (15:01 +0000)
committerYegor Kozlov <yegor@apache.org>
Sun, 21 Aug 2011 15:01:23 +0000 (15:01 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1159993 13f79535-47bb-0310-9956-ffa450edef68

src/scratchpad/testcases/org/apache/poi/hwpf/HWPFTestDataSamples.java
src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestBugs.java
test-data/document/Bug51524.zip [deleted file]

index 4f0f81457ea40fda7805955691f82af6234a1ed2..891acc58389faa47b71ca9842e90c1a14f76759a 100644 (file)
@@ -20,6 +20,7 @@ import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;\r
 import java.io.IOException;\r
 import java.io.InputStream;\r
+import java.net.URL;\r
 import java.util.zip.ZipInputStream;\r
 \r
 import org.apache.poi.POIDataSamples;\r
@@ -90,6 +91,58 @@ public class HWPFTestDataSamples {
         }\r
     }\r
 \r
+    /**\r
+     * Open a remote sample from URL. opening is performd in two phases:\r
+     *  (1) download content into a byte array\r
+     *  (2) construct HWPFDocument\r
+     *\r
+     * @param sampleFileUrl the url to open\r
+     */\r
+    public static HWPFDocument openRemoteFile( String sampleFileUrl )\r
+    {\r
+        final long start = System.currentTimeMillis();\r
+        try\r
+        {\r
+            InputStream is = new URL( sampleFileUrl ).openStream();\r
+            try\r
+            {\r
+                ByteArrayOutputStream baos = new ByteArrayOutputStream();\r
+                try\r
+                {\r
+                    IOUtils.copy( is, baos );\r
+                }\r
+                finally\r
+                {\r
+                    baos.close();\r
+                }\r
+\r
+                final long endDownload = System.currentTimeMillis();\r
+                byte[] byteArray = baos.toByteArray();\r
+\r
+                logger.log( POILogger.DEBUG, "Downloaded in ",\r
+                        Long.valueOf( endDownload - start ), " ms -- ",\r
+                        Long.valueOf( byteArray.length ), " byte(s)" );\r
+\r
+                ByteArrayInputStream bais = new ByteArrayInputStream( byteArray );\r
+                HWPFDocument doc = new HWPFDocument( bais );\r
+                final long endParse = System.currentTimeMillis();\r
+\r
+                logger.log( POILogger.DEBUG, "Parsed in ",\r
+                        Long.valueOf( endParse - start ), " ms" );\r
+\r
+                return doc;\r
+            }\r
+            finally\r
+            {\r
+                is.close();\r
+            }\r
+        }\r
+        catch ( IOException e )\r
+        {\r
+            throw new RuntimeException( e );\r
+        }\r
+    }\r
+\r
     public static HWPFOldDocument openOldSampleFile(String sampleFileName) {\r
        try {\r
            InputStream is = POIDataSamples.getDocumentInstance().openResourceAsStream(sampleFileName);\r
index b19622ff35831b2958358192b4cbb4b7a885577b..5566caf468b85515bb22963ee40fe566394425dc 100644 (file)
@@ -511,14 +511,6 @@ public class TestBugs extends TestCase
         }
     }
 
-    /**
-     * Bug 51524 - PapBinTable constructor is slow
-     */
-    public void test51524()
-    {
-        HWPFTestDataSamples.openSampleFileFromArchive( "Bug51524.zip" );
-    }
-
     /**
      * [RESOLVED FIXED] Bug 51604 - replace text fails for doc ( poi 3.8 beta
      * release from download site )
@@ -649,13 +641,22 @@ public class TestBugs extends TestCase
     }
 
 
+
     /**
      * Bug 51678 - Extracting text from Bug51524.zip is slow
+     * Bug 51524 - PapBinTable constructor is slow
      */
-    public void test51678()
+    public void test51678And51524()
     {
-        HWPFDocument hwpfDocument = HWPFTestDataSamples.openSampleFileFromArchive( "Bug51524.zip" );
-        WordExtractor wordExtractor = new WordExtractor( hwpfDocument );
-        wordExtractor.getText();
+        // YK: the test will run only if the poi.test.remote system property is set.
+        // TODO: refactor into something nicer!
+        if(System.getProperty("poi.test.remote") != null) {
+            String href = "http://domex.nps.edu/corp/files/govdocs1/007/007488.doc";
+            HWPFDocument hwpfDocument = HWPFTestDataSamples.openRemoteFile( href );
+
+            WordExtractor wordExtractor = new WordExtractor( hwpfDocument );
+            wordExtractor.getText();
+        }
+
     }
 }
diff --git a/test-data/document/Bug51524.zip b/test-data/document/Bug51524.zip
deleted file mode 100644 (file)
index 4e5281f..0000000
Binary files a/test-data/document/Bug51524.zip and /dev/null differ