mirror of https://github.com/apache/poi.git
minor improvements to junits
git-svn-id: https://svn.apache.org/repos/asf/poi/branches/ooxml@696401 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
4ec0dadc6b
commit
162d9bd11d
|
@ -17,12 +17,14 @@
|
|||
|
||||
package org.apache.poi.xssf.usermodel;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.io.PrintStream;
|
||||
|
||||
import junit.framework.Assert;
|
||||
import junit.framework.AssertionFailedError;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.apache.poi.hssf.HSSFTestDataSamples;
|
||||
import org.apache.poi.hssf.record.formula.eval.TestFormulasFromSpreadsheet;
|
||||
import org.apache.poi.hssf.record.formula.functions.TestMathX;
|
||||
import org.apache.poi.ss.usermodel.Cell;
|
||||
|
@ -113,15 +115,6 @@ public final class TestFormulaEvaluatorOnXSSF extends TestCase {
|
|||
throw new AssertionFailedError(msg + " - actual value was null");
|
||||
}
|
||||
|
||||
if (expected.getCellType() == Cell.CELL_TYPE_STRING) {
|
||||
String value = expected.getRichStringCellValue().getString();
|
||||
if (value.startsWith("#")) {
|
||||
// TODO - this code never called
|
||||
expected.setCellType(Cell.CELL_TYPE_ERROR);
|
||||
// expected.setCellErrorValue(...?);
|
||||
}
|
||||
}
|
||||
|
||||
switch (expected.getCellType()) {
|
||||
case Cell.CELL_TYPE_BLANK:
|
||||
assertEquals(msg, Cell.CELL_TYPE_BLANK, actual.getCellType());
|
||||
|
@ -147,7 +140,7 @@ public final class TestFormulaEvaluatorOnXSSF extends TestCase {
|
|||
break;
|
||||
case Cell.CELL_TYPE_STRING:
|
||||
assertEquals(msg, Cell.CELL_TYPE_STRING, actual.getCellType());
|
||||
assertEquals(msg, expected.getRichStringCellValue().getString(), actual.getRichTextStringValue().getString());
|
||||
assertEquals(msg, expected.getRichStringCellValue().getString(), actual.getStringValue());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -155,8 +148,8 @@ public final class TestFormulaEvaluatorOnXSSF extends TestCase {
|
|||
|
||||
protected void setUp() throws Exception {
|
||||
if (workbook == null) {
|
||||
String filePath = System.getProperty("HSSF.testdata.path")+ "/" + SS.FILENAME;
|
||||
Package pkg = Package.open(filePath);
|
||||
InputStream is = HSSFTestDataSamples.openSampleFileStream(SS.FILENAME);
|
||||
Package pkg = Package.open(is);
|
||||
workbook = new XSSFWorkbook( pkg );
|
||||
sheet = workbook.getSheetAt( 0 );
|
||||
}
|
||||
|
@ -206,7 +199,7 @@ public final class TestFormulaEvaluatorOnXSSF extends TestCase {
|
|||
*/
|
||||
private void processFunctionGroup(int startRowIndex, String testFocusFunctionName) {
|
||||
|
||||
FormulaEvaluator evaluator = new FormulaEvaluator(sheet, workbook);
|
||||
FormulaEvaluator evaluator = new FormulaEvaluator(workbook);
|
||||
|
||||
int rowIndex = startRowIndex;
|
||||
while (true) {
|
||||
|
@ -252,7 +245,6 @@ public final class TestFormulaEvaluatorOnXSSF extends TestCase {
|
|||
|
||||
int result = Result.NO_EVALUATIONS_FOUND; // so far
|
||||
short endcolnum = formulasRow.getLastCellNum();
|
||||
evaluator.setCurrentRow(formulasRow);
|
||||
|
||||
// iterate across the row for all the evaluation cases
|
||||
for (short colnum=SS.COLUMN_INDEX_FIRST_TEST_VALUE; colnum < endcolnum; colnum++) {
|
||||
|
@ -341,7 +333,6 @@ public final class TestFormulaEvaluatorOnXSSF extends TestCase {
|
|||
for(int i=startIx; i<endIx; i++) {
|
||||
ps.println("\tat " + stes[i].toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -29,7 +29,11 @@ import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTSheet;
|
|||
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorksheet;
|
||||
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTXf;
|
||||
|
||||
public class TestColumnHelper extends TestCase {
|
||||
/**
|
||||
* Tests for {@link ColumnHelper}
|
||||
*
|
||||
*/
|
||||
public final class TestColumnHelper extends TestCase {
|
||||
|
||||
public void testCleanColumns() {
|
||||
CTWorksheet worksheet = CTWorksheet.Factory.newInstance();
|
||||
|
@ -182,7 +186,14 @@ public class TestColumnHelper extends TestCase {
|
|||
col9.setMax(27);
|
||||
helper.addCleanColIntoCols(cols1, col9);
|
||||
|
||||
System.err.println(cols1);
|
||||
if (false) {
|
||||
System.err.println(cols1);
|
||||
}
|
||||
// TODO - assert something interesting
|
||||
CTCol[] colArray = cols1.getColArray();
|
||||
assertEquals(12, colArray.length);
|
||||
assertEquals(1, colArray[0].getMin());
|
||||
assertEquals(16750, colArray[11].getMax());
|
||||
}
|
||||
|
||||
public void testGetColumn() {
|
||||
|
@ -230,7 +241,7 @@ public class TestColumnHelper extends TestCase {
|
|||
|
||||
public void testGetOrCreateColumn() {
|
||||
XSSFWorkbook workbook = new XSSFWorkbook();
|
||||
XSSFSheet sheet = (XSSFSheet) workbook.createSheet("Sheet 1");
|
||||
XSSFSheet sheet = workbook.createSheet("Sheet 1");
|
||||
ColumnHelper columnHelper = sheet.getColumnHelper();
|
||||
|
||||
// Check POI 0 based, OOXML 1 based
|
||||
|
@ -250,10 +261,10 @@ public class TestColumnHelper extends TestCase {
|
|||
}
|
||||
|
||||
public void testGetSetColDefaultStyle() {
|
||||
XSSFWorkbook workbook = new XSSFWorkbook();
|
||||
CTSheet ctSheet = CTSheet.Factory.newInstance();
|
||||
CTWorksheet ctWorksheet = CTWorksheet.Factory.newInstance();
|
||||
XSSFSheet sheet = new XSSFSheet(ctSheet, ctWorksheet, (XSSFWorkbook) workbook);
|
||||
XSSFWorkbook workbook = new XSSFWorkbook();
|
||||
CTSheet ctSheet = CTSheet.Factory.newInstance();
|
||||
CTWorksheet ctWorksheet = CTWorksheet.Factory.newInstance();
|
||||
XSSFSheet sheet = new XSSFSheet(ctSheet, ctWorksheet, workbook);
|
||||
ColumnHelper columnHelper = sheet.getColumnHelper();
|
||||
|
||||
// POI column 3, OOXML column 4
|
||||
|
@ -283,7 +294,7 @@ public class TestColumnHelper extends TestCase {
|
|||
assertEquals(1, columnHelper.getColDefaultStyle(10));
|
||||
}
|
||||
|
||||
private int countColumns(CTWorksheet worksheet) {
|
||||
private static int countColumns(CTWorksheet worksheet) {
|
||||
int count;
|
||||
count = 0;
|
||||
for (int i = 0; i < worksheet.sizeOfColsArray(); i++) {
|
||||
|
@ -296,5 +307,4 @@ public class TestColumnHelper extends TestCase {
|
|||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue