aboutsummaryrefslogtreecommitdiffstats
path: root/src/ooxml
diff options
context:
space:
mode:
authorJosh Micich <josh@apache.org>2009-12-26 02:17:34 +0000
committerJosh Micich <josh@apache.org>2009-12-26 02:17:34 +0000
commitfeafcb8f48e24a6b1967e4cbf9e50d8f1b3224fd (patch)
tree9895a650914dded40eefb3f018702376de7301db /src/ooxml
parent136e09be840acfdf69f77b42725d2c2a6ce1b2f6 (diff)
downloadpoi-feafcb8f48e24a6b1967e4cbf9e50d8f1b3224fd.tar.gz
poi-feafcb8f48e24a6b1967e4cbf9e50d8f1b3224fd.zip
Replaced getInstance methods with field for instances of ITestDataProvider. Some simplification in hierarchy of related tests.
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@893929 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/ooxml')
-rw-r--r--src/ooxml/testcases/org/apache/poi/xssf/XSSFITestDataProvider.java3
-rw-r--r--src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java15
-rw-r--r--src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCell.java8
-rw-r--r--src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFChartSheet.java36
-rw-r--r--src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFComment.java51
-rw-r--r--src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFDataFormat.java14
-rw-r--r--src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFFont.java5
-rw-r--r--src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFHyperlink.java7
-rw-r--r--src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFName.java7
-rw-r--r--src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFPicture.java5
-rw-r--r--src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFRow.java5
-rw-r--r--src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java13
-rw-r--r--src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheetUpdateArrayFormulas.java2
-rw-r--r--src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFWorkbook.java112
14 files changed, 104 insertions, 179 deletions
diff --git a/src/ooxml/testcases/org/apache/poi/xssf/XSSFITestDataProvider.java b/src/ooxml/testcases/org/apache/poi/xssf/XSSFITestDataProvider.java
index 4982081ca1..b08403b240 100644
--- a/src/ooxml/testcases/org/apache/poi/xssf/XSSFITestDataProvider.java
+++ b/src/ooxml/testcases/org/apache/poi/xssf/XSSFITestDataProvider.java
@@ -32,9 +32,6 @@ public final class XSSFITestDataProvider implements ITestDataProvider {
private XSSFITestDataProvider() {
// enforce singleton
}
- public static XSSFITestDataProvider getInstance(){
- return instance;
- }
public XSSFWorkbook openSampleWorkbook(String sampleFileName) {
return XSSFTestDataSamples.openSampleWorkbook(sampleFileName);
}
diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java
index e98676114c..1d8a8fb545 100644
--- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java
+++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java
@@ -28,9 +28,9 @@ import org.apache.poi.xssf.XSSFITestDataProvider;
import org.apache.poi.xssf.XSSFTestDataSamples;
public final class TestXSSFBugs extends BaseTestBugzillaIssues {
- @Override
- protected XSSFITestDataProvider getTestDataProvider(){
- return XSSFITestDataProvider.getInstance();
+
+ public TestXSSFBugs() {
+ super(XSSFITestDataProvider.instance);
}
/**
@@ -46,7 +46,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
* the wrong sheet name
*/
public void test45430() {
- XSSFWorkbook wb = getTestDataProvider().openSampleWorkbook("45430.xlsx");
+ XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("45430.xlsx");
assertFalse(wb.isMacroEnabled());
assertEquals(3, wb.getNumberOfNames());
@@ -75,7 +75,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
* We should carry vba macros over after save
*/
public void test45431() throws Exception {
- XSSFWorkbook wb = getTestDataProvider().openSampleWorkbook("45431.xlsm");
+ XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("45431.xlsm");
OPCPackage pkg = wb.getPackage();
assertTrue(wb.isMacroEnabled());
@@ -119,8 +119,9 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
);
assertNotNull(drw);
}
+
public void test47504() {
- XSSFWorkbook wb = getTestDataProvider().openSampleWorkbook("47504.xlsx");
+ XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("47504.xlsx");
assertEquals(1, wb.getNumberOfSheets());
XSSFSheet sh = wb.getSheetAt(0);
XSSFDrawing drawing = sh.createDrawingPatriarch();
@@ -136,7 +137,5 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
rels = drawing.getRelations();
assertEquals(1, rels.size());
assertEquals("Sheet1!A1", rels.get(0).getPackageRelationship().getTargetURI().getFragment());
-
}
-
}
diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCell.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCell.java
index 256bb7bd07..bd7319e5f3 100644
--- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCell.java
+++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCell.java
@@ -28,9 +28,9 @@ import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCell;
*/
public final class TestXSSFCell extends BaseTestCell {
- public TestXSSFCell() {
- super(XSSFITestDataProvider.getInstance());
- }
+ public TestXSSFCell() {
+ super(XSSFITestDataProvider.instance);
+ }
/**
* Bug 47026: trouble changing cell type when workbook doesn't contain
@@ -166,7 +166,7 @@ public final class TestXSSFCell extends BaseTestCell {
//make sure we return null for that instead of throwing OutOfBounds
assertEquals(null, cell.getCellStyle());
}
-
+
/**
* Cell with the formula that returns error must return error code(There was
* an problem that cell could not return error value form formula cell).
diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFChartSheet.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFChartSheet.java
index 5ecb187547..e31bbed41f 100644
--- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFChartSheet.java
+++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFChartSheet.java
@@ -17,31 +17,12 @@
package org.apache.poi.xssf.usermodel;
-import org.apache.poi.ss.usermodel.BaseTestSheet;
-import org.apache.poi.ss.usermodel.Cell;
-import org.apache.poi.ss.usermodel.Workbook;
+import junit.framework.TestCase;
+
import org.apache.poi.ss.usermodel.Row;
-import org.apache.poi.ss.util.CellRangeAddress;
-import org.apache.poi.xssf.XSSFITestDataProvider;
import org.apache.poi.xssf.XSSFTestDataSamples;
-import org.apache.poi.xssf.model.CommentsTable;
-import org.apache.poi.xssf.model.StylesTable;
-import org.apache.poi.xssf.usermodel.helpers.ColumnHelper;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCol;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCols;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTComments;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTRow;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorksheet;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTXf;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.STPane;
-
-public class TestXSSFChartSheet extends BaseTestSheet {
-
- @Override
- protected XSSFITestDataProvider getTestDataProvider() {
- return XSSFITestDataProvider.getInstance();
- }
+public final class TestXSSFChartSheet extends TestCase {
public void testXSSFFactory() {
XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("chart_sheet.xlsx");
@@ -57,6 +38,7 @@ public class TestXSSFChartSheet extends BaseTestSheet {
public void testGetAccessors() {
XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("chart_sheet.xlsx");
XSSFChartSheet sheet = (XSSFChartSheet)wb.getSheetAt(2);
+
for(Row row : sheet) {
fail("Row iterator for chart sheets should return zero rows");
}
@@ -73,12 +55,4 @@ public class TestXSSFChartSheet extends BaseTestSheet {
assertEquals(0, sheet.getColumnBreaks().length);
assertEquals(true, sheet.getRowSumsBelow());
}
-
- /**
- * YK: disable failing test from the superclass
- */
- @Override
- public void testDefaultColumnStyle() {
-
- }
-} \ No newline at end of file
+}
diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFComment.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFComment.java
index 34edb48f3f..1d352f27fa 100644
--- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFComment.java
+++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFComment.java
@@ -18,51 +18,26 @@
package org.apache.poi.xssf.usermodel;
import org.apache.poi.hssf.usermodel.HSSFRichTextString;
-import org.apache.poi.ss.usermodel.*;
+import org.apache.poi.ss.usermodel.BaseTestCellComment;
+import org.apache.poi.ss.usermodel.IndexedColors;
import org.apache.poi.ss.util.CellReference;
-import org.apache.poi.xssf.model.CommentsTable;
-import org.apache.poi.xssf.XSSFTestDataSamples;
import org.apache.poi.xssf.XSSFITestDataProvider;
-import org.apache.poi.POIXMLDocumentPart;
+import org.apache.poi.xssf.model.CommentsTable;
import org.apache.xmlbeans.XmlObject;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.*;
-
-import junit.framework.TestCase;
-import junit.framework.AssertionFailedError;
-
-import java.io.ByteArrayOutputStream;
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.util.List;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTComment;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTRPrElt;
import schemasMicrosoftComVml.CTShape;
-
-public class TestXSSFComment extends BaseTestCellComment {
+/**
+ * @author Yegor Kozlov
+ */
+public final class TestXSSFComment extends BaseTestCellComment {
private static final String TEST_RICHTEXTSTRING = "test richtextstring";
- @Override
- protected XSSFITestDataProvider getTestDataProvider(){
- return XSSFITestDataProvider.getInstance();
- }
-
- /**
- * test that we can read cell comments from an existing workbook.
- */
- public void testReadComments() {
- readComments("SimpleWithComments.xlsx");
- }
-
- /**
- * test that we can modify existing cell comments
- */
- public void testModifyComments() throws IOException {
- modifyComments("SimpleWithComments.xlsx");
- }
-
- public void testDeleteComments() throws Exception {
- deleteComments("SimpleWithComments.xlsx");
+ public TestXSSFComment() {
+ super(XSSFITestDataProvider.instance);
}
/**
@@ -132,7 +107,7 @@ public class TestXSSFComment extends BaseTestCellComment {
comment.setString(new HSSFRichTextString(TEST_RICHTEXTSTRING));
fail("expected exception");
} catch (IllegalArgumentException e){
- ;
+ assertEquals("Only XSSFRichTextString argument is supported", e.getMessage());
}
//simple string argument
@@ -189,6 +164,4 @@ public class TestXSSFComment extends BaseTestCellComment {
assertEquals("", comment.getAuthor());
assertEquals(2, sheetComments.getNumberOfAuthors());
}
-
-
}
diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFDataFormat.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFDataFormat.java
index 6596edaf5a..963d0df2d2 100644
--- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFDataFormat.java
+++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFDataFormat.java
@@ -17,25 +17,15 @@
package org.apache.poi.xssf.usermodel;
-import org.apache.poi.ss.ITestDataProvider;
import org.apache.poi.ss.usermodel.BaseTestDataFormat;
import org.apache.poi.xssf.XSSFITestDataProvider;
/**
* Tests for {@link XSSFDataFormat}
- *
*/
public final class TestXSSFDataFormat extends BaseTestDataFormat {
- @Override
- protected ITestDataProvider getTestDataProvider() {
- return XSSFITestDataProvider.getInstance();
- }
-
- /**
- * Test setting and getting boolean values.
- */
- public void testBuiltinFormats() {
- baseBuiltinFormats();
+ public TestXSSFDataFormat() {
+ super(XSSFITestDataProvider.instance);
}
}
diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFFont.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFFont.java
index 288ffca69c..1bcc98149e 100644
--- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFFont.java
+++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFFont.java
@@ -34,9 +34,8 @@ import org.openxmlformats.schemas.spreadsheetml.x2006.main.STVerticalAlignRun;
public final class TestXSSFFont extends BaseTestFont{
- @Override
- protected XSSFITestDataProvider getTestDataProvider() {
- return XSSFITestDataProvider.getInstance();
+ public TestXSSFFont() {
+ super(XSSFITestDataProvider.instance);
}
public void testDefaultFont() {
diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFHyperlink.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFHyperlink.java
index 7c0d01b3a3..6e226e331b 100644
--- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFHyperlink.java
+++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFHyperlink.java
@@ -26,9 +26,8 @@ import org.apache.poi.xssf.XSSFITestDataProvider;
import org.apache.poi.xssf.XSSFTestDataSamples;
public final class TestXSSFHyperlink extends BaseTestHyperlink {
- @Override
- protected XSSFITestDataProvider getTestDataProvider() {
- return XSSFITestDataProvider.getInstance();
+ public TestXSSFHyperlink() {
+ super(XSSFITestDataProvider.instance);
}
@Override
@@ -123,7 +122,7 @@ public final class TestXSSFHyperlink extends BaseTestHyperlink {
/**
* Only for WithMoreVariousData.xlsx !
*/
- private void doTestHyperlinkContents(XSSFSheet sheet) {
+ private static void doTestHyperlinkContents(XSSFSheet sheet) {
assertNotNull(sheet.getRow(3).getCell(2).getHyperlink());
assertNotNull(sheet.getRow(14).getCell(2).getHyperlink());
assertNotNull(sheet.getRow(15).getCell(2).getHyperlink());
diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFName.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFName.java
index 230dc50af5..1c640b4177 100644
--- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFName.java
+++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFName.java
@@ -26,16 +26,15 @@ import org.apache.poi.ss.usermodel.BaseTestNamedRange;
*/
public final class TestXSSFName extends BaseTestNamedRange {
- @Override
- protected XSSFITestDataProvider getTestDataProvider(){
- return XSSFITestDataProvider.getInstance();
+ public TestXSSFName() {
+ super(XSSFITestDataProvider.instance);
}
//TODO combine testRepeatingRowsAndColums() for HSSF and XSSF
public void testRepeatingRowsAndColums() {
// First test that setting RR&C for same sheet more than once only creates a
// single Print_Titles built-in record
- XSSFWorkbook wb = getTestDataProvider().createWorkbook();
+ XSSFWorkbook wb = new XSSFWorkbook();
wb.createSheet("First Sheet");
wb.setRepeatingRowsAndColumns(0, -1, -1, -1, -1);
diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFPicture.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFPicture.java
index 2437767bf1..aea0bca8ed 100644
--- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFPicture.java
+++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFPicture.java
@@ -31,9 +31,8 @@ import java.util.Arrays;
*/
public final class TestXSSFPicture extends BaseTestPicture {
- @Override
- protected XSSFITestDataProvider getTestDataProvider(){
- return XSSFITestDataProvider.getInstance();
+ public TestXSSFPicture() {
+ super(XSSFITestDataProvider.instance);
}
public void testResize() {
diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFRow.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFRow.java
index 5ac850e6aa..81f9ce8119 100644
--- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFRow.java
+++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFRow.java
@@ -26,9 +26,8 @@ import org.apache.poi.xssf.XSSFITestDataProvider;
*/
public final class TestXSSFRow extends BaseTestRow {
- @Override
- protected XSSFITestDataProvider getTestDataProvider(){
- return XSSFITestDataProvider.getInstance();
+ public TestXSSFRow() {
+ super(XSSFITestDataProvider.instance);
}
public void testRowBounds() {
diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java
index ab9bb8fce0..33c5eee1d9 100644
--- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java
+++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java
@@ -33,11 +33,10 @@ import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTXf;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.STPane;
-public class TestXSSFSheet extends BaseTestSheet {
+public final class TestXSSFSheet extends BaseTestSheet {
- @Override
- protected XSSFITestDataProvider getTestDataProvider() {
- return XSSFITestDataProvider.getInstance();
+ public TestXSSFSheet() {
+ super(XSSFITestDataProvider.instance);
}
//TODO column styles are not yet supported by XSSF
@@ -106,7 +105,7 @@ public class TestXSSFSheet extends BaseTestSheet {
}
public void testGetAllHeadersFooters() {
- XSSFWorkbook workbook = getTestDataProvider().createWorkbook();
+ XSSFWorkbook workbook = new XSSFWorkbook();
XSSFSheet sheet = workbook.createSheet("Sheet 1");
assertNotNull(sheet.getOddFooter());
assertNotNull(sheet.getEvenFooter());
@@ -780,7 +779,7 @@ public class TestXSSFSheet extends BaseTestSheet {
}
//serialize and check again
- wb = getTestDataProvider().writeOutAndReadBack(wb);
+ wb = XSSFTestDataSamples.writeOutAndReadBack(wb);
sheet = wb.getSheetAt(0);
cols = sheet.getCTWorksheet().getColsArray(0);
assertEquals(5, cols.sizeOfColArray());
@@ -850,7 +849,7 @@ public class TestXSSFSheet extends BaseTestSheet {
assertEquals(7, col.getMax());
//serialize and check again
- wb = getTestDataProvider().writeOutAndReadBack(wb);
+ wb = XSSFTestDataSamples.writeOutAndReadBack(wb);
sheet = wb.getSheetAt(0);
assertTrue(sheet.isColumnHidden(2));
assertTrue(sheet.isColumnHidden(6));
diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheetUpdateArrayFormulas.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheetUpdateArrayFormulas.java
index c8e5357444..b703c48cd0 100644
--- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheetUpdateArrayFormulas.java
+++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheetUpdateArrayFormulas.java
@@ -35,7 +35,7 @@ import org.openxmlformats.schemas.spreadsheetml.x2006.main.STCellFormulaType;
public final class TestXSSFSheetUpdateArrayFormulas extends BaseTestSheetUpdateArrayFormulas {
public TestXSSFSheetUpdateArrayFormulas() {
- super(XSSFITestDataProvider.getInstance());
+ super(XSSFITestDataProvider.instance);
}
// Test methods common with HSSF are in superclass
diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFWorkbook.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFWorkbook.java
index b25cd26c9c..5ec6257d7c 100644
--- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFWorkbook.java
+++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFWorkbook.java
@@ -36,12 +36,10 @@ import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorkbookPr;
public final class TestXSSFWorkbook extends BaseTestWorkbook {
- @Override
- protected XSSFITestDataProvider getTestDataProvider(){
- return XSSFITestDataProvider.getInstance();
+ public TestXSSFWorkbook() {
+ super(XSSFITestDataProvider.instance);
}
-
/**
* Tests that we can save, and then re-load a new document
*/
@@ -232,14 +230,14 @@ public final class TestXSSFWorkbook extends BaseTestWorkbook {
}
public void testIncrementSheetId() {
- XSSFWorkbook wb = getTestDataProvider().createWorkbook();
+ XSSFWorkbook wb = new XSSFWorkbook();
int sheetId = (int)wb.createSheet().sheet.getSheetId();
assertEquals(1, sheetId);
sheetId = (int)wb.createSheet().sheet.getSheetId();
assertEquals(2, sheetId);
//test file with gaps in the sheetId sequence
- wb = getTestDataProvider().openSampleWorkbook("47089.xlsm");
+ wb = XSSFTestDataSamples.openSampleWorkbook("47089.xlsm");
int lastSheetId = (int)wb.getSheetAt(wb.getNumberOfSheets() - 1).sheet.getSheetId();
sheetId = (int)wb.createSheet().sheet.getSheetId();
assertEquals(lastSheetId+1, sheetId);
@@ -305,55 +303,55 @@ public final class TestXSSFWorkbook extends BaseTestWorkbook {
assertEquals(crc0.getValue(), crc1.getValue());
}
- /**
- * When deleting a sheet make sure that we adjust sheet indices of named ranges
- */
- public void testBug47737() {
- XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("47737.xlsx");
- assertEquals(2, wb.getNumberOfNames());
- assertNotNull(wb.getCalculationChain());
-
- XSSFName nm0 = wb.getNameAt(0);
- assertTrue(nm0.getCTName().isSetLocalSheetId());
- assertEquals(0, nm0.getCTName().getLocalSheetId());
-
- XSSFName nm1 = wb.getNameAt(1);
- assertTrue(nm1.getCTName().isSetLocalSheetId());
- assertEquals(1, nm1.getCTName().getLocalSheetId());
-
- wb.removeSheetAt(0);
- assertEquals(1, wb.getNumberOfNames());
- XSSFName nm2 = wb.getNameAt(0);
- assertTrue(nm2.getCTName().isSetLocalSheetId());
- assertEquals(0, nm2.getCTName().getLocalSheetId());
- //calculation chain is removed as well
- assertNull(wb.getCalculationChain());
-
- }
-
- /**
- * Problems with XSSFWorkbook.removeSheetAt when workbook contains chart
- */
- public void testBug47813() {
- XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("47813.xlsx");
- assertEquals(3, wb.getNumberOfSheets());
- assertNotNull(wb.getCalculationChain());
-
- assertEquals("Numbers", wb.getSheetName(0));
- //the second sheet is of type 'chartsheet'
- assertEquals("Chart", wb.getSheetName(1));
- assertTrue(wb.getSheetAt(1) instanceof XSSFChartSheet);
- assertEquals("SomeJunk", wb.getSheetName(2));
-
- wb.removeSheetAt(2);
- assertEquals(2, wb.getNumberOfSheets());
- assertNull(wb.getCalculationChain());
-
- wb = XSSFTestDataSamples.writeOutAndReadBack(wb);
- assertEquals(2, wb.getNumberOfSheets());
- assertNull(wb.getCalculationChain());
-
- assertEquals("Numbers", wb.getSheetName(0));
- assertEquals("Chart", wb.getSheetName(1));
- }
+ /**
+ * When deleting a sheet make sure that we adjust sheet indices of named ranges
+ */
+ public void testBug47737() {
+ XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("47737.xlsx");
+ assertEquals(2, wb.getNumberOfNames());
+ assertNotNull(wb.getCalculationChain());
+
+ XSSFName nm0 = wb.getNameAt(0);
+ assertTrue(nm0.getCTName().isSetLocalSheetId());
+ assertEquals(0, nm0.getCTName().getLocalSheetId());
+
+ XSSFName nm1 = wb.getNameAt(1);
+ assertTrue(nm1.getCTName().isSetLocalSheetId());
+ assertEquals(1, nm1.getCTName().getLocalSheetId());
+
+ wb.removeSheetAt(0);
+ assertEquals(1, wb.getNumberOfNames());
+ XSSFName nm2 = wb.getNameAt(0);
+ assertTrue(nm2.getCTName().isSetLocalSheetId());
+ assertEquals(0, nm2.getCTName().getLocalSheetId());
+ //calculation chain is removed as well
+ assertNull(wb.getCalculationChain());
+
+ }
+
+ /**
+ * Problems with XSSFWorkbook.removeSheetAt when workbook contains chart
+ */
+ public void testBug47813() {
+ XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("47813.xlsx");
+ assertEquals(3, wb.getNumberOfSheets());
+ assertNotNull(wb.getCalculationChain());
+
+ assertEquals("Numbers", wb.getSheetName(0));
+ //the second sheet is of type 'chartsheet'
+ assertEquals("Chart", wb.getSheetName(1));
+ assertTrue(wb.getSheetAt(1) instanceof XSSFChartSheet);
+ assertEquals("SomeJunk", wb.getSheetName(2));
+
+ wb.removeSheetAt(2);
+ assertEquals(2, wb.getNumberOfSheets());
+ assertNull(wb.getCalculationChain());
+
+ wb = XSSFTestDataSamples.writeOutAndReadBack(wb);
+ assertEquals(2, wb.getNumberOfSheets());
+ assertNull(wb.getCalculationChain());
+
+ assertEquals("Numbers", wb.getSheetName(0));
+ assertEquals("Chart", wb.getSheetName(1));
+ }
}