poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ser...@apache.org
Subject svn commit: r1155336 [2/2] - in /poi/trunk/src: documentation/content/xdocs/ java/org/apache/poi/ java/org/apache/poi/hssf/extractor/ java/org/apache/poi/poifs/filesystem/ ooxml/java/org/apache/poi/extractor/ scratchpad/src/org/apache/poi/hwpf/ scratch...
Date Tue, 09 Aug 2011 12:38:53 GMT
Added: poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/converter/TestWordToTextConverter.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/converter/TestWordToTextConverter.java?rev=1155336&view=auto
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/converter/TestWordToTextConverter.java
(added)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/converter/TestWordToTextConverter.java
Tue Aug  9 12:38:52 2011
@@ -0,0 +1,22 @@
+package org.apache.poi.hwpf.converter;
+
+import junit.framework.TestCase;
+import org.apache.poi.hwpf.HWPFDocument;
+import org.apache.poi.hwpf.HWPFTestDataSamples;
+
+public class TestWordToTextConverter extends TestCase
+{
+
+    /**
+     * [FAILING] Bug 47731 - Word Extractor considers text copied from some
+     * website as an embedded object
+     */
+    public void testBug47731() throws Exception
+    {
+        HWPFDocument doc = HWPFTestDataSamples.openSampleFile( "Bug47731.doc" );
+        String foundText = WordToTextConverter.getText( doc );
+
+        assertTrue( foundText
+                .contains( "Soak the rice in water for three to four hours" ) );
+    }
+}

Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/extractor/TestWordExtractor.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/extractor/TestWordExtractor.java?rev=1155336&r1=1155335&r2=1155336&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/extractor/TestWordExtractor.java
(original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/extractor/TestWordExtractor.java
Tue Aug  9 12:38:52 2011
@@ -33,6 +33,16 @@ import org.apache.poi.poifs.filesystem.P
  * @author Nick Burch (nick at torchbox dot com)
  */
 public final class TestWordExtractor extends TestCase {
+
+    public static void assertEquals( String expected, String actual )
+    {
+        String newExpected = expected.replaceAll( "\r\n", "\n" )
+                .replaceAll( "\r", "\n" ).trim();
+        String newActual = actual.replaceAll( "\r\n", "\n" )
+                .replaceAll( "\r", "\n" ).trim();
+        TestCase.assertEquals( newExpected, newActual );
+    }
+
 	private String[] p_text1 = new String[] {
 			"This is a simple word document\r\n",
 			"\r\n",
@@ -107,12 +117,14 @@ public final class TestWordExtractor ext
 	public void testGetText() {
 		assertEquals(p_text1_block, extractor.getText());
 
-		// For the 2nd, should give similar answers for
-		//  the two methods, differing only in line endings
-		assertEquals(
-		      extractor2.getTextFromPieces().replaceAll("[\\r\\n]", ""), 
-		      extractor2.getText().replaceAll("[\\r\\n]", ""));
-	}
+        // For the 2nd, should give similar answers for
+        // the two methods, differing only in line endings
+
+        // nope, they must have different results, because of garbage
+        // assertEquals(
+        // extractor2.getTextFromPieces().replaceAll("[\\r\\n]", ""),
+        // extractor2.getText().replaceAll("[\\r\\n]", ""));
+    }
 
 	/**
 	 * Test textPieces based extraction
@@ -330,7 +342,7 @@ public final class TestWordExtractor ext
        
        // Open directly 
        for(DirectoryNode dir : files) {
-          WordExtractor extractor = new WordExtractor(dir, null);
+          WordExtractor extractor = new WordExtractor(dir);
           assertEquals(p_text1_block, extractor.getText());
        }
 

Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestBugs.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestBugs.java?rev=1155336&r1=1155335&r2=1155336&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestBugs.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestBugs.java Tue Aug
 9 12:38:52 2011
@@ -43,6 +43,15 @@ import org.apache.poi.util.IOUtils;
 public class TestBugs extends TestCase
 {
 
+    public static void assertEquals( String expected, String actual )
+    {
+        String newExpected = expected.replaceAll( "\r\n", "\n" )
+                .replaceAll( "\r", "\n" ).trim();
+        String newActual = actual.replaceAll( "\r\n", "\n" )
+                .replaceAll( "\r", "\n" ).trim();
+        TestCase.assertEquals( newExpected, newActual );
+    }
+
     private static void assertTableStructures( Range expected, Range actual )
     {
         assertEquals( expected.numParagraphs(), actual.numParagraphs() );



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org


Mime
View raw message