aboutsummaryrefslogtreecommitdiffstats
path: root/src/testcases/org/apache
diff options
context:
space:
mode:
authorDominik Stadler <centic@apache.org>2014-12-28 09:06:12 +0000
committerDominik Stadler <centic@apache.org>2014-12-28 09:06:12 +0000
commitca12a2116332340fc4c268f5ec1f87808e4e07d7 (patch)
tree41e4542f85879bf5475ac6d5d6bbd3567c2fe75c /src/testcases/org/apache
parent29f23904bb408061a23366086b5ba3a50cece897 (diff)
downloadpoi-ca12a2116332340fc4c268f5ec1f87808e4e07d7.tar.gz
poi-ca12a2116332340fc4c268f5ec1f87808e4e07d7.zip
Fix Eclipse warnings, unnecessary casts, use generics, static access...
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1648156 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/testcases/org/apache')
-rw-r--r--src/testcases/org/apache/poi/hssf/usermodel/TestDataValidation.java7
-rw-r--r--src/testcases/org/apache/poi/hssf/usermodel/TestWorkbook.java3
-rw-r--r--src/testcases/org/apache/poi/ss/formula/eval/TestEqualEval.java42
-rw-r--r--src/testcases/org/apache/poi/ss/formula/eval/TestFormulaBugs.java83
-rw-r--r--src/testcases/org/apache/poi/ss/formula/eval/TestMinusZeroResult.java25
-rw-r--r--src/testcases/org/apache/poi/ss/formula/functions/TestIndirect.java34
-rw-r--r--src/testcases/org/apache/poi/ss/formula/functions/TestRoundFuncs.java4
-rw-r--r--src/testcases/org/apache/poi/ss/formula/functions/TestTrunc.java4
-rw-r--r--src/testcases/org/apache/poi/ss/usermodel/BaseTestCell.java4
-rw-r--r--src/testcases/org/apache/poi/ss/usermodel/BaseTestDataValidation.java119
-rw-r--r--src/testcases/org/apache/poi/util/DummyPOILogger.java4
11 files changed, 169 insertions, 160 deletions
diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestDataValidation.java b/src/testcases/org/apache/poi/hssf/usermodel/TestDataValidation.java
index 1d71ca5c6f..b3bfc534ed 100644
--- a/src/testcases/org/apache/poi/hssf/usermodel/TestDataValidation.java
+++ b/src/testcases/org/apache/poi/hssf/usermodel/TestDataValidation.java
@@ -45,6 +45,9 @@ import org.apache.poi.ss.usermodel.DateUtil;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.util.CellRangeAddress;
+import org.apache.poi.ss.usermodel.*;
+import org.apache.poi.ss.usermodel.DataValidation.ErrorStyle;
+import org.apache.poi.ss.usermodel.DataValidationConstraint.OperatorType;
import org.apache.poi.ss.util.CellRangeAddressList;
/**
@@ -149,11 +152,11 @@ public final class TestDataValidation extends BaseTestDataValidation {
int dvRow = 0;
Sheet sheet = wb.getSheetAt(0);
DataValidationHelper dataValidationHelper = sheet.getDataValidationHelper();
- DataValidationConstraint dc = dataValidationHelper.createIntegerConstraint(OP.EQUAL, "42", null);
+ DataValidationConstraint dc = dataValidationHelper.createIntegerConstraint(OperatorType.EQUAL, "42", null);
DataValidation dv = dataValidationHelper.createValidation(dc,new CellRangeAddressList(dvRow, dvRow, 0, 0));
dv.setEmptyCellAllowed(false);
- dv.setErrorStyle(ES.STOP);
+ dv.setErrorStyle(ErrorStyle.STOP);
dv.setShowPromptBox(true);
dv.createErrorBox("Xxx", "Yyy");
dv.setSuppressDropDownArrow(true);
diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestWorkbook.java b/src/testcases/org/apache/poi/hssf/usermodel/TestWorkbook.java
index c9ce13fca3..7fdb4bd752 100644
--- a/src/testcases/org/apache/poi/hssf/usermodel/TestWorkbook.java
+++ b/src/testcases/org/apache/poi/hssf/usermodel/TestWorkbook.java
@@ -31,6 +31,7 @@ import org.apache.poi.hssf.record.LabelSSTRecord;
import org.apache.poi.hssf.record.Record;
import org.apache.poi.hssf.record.aggregates.RecordAggregate.RecordVisitor;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
+import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.ss.util.Region;
import org.apache.poi.util.TempFile;
@@ -395,7 +396,7 @@ public final class TestWorkbook extends TestCase {
HSSFCell c = s.getRow(0).getCell(0);
int a = c.getCellType();
- assertEquals(a, c.CELL_TYPE_NUMERIC);
+ assertEquals(a, Cell.CELL_TYPE_NUMERIC);
}
/**
diff --git a/src/testcases/org/apache/poi/ss/formula/eval/TestEqualEval.java b/src/testcases/org/apache/poi/ss/formula/eval/TestEqualEval.java
index 7eaa3e9132..e10de014cd 100644
--- a/src/testcases/org/apache/poi/ss/formula/eval/TestEqualEval.java
+++ b/src/testcases/org/apache/poi/ss/formula/eval/TestEqualEval.java
@@ -43,7 +43,7 @@ public final class TestEqualEval extends TestCase {
EvalFactory.createAreaEval("B1:B1", values),
BoolEval.FALSE,
};
- ValueEval result = evaluate(EI.Equal, args, 10, 10);
+ ValueEval result = evaluate(EvalInstances.Equal, args, 10, 10);
if (result instanceof ErrorEval) {
if (result == ErrorEval.VALUE_INVALID) {
throw new AssertionFailedError("Identified bug in evaluation of 1x1 area");
@@ -61,7 +61,7 @@ public final class TestEqualEval extends TestCase {
new StringEval(""),
BlankEval.instance,
};
- ValueEval result = evaluate(EI.Equal, args, 10, 10);
+ ValueEval result = evaluate(EvalInstances.Equal, args, 10, 10);
assertEquals(BoolEval.class, result.getClass());
BoolEval be = (BoolEval) result;
if (!be.getBooleanValue()) {
@@ -74,14 +74,14 @@ public final class TestEqualEval extends TestCase {
* Test for bug 46613 (observable at svn r737248)
*/
public void testStringInsensitive_bug46613() {
- if (!evalStringCmp("abc", "aBc", EI.Equal)) {
+ if (!evalStringCmp("abc", "aBc", EvalInstances.Equal)) {
throw new AssertionFailedError("Identified bug 46613");
}
- assertTrue(evalStringCmp("abc", "aBc", EI.Equal));
- assertTrue(evalStringCmp("ABC", "azz", EI.LessThan));
- assertTrue(evalStringCmp("abc", "AZZ", EI.LessThan));
- assertTrue(evalStringCmp("ABC", "aaa", EI.GreaterThan));
- assertTrue(evalStringCmp("abc", "AAA", EI.GreaterThan));
+ assertTrue(evalStringCmp("abc", "aBc", EvalInstances.Equal));
+ assertTrue(evalStringCmp("ABC", "azz", EvalInstances.LessThan));
+ assertTrue(evalStringCmp("abc", "AZZ", EvalInstances.LessThan));
+ assertTrue(evalStringCmp("ABC", "aaa", EvalInstances.GreaterThan));
+ assertTrue(evalStringCmp("abc", "AAA", EvalInstances.GreaterThan));
}
private static boolean evalStringCmp(String a, String b, Function cmpOp) {
@@ -107,17 +107,17 @@ public final class TestEqualEval extends TestCase {
confirmCompares(BoolEval.FALSE, BoolEval.FALSE, 0);
}
private static void confirmCompares(ValueEval a, ValueEval b, int expRes) {
- confirm(a, b, expRes>0, EI.GreaterThan);
- confirm(a, b, expRes>=0, EI.GreaterEqual);
- confirm(a, b, expRes==0, EI.Equal);
- confirm(a, b, expRes<=0, EI.LessEqual);
- confirm(a, b, expRes<0, EI.LessThan);
-
- confirm(b, a, expRes<0, EI.GreaterThan);
- confirm(b, a, expRes<=0, EI.GreaterEqual);
- confirm(b, a, expRes==0, EI.Equal);
- confirm(b, a, expRes>=0, EI.LessEqual);
- confirm(b, a, expRes>0, EI.LessThan);
+ confirm(a, b, expRes>0, EvalInstances.GreaterThan);
+ confirm(a, b, expRes>=0, EvalInstances.GreaterEqual);
+ confirm(a, b, expRes==0, EvalInstances.Equal);
+ confirm(a, b, expRes<=0, EvalInstances.LessEqual);
+ confirm(a, b, expRes<0, EvalInstances.LessThan);
+
+ confirm(b, a, expRes<0, EvalInstances.GreaterThan);
+ confirm(b, a, expRes<=0, EvalInstances.GreaterEqual);
+ confirm(b, a, expRes==0, EvalInstances.Equal);
+ confirm(b, a, expRes>=0, EvalInstances.LessEqual);
+ confirm(b, a, expRes>0, EvalInstances.LessThan);
}
private static void confirm(ValueEval a, ValueEval b, boolean expectedResult, Function cmpOp) {
ValueEval[] args = { a, b, };
@@ -142,7 +142,7 @@ public final class TestEqualEval extends TestCase {
throw new AssertionFailedError("Identified bug 47198: unary minus should convert -0.0 to 0.0");
}
ValueEval[] args = { zero, mZero, };
- BoolEval result = (BoolEval) evaluate(EI.Equal, args, 0, 0);
+ BoolEval result = (BoolEval) evaluate(EvalInstances.Equal, args, 0, 0);
if (!result.getBooleanValue()) {
throw new AssertionFailedError("Identified bug 47198: -0.0 != 0.0");
}
@@ -157,7 +157,7 @@ public final class TestEqualEval extends TestCase {
assertEquals("1.0055", b.getStringValue());
ValueEval[] args = { a, b, };
- BoolEval result = (BoolEval) evaluate(EI.Equal, args, 0, 0);
+ BoolEval result = (BoolEval) evaluate(EvalInstances.Equal, args, 0, 0);
if (!result.getBooleanValue()) {
throw new AssertionFailedError("Identified bug 47598: 1+1.0028-0.9973 != 1.0055");
}
diff --git a/src/testcases/org/apache/poi/ss/formula/eval/TestFormulaBugs.java b/src/testcases/org/apache/poi/ss/formula/eval/TestFormulaBugs.java
index 824c8aba5d..31ad51246b 100644
--- a/src/testcases/org/apache/poi/ss/formula/eval/TestFormulaBugs.java
+++ b/src/testcases/org/apache/poi/ss/formula/eval/TestFormulaBugs.java
@@ -124,49 +124,54 @@ public final class TestFormulaBugs extends TestCase {
/**
* Bug 42448 - Can't parse SUMPRODUCT(A!C7:A!C67, B8:B68) / B69 <p/>
+ * @throws IOException
*/
- public void test42448() {
+ public void test42448() throws IOException {
HSSFWorkbook wb = new HSSFWorkbook();
- HSSFSheet sheet1 = wb.createSheet("Sheet1");
-
- HSSFRow row = sheet1.createRow(0);
- HSSFCell cell = row.createCell(0);
-
- // it's important to create the referenced sheet first
- HSSFSheet sheet2 = wb.createSheet("A"); // note name 'A'
- // TODO - POI crashes if the formula is added before this sheet
- // RuntimeException("Zero length string is an invalid sheet name")
- // Excel doesn't crash but the formula doesn't work until it is
- // re-entered
-
- String inputFormula = "SUMPRODUCT(A!C7:A!C67, B8:B68) / B69"; // as per bug report
try {
- cell.setCellFormula(inputFormula);
- } catch (StringIndexOutOfBoundsException e) {
- throw new AssertionFailedError("Identified bug 42448");
+ HSSFSheet sheet1 = wb.createSheet("Sheet1");
+
+ HSSFRow row = sheet1.createRow(0);
+ HSSFCell cell = row.createCell(0);
+
+ // it's important to create the referenced sheet first
+ HSSFSheet sheet2 = wb.createSheet("A"); // note name 'A'
+ // TODO - POI crashes if the formula is added before this sheet
+ // RuntimeException("Zero length string is an invalid sheet name")
+ // Excel doesn't crash but the formula doesn't work until it is
+ // re-entered
+
+ String inputFormula = "SUMPRODUCT(A!C7:A!C67, B8:B68) / B69"; // as per bug report
+ try {
+ cell.setCellFormula(inputFormula);
+ } catch (StringIndexOutOfBoundsException e) {
+ throw new AssertionFailedError("Identified bug 42448");
+ }
+
+ assertEquals("SUMPRODUCT(A!C7:A!C67,B8:B68)/B69", cell.getCellFormula());
+
+ // might as well evaluate the sucker...
+
+ addCell(sheet2, 5, 2, 3.0); // A!C6
+ addCell(sheet2, 6, 2, 4.0); // A!C7
+ addCell(sheet2, 66, 2, 5.0); // A!C67
+ addCell(sheet2, 67, 2, 6.0); // A!C68
+
+ addCell(sheet1, 6, 1, 7.0); // B7
+ addCell(sheet1, 7, 1, 8.0); // B8
+ addCell(sheet1, 67, 1, 9.0); // B68
+ addCell(sheet1, 68, 1, 10.0); // B69
+
+ double expectedResult = (4.0 * 8.0 + 5.0 * 9.0) / 10.0;
+
+ HSSFFormulaEvaluator fe = new HSSFFormulaEvaluator(wb);
+ CellValue cv = fe.evaluate(cell);
+
+ assertEquals(HSSFCell.CELL_TYPE_NUMERIC, cv.getCellType());
+ assertEquals(expectedResult, cv.getNumberValue(), 0.0);
+ } finally {
+ wb.close();
}
-
- assertEquals("SUMPRODUCT(A!C7:A!C67,B8:B68)/B69", cell.getCellFormula());
-
- // might as well evaluate the sucker...
-
- addCell(sheet2, 5, 2, 3.0); // A!C6
- addCell(sheet2, 6, 2, 4.0); // A!C7
- addCell(sheet2, 66, 2, 5.0); // A!C67
- addCell(sheet2, 67, 2, 6.0); // A!C68
-
- addCell(sheet1, 6, 1, 7.0); // B7
- addCell(sheet1, 7, 1, 8.0); // B8
- addCell(sheet1, 67, 1, 9.0); // B68
- addCell(sheet1, 68, 1, 10.0); // B69
-
- double expectedResult = (4.0 * 8.0 + 5.0 * 9.0) / 10.0;
-
- HSSFFormulaEvaluator fe = new HSSFFormulaEvaluator(wb);
- CellValue cv = fe.evaluate(cell);
-
- assertEquals(HSSFCell.CELL_TYPE_NUMERIC, cv.getCellType());
- assertEquals(expectedResult, cv.getNumberValue(), 0.0);
}
private static void addCell(HSSFSheet sheet, int rowIx, int colIx,
diff --git a/src/testcases/org/apache/poi/ss/formula/eval/TestMinusZeroResult.java b/src/testcases/org/apache/poi/ss/formula/eval/TestMinusZeroResult.java
index 656c47dfd6..1ee9b45a8c 100644
--- a/src/testcases/org/apache/poi/ss/formula/eval/TestMinusZeroResult.java
+++ b/src/testcases/org/apache/poi/ss/formula/eval/TestMinusZeroResult.java
@@ -40,24 +40,21 @@ import org.apache.poi.util.HexDump;
public final class TestMinusZeroResult extends TestCase {
private static final double MINUS_ZERO = -0.0;
- // convenient access to namepace
- private static final EvalInstances EI = null;
-
public void testSimpleOperators() {
// unary plus is a no-op
checkEval(MINUS_ZERO, UnaryPlusEval.instance, MINUS_ZERO);
// most simple operators convert -0.0 to +0.0
- checkEval(0.0, EI.UnaryMinus, 0.0);
- checkEval(0.0, EI.Percent, MINUS_ZERO);
- checkEval(0.0, EI.Multiply, MINUS_ZERO, 1.0);
- checkEval(0.0, EI.Divide, MINUS_ZERO, 1.0);
- checkEval(0.0, EI.Power, MINUS_ZERO, 1.0);
+ checkEval(0.0, EvalInstances.UnaryMinus, 0.0);
+ checkEval(0.0, EvalInstances.Percent, MINUS_ZERO);
+ checkEval(0.0, EvalInstances.Multiply, MINUS_ZERO, 1.0);
+ checkEval(0.0, EvalInstances.Divide, MINUS_ZERO, 1.0);
+ checkEval(0.0, EvalInstances.Power, MINUS_ZERO, 1.0);
// but SubtractEval does not convert -0.0, so '-' and '+' work like java
- checkEval(MINUS_ZERO, EI.Subtract, MINUS_ZERO, 0.0); // this is the main point of bug 47198
- checkEval(0.0, EI.Add, MINUS_ZERO, 0.0);
+ checkEval(MINUS_ZERO, EvalInstances.Subtract, MINUS_ZERO, 0.0); // this is the main point of bug 47198
+ checkEval(0.0, EvalInstances.Add, MINUS_ZERO, 0.0);
}
/**
@@ -65,9 +62,9 @@ public final class TestMinusZeroResult extends TestCase {
* gets to the comparison operator)
*/
public void testComparisonOperators() {
- checkEval(false, EI.Equal, 0.0, MINUS_ZERO);
- checkEval(true, EI.GreaterThan, 0.0, MINUS_ZERO);
- checkEval(true, EI.LessThan, MINUS_ZERO, 0.0);
+ checkEval(false, EvalInstances.Equal, 0.0, MINUS_ZERO);
+ checkEval(true, EvalInstances.GreaterThan, 0.0, MINUS_ZERO);
+ checkEval(true, EvalInstances.LessThan, MINUS_ZERO, 0.0);
}
public void testTextRendering() {
@@ -81,7 +78,7 @@ public final class TestMinusZeroResult extends TestCase {
*/
private static void confirmTextRendering(String expRendering, double d) {
ValueEval[] args = { StringEval.EMPTY_INSTANCE, new NumberEval(d), };
- StringEval se = (StringEval) EI.Concat.evaluate(args, -1, (short)-1);
+ StringEval se = (StringEval) EvalInstances.Concat.evaluate(args, -1, (short)-1);
String result = se.getStringValue();
assertEquals(expRendering, result);
}
diff --git a/src/testcases/org/apache/poi/ss/formula/functions/TestIndirect.java b/src/testcases/org/apache/poi/ss/formula/functions/TestIndirect.java
index 3a35ed942d..2c4de24749 100644
--- a/src/testcases/org/apache/poi/ss/formula/functions/TestIndirect.java
+++ b/src/testcases/org/apache/poi/ss/formula/functions/TestIndirect.java
@@ -118,31 +118,31 @@ public final class TestIndirect extends TestCase {
// simple error propagation:
// arg0 is evaluated to text first
- confirm(feA, c, "INDIRECT(#DIV/0!)", EE.DIV_ZERO);
- confirm(feA, c, "INDIRECT(#DIV/0!)", EE.DIV_ZERO);
- confirm(feA, c, "INDIRECT(#NAME?, \"x\")", EE.NAME_INVALID);
- confirm(feA, c, "INDIRECT(#NUM!, #N/A)", EE.NUM_ERROR);
+ confirm(feA, c, "INDIRECT(#DIV/0!)", ErrorEval.DIV_ZERO);
+ confirm(feA, c, "INDIRECT(#DIV/0!)", ErrorEval.DIV_ZERO);
+ confirm(feA, c, "INDIRECT(#NAME?, \"x\")", ErrorEval.NAME_INVALID);
+ confirm(feA, c, "INDIRECT(#NUM!, #N/A)", ErrorEval.NUM_ERROR);
// arg1 is evaluated to boolean before arg0 is decoded
- confirm(feA, c, "INDIRECT(\"garbage\", #N/A)", EE.NA);
- confirm(feA, c, "INDIRECT(\"garbage\", \"\")", EE.VALUE_INVALID); // empty string is not valid boolean
- confirm(feA, c, "INDIRECT(\"garbage\", \"flase\")", EE.VALUE_INVALID); // must be "TRUE" or "FALSE"
+ confirm(feA, c, "INDIRECT(\"garbage\", #N/A)", ErrorEval.NA);
+ confirm(feA, c, "INDIRECT(\"garbage\", \"\")", ErrorEval.VALUE_INVALID); // empty string is not valid boolean
+ confirm(feA, c, "INDIRECT(\"garbage\", \"flase\")", ErrorEval.VALUE_INVALID); // must be "TRUE" or "FALSE"
// spaces around sheet name (with or without quotes makes no difference)
- confirm(feA, c, "INDIRECT(\"'Sheet1 '!D3\")", EE.REF_INVALID);
- confirm(feA, c, "INDIRECT(\" Sheet1!D3\")", EE.REF_INVALID);
- confirm(feA, c, "INDIRECT(\"'Sheet1' !D3\")", EE.REF_INVALID);
+ confirm(feA, c, "INDIRECT(\"'Sheet1 '!D3\")", ErrorEval.REF_INVALID);
+ confirm(feA, c, "INDIRECT(\" Sheet1!D3\")", ErrorEval.REF_INVALID);
+ confirm(feA, c, "INDIRECT(\"'Sheet1' !D3\")", ErrorEval.REF_INVALID);
- confirm(feA, c, "SUM(INDIRECT(\"'John's sales'!A1:C1\"))", EE.REF_INVALID); // bad quote escaping
- confirm(feA, c, "INDIRECT(\"[Book1]Sheet1!A1\")", EE.REF_INVALID); // unknown external workbook
- confirm(feA, c, "INDIRECT(\"Sheet3!A1\")", EE.REF_INVALID); // unknown sheet
+ confirm(feA, c, "SUM(INDIRECT(\"'John's sales'!A1:C1\"))", ErrorEval.REF_INVALID); // bad quote escaping
+ confirm(feA, c, "INDIRECT(\"[Book1]Sheet1!A1\")", ErrorEval.REF_INVALID); // unknown external workbook
+ confirm(feA, c, "INDIRECT(\"Sheet3!A1\")", ErrorEval.REF_INVALID); // unknown sheet
if (false) { // TODO - support evaluation of defined names
- confirm(feA, c, "INDIRECT(\"Sheet1!IW1\")", EE.REF_INVALID); // bad column
- confirm(feA, c, "INDIRECT(\"Sheet1!A65537\")", EE.REF_INVALID); // bad row
+ confirm(feA, c, "INDIRECT(\"Sheet1!IW1\")", ErrorEval.REF_INVALID); // bad column
+ confirm(feA, c, "INDIRECT(\"Sheet1!A65537\")", ErrorEval.REF_INVALID); // bad row
}
- confirm(feA, c, "INDIRECT(\"Sheet1!A 1\")", EE.REF_INVALID); // space in cell ref
+ confirm(feA, c, "INDIRECT(\"Sheet1!A 1\")", ErrorEval.REF_INVALID); // space in cell ref
}
public void testMultipleWorkbooks() {
@@ -186,7 +186,7 @@ public final class TestIndirect extends TestCase {
}
int expCode = expectedResult.getErrorCode();
if (cv.getErrorValue() != expCode) {
- throw new AssertionFailedError("Expected error '" + EE.getText(expCode)
+ throw new AssertionFailedError("Expected error '" + ErrorEval.getText(expCode)
+ "' but got '" + cv.formatAsString() + "'.");
}
}
diff --git a/src/testcases/org/apache/poi/ss/formula/functions/TestRoundFuncs.java b/src/testcases/org/apache/poi/ss/formula/functions/TestRoundFuncs.java
index 10166eee0d..5d2398d2be 100644
--- a/src/testcases/org/apache/poi/ss/formula/functions/TestRoundFuncs.java
+++ b/src/testcases/org/apache/poi/ss/formula/functions/TestRoundFuncs.java
@@ -35,7 +35,7 @@ public final class TestRoundFuncs extends TestCase {
ValueEval strArg = new StringEval("abc");
ValueEval[] args = { strArg, new NumberEval(2), };
- ValueEval result = F.ROUNDDOWN.evaluate(args, -1, (short)-1);
+ ValueEval result = NumericFunction.ROUNDDOWN.evaluate(args, -1, (short)-1);
assertEquals(ErrorEval.VALUE_INVALID, result);
}
@@ -43,7 +43,7 @@ public final class TestRoundFuncs extends TestCase {
ValueEval strArg = new StringEval("abc");
ValueEval[] args = { strArg, new NumberEval(2), };
- ValueEval result = F.ROUNDUP.evaluate(args, -1, (short)-1);
+ ValueEval result = NumericFunction.ROUNDUP.evaluate(args, -1, (short)-1);
assertEquals(ErrorEval.VALUE_INVALID, result);
}
diff --git a/src/testcases/org/apache/poi/ss/formula/functions/TestTrunc.java b/src/testcases/org/apache/poi/ss/formula/functions/TestTrunc.java
index 55360b96c4..91bb8e7d7f 100644
--- a/src/testcases/org/apache/poi/ss/formula/functions/TestTrunc.java
+++ b/src/testcases/org/apache/poi/ss/formula/functions/TestTrunc.java
@@ -33,7 +33,7 @@ public final class TestTrunc extends AbstractNumericTestCase {
ValueEval strArg = new StringEval("abc");
ValueEval[] args = { strArg, new NumberEval(2) };
- ValueEval result = F.TRUNC.evaluate(args, -1, (short)-1);
+ ValueEval result = NumericFunction.TRUNC.evaluate(args, -1, (short)-1);
assertEquals(ErrorEval.VALUE_INVALID, result);
}
@@ -53,7 +53,7 @@ public final class TestTrunc extends AbstractNumericTestCase {
public void testTruncWithDecimalNumberOneArg() {
ValueEval[] args = { new NumberEval(2.612777) };
- ValueEval result = F.TRUNC.evaluate(args, -1, (short)-1);
+ ValueEval result = NumericFunction.TRUNC.evaluate(args, -1, (short)-1);
assertEquals("TRUNC", (new NumberEval(2d)).getNumberValue(), ((NumberEval)result).getNumberValue());
}
diff --git a/src/testcases/org/apache/poi/ss/usermodel/BaseTestCell.java b/src/testcases/org/apache/poi/ss/usermodel/BaseTestCell.java
index 14f70295a6..a93c330fd9 100644
--- a/src/testcases/org/apache/poi/ss/usermodel/BaseTestCell.java
+++ b/src/testcases/org/apache/poi/ss/usermodel/BaseTestCell.java
@@ -178,7 +178,7 @@ public abstract class BaseTestCell extends TestCase {
Font f = wb.createFont();
f.setFontHeightInPoints((short) 20);
f.setColor(IndexedColors.RED.getIndex());
- f.setBoldweight(f.BOLDWEIGHT_BOLD);
+ f.setBoldweight(Font.BOLDWEIGHT_BOLD);
f.setFontName("Arial Unicode MS");
cs.setFillBackgroundColor((short)3);
cs.setFont(f);
@@ -197,7 +197,7 @@ public abstract class BaseTestCell extends TestCase {
r = s.getRow(0);
c = r.getCell(0);
- assertTrue("Formula Cell at 0,0", (c.getCellType()==c.CELL_TYPE_FORMULA));
+ assertTrue("Formula Cell at 0,0", (c.getCellType()==Cell.CELL_TYPE_FORMULA));
cs = c.getCellStyle();
assertNotNull("Formula Cell Style", cs);
diff --git a/src/testcases/org/apache/poi/ss/usermodel/BaseTestDataValidation.java b/src/testcases/org/apache/poi/ss/usermodel/BaseTestDataValidation.java
index 40893c9dc6..e73befca43 100644
--- a/src/testcases/org/apache/poi/ss/usermodel/BaseTestDataValidation.java
+++ b/src/testcases/org/apache/poi/ss/usermodel/BaseTestDataValidation.java
@@ -20,6 +20,9 @@ package org.apache.poi.ss.usermodel;
import junit.framework.TestCase;
import org.apache.poi.ss.ITestDataProvider;
+import org.apache.poi.ss.usermodel.DataValidation.ErrorStyle;
+import org.apache.poi.ss.usermodel.DataValidationConstraint.OperatorType;
+import org.apache.poi.ss.usermodel.DataValidationConstraint.ValidationType;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.ss.util.CellRangeAddressList;
import org.apache.poi.util.POILogFactory;
@@ -107,29 +110,29 @@ public abstract class BaseTestDataValidation extends TestCase {
}
private DataValidationConstraint createConstraint(DataValidationHelper dataValidationHelper,int operatorType, String firstFormula,
String secondFormula, String[] explicitListValues) {
- if (_validationType == VT.LIST) {
+ if (_validationType == ValidationType.LIST) {
if (explicitListValues != null) {
return dataValidationHelper.createExplicitListConstraint(explicitListValues);
}
return dataValidationHelper.createFormulaListConstraint(firstFormula);
}
- if (_validationType == VT.TIME) {
+ if (_validationType == ValidationType.TIME) {
return dataValidationHelper.createTimeConstraint(operatorType, firstFormula, secondFormula);
}
- if (_validationType == VT.DATE) {
+ if (_validationType == ValidationType.DATE) {
return dataValidationHelper.createDateConstraint(operatorType, firstFormula, secondFormula, null);
}
- if (_validationType == VT.FORMULA) {
+ if (_validationType == ValidationType.FORMULA) {
return dataValidationHelper.createCustomConstraint(firstFormula);
}
- if( _validationType == VT.INTEGER) {
+ if( _validationType == ValidationType.INTEGER) {
return dataValidationHelper.createIntegerConstraint(operatorType, firstFormula, secondFormula);
}
- if( _validationType == VT.DECIMAL) {
+ if( _validationType == ValidationType.DECIMAL) {
return dataValidationHelper.createDecimalConstraint(operatorType, firstFormula, secondFormula);
}
- if( _validationType == VT.TEXT_LENGTH) {
+ if( _validationType == ValidationType.TEXT_LENGTH) {
return dataValidationHelper.createTextLengthConstraint(operatorType, firstFormula, secondFormula);
}
return null;
@@ -170,7 +173,7 @@ public abstract class BaseTestDataValidation extends TestCase {
boolean allowEmpty, boolean suppressDropDown) {
String promptDescr = (allowEmpty ? "empty ok" : "not empty")
+ ", " + (suppressDropDown ? "no drop-down" : "drop-down");
- addValidationInternal(VT.LIST, listFormula, null, ES.STOP, listValsDescr, promptDescr,
+ addValidationInternal(ValidationType.LIST, listFormula, null, ErrorStyle.STOP, listValsDescr, promptDescr,
allowEmpty, false, true, suppressDropDown, explicitListValues);
}
}
@@ -312,9 +315,9 @@ public abstract class BaseTestDataValidation extends TestCase {
wf.createSheet("Custom");
wf.createHeaderRow();
- ValidationAdder va = wf.createValidationAdder(null, VT.FORMULA);
- va.addValidation(OP.BETWEEN, "ISNUMBER($A2)", null, ES.STOP, "ISNUMBER(A2)", "Error box type = STOP", true, true, true);
- va.addValidation(OP.BETWEEN, "IF(SUM(A2:A3)=5,TRUE,FALSE)", null, ES.WARNING, "IF(SUM(A2:A3)=5,TRUE,FALSE)", "Error box type = WARNING", false, false, true);
+ ValidationAdder va = wf.createValidationAdder(null, ValidationType.FORMULA);
+ va.addValidation(OperatorType.BETWEEN, "ISNUMBER($A2)", null, ErrorStyle.STOP, "ISNUMBER(A2)", "Error box type = STOP", true, true, true);
+ va.addValidation(OperatorType.BETWEEN, "IF(SUM(A2:A3)=5,TRUE,FALSE)", null, ErrorStyle.WARNING, "IF(SUM(A2:A3)=5,TRUE,FALSE)", "Error box type = WARNING", false, false, true);
}
private static void addSimpleNumericValidations(WorkbookFormatter wf) {
@@ -325,29 +328,29 @@ public abstract class BaseTestDataValidation extends TestCase {
wf.createDVTypeRow("Whole number");
wf.createHeaderRow();
- ValidationAdder va = wf.createValidationAdder(null, VT.INTEGER);
- va.addValidation(OP.BETWEEN, "2", "6", ES.STOP, "Between 2 and 6 ", "Error box type = STOP", true, true, true);
- va.addValidation(OP.NOT_BETWEEN, "2", "6", ES.INFO, "Not between 2 and 6 ", "Error box type = INFO", false, true, true);
- va.addValidation(OP.EQUAL, "=3+2", null, ES.WARNING, "Equal to (3+2)", "Error box type = WARNING", false, false, true);
- va.addValidation(OP.NOT_EQUAL, "3", null, ES.WARNING, "Not equal to 3", "-", false, false, false);
- va.addValidation(OP.GREATER_THAN, "3", null, ES.WARNING, "Greater than 3", "-", true, false, false);
- va.addValidation(OP.LESS_THAN, "3", null, ES.WARNING, "Less than 3", "-", true, true, false);
- va.addValidation(OP.GREATER_OR_EQUAL, "4", null, ES.STOP, "Greater than or equal to 4", "Error box type = STOP", true, false, true);
- va.addValidation(OP.LESS_OR_EQUAL, "4", null, ES.STOP, "Less than or equal to 4", "-", false, true, false);
+ ValidationAdder va = wf.createValidationAdder(null, ValidationType.INTEGER);
+ va.addValidation(OperatorType.BETWEEN, "2", "6", ErrorStyle.STOP, "Between 2 and 6 ", "Error box type = STOP", true, true, true);
+ va.addValidation(OperatorType.NOT_BETWEEN, "2", "6", ErrorStyle.INFO, "Not between 2 and 6 ", "Error box type = INFO", false, true, true);
+ va.addValidation(OperatorType.EQUAL, "=3+2", null, ErrorStyle.WARNING, "Equal to (3+2)", "Error box type = WARNING", false, false, true);
+ va.addValidation(OperatorType.NOT_EQUAL, "3", null, ErrorStyle.WARNING, "Not equal to 3", "-", false, false, false);
+ va.addValidation(OperatorType.GREATER_THAN, "3", null, ErrorStyle.WARNING, "Greater than 3", "-", true, false, false);
+ va.addValidation(OperatorType.LESS_THAN, "3", null, ErrorStyle.WARNING, "Less than 3", "-", true, true, false);
+ va.addValidation(OperatorType.GREATER_OR_EQUAL, "4", null, ErrorStyle.STOP, "Greater than or equal to 4", "Error box type = STOP", true, false, true);
+ va.addValidation(OperatorType.LESS_OR_EQUAL, "4", null, ErrorStyle.STOP, "Less than or equal to 4", "-", false, true, false);
// "Decimal" validation type
wf.createDVTypeRow("Decimal");
wf.createHeaderRow();
- va = wf.createValidationAdder(null, VT.DECIMAL);
- va.addValidation(OP.BETWEEN, "2", "6", ES.STOP, "Between 2 and 6 ", "Error box type = STOP", true, true, true);
- va.addValidation(OP.NOT_BETWEEN, "2", "6", ES.INFO, "Not between 2 and 6 ", "Error box type = INFO", false, true, true);
- va.addValidation(OP.EQUAL, "3", null, ES.WARNING, "Equal to 3", "Error box type = WARNING", false, false, true);
- va.addValidation(OP.NOT_EQUAL, "3", null, ES.WARNING, "Not equal to 3", "-", false, false, false);
- va.addValidation(OP.GREATER_THAN, "=12/6", null, ES.WARNING, "Greater than (12/6)", "-", true, false, false);
- va.addValidation(OP.LESS_THAN, "3", null, ES.WARNING, "Less than 3", "-", true, true, false);
- va.addValidation(OP.GREATER_OR_EQUAL, "4", null, ES.STOP, "Greater than or equal to 4", "Error box type = STOP", true, false, true);
- va.addValidation(OP.LESS_OR_EQUAL, "4", null, ES.STOP, "Less than or equal to 4", "-", false, true, false);
+ va = wf.createValidationAdder(null, ValidationType.DECIMAL);
+ va.addValidation(OperatorType.BETWEEN, "2", "6", ErrorStyle.STOP, "Between 2 and 6 ", "Error box type = STOP", true, true, true);
+ va.addValidation(OperatorType.NOT_BETWEEN, "2", "6", ErrorStyle.INFO, "Not between 2 and 6 ", "Error box type = INFO", false, true, true);
+ va.addValidation(OperatorType.EQUAL, "3", null, ErrorStyle.WARNING, "Equal to 3", "Error box type = WARNING", false, false, true);
+ va.addValidation(OperatorType.NOT_EQUAL, "3", null, ErrorStyle.WARNING, "Not equal to 3", "-", false, false, false);
+ va.addValidation(OperatorType.GREATER_THAN, "=12/6", null, ErrorStyle.WARNING, "Greater than (12/6)", "-", true, false, false);
+ va.addValidation(OperatorType.LESS_THAN, "3", null, ErrorStyle.WARNING, "Less than 3", "-", true, true, false);
+ va.addValidation(OperatorType.GREATER_OR_EQUAL, "4", null, ErrorStyle.STOP, "Greater than or equal to 4", "Error box type = STOP", true, false, true);
+ va.addValidation(OperatorType.LESS_OR_EQUAL, "4", null, ErrorStyle.STOP, "Less than or equal to 4", "-", false, true, false);
}
private static void addListValidations(WorkbookFormatter wf, Workbook wb) {
@@ -366,7 +369,7 @@ public abstract class BaseTestDataValidation extends TestCase {
wf.createDVDescriptionRow("Disadvantage - sum of item's length should be less than 255 characters");
wf.createHeaderRow();
- ValidationAdder va = wf.createValidationAdder(null, VT.LIST);
+ ValidationAdder va = wf.createValidationAdder(null, ValidationType.LIST);
String listValsDescr = "POIFS,HSSF,HWPF,HPSF";
String[] listVals = listValsDescr.split(",");
va.addListValidation(listVals, null, listValsDescr, false, false);
@@ -379,7 +382,7 @@ public abstract class BaseTestDataValidation extends TestCase {
wf.createDVTypeRow("Reference lists - list items are taken from others cells");
wf.createDVDescriptionRow("Advantage - no restriction regarding the sum of item's length");
wf.createHeaderRow();
- va = wf.createValidationAdder(null, VT.LIST);
+ va = wf.createValidationAdder(null, ValidationType.LIST);
String strFormula = "$A$30:$A$39";
va.addListValidation(null, strFormula, strFormula, false, false);
@@ -422,44 +425,44 @@ public abstract class BaseTestDataValidation extends TestCase {
wf.createDVTypeRow("Date ( cells are already formated as date - m/d/yyyy)");
wf.createHeaderRow();
- ValidationAdder va = wf.createValidationAdder(cellStyle_date, VT.DATE);
- va.addValidation(OP.BETWEEN, "2004/01/02", "2004/01/06", ES.STOP, "Between 1/2/2004 and 1/6/2004 ", "Error box type = STOP", true, true, true);
- va.addValidation(OP.NOT_BETWEEN, "2004/01/01", "2004/01/06", ES.INFO, "Not between 1/2/2004 and 1/6/2004 ", "Error box type = INFO", false, true, true);
- va.addValidation(OP.EQUAL, "2004/03/02", null, ES.WARNING, "Equal to 3/2/2004", "Error box type = WARNING", false, false, true);
- va.addValidation(OP.NOT_EQUAL, "2004/03/02", null, ES.WARNING, "Not equal to 3/2/2004", "-", false, false, false);
- va.addValidation(OP.GREATER_THAN,"=DATEVALUE(\"4-Jul-2001\")", null, ES.WARNING, "Greater than DATEVALUE('4-Jul-2001')", "-", true, false, false);
- va.addValidation(OP.LESS_THAN, "2004/03/02", null, ES.WARNING, "Less than 3/2/2004", "-", true, true, false);
- va.addValidation(OP.GREATER_OR_EQUAL, "2004/03/02", null, ES.STOP, "Greater than or equal to 3/2/2004", "Error box type = STOP", true, false, true);
- va.addValidation(OP.LESS_OR_EQUAL, "2004/03/04", null, ES.STOP, "Less than or equal to 3/4/2004", "-", false, true, false);
+ ValidationAdder va = wf.createValidationAdder(cellStyle_date, ValidationType.DATE);
+ va.addValidation(OperatorType.BETWEEN, "2004/01/02", "2004/01/06", ErrorStyle.STOP, "Between 1/2/2004 and 1/6/2004 ", "Error box type = STOP", true, true, true);
+ va.addValidation(OperatorType.NOT_BETWEEN, "2004/01/01", "2004/01/06", ErrorStyle.INFO, "Not between 1/2/2004 and 1/6/2004 ", "Error box type = INFO", false, true, true);
+ va.addValidation(OperatorType.EQUAL, "2004/03/02", null, ErrorStyle.WARNING, "Equal to 3/2/2004", "Error box type = WARNING", false, false, true);
+ va.addValidation(OperatorType.NOT_EQUAL, "2004/03/02", null, ErrorStyle.WARNING, "Not equal to 3/2/2004", "-", false, false, false);
+ va.addValidation(OperatorType.GREATER_THAN,"=DATEVALUE(\"4-Jul-2001\")", null, ErrorStyle.WARNING, "Greater than DATEVALUE('4-Jul-2001')", "-", true, false, false);
+ va.addValidation(OperatorType.LESS_THAN, "2004/03/02", null, ErrorStyle.WARNING, "Less than 3/2/2004", "-", true, true, false);
+ va.addValidation(OperatorType.GREATER_OR_EQUAL, "2004/03/02", null, ErrorStyle.STOP, "Greater than or equal to 3/2/2004", "Error box type = STOP", true, false, true);
+ va.addValidation(OperatorType.LESS_OR_EQUAL, "2004/03/04", null, ErrorStyle.STOP, "Less than or equal to 3/4/2004", "-", false, true, false);
// "Time" validation type
wf.createDVTypeRow("Time ( cells are already formated as time - h:mm)");
wf.createHeaderRow();
- va = wf.createValidationAdder(cellStyle_time, VT.TIME);
- va.addValidation(OP.BETWEEN, "12:00", "16:00", ES.STOP, "Between 12:00 and 16:00 ", "Error box type = STOP", true, true, true);
- va.addValidation(OP.NOT_BETWEEN, "12:00", "16:00", ES.INFO, "Not between 12:00 and 16:00 ", "Error box type = INFO", false, true, true);
- va.addValidation(OP.EQUAL, "13:35", null, ES.WARNING, "Equal to 13:35", "Error box type = WARNING", false, false, true);
- va.addValidation(OP.NOT_EQUAL, "13:35", null, ES.WARNING, "Not equal to 13:35", "-", false, false, false);
- va.addValidation(OP.GREATER_THAN,"12:00", null, ES.WARNING, "Greater than 12:00", "-", true, false, false);
- va.addValidation(OP.LESS_THAN, "=1/2", null, ES.WARNING, "Less than (1/2) -> 12:00", "-", true, true, false);
- va.addValidation(OP.GREATER_OR_EQUAL, "14:00", null, ES.STOP, "Greater than or equal to 14:00", "Error box type = STOP", true, false, true);
- va.addValidation(OP.LESS_OR_EQUAL,"14:00", null, ES.STOP, "Less than or equal to 14:00", "-", false, true, false);
+ va = wf.createValidationAdder(cellStyle_time, ValidationType.TIME);
+ va.addValidation(OperatorType.BETWEEN, "12:00", "16:00", ErrorStyle.STOP, "Between 12:00 and 16:00 ", "Error box type = STOP", true, true, true);
+ va.addValidation(OperatorType.NOT_BETWEEN, "12:00", "16:00", ErrorStyle.INFO, "Not between 12:00 and 16:00 ", "Error box type = INFO", false, true, true);
+ va.addValidation(OperatorType.EQUAL, "13:35", null, ErrorStyle.WARNING, "Equal to 13:35", "Error box type = WARNING", false, false, true);
+ va.addValidation(OperatorType.NOT_EQUAL, "13:35", null, ErrorStyle.WARNING, "Not equal to 13:35", "-", false, false, false);
+ va.addValidation(OperatorType.GREATER_THAN,"12:00", null, ErrorStyle.WARNING, "Greater than 12:00", "-", true, false, false);
+ va.addValidation(OperatorType.LESS_THAN, "=1/2", null, ErrorStyle.WARNING, "Less than (1/2) -> 12:00", "-", true, true, false);
+ va.addValidation(OperatorType.GREATER_OR_EQUAL, "14:00", null, ErrorStyle.STOP, "Greater than or equal to 14:00", "Error box type = STOP", true, false, true);
+ va.addValidation(OperatorType.LESS_OR_EQUAL,"14:00", null, ErrorStyle.STOP, "Less than or equal to 14:00", "-", false, true, false);
}
private static void addTextLengthValidations(WorkbookFormatter wf) {
wf.createSheet("Text lengths");
wf.createHeaderRow();
- ValidationAdder va = wf.createValidationAdder(null, VT.TEXT_LENGTH);
- va.addValidation(OP.BETWEEN, "2", "6", ES.STOP, "Between 2 and 6 ", "Error box type = STOP", true, true, true);
- va.addValidation(OP.NOT_BETWEEN, "2", "6", ES.INFO, "Not between 2 and 6 ", "Error box type = INFO", false, true, true);
- va.addValidation(OP.EQUAL, "3", null, ES.WARNING, "Equal to 3", "Error box type = WARNING", false, false, true);
- va.addValidation(OP.NOT_EQUAL, "3", null, ES.WARNING, "Not equal to 3", "-", false, false, false);
- va.addValidation(OP.GREATER_THAN, "3", null, ES.WARNING, "Greater than 3", "-", true, false, false);
- va.addValidation(OP.LESS_THAN, "3", null, ES.WARNING, "Less than 3", "-", true, true, false);
- va.addValidation(OP.GREATER_OR_EQUAL, "4", null, ES.STOP, "Greater than or equal to 4", "Error box type = STOP", true, false, true);
- va.addValidation(OP.LESS_OR_EQUAL, "4", null, ES.STOP, "Less than or equal to 4", "-", false, true, false);
+ ValidationAdder va = wf.createValidationAdder(null, ValidationType.TEXT_LENGTH);
+ va.addValidation(OperatorType.BETWEEN, "2", "6", ErrorStyle.STOP, "Between 2 and 6 ", "Error box type = STOP", true, true, true);
+ va.addValidation(OperatorType.NOT_BETWEEN, "2", "6", ErrorStyle.INFO, "Not between 2 and 6 ", "Error box type = INFO", false, true, true);
+ va.addValidation(OperatorType.EQUAL, "3", null, ErrorStyle.WARNING, "Equal to 3", "Error box type = WARNING", false, false, true);
+ va.addValidation(OperatorType.NOT_EQUAL, "3", null, ErrorStyle.WARNING, "Not equal to 3", "-", false, false, false);
+ va.addValidation(OperatorType.GREATER_THAN, "3", null, ErrorStyle.WARNING, "Greater than 3", "-", true, false, false);
+ va.addValidation(OperatorType.LESS_THAN, "3", null, ErrorStyle.WARNING, "Less than 3", "-", true, true, false);
+ va.addValidation(OperatorType.GREATER_OR_EQUAL, "4", null, ErrorStyle.STOP, "Greater than or equal to 4", "Error box type = STOP", true, false, true);
+ va.addValidation(OperatorType.LESS_OR_EQUAL, "4", null, ErrorStyle.STOP, "Less than or equal to 4", "-", false, true, false);
}
public void testDataValidation() {
diff --git a/src/testcases/org/apache/poi/util/DummyPOILogger.java b/src/testcases/org/apache/poi/util/DummyPOILogger.java
index f72e37b512..976c7d918e 100644
--- a/src/testcases/org/apache/poi/util/DummyPOILogger.java
+++ b/src/testcases/org/apache/poi/util/DummyPOILogger.java
@@ -24,10 +24,10 @@ import java.util.List;
* tests can see what got logged
*/
public class DummyPOILogger extends POILogger {
- public List logged = new ArrayList();
+ public List<String>logged = new ArrayList<String>();
public void reset() {
- logged = new ArrayList();
+ logged = new ArrayList<String>();
}
public boolean check(int level) {