==================================================================== */
package org.apache.poi.xssf.usermodel;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellType;
import org.apache.poi.ss.usermodel.DataConsolidateFunction;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.util.AreaReference;
import org.apache.poi.ss.util.CellReference;
+import org.junit.Before;
+import org.junit.Test;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTPageField;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTPageFields;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTPivotFields;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTPivotTableDefinition;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.STDataConsolidateFunction;
-import junit.framework.TestCase;
-
-public class TestXSSFPivotTable extends TestCase {
+public class TestXSSFPivotTable {
private XSSFPivotTable pivotTable;
private XSSFPivotTable offsetPivotTable;
private Cell offsetOuterCell;
- @Override
+ @Before
public void setUp(){
Workbook wb = new XSSFWorkbook();
XSSFSheet sheet = (XSSFSheet) wb.createSheet();
* Verify that when creating a row label it's created on the correct row
* and the count is increased by one.
*/
+ @Test
public void testAddRowLabelToPivotTable() {
int columnIndex = 0;
/**
* Verify that it's not possible to create a row label outside of the referenced area.
*/
+ @Test
public void testAddRowLabelOutOfRangeThrowsException() {
int columnIndex = 5;
/**
* Verify that when creating one column label, no col fields are being created.
*/
+ @Test
public void testAddOneColumnLabelToPivotTableDoesNotCreateColField() {
int columnIndex = 0;
/**
* Verify that it's possible to create three column labels with different DataConsolidateFunction
*/
+ @Test
public void testAddThreeDifferentColumnLabelsToPivotTable() {
int columnOne = 0;
int columnTwo = 1;
/**
* Verify that it's possible to create three column labels with the same DataConsolidateFunction
*/
+ @Test
public void testAddThreeSametColumnLabelsToPivotTable() {
int columnOne = 0;
int columnTwo = 1;
/**
* Verify that when creating two column labels, a col field is being created and X is set to -2.
*/
+ @Test
public void testAddTwoColumnLabelsToPivotTable() {
int columnOne = 0;
int columnTwo = 1;
/**
* Verify that a data field is created when creating a data column
*/
+ @Test
public void testColumnLabelCreatesDataField() {
int columnIndex = 0;
/**
* Verify that it's possible to set a custom name when creating a data column
*/
+ @Test
public void testColumnLabelSetCustomName() {
int columnIndex = 0;
/**
* Verify that it's not possible to create a column label outside of the referenced area.
*/
+ @Test
public void testAddColumnLabelOutOfRangeThrowsException() {
int columnIndex = 5;
* Verify when creating a data column set to a data field, the data field with the corresponding
* column index will be set to true.
*/
+ @Test
public void testAddDataColumn() {
int columnIndex = 0;
boolean isDataField = true;
/**
* Verify that it's not possible to create a data column outside of the referenced area.
*/
+ @Test
public void testAddDataColumnOutOfRangeThrowsException() {
int columnIndex = 5;
boolean isDataField = true;
/**
* Verify that it's not possible to create a new filter outside of the referenced area.
*/
+ @Test
public void testAddReportFilterOutOfRangeThrowsException() {
int columnIndex = 5;
try {
* Verify that the Pivot Table operates only within the referenced area, even when the
* first column of the referenced area is not index 0.
*/
+ @Test
public void testAddDataColumnWithOffsetData() {
offsetPivotTable.addColumnLabel(DataConsolidateFunction.SUM, 1);
assertEquals(CellType.NUMERIC, offsetOuterCell.getCellTypeEnum());