mirror of https://github.com/apache/poi.git
avoid creating unnecessary temp files, tighten up usage of temp files in unit tests
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@899364 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
2956525db2
commit
5bb2570155
|
@ -266,7 +266,7 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Iterable<X
|
|||
*/
|
||||
protected static OPCPackage newPackage() {
|
||||
try {
|
||||
OPCPackage pkg = OPCPackage.create(PackageHelper.createTempFile());
|
||||
OPCPackage pkg = OPCPackage.create(new ByteArrayOutputStream());
|
||||
// Main part
|
||||
PackagePartName corePartName = PackagingURIHelper.createPartName(XSSFRelation.WORKBOOK.getDefaultFileName());
|
||||
// Create main part relationship
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
==================================================================== */
|
||||
package org.apache.poi.xwpf.usermodel;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
|
@ -195,7 +196,7 @@ public class XWPFDocument extends POIXMLDocument {
|
|||
*/
|
||||
protected static OPCPackage newPackage() {
|
||||
try {
|
||||
OPCPackage pkg = OPCPackage.create(PackageHelper.createTempFile());
|
||||
OPCPackage pkg = OPCPackage.create(new ByteArrayOutputStream());
|
||||
// Main part
|
||||
PackagePartName corePartName = PackagingURIHelper.createPartName(XWPFRelation.DOCUMENT.getDefaultFileName());
|
||||
// Create main part relationship
|
||||
|
|
|
@ -23,6 +23,7 @@ import java.io.FileOutputStream;
|
|||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.apache.poi.util.TempFile;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
|
||||
public class TestWorkbookProtection extends TestCase {
|
||||
|
@ -95,7 +96,7 @@ public class TestWorkbookProtection extends TestCase {
|
|||
|
||||
wb.lockRevision();
|
||||
|
||||
File tempFile = File.createTempFile("workbookProtection", ".xlsx");
|
||||
File tempFile = TempFile.createTempFile("workbookProtection", ".xlsx");
|
||||
FileOutputStream out = new FileOutputStream(tempFile);
|
||||
wb.write(out);
|
||||
out.close();
|
||||
|
|
|
@ -25,6 +25,7 @@ import java.io.IOException;
|
|||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.apache.poi.util.TempFile;
|
||||
import org.apache.poi.xwpf.usermodel.XWPFDocument;
|
||||
import org.apache.poi.xwpf.usermodel.XWPFParagraph;
|
||||
import org.apache.poi.xwpf.usermodel.XWPFRun;
|
||||
|
@ -126,7 +127,7 @@ public class TestDocumentProtection extends TestCase {
|
|||
r1.setText("Lorem ipsum dolor sit amet.");
|
||||
doc.enforceCommentsProtection();
|
||||
|
||||
File tempFile = File.createTempFile("documentProtectionFile", ".docx");
|
||||
File tempFile = TempFile.createTempFile("documentProtectionFile", ".docx");
|
||||
FileOutputStream out = new FileOutputStream(tempFile);
|
||||
|
||||
doc.write(out);
|
||||
|
|
|
@ -54,6 +54,7 @@ import org.apache.poi.poifs.filesystem.DocumentEntry;
|
|||
import org.apache.poi.poifs.filesystem.DocumentInputStream;
|
||||
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
|
||||
import org.apache.poi.POIDataSamples;
|
||||
import org.apache.poi.util.TempFile;
|
||||
|
||||
/**
|
||||
* <p>Tests HPSF's high-level writing functionality for the well-known property
|
||||
|
@ -374,7 +375,7 @@ public class TestWriteWellKnown extends TestCase {
|
|||
|
||||
/* Write the POI filesystem to a (temporary) file <em>doc2</em>
|
||||
* and close the latter. */
|
||||
final File doc2 = File.createTempFile("POI_HPSF_Test.", ".tmp");
|
||||
final File doc2 = TempFile.createTempFile("POI_HPSF_Test.", ".tmp");
|
||||
doc2.deleteOnExit();
|
||||
OutputStream out = new FileOutputStream(doc2);
|
||||
poifs.writeFilesystem(out);
|
||||
|
@ -503,7 +504,7 @@ public class TestWriteWellKnown extends TestCase {
|
|||
/*
|
||||
* <li><p>Write the POI filesystem to a (temporary) file <em>doc3</em>
|
||||
* and close the latter. */
|
||||
final File doc3 = File.createTempFile("POI_HPSF_Test.", ".tmp");
|
||||
final File doc3 = TempFile.createTempFile("POI_HPSF_Test.", ".tmp");
|
||||
doc3.deleteOnExit();
|
||||
out = new FileOutputStream(doc3);
|
||||
poifs.writeFilesystem(out);
|
||||
|
|
Loading…
Reference in New Issue