You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

TestSXSSFSheet.java 3.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. /*
  2. * ====================================================================
  3. * Licensed to the Apache Software Foundation (ASF) under one or more
  4. * contributor license agreements. See the NOTICE file distributed with
  5. * this work for additional information regarding copyright ownership.
  6. * The ASF licenses this file to You under the Apache License, Version 2.0
  7. * (the "License"); you may not use this file except in compliance with
  8. * the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. * ====================================================================
  18. */
  19. package org.apache.poi.xssf.streaming;
  20. import static org.junit.Assert.assertEquals;
  21. import static org.junit.Assert.fail;
  22. import org.apache.poi.ss.usermodel.BaseTestSheet;
  23. import org.apache.poi.ss.usermodel.Sheet;
  24. import org.apache.poi.ss.usermodel.Workbook;
  25. import org.apache.poi.xssf.SXSSFITestDataProvider;
  26. import org.apache.poi.xssf.usermodel.XSSFWorkbook;
  27. import org.junit.After;
  28. import org.junit.Test;
  29. public class TestSXSSFSheet extends BaseTestSheet {
  30. public TestSXSSFSheet() {
  31. super(SXSSFITestDataProvider.instance);
  32. }
  33. @After
  34. public void tearDown(){
  35. SXSSFITestDataProvider.instance.cleanup();
  36. }
  37. /**
  38. * cloning of sheets is not supported in SXSSF
  39. */
  40. @Override
  41. @Test
  42. public void cloneSheet() {
  43. thrown.expect(RuntimeException.class);
  44. thrown.expectMessage("NotImplemented");
  45. super.cloneSheet();
  46. }
  47. @Override
  48. @Test
  49. public void cloneSheetMultipleTimes() {
  50. thrown.expect(RuntimeException.class);
  51. thrown.expectMessage("NotImplemented");
  52. super.cloneSheetMultipleTimes();
  53. }
  54. /**
  55. * shifting rows is not supported in SXSSF
  56. */
  57. @Override
  58. @Test
  59. public void shiftMerged(){
  60. thrown.expect(RuntimeException.class);
  61. thrown.expectMessage("NotImplemented");
  62. super.shiftMerged();
  63. }
  64. /**
  65. * Bug 35084: cloning cells with formula
  66. *
  67. * The test is disabled because cloning of sheets is not supported in SXSSF
  68. */
  69. @Override
  70. @Test
  71. public void bug35084(){
  72. thrown.expect(RuntimeException.class);
  73. thrown.expectMessage("NotImplemented");
  74. super.bug35084();
  75. }
  76. @Override
  77. @Test
  78. public void defaultColumnStyle() {
  79. //TODO column styles are not yet supported by XSSF
  80. }
  81. @Test
  82. public void overrideFlushedRows() {
  83. Workbook wb = new SXSSFWorkbook(3);
  84. Sheet sheet = wb.createSheet();
  85. sheet.createRow(1);
  86. sheet.createRow(2);
  87. sheet.createRow(3);
  88. sheet.createRow(4);
  89. thrown.expect(Throwable.class);
  90. thrown.expectMessage("Attempting to write a row[1] in the range [0,1] that is already written to disk.");
  91. sheet.createRow(1);
  92. }
  93. @Test
  94. public void overrideRowsInTemplate() {
  95. XSSFWorkbook template = new XSSFWorkbook();
  96. template.createSheet().createRow(1);
  97. Workbook wb = new SXSSFWorkbook(template);
  98. Sheet sheet = wb.getSheetAt(0);
  99. try {
  100. sheet.createRow(1);
  101. fail("expected exception");
  102. } catch (Throwable e){
  103. assertEquals("Attempting to write a row[1] in the range [0,1] that is already written to disk.", e.getMessage());
  104. }
  105. try {
  106. sheet.createRow(0);
  107. fail("expected exception");
  108. } catch (Throwable e){
  109. assertEquals("Attempting to write a row[0] in the range [0,1] that is already written to disk.", e.getMessage());
  110. }
  111. sheet.createRow(2);
  112. }
  113. }