Tried to reproduce bug 55476, but could not, added unit test anyway

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1730598 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Dominik Stadler 2016-02-15 19:16:45 +00:00
parent 8c203f1366
commit e7729d8b1b
1 changed files with 29 additions and 13 deletions

View File

@ -16,25 +16,19 @@
==================================================================== */ ==================================================================== */
package org.apache.poi.xwpf.usermodel; package org.apache.poi.xwpf.usermodel;
import junit.framework.TestCase;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.util.Units;
import org.apache.poi.xwpf.XWPFTestDataSamples;
import org.apache.poi.xwpf.model.XWPFHeaderFooterPolicy;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.*;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.IOException; import java.io.IOException;
import java.math.BigInteger; import java.math.BigInteger;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import junit.framework.TestCase;
import org.apache.poi.xwpf.XWPFTestDataSamples;
import org.apache.poi.xwpf.model.XWPFHeaderFooterPolicy;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTBr;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTR;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTRPr;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.STBrClear;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.STHighlightColor;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.STOnOff;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.STUnderline;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.STVerticalAlignRun;
/** /**
* Tests for XWPF Run * Tests for XWPF Run
*/ */
@ -444,4 +438,26 @@ public class TestXWPFRun extends TestCase {
} }
} }
} }
public void testBug55476() throws IOException, InvalidFormatException {
byte[] image = XWPFTestDataSamples.getImage("abstract1.jpg");
XWPFDocument document = new XWPFDocument();
document.createParagraph().createRun().addPicture(
new ByteArrayInputStream(image), Document.PICTURE_TYPE_JPEG, "test.jpg", Units.toEMU(300), Units.toEMU(100));
XWPFDocument docBack = XWPFTestDataSamples.writeOutAndReadBack(document);
List<XWPFPicture> pictures = docBack.getParagraphArray(0).getRuns().get(0).getEmbeddedPictures();
assertEquals(1, pictures.size());
docBack.close();
/*OutputStream stream = new FileOutputStream("c:\\temp\\55476.docx");
try {
document.write(stream);
} finally {
stream.close();
}*/
document.close();
}
} }