diff options
author | Vladislav Galas <gallon@apache.org> | 2019-01-03 00:08:52 +0000 |
---|---|---|
committer | Vladislav Galas <gallon@apache.org> | 2019-01-03 00:08:52 +0000 |
commit | 3b8055baa0a26e48c8e5cfecbe6120a147da7777 (patch) | |
tree | 06a411b49323e6dc1f5fa774ac5d25d199fa88fd /src/testcases | |
parent | e501d4015df167e69688635df8092f993d5a9094 (diff) | |
download | poi-3b8055baa0a26e48c8e5cfecbe6120a147da7777.tar.gz poi-3b8055baa0a26e48c8e5cfecbe6120a147da7777.zip |
Bug 62993: XSSFEvaluationSheet now retrieves valid last row index from underlying XSSFSheet. Thanks to Axel Howind.
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1850212 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/testcases')
-rw-r--r-- | src/testcases/org/apache/poi/hssf/usermodel/TestHSSFEvaluationSheet.java | 33 | ||||
-rw-r--r-- | src/testcases/org/apache/poi/ss/usermodel/BaseTestXEvaluationSheet.java | 49 |
2 files changed, 82 insertions, 0 deletions
diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFEvaluationSheet.java b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFEvaluationSheet.java new file mode 100644 index 0000000000..81700ae56a --- /dev/null +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFEvaluationSheet.java @@ -0,0 +1,33 @@ +/* ==================================================================== + 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.hssf.usermodel; + +import org.apache.poi.ss.formula.EvaluationSheet; +import org.apache.poi.ss.usermodel.BaseTestXEvaluationSheet; +import org.apache.poi.ss.usermodel.Sheet; + +import java.util.AbstractMap; +import java.util.Map; + +public class TestHSSFEvaluationSheet extends BaseTestXEvaluationSheet { + @Override + protected Map.Entry<Sheet, EvaluationSheet> getInstance() { + HSSFSheet sheet = new HSSFWorkbook().createSheet(); + return new AbstractMap.SimpleEntry<>(sheet, new HSSFEvaluationSheet(sheet)); + } +} diff --git a/src/testcases/org/apache/poi/ss/usermodel/BaseTestXEvaluationSheet.java b/src/testcases/org/apache/poi/ss/usermodel/BaseTestXEvaluationSheet.java new file mode 100644 index 0000000000..cd60b3f6ff --- /dev/null +++ b/src/testcases/org/apache/poi/ss/usermodel/BaseTestXEvaluationSheet.java @@ -0,0 +1,49 @@ +/* ==================================================================== + 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.ss.usermodel; + +import org.apache.poi.ss.formula.EvaluationSheet; +import org.junit.Test; + +import java.util.Map; + +import static org.junit.Assert.assertEquals; + +public abstract class BaseTestXEvaluationSheet { + /** + * Get a pair of underlying sheet and evaluation sheet. + */ + protected abstract Map.Entry<Sheet, EvaluationSheet> getInstance(); + + @Test + public void lastRowNumIsUpdatedFromUnderlyingSheet_bug62993() { + Map.Entry<Sheet, EvaluationSheet> sheetPair = getInstance(); + Sheet underlyingSheet = sheetPair.getKey(); + EvaluationSheet instance = sheetPair.getValue(); + + assertEquals(0, instance.getLastRowNum()); + + underlyingSheet.createRow(0); + underlyingSheet.createRow(1); + underlyingSheet.createRow(2); + assertEquals(2, instance.getLastRowNum()); + + underlyingSheet.removeRow(underlyingSheet.getRow(2)); + assertEquals(1, instance.getLastRowNum()); + } +} |