poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cen...@apache.org
Subject svn commit: r1846706 - /poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFPictureData.java
Date Fri, 16 Nov 2018 11:25:59 GMT
Author: centic
Date: Fri Nov 16 11:25:59 2018
New Revision: 1846706

URL: http://svn.apache.org/viewvc?rev=1846706&view=rev
Log:
Try to create the temporary directory for ImageIO to see if that makes 
the tests work again when built with Maven

Modified:
    poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFPictureData.java

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFPictureData.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFPictureData.java?rev=1846706&r1=1846705&r2=1846706&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFPictureData.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFPictureData.java Fri Nov
16 11:25:59 2018
@@ -19,6 +19,7 @@ package org.apache.poi.hssf.usermodel;
 
 import java.awt.image.BufferedImage;
 import java.io.ByteArrayInputStream;
+import java.io.File;
 import java.io.IOException;
 import java.util.List;
 
@@ -27,6 +28,7 @@ import javax.imageio.ImageIO;
 import junit.framework.TestCase;
 
 import org.apache.poi.hssf.HSSFTestDataSamples;
+import org.junit.BeforeClass;
 
 /**
  * Test <code>HSSFPictureData</code>.
@@ -36,7 +38,19 @@ import org.apache.poi.hssf.HSSFTestDataS
  * @author Trejkaz (trejkaz at trypticon dot org)
  */
 public final class TestHSSFPictureData extends TestCase{
-
+    @BeforeClass
+    public static void setUpClass() {
+        // ensure that temp-dir exists because ImageIO requires it
+        String tmpDirProperty = System.getProperty("java.io.tmpdir");
+        if(tmpDirProperty != null) {
+            final File tmpDir = new File(tmpDirProperty);
+            if(!tmpDir.exists()) {
+                if(!tmpDir.mkdirs()) {
+                    throw new IllegalStateException("Could not create temporary directory
" + tmpDirProperty + ", full path " + tmpDir.getAbsolutePath());
+                }
+            }
+        }
+    }
 
 	public void testPictures() throws IOException {
         HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("SimpleWithImages.xls");
@@ -64,8 +78,8 @@ public final class TestHSSFPictureData e
                 assertEquals(300, png.getHeight());
                 assertEquals(HSSFWorkbook.PICTURE_TYPE_PNG, pict.getFormat());
                 assertEquals("image/png", pict.getMimeType());
-            } else {
-                //TODO: test code for PICT, WMF and EMF
+            /*} else {
+                //TODO: test code for PICT, WMF and EMF*/
             }
         }
     }
@@ -93,7 +107,7 @@ public final class TestHSSFPictureData e
         assertEquals("image/png", pict.getMimeType());
     }
 
-    public void testNotNullPictures() throws IOException {
+    public void testNotNullPictures() {
 
         HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("SheetWithDrawing.xls");
 
@@ -103,5 +117,4 @@ public final class TestHSSFPictureData e
             assertNotNull(pict);
         }
     }
-
 }



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


Mime
View raw message