Lines 23-28
import static org.junit.Assert.assertNotNull;
Link Here
|
23 |
import static org.junit.Assert.assertNull; |
23 |
import static org.junit.Assert.assertNull; |
24 |
import static org.junit.Assert.assertSame; |
24 |
import static org.junit.Assert.assertSame; |
25 |
import static org.junit.Assert.assertTrue; |
25 |
import static org.junit.Assert.assertTrue; |
|
|
26 |
import static org.junit.Assert.assertFalse; |
26 |
|
27 |
|
27 |
import java.io.IOException; |
28 |
import java.io.IOException; |
28 |
import java.util.List; |
29 |
import java.util.List; |
Lines 30-35
import java.util.List;
Link Here
|
30 |
import org.apache.poi.common.usermodel.HyperlinkType; |
31 |
import org.apache.poi.common.usermodel.HyperlinkType; |
31 |
import org.apache.poi.hssf.HSSFITestDataProvider; |
32 |
import org.apache.poi.hssf.HSSFITestDataProvider; |
32 |
import org.apache.poi.ss.SpreadsheetVersion; |
33 |
import org.apache.poi.ss.SpreadsheetVersion; |
|
|
34 |
import org.apache.poi.ss.formula.FormulaParseException; |
33 |
import org.apache.poi.ss.usermodel.BaseTestXCell; |
35 |
import org.apache.poi.ss.usermodel.BaseTestXCell; |
34 |
import org.apache.poi.ss.usermodel.BorderStyle; |
36 |
import org.apache.poi.ss.usermodel.BorderStyle; |
35 |
import org.apache.poi.ss.usermodel.Cell; |
37 |
import org.apache.poi.ss.usermodel.Cell; |
Lines 179-184
public final class TestXSSFCell extends BaseTestXCell {
Link Here
|
179 |
assertEquals(CellType.BLANK, cell.getCellTypeEnum()); |
181 |
assertEquals(CellType.BLANK, cell.getCellTypeEnum()); |
180 |
assertEquals(STCellType.N, ctCell.getT()); |
182 |
assertEquals(STCellType.N, ctCell.getT()); |
181 |
assertEquals("", cell.getStringCellValue()); |
183 |
assertEquals("", cell.getStringCellValue()); |
|
|
184 |
|
185 |
// check behavior with setCellFormulaValidation |
186 |
final String invalidFormula = "A", validFormula = "A2"; |
187 |
FormulaParseException fpe = null; |
188 |
// check that default is true |
189 |
assertTrue(wb.getCellFormulaValidation()); |
190 |
|
191 |
// check that valid formula does not throw exception |
192 |
try { |
193 |
cell.setCellFormula(validFormula); |
194 |
} catch(FormulaParseException e) { |
195 |
fpe = e; |
196 |
} |
197 |
assertNull(fpe); |
198 |
|
199 |
// check that invalid formula does throw exception |
200 |
try { |
201 |
cell.setCellFormula(invalidFormula); |
202 |
} catch(FormulaParseException e) { |
203 |
fpe = e; |
204 |
} |
205 |
assertNotNull(fpe); |
206 |
fpe = null; |
207 |
|
208 |
// set cell formula validation to false |
209 |
wb.setCellFormulaValidation(false); |
210 |
assertFalse(wb.getCellFormulaValidation()); |
211 |
|
212 |
// check that neither valid nor invalid formula throw an exception |
213 |
try { |
214 |
cell.setCellFormula(validFormula); |
215 |
cell.setCellFormula(invalidFormula); |
216 |
} catch(FormulaParseException e) { |
217 |
fpe = e; |
218 |
} |
219 |
assertNull(fpe); |
182 |
} finally { |
220 |
} finally { |
183 |
wb.close(); |
221 |
wb.close(); |
184 |
} |
222 |
} |
185 |
- |
|
|