Author: onealj
Date: Thu Jul 13 04:19:20 2017
New Revision: 1801801
URL: http://svn.apache.org/viewvc?rev=1801801&view=rev
Log:
replace commented-out throw-away code that writes workbook to
C:\temp\xxxxx.xlsx for manual review with XSSFTestDataSamples.writeOut(wb, "bug
xxxxx for manual review")
Modified:
poi/trunk/src/java/org/apache/poi/util/IOUtils.java
poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/XSSFTestDataSamples.java
poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestUnfixedBugs.java
Modified: poi/trunk/src/java/org/apache/poi/util/IOUtils.java
URL:
http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/util/IOUtils.java?rev=1801801&r1=1801800&r2=1801801&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/util/IOUtils.java (original)
+++ poi/trunk/src/java/org/apache/poi/util/IOUtils.java Thu Jul 13 04:19:20 2017
@@ -210,6 +210,17 @@ public final class IOUtils {
}
}
+ /**
+ * Write a ({@link org.apache.poi.ss.usermodel.Workbook}) to an output
stream and close the output stream.
+ * This will attempt to close the output stream at the end even if there
was a problem writing the document to the stream.
+ *
+ * If you are using Java 7 or higher, you may prefer to use a
try-with-resources statement instead.
+ * This function exists for Java 6 code.
+ *
+ * @param doc a writeable document to write to the output stream
+ * @param out the output stream that the document is written to
+ * @throws IOException
+ */
public static void write(Workbook doc, OutputStream out) throws
IOException {
try {
doc.write(out);
Modified:
poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/XSSFTestDataSamples.java
URL:
http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/XSSFTestDataSamples.java?rev=1801801&r1=1801800&r2=1801801&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/XSSFTestDataSamples.java
(original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/XSSFTestDataSamples.java
Thu Jul 13 04:19:20 2017
@@ -88,11 +88,16 @@ public class XSSFTestDataSamples {
// with unique names. Subsequent calls with the same argument may return a
different file.
// Gets a test data sample file, deleting the file if it exists.
// This is used in preparation for writing a workbook out to the returned
output file.
+ // testName is a filename fragment and should not include the extension
private static File getOutputFile(String testName) throws IOException {
final String testOutputDir = System.getProperty(TEST_OUTPUT_DIR);
final File file;
if (testOutputDir != null) {
- file = new File(testOutputDir, testName + ".xlsx");
+ // In case user provided testName with a file extension, don't
repeat the file extension a second time
+ final String testNameWithExtension = testName.endsWith(".xlsx") ?
testName : testName + ".xlsx";
+ // FIXME: may want to defer to the TempFile with a persistent file
creation strategy to the test output dir
+ // This would add the random value in the middle of the filename
so that test runs wouldn't overwrite files
+ file = new File(testOutputDir, testNameWithExtension);
}
else {
file = TempFile.createTempFile(testName, ".xlsx");
Modified:
poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestUnfixedBugs.java
URL:
http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestUnfixedBugs.java?rev=1801801&r1=1801800&r2=1801801&view=diff
==============================================================================
---
poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestUnfixedBugs.java
(original)
+++
poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestUnfixedBugs.java
Thu Jul 13 04:19:20 2017
@@ -66,12 +66,7 @@ public final class TestUnfixedBugs {
verifyBug54084Unicode(wb);
-// OutputStream baos = new FileOutputStream("/tmp/test.xlsx");
-// try {
-// wb.write(baos);
-// } finally {
-// baos.close();
-// }
+ //XSSFTestDataSamples.writeOut(wb, "bug 54084 for manual review");
// now write the file and read it back in
XSSFWorkbook wbWritten = XSSFTestDataSamples.writeOutAndReadBack(wb);
@@ -254,13 +249,8 @@ public final class TestUnfixedBugs {
RegionUtil.setBorderBottom(BorderStyle.THIN, range4, sheet);
- // write to file
- OutputStream stream = new FileOutputStream(new
File("C:/temp/55752.xlsx"));
- try {
- wb.write(stream);
- } finally {
- stream.close();
- }
+ // write to file for manual inspection
+ XSSFTestDataSamples.writeOut(wb, "bug 55752 for review");
} finally {
wb.close();
}
@@ -288,13 +278,7 @@ public final class TestUnfixedBugs {
checkRows57423(testSheet);
Workbook wbBack = XSSFTestDataSamples.writeOutAndReadBack(wb);
-
- /*FileOutputStream stream = new
FileOutputStream("C:\\temp\\57423.xlsx");
- try {
- wb.write(stream);
- } finally {
- stream.close();
- }*/
+ /* XSSFTestDataSamples.writeOut(wb, "bug 57423 for manual review"); */
wb.close();
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]