<artifactId>maven-surefire-plugin</artifactId>
<version>${maven.plugin.surefire.version}</version>
<configuration>
- <argLine>@{argLine} -Duser.language=en -Duser.country=US -Xmx1024m -Djava.io.tmpdir=target/tmp -XX:-OmitStackTraceInFastThrow</argLine>
+ <argLine>@{argLine} -Duser.language=en -Duser.country=US -Xmx1024m -Djava.io.tmpdir=${basedir}/target/tmp -XX:-OmitStackTraceInFastThrow</argLine>
</configuration>
</plugin>
</plugins>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven.plugin.surefire.version}</version>
<configuration>
- <argLine>@{argLine} -Duser.language=en -Duser.country=US -Xmx1024m -Djava.io.tmpdir=target/tmp -XX:-OmitStackTraceInFastThrow</argLine>
+ <argLine>@{argLine} -Duser.language=en -Duser.country=US -Xmx1024m -Djava.io.tmpdir=${basedir}/target/tmp -XX:-OmitStackTraceInFastThrow</argLine>
</configuration>
</plugin>
</plugins>
<org.apache.poi.util.POILogger>org.apache.poi.util.NullLogger</org.apache.poi.util.POILogger>
</systemPropertyVariables>
<!-- use to following to analyze OOM issues: -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/tmp -->
- <argLine>@{argLine} -Duser.language=en -Duser.country=US -Xmx1024m -Djava.io.tmpdir=target/tmp
+ <argLine>@{argLine} -Duser.language=en -Duser.country=US -Xmx1024m -Djava.io.tmpdir=${basedir}/target/tmp
</argLine>
<excludes>
<exclude>**/All*Tests.java</exclude>
import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream;
+import java.io.File;
import java.io.IOException;
import java.util.List;
import junit.framework.TestCase;
import org.apache.poi.hssf.HSSFTestDataSamples;
-import org.junit.AfterClass;
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 {
- private static boolean cacheBefore = ImageIO.getUseCache();
-
+public final class TestHSSFPictureData extends TestCase{
@BeforeClass
public static void setUpClass() {
- // 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);
+ final String tmpDirProperty = System.getProperty("java.io.tmpdir");
+ if(tmpDirProperty == null || "".equals(tmpDirProperty)) {
+ return;
+ }
+ // ensure that temp-dir exists because ImageIO requires it
+ final File tmpDir = new File(tmpDirProperty);
+ if(!tmpDir.exists() && !tmpDir.mkdirs()) {
+ throw new IllegalStateException("Could not create temporary directory " + tmpDirProperty + ", full path " + tmpDir.getAbsolutePath());
+ }
+ ImageIO.setCacheDirectory(tmpDir);
}
public void testPictures() throws IOException {