aboutsummaryrefslogtreecommitdiffstats
path: root/src/testcases
diff options
context:
space:
mode:
authorDominik Stadler <centic@apache.org>2015-10-17 14:40:36 +0000
committerDominik Stadler <centic@apache.org>2015-10-17 14:40:36 +0000
commit2afe97762259bd86d8209b77155beda8235e3e85 (patch)
tree7740827aa7833a572748deefb4364f009edf00e9 /src/testcases
parente62cac4f717a05e7f934c1665a11c697af21719e (diff)
downloadpoi-2afe97762259bd86d8209b77155beda8235e3e85.tar.gz
poi-2afe97762259bd86d8209b77155beda8235e3e85.zip
Bug 58499: Don't report Zip-Bomb for small files which should not cause memory issues anyway
Also make error message a bit more specific and list classname in Zip-Bomb-Error to make it easier for users what the problem is and how to find out where the static methods are git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1709180 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/testcases')
-rw-r--r--src/testcases/org/apache/poi/hssf/usermodel/TestHSSFWorkbook.java13
-rw-r--r--src/testcases/org/apache/poi/ss/usermodel/BaseTestWorkbook.java49
2 files changed, 47 insertions, 15 deletions
diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFWorkbook.java b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFWorkbook.java
index f40ce344f2..4b92b30bc2 100644
--- a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFWorkbook.java
+++ b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFWorkbook.java
@@ -81,19 +81,6 @@ public final class TestHSSFWorkbook extends BaseTestWorkbook {
return wb.getWorkbook();
}
- @Test
- public void windowOneDefaults() throws IOException {
- HSSFWorkbook b = new HSSFWorkbook( );
- try {
- assertEquals(b.getActiveSheetIndex(), 0);
- assertEquals(b.getFirstVisibleTab(), 0);
- } catch (NullPointerException npe) {
- fail("WindowOneRecord in Workbook is probably not initialized");
- }
-
- b.close();
- }
-
/**
* Tests for {@link HSSFWorkbook#isHidden()} etc
* @throws IOException
diff --git a/src/testcases/org/apache/poi/ss/usermodel/BaseTestWorkbook.java b/src/testcases/org/apache/poi/ss/usermodel/BaseTestWorkbook.java
index 4a9dd65c09..ca69fa6266 100644
--- a/src/testcases/org/apache/poi/ss/usermodel/BaseTestWorkbook.java
+++ b/src/testcases/org/apache/poi/ss/usermodel/BaseTestWorkbook.java
@@ -26,15 +26,16 @@ import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.io.IOException;
+import java.io.OutputStream;
import java.util.ConcurrentModificationException;
import java.util.Iterator;
-import junit.framework.AssertionFailedError;
-
import org.apache.poi.ss.ITestDataProvider;
import org.apache.poi.ss.util.CellRangeAddress;
import org.junit.Test;
+import junit.framework.AssertionFailedError;
+
/**
* @author Yegor Kozlov
*/
@@ -753,4 +754,48 @@ public abstract class BaseTestWorkbook {
sheets[i], wb.getSheetAt(i).getSheetName());
}
}
+
+ protected static class NullOutputStream extends OutputStream {
+ public NullOutputStream() {
+ }
+
+ @Override
+ public void write(int b) throws IOException {
+ }
+ }
+
+ @Test
+ public void test58499() throws IOException {
+ Workbook workbook = _testDataProvider.createWorkbook();
+ Sheet sheet = workbook.createSheet();
+ for (int i = 0; i < 900; i++) {
+ Row r = sheet.createRow(i);
+ Cell c = r.createCell(0);
+ CellStyle cs = workbook.createCellStyle();
+ c.setCellStyle(cs);
+ c.setCellValue("AAA");
+ }
+ OutputStream os = new NullOutputStream();
+ try {
+ workbook.write(os);
+ } finally {
+ os.close();
+ }
+ //workbook.dispose();
+ workbook.close();
+ }
+
+
+ @Test
+ public void windowOneDefaults() throws IOException {
+ Workbook b = _testDataProvider.createWorkbook();
+ try {
+ assertEquals(b.getActiveSheetIndex(), 0);
+ assertEquals(b.getFirstVisibleTab(), 0);
+ } catch (NullPointerException npe) {
+ fail("WindowOneRecord in Workbook is probably not initialized");
+ }
+
+ b.close();
+ }
}