Reduce required memory in tests by not actually creating all the rows/cells when verifying the max number of cellstyles. Hopefully this will avoid the OOMs that we see in various CI environments currently while still verifying the limits correctly.
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1697326 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
2d677beac8
commit
639b847d6e
@ -741,6 +741,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
|
||||
/**
|
||||
* Excel .xls style indexed colours in a .xlsx file
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
@Test
|
||||
public void bug50786() throws Exception {
|
||||
XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("50786-indexed_colours.xlsx");
|
||||
@ -792,6 +793,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
|
||||
* then being set explicitly still should allow the
|
||||
* fetching of the RGB.
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
@Test
|
||||
public void bug50784() throws Exception {
|
||||
XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("50784-font_theme_colours.xlsx");
|
||||
@ -1802,7 +1804,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
|
||||
|
||||
// Now check the spreadsheet itself
|
||||
try {
|
||||
new XSSFWorkbook(pkg);
|
||||
new XSSFWorkbook(pkg).close();
|
||||
fail("Should fail as too much expansion occurs");
|
||||
} catch(POIXMLException e) {
|
||||
// Expected
|
||||
@ -1848,7 +1850,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
|
||||
|
||||
// XSSF Workbook gives helpful error
|
||||
try {
|
||||
new XSSFWorkbook(pkg);
|
||||
new XSSFWorkbook(pkg).close();
|
||||
fail(".xlsb files not supported");
|
||||
} catch (XLSBUnsupportedException e) {
|
||||
// Good, detected and warned
|
||||
@ -2359,7 +2361,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
|
||||
public void bug57880() throws Exception {
|
||||
int numStyles = 33000;
|
||||
XSSFWorkbook wb = new XSSFWorkbook();
|
||||
XSSFSheet s = wb.createSheet("TestSheet");
|
||||
//XSSFSheet s = wb.createSheet("TestSheet");
|
||||
XSSFDataFormat fmt = wb.getCreationHelper().createDataFormat();
|
||||
for (int i=1; i<numStyles; i++) {
|
||||
short df = fmt.getFormat("test"+i);
|
||||
@ -2369,9 +2371,9 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
|
||||
XSSFCellStyle style = wb.createCellStyle();
|
||||
assertEquals(i, style.getUIndex());
|
||||
style.setDataFormat(df);
|
||||
XSSFCell c = s.createRow(i).createCell(0, Cell.CELL_TYPE_NUMERIC);
|
||||
/*XSSFCell c = s.createRow(i).createCell(0, Cell.CELL_TYPE_NUMERIC);
|
||||
c.setCellStyle(style);
|
||||
c.setCellValue(i);
|
||||
c.setCellValue(i);*/
|
||||
}
|
||||
|
||||
// using temp file instead of ByteArrayOutputStream because of OOM in gump run
|
||||
@ -2381,12 +2383,12 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
|
||||
fos.close();
|
||||
|
||||
wb.close();
|
||||
fmt = null; s = null; wb = null;
|
||||
fmt = null; /*s = null;*/ wb = null;
|
||||
// System.gc();
|
||||
|
||||
wb = new XSSFWorkbook(tmp);
|
||||
fmt = wb.getCreationHelper().createDataFormat();
|
||||
s = wb.getSheetAt(0);
|
||||
// s = wb.getSheetAt(0);
|
||||
for (int i=1; i<numStyles; i++) {
|
||||
XSSFCellStyle style = wb.getCellStyleAt((short)i);
|
||||
assertNotNull(style);
|
||||
|
@ -30,7 +30,6 @@ import java.io.IOException;
|
||||
import java.text.AttributedString;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||
import org.apache.poi.hssf.util.PaneInformation;
|
||||
@ -1177,15 +1176,15 @@ public abstract class BaseTestBugzillaIssues {
|
||||
public void bug58260() throws IOException {
|
||||
//Create workbook and worksheet
|
||||
Workbook wb = _testDataProvider.createWorkbook();
|
||||
Sheet worksheet = wb.createSheet("sample");
|
||||
//Sheet worksheet = wb.createSheet("sample");
|
||||
|
||||
//Loop through and add all values from array list
|
||||
// use a fixed seed to always produce the same file which makes comparing stuff easier
|
||||
Random rnd = new Random(4352345);
|
||||
//Random rnd = new Random(4352345);
|
||||
int maxStyles = (wb instanceof HSSFWorkbook) ? 4009 : 64000;
|
||||
for(int i = 0;i < maxStyles;i++) {
|
||||
//Create new row
|
||||
Row row = worksheet.createRow(i);
|
||||
//Row row = worksheet.createRow(i);
|
||||
|
||||
//Create cell style
|
||||
final CellStyle style;
|
||||
@ -1206,13 +1205,13 @@ public abstract class BaseTestBugzillaIssues {
|
||||
}
|
||||
|
||||
//Create cell
|
||||
Cell cell = row.createCell(0);
|
||||
//Cell cell = row.createCell(0);
|
||||
|
||||
//Set cell style
|
||||
cell.setCellStyle(style);
|
||||
//cell.setCellStyle(style);
|
||||
|
||||
//Set cell value
|
||||
cell.setCellValue("r" + rnd.nextInt());
|
||||
//cell.setCellValue("r" + rnd.nextInt());
|
||||
}
|
||||
|
||||
// should fail if we try to add more now
|
||||
|
Loading…
Reference in New Issue
Block a user