Add tests for wide XLS/XLSX export (#2945)

Refs #2122. Also reenable a couple of disabled tests
This commit is contained in:
Tom Morris 2020-07-16 04:01:17 -04:00 committed by GitHub
parent 67801e68b4
commit f2e61b6628
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 74 additions and 3 deletions

View File

@ -139,7 +139,44 @@ public class XlsExporterTests extends RefineTest {
Assert.assertEquals(cell0.toString(),"row0cell0");
}
}
@Test
public void test256Columns() throws IOException {
CreateGrid(2, 256);
try {
SUT.export(project, options, engine, stream);
} catch (IOException e) {
Assert.fail();
}
try (HSSFWorkbook wb = new HSSFWorkbook(new ByteArrayInputStream(stream.toByteArray()))) {
org.apache.poi.ss.usermodel.Sheet ws = wb.getSheetAt(0);
org.apache.poi.ss.usermodel.Row row1 = ws.getRow(1);
org.apache.poi.ss.usermodel.Cell cell0 = row1.getCell(255);
Assert.assertEquals(cell0.toString(),"row0cell255");
}
}
@Test
public void test257Columns() throws IOException {
CreateGrid(2, 257);
try {
SUT.export(project, options, engine, stream);
} catch (IOException e) {
Assert.fail();
}
try (HSSFWorkbook wb = new HSSFWorkbook(new ByteArrayInputStream(stream.toByteArray()))) {
org.apache.poi.ss.usermodel.Sheet ws = wb.getSheetAt(0);
org.apache.poi.ss.usermodel.Row row1 = ws.getRow(1);
org.apache.poi.ss.usermodel.Cell cell0 = row1.getCell(255);
// FIXME: This is not a good error reporting mechanism, but it's what there today
Assert.assertEquals(cell0.toString(),"ERROR: TOO MANY COLUMNS");
}
}
@Test
public void exportDateType() throws IOException{
OffsetDateTime odt = OffsetDateTime.parse("2019-04-09T12:00+00:00");
@ -161,7 +198,6 @@ public class XlsExporterTests extends RefineTest {
}
}
@Test(enabled=false)
public void exportSimpleXlsNoHeader(){
CreateGrid(2, 2);
when(options.getProperty("printColumnHeader")).thenReturn("false");
@ -178,7 +214,6 @@ public class XlsExporterTests extends RefineTest {
}
@Test(enabled=false)
public void exportXlsWithEmptyCells(){
CreateGrid(3,3);

View File

@ -194,6 +194,42 @@ public class XlsxExporterTests extends RefineTest {
}
}
@Test
public void test257Columns() throws IOException {
CreateGrid(2, 257);
try {
SUT.export(project, options, engine, stream);
} catch (IOException e) {
Assert.fail();
}
try (XSSFWorkbook wb = new XSSFWorkbook(new ByteArrayInputStream(stream.toByteArray()))) {
org.apache.poi.ss.usermodel.Sheet ws = wb.getSheetAt(0);
org.apache.poi.ss.usermodel.Row row1 = ws.getRow(1);
org.apache.poi.ss.usermodel.Cell cell0 = row1.getCell(256);
Assert.assertEquals(cell0.toString(),"row0cell256");
}
}
@Test
public void test10000Columns() throws IOException {
CreateGrid(2, 10000);
try {
SUT.export(project, options, engine, stream);
} catch (IOException e) {
Assert.fail();
}
try (XSSFWorkbook wb = new XSSFWorkbook(new ByteArrayInputStream(stream.toByteArray()))) {
org.apache.poi.ss.usermodel.Sheet ws = wb.getSheetAt(0);
org.apache.poi.ss.usermodel.Row row1 = ws.getRow(1);
org.apache.poi.ss.usermodel.Cell cell0 = row1.getCell(9999);
Assert.assertEquals(cell0.toString(),"row0cell9999");
}
}
//helper methods
protected void CreateColumns(int noOfColumns){