You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ce...@apache.org on 2018/11/16 15:08:59 UTC
svn commit: r1846719 -
/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFPictureData.java
Author: centic
Date: Fri Nov 16 15:08:59 2018
New Revision: 1846719
URL: http://svn.apache.org/viewvc?rev=1846719&view=rev
Log:
One more try to avoid the test-failures related to ImageIO-cache dir
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=1846719&r1=1846718&r2=1846719&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 15:08:59 2018
@@ -19,7 +19,6 @@ 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;
@@ -28,6 +27,7 @@ import javax.imageio.ImageIO;
import junit.framework.TestCase;
import org.apache.poi.hssf.HSSFTestDataSamples;
+import org.junit.AfterClass;
import org.junit.BeforeClass;
/**
@@ -37,19 +37,19 @@ import org.junit.BeforeClass;
* @author Yegor Kozlov (yegor at apache dot org)
* @author Trejkaz (trejkaz at trypticon dot org)
*/
-public final class TestHSSFPictureData extends TestCase{
+public final class TestHSSFPictureData extends TestCase {
+ private static boolean cacheBefore = ImageIO.getUseCache();
+
@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());
- }
- }
- }
+ // disable cache to avoid strange errors related to temporary directories in CI-builds
+ ImageIO.setUseCache(false);
+ }
+
+ @AfterClass
+ public static void tearDownClass() {
+ // reset image cache to previous state
+ ImageIO.setUseCache(cacheBefore);
}
public void testPictures() throws IOException {
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org