import java.io.ByteArrayOutputStream;
import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.io.OutputStream;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
-import junit.framework.TestCase;
-
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.poi.POIDataSamples;
import org.apache.poi.hwpf.HWPFDocument;
import org.apache.poi.hwpf.extractor.WordExtractor;
import org.apache.poi.hwpf.model.FieldsDocumentPart;
import org.apache.poi.hwpf.model.FileInformationBlock;
+import org.apache.poi.hwpf.model.PicturesTable;
import org.apache.poi.hwpf.model.PlexOfField;
import org.apache.poi.hwpf.model.SubdocumentType;
import org.apache.poi.hwpf.model.io.HWPFOutputStream;
import org.apache.poi.util.POILogFactory;
import org.apache.poi.util.POILogger;
+import junit.framework.TestCase;
+
/**
* Test different problems reported in Apache Bugzilla
*
* Bug 44331 - HWPFDocument.write destroys fields
* @throws IOException
*/
+ @SuppressWarnings("deprecation")
public void test44431() throws IOException
{
HWPFDocument doc1 = HWPFTestDataSamples.openSampleFile("Bug44431.doc");
*
* @throws IOException
*/
+ @SuppressWarnings("deprecation")
public void test47286() throws IOException
{
HWPFDocument doc1 = HWPFTestDataSamples.openSampleFile("Bug47286.doc");
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
+import java.io.FileOutputStream;
+import java.io.OutputStream;
import java.util.List;
import org.apache.poi.POIDataSamples;
import org.apache.poi.hwpf.HWPFDocument;
import org.apache.poi.hwpf.HWPFTestDataSamples;
import org.apache.poi.hwpf.model.PicturesTable;
+import org.junit.Ignore;
import org.junit.Test;
/**
assertEquals("This is the alternative text for the picture.", picture.getDescription());
}
+
+ @Ignore("This bug is not fixed yet")
+ @Test
+ public void test58804_1() throws Exception {
+ HWPFDocument docA = HWPFTestDataSamples.openSampleFile("58804_1.doc");
+
+ expectImages(docA, 1);
+
+ HWPFDocument docB = HWPFTestDataSamples.writeOutAndReadBack(docA);
+
+ OutputStream out = new FileOutputStream("/tmp/58804_1_out.doc");
+ try {
+ docB.write(out);
+ } finally {
+ out.close();
+ }
+
+ expectImages(docB, 1);
+ }
+
+ @Ignore("This bug is not fixed yet")
+ @Test
+ public void test58804() throws Exception {
+ HWPFDocument docA = HWPFTestDataSamples.openSampleFile("58804.doc");
+
+ expectImages(docA, 7);
+
+ HWPFDocument docB = HWPFTestDataSamples.writeOutAndReadBack(docA);
+
+ expectImages(docB, 7);
+ }
+
+ private void expectImages(HWPFDocument docA, int expectedCount) {
+ assertNotNull(docA.getPicturesTable());
+ PicturesTable picA = docA.getPicturesTable();
+ List<Picture> picturesA = picA.getAllPictures();
+ assertEquals(expectedCount, picturesA.size());
+ }
}