From c5dbecedab984c4110dfd75b474c511cedd32a8d Mon Sep 17 00:00:00 2001 From: Dominik Stadler Date: Wed, 5 Oct 2016 20:13:38 +0000 Subject: [PATCH] Bug 59958: Add simple test-case git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1763487 13f79535-47bb-0310-9956-ffa450edef68 --- .../xssf/usermodel/XSSFEvaluationSheet.java | 2 +- .../usermodel/TestXSSFEvaluationSheet.java | 55 +++++++++++++++++++ 2 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFEvaluationSheet.java diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFEvaluationSheet.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFEvaluationSheet.java index 7d9d0286f3..fb042afaf4 100644 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFEvaluationSheet.java +++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFEvaluationSheet.java @@ -87,7 +87,7 @@ final class XSSFEvaluationSheet implements EvaluationSheet { evalcell = new XSSFEvaluationCell(cell, this); _cellCache.put(key, evalcell); } - + return evalcell; } diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFEvaluationSheet.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFEvaluationSheet.java new file mode 100644 index 0000000000..1b1417fbb3 --- /dev/null +++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFEvaluationSheet.java @@ -0,0 +1,55 @@ +/* ==================================================================== + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +==================================================================== */ +package org.apache.poi.xssf.usermodel; + +import org.junit.Test; + +import static org.junit.Assert.*; + +public class TestXSSFEvaluationSheet { + + @Test + public void test() throws Exception { + XSSFWorkbook wb = new XSSFWorkbook(); + XSSFSheet sheet = wb.createSheet("test"); + XSSFRow row = sheet.createRow(0); + row.createCell(0); + XSSFEvaluationSheet evalsheet = new XSSFEvaluationSheet(sheet); + + assertNotNull("Cell 0,0 is found", evalsheet.getCell(0, 0)); + assertNull("Cell 0,1 is not found", evalsheet.getCell(0, 1)); + assertNull("Cell 1,0 is not found", evalsheet.getCell(1, 0)); + + // now add Cell 0,1 + row.createCell(1); + + assertNotNull("Cell 0,0 is found", evalsheet.getCell(0, 0)); + assertNotNull("Cell 0,1 is now also found", evalsheet.getCell(0, 1)); + assertNull("Cell 1,0 is not found", evalsheet.getCell(1, 0)); + + // after clearing all values it also works + row.createCell(2); + evalsheet.clearAllCachedResultValues(); + + assertNotNull("Cell 0,0 is found", evalsheet.getCell(0, 0)); + assertNotNull("Cell 0,2 is now also found", evalsheet.getCell(0, 2)); + assertNull("Cell 1,0 is not found", evalsheet.getCell(1, 0)); + + // other things + assertEquals(sheet, evalsheet.getXSSFSheet()); + } +} \ No newline at end of file -- 2.39.5