Bug 60374: Add test for ArrayIndexOutOfBounds on old Word Documents due to Non-Unicode

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1798200 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Dominik Stadler 2017-06-09 12:47:03 +00:00
parent 993801aa1c
commit 938bb91c51
3 changed files with 21 additions and 4 deletions

View File

@ -230,10 +230,10 @@ public class TestAllFiles {
FILE_PASSWORD = Collections.unmodifiableMap(passmap);
}
private static final Set<String> unmodifiableHashSet(String... a) {
private static Set<String> unmodifiableHashSet(String... a) {
return Collections.unmodifiableSet(hashSet(a));
}
private static final Set<String> hashSet(String... a) {
private static Set<String> hashSet(String... a) {
return new HashSet<String>(Arrays.asList(a));
}
@ -249,6 +249,7 @@ public class TestAllFiles {
"document/Bug60936.doc",
"document/Bug60942.doc",
"document/Bug60942b.doc",
"document/cn.orthodox.www_divenbog_APRIL_30-APRIL.DOC",
"hpsf/TestMickey.doc",
"document/52117.doc",
"hpsf/TestInvertedClassID.doc",

View File

@ -17,11 +17,16 @@
package org.apache.poi.hwpf.extractor;
import org.apache.poi.POIDataSamples;
import org.apache.poi.POITextExtractor;
import org.apache.poi.extractor.OLE2ExtractorFactory;
import org.apache.poi.poifs.filesystem.NPOIFSFileSystem;
import org.junit.Test;
import java.io.IOException;
import java.io.InputStream;
import org.apache.poi.POIDataSamples;
import org.junit.Test;
import static org.junit.Assert.assertNotNull;
/**
* Tests for bugs with the WordExtractor
@ -52,4 +57,15 @@ public final class TestWordExtractorBugs {
extractor.getText();
extractor.close();
}
@Test
public void testBug60374() throws Exception {
NPOIFSFileSystem fs = new NPOIFSFileSystem(SAMPLES.openResourceAsStream("cn.orthodox.www_divenbog_APRIL_30-APRIL.DOC"));
final POITextExtractor extractor = OLE2ExtractorFactory.createExtractor(fs);
// Check it gives text without error
assertNotNull(extractor.getText());
extractor.close();
}
}