convert TestXSSFPivotTable to junit4

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1760806 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Javen O'Neal 2016-09-14 22:01:11 +00:00
parent 1de973e2a7
commit 16acf81b9e
2 changed files with 21 additions and 5 deletions

View File

@ -59,7 +59,7 @@ import org.junit.runners.Suite;
TestXSSFSheetComments.class,
TestColumnHelper.class,
TestHeaderFooterHelper.class,
TestXSSFPivotTable.class,
//TestXSSFPivotTable.class, //converted to junit4
TestForkedEvaluator.class
})
public final class AllXSSFUsermodelTests {

View File

@ -16,6 +16,9 @@
==================================================================== */
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;
@ -23,20 +26,20 @@ import org.apache.poi.ss.usermodel.Row;
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();
@ -119,6 +122,7 @@ public class TestXSSFPivotTable extends TestCase {
* 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;
@ -141,6 +145,7 @@ public class TestXSSFPivotTable extends TestCase {
/**
* Verify that it's not possible to create a row label outside of the referenced area.
*/
@Test
public void testAddRowLabelOutOfRangeThrowsException() {
int columnIndex = 5;
@ -155,6 +160,7 @@ public class TestXSSFPivotTable extends TestCase {
/**
* Verify that when creating one column label, no col fields are being created.
*/
@Test
public void testAddOneColumnLabelToPivotTableDoesNotCreateColField() {
int columnIndex = 0;
@ -167,6 +173,7 @@ public class TestXSSFPivotTable extends TestCase {
/**
* Verify that it's possible to create three column labels with different DataConsolidateFunction
*/
@Test
public void testAddThreeDifferentColumnLabelsToPivotTable() {
int columnOne = 0;
int columnTwo = 1;
@ -184,6 +191,7 @@ public class TestXSSFPivotTable extends TestCase {
/**
* Verify that it's possible to create three column labels with the same DataConsolidateFunction
*/
@Test
public void testAddThreeSametColumnLabelsToPivotTable() {
int columnOne = 0;
int columnTwo = 1;
@ -200,6 +208,7 @@ public class TestXSSFPivotTable extends TestCase {
/**
* 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;
@ -214,6 +223,7 @@ public class TestXSSFPivotTable extends TestCase {
/**
* Verify that a data field is created when creating a data column
*/
@Test
public void testColumnLabelCreatesDataField() {
int columnIndex = 0;
@ -229,6 +239,7 @@ public class TestXSSFPivotTable extends TestCase {
/**
* Verify that it's possible to set a custom name when creating a data column
*/
@Test
public void testColumnLabelSetCustomName() {
int columnIndex = 0;
@ -245,6 +256,7 @@ public class TestXSSFPivotTable extends TestCase {
/**
* Verify that it's not possible to create a column label outside of the referenced area.
*/
@Test
public void testAddColumnLabelOutOfRangeThrowsException() {
int columnIndex = 5;
@ -260,6 +272,7 @@ public class TestXSSFPivotTable extends TestCase {
* 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;
@ -272,6 +285,7 @@ public class TestXSSFPivotTable extends TestCase {
/**
* 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;
@ -301,6 +315,7 @@ public class TestXSSFPivotTable extends TestCase {
/**
* Verify that it's not possible to create a new filter outside of the referenced area.
*/
@Test
public void testAddReportFilterOutOfRangeThrowsException() {
int columnIndex = 5;
try {
@ -315,6 +330,7 @@ public class TestXSSFPivotTable extends TestCase {
* 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());