diff --git a/main/tests/server/src/com/google/refine/exporters/XlsExporterTests.java b/main/tests/server/src/com/google/refine/exporters/XlsExporterTests.java index 55a4f6344..78ad67877 100644 --- a/main/tests/server/src/com/google/refine/exporters/XlsExporterTests.java +++ b/main/tests/server/src/com/google/refine/exporters/XlsExporterTests.java @@ -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); diff --git a/main/tests/server/src/com/google/refine/exporters/XlsxExporterTests.java b/main/tests/server/src/com/google/refine/exporters/XlsxExporterTests.java index 9e43a615d..22d0e3e1b 100644 --- a/main/tests/server/src/com/google/refine/exporters/XlsxExporterTests.java +++ b/main/tests/server/src/com/google/refine/exporters/XlsxExporterTests.java @@ -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){