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 2021/03/24 09:32:12 UTC
svn commit: r1887998 -
/poi/trunk/src/ooxml/testcases/org/apache/poi/xddf/usermodel/chart/TestXDDFChart.java
Author: centic
Date: Wed Mar 24 09:32:12 2021
New Revision: 1887998
URL: http://svn.apache.org/viewvc?rev=1887998&view=rev
Log:
Don't use a hardcoded temporary file (and also not a hardcoded /tmp directory)
This could cause issues in CI or when multiple different users run tests of POI on one machine!
Modified:
poi/trunk/src/ooxml/testcases/org/apache/poi/xddf/usermodel/chart/TestXDDFChart.java
Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xddf/usermodel/chart/TestXDDFChart.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xddf/usermodel/chart/TestXDDFChart.java?rev=1887998&r1=1887997&r2=1887998&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xddf/usermodel/chart/TestXDDFChart.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xddf/usermodel/chart/TestXDDFChart.java Wed Mar 24 09:32:12 2021
@@ -20,16 +20,19 @@ package org.apache.poi.xddf.usermodel.ch
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import org.apache.poi.ooxml.POIXMLFactory;
import org.apache.poi.ooxml.POIXMLRelation;
import org.apache.poi.ss.util.CellRangeAddress;
+import org.apache.poi.util.TempFile;
import org.apache.poi.xssf.XSSFTestDataSamples;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.junit.jupiter.api.Test;
import org.openxmlformats.schemas.drawingml.x2006.chart.CTChartSpace;
+import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
@@ -83,14 +86,19 @@ class TestXDDFChart {
chart.plot(data);
- try (OutputStream out = new FileOutputStream("/tmp/chart20201220.xlsx")) {
- wb.write(out);
+ File file = TempFile.createTempFile("chart20201220", ".xlsx");
+ try {
+ try (OutputStream out = new FileOutputStream(file)) {
+ wb.write(out);
+ }
+ } finally {
+ assertTrue(!file.exists() || file.delete());
}
}
}
private XDDFChart newXDDFChart() {
- XDDFChart xddfChart = new XDDFChart() {
+ return new XDDFChart() {
@Override
protected POIXMLRelation getChartRelation() {
return null;
@@ -106,6 +114,5 @@ class TestXDDFChart {
return null;
}
};
- return xddfChart;
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org