poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cen...@apache.org
Subject svn commit: r1535959 - in /poi/trunk/src: ooxml/testcases/org/apache/poi/xssf/streaming/TestSXSSFWorkbook.java testcases/org/apache/poi/ss/usermodel/BaseTestWorkbook.java
Date Sat, 26 Oct 2013 10:05:25 GMT
Author: centic
Date: Sat Oct 26 10:05:24 2013
New Revision: 1535959

URL: http://svn.apache.org/r1535959
Log:
Add reproducer tests for Bug 53515, disabled as we do not fix any of the
reported issues. Also fix some Ecliipse warnings.

Modified:
    poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestSXSSFWorkbook.java
    poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestWorkbook.java

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestSXSSFWorkbook.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestSXSSFWorkbook.java?rev=1535959&r1=1535958&r2=1535959&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestSXSSFWorkbook.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestSXSSFWorkbook.java Sat
Oct 26 10:05:24 2013
@@ -19,13 +19,21 @@
 
 package org.apache.poi.xssf.streaming;
 
-import org.apache.poi.ss.usermodel.*;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+
+import org.apache.poi.ss.usermodel.BaseTestWorkbook;
+import org.apache.poi.ss.usermodel.Cell;
+import org.apache.poi.ss.usermodel.Row;
+import org.apache.poi.ss.usermodel.Sheet;
+import org.apache.poi.ss.usermodel.Workbook;
+import org.apache.poi.ss.usermodel.WorkbookFactory;
 import org.apache.poi.ss.util.CellReference;
 import org.apache.poi.xssf.SXSSFITestDataProvider;
 import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 
-import java.io.File;
-
 public final class TestSXSSFWorkbook extends BaseTestWorkbook {
     public static final SXSSFITestDataProvider _testDataProvider = SXSSFITestDataProvider.instance;
 
@@ -264,4 +272,81 @@ public final class TestSXSSFWorkbook ext
         assertWorkbookDispose(wb);
 
     }
+
+    // currently writing the same sheet multiple times is not supported...
+	public void DISABLEDtestBug53515() throws Exception {
+		Workbook wb = new SXSSFWorkbook(10);
+		populateWorkbook(wb);
+		saveTwice(wb);
+		wb = new XSSFWorkbook();
+		populateWorkbook(wb);
+		saveTwice(wb);
+	}
+
+	// Crashes the JVM because of documented JVM behavior with concurrent writing/reading of
zip-files
+	// See http://www.oracle.com/technetwork/java/javase/documentation/overview-156328.html
+	public void DISABLEDtestBug53515a() throws Exception {
+		File out = new File("Test.xlsx");
+		out.delete();
+		for (int i = 0; i < 2; i++) {
+			System.out.println("Iteration " + i);
+			final SXSSFWorkbook wb;
+			if (out.exists()) {
+				wb = new SXSSFWorkbook(
+						(XSSFWorkbook) WorkbookFactory.create(out));
+			} else {
+				wb = new SXSSFWorkbook(10);
+			}
+
+			try {
+				FileOutputStream outSteam = new FileOutputStream(out);
+				if (i == 0) {
+					populateWorkbook(wb);
+				} else {
+					System.gc();
+					System.gc();
+					System.gc();
+				}
+
+				wb.write(outSteam);
+				// wb.dispose();
+				outSteam.close();
+			} finally {
+				wb.dispose();
+			}
+		}
+		out.delete();
+	}
+
+	private static void populateWorkbook(Workbook wb) {
+		Sheet sh = wb.createSheet();
+		for (int rownum = 0; rownum < 100; rownum++) {
+			Row row = sh.createRow(rownum);
+			for (int cellnum = 0; cellnum < 10; cellnum++) {
+				Cell cell = row.createCell(cellnum);
+				String address = new CellReference(cell).formatAsString();
+				cell.setCellValue(address);
+			}
+		}
+	}
+
+	private static void saveTwice(Workbook wb) throws Exception {
+		for (int i = 0; i < 2; i++) {
+			try {
+				NullOutputStream out = new NullOutputStream();
+				wb.write(out);
+				out.close();
+			} catch (Exception e) {
+				throw new Exception("ERROR: failed on " + (i + 1)
+						+ "th time calling " + wb.getClass().getName()
+						+ ".write() with exception " + e.getMessage(), e);
+			}
+		}
+	}
+
+	private static class NullOutputStream extends OutputStream {
+		@Override
+		public void write(int b) throws IOException {
+		}
+	}
 }

Modified: poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestWorkbook.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestWorkbook.java?rev=1535959&r1=1535958&r2=1535959&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestWorkbook.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestWorkbook.java Sat Oct 26 10:05:24
2013
@@ -156,7 +156,7 @@ public abstract class BaseTestWorkbook e
         String sheetName2 = "My very long sheet name which is longer than 31 chars " +
                 "and sheetName2.substring(0, 31) == sheetName1.substring(0, 31)";
         try {
-            Sheet sh2 = wb.createSheet(sheetName2);
+            /*Sheet sh2 =*/ wb.createSheet(sheetName2);
             fail("expected exception");
         } catch (IllegalArgumentException e) {
             // expected during successful test
@@ -415,7 +415,7 @@ public abstract class BaseTestWorkbook e
         c.setCellValue(12.34);
         c.getCellStyle().setDataFormat(fmt);
 
-        Cell c2 = r.createCell(2); // TODO - c2 unused but changing next line ('c'->'c2')
causes test to fail
+        /*Cell c2 =*/ r.createCell(2); // TODO - c2 unused but changing next line ('c'->'c2')
causes test to fail
         c.setCellValue(factory.createRichTextString("\u20ac"));
 
         Cell c3 = r.createCell(3);
@@ -447,7 +447,7 @@ public abstract class BaseTestWorkbook e
         assertEquals(formatStr, df.getFormat(c.getCellStyle().getDataFormat()));
 
         //Test the cell string value
-        c2 = r.getCell(2);
+        /*c2 =*/ r.getCell(2);
         assertEquals(c.getRichStringCellValue().getString(), "\u20ac");
 
         //Test the cell formula



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org


Mime
View raw message