]> source.dussan.org Git - poi.git/commitdiff
Ignore IIOException "Can't create ..."
authorAndreas Beeker <kiwiwings@apache.org>
Sun, 23 Feb 2020 15:01:54 +0000 (15:01 +0000)
committerAndreas Beeker <kiwiwings@apache.org>
Sun, 23 Feb 2020 15:01:54 +0000 (15:01 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1874429 13f79535-47bb-0310-9956-ffa450edef68

src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFPictureShape.java

index 315a8f561c149b69091505309f4fd22b91c88c43..dcf94f77a9ceca0aceae5c0dcdad54c3955ba67c 100644 (file)
@@ -34,6 +34,8 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
+import javax.imageio.IIOException;
+
 import org.apache.poi.POIDataSamples;
 import org.apache.poi.sl.usermodel.PictureData.PictureType;
 import org.apache.poi.util.IOUtils;
@@ -258,28 +260,32 @@ public class TestXSLFPictureShape {
         XMLSlideShow ppt = new XMLSlideShow();
         XSLFSlide slide = ppt.createSlide();
 
-        XSLFPictureData svgPic = ppt.addPicture(POIDataSamples.getDocumentInstance().getFile("../project-header.svg"), PictureType.SVG);
-        XSLFPictureShape shape = XSLFPictureShape.addSvgImage(slide, svgPic, PictureType.JPEG, null);
-
-        Rectangle2D anchor = shape.getAnchor();
-        anchor.setRect(100, 100, anchor.getWidth(), anchor.getHeight());
-        shape.setAnchor(anchor);
-
-        assertNotNull(shape.getSvgImage());
-
-        final File tmpFile = TempFile.createTempFile("svgtest", ".pptx");
-        System.out.println(tmpFile);
-        try (FileOutputStream fos = new FileOutputStream(tmpFile)) {
-            ppt.write(fos);
+        try {
+            XSLFPictureData svgPic = ppt.addPicture(POIDataSamples.getDocumentInstance().getFile("../project-header.svg"), PictureType.SVG);
+            XSLFPictureShape shape = XSLFPictureShape.addSvgImage(slide, svgPic, PictureType.JPEG, null);
+
+            Rectangle2D anchor = shape.getAnchor();
+            anchor.setRect(100, 100, anchor.getWidth(), anchor.getHeight());
+            shape.setAnchor(anchor);
+
+            assertNotNull(shape.getSvgImage());
+
+            final File tmpFile = TempFile.createTempFile("svgtest", ".pptx");
+            System.out.println(tmpFile);
+            try (FileOutputStream fos = new FileOutputStream(tmpFile)) {
+                ppt.write(fos);
+            }
+
+            String[] args = {
+                    "-format", "png", // png,gif,jpg or null for test
+                    "-slide", "-1", // -1 for all
+                    "-outdir", tmpFile.getParentFile().getCanonicalPath(),
+                    "-quiet",
+                    tmpFile.getAbsolutePath()
+            };
+            PPTX2PNG.main(args);
+        } catch (IIOException e) {
+            assertFalse(e.getMessage(), e.getMessage().contains("Can't create"));
         }
-
-        String[] args = {
-                "-format", "png", // png,gif,jpg or null for test
-                "-slide", "-1", // -1 for all
-                "-outdir", tmpFile.getParentFile().getCanonicalPath(),
-                "-quiet",
-                tmpFile.getAbsolutePath()
-        };
-        PPTX2PNG.main(args);
     }
 }
\ No newline at end of file