aboutsummaryrefslogtreecommitdiffstats
path: root/src/testcases/org/apache
diff options
context:
space:
mode:
authorPJ Fanning <fanningpj@apache.org>2020-06-27 09:33:06 +0000
committerPJ Fanning <fanningpj@apache.org>2020-06-27 09:33:06 +0000
commit38e58f1ead7ff22c7095d1f9f0c71196739467cd (patch)
tree8608618c0e4e29980336a920a05336f469ae5a59 /src/testcases/org/apache
parentf99533c56e8b5926f2a448d075365c8b9716ea6a (diff)
downloadpoi-38e58f1ead7ff22c7095d1f9f0c71196739467cd.tar.gz
poi-38e58f1ead7ff22c7095d1f9f0c71196739467cd.zip
remove some deprecated Name methods from Workbook
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1879255 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/testcases/org/apache')
-rw-r--r--src/testcases/org/apache/poi/hssf/usermodel/TestHSSFName.java48
-rw-r--r--src/testcases/org/apache/poi/ss/usermodel/BaseTestNamedRange.java31
2 files changed, 51 insertions, 28 deletions
diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFName.java b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFName.java
index fde3908f9e..5290e17ec4 100644
--- a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFName.java
+++ b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFName.java
@@ -25,6 +25,8 @@ import org.apache.poi.hssf.record.NameRecord;
import org.apache.poi.ss.formula.FormulaType;
import org.apache.poi.ss.formula.ptg.Ptg;
import org.apache.poi.ss.usermodel.BaseTestNamedRange;
+import org.apache.poi.ss.usermodel.Name;
+import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.util.CellRangeAddress;
import org.junit.Test;
@@ -50,7 +52,7 @@ public final class TestHSSFName extends BaseTestNamedRange {
}
@Test
- public void testRepeatingRowsAndColumsNames() throws Exception {
+ public void testRepeatingRowsAndColumnsNames() throws Exception {
// First test that setting RR&C for same sheet more than once only creates a
// single Print_Titles built-in record
HSSFWorkbook wb = new HSSFWorkbook();
@@ -240,4 +242,48 @@ public final class TestHSSFName extends BaseTestNamedRange {
}
wb.close();
}
+
+ @Test
+ public final void testUnicodeNamedRange() throws Exception {
+ HSSFWorkbook wb1 = new HSSFWorkbook();
+ wb1.createSheet("Test");
+ Name name = wb1.createName();
+ name.setNameName("\u03B1");
+ name.setRefersToFormula("Test!$D$3:$E$8");
+
+
+ HSSFWorkbook wb2 = HSSFITestDataProvider.instance.writeOutAndReadBack(wb1);
+ Name name2 = wb2.getNameAt(0);
+
+ assertEquals("\u03B1", name2.getNameName());
+ assertEquals("Test!$D$3:$E$8", name2.getRefersToFormula());
+
+ wb2.close();
+ wb1.close();
+ }
+
+ @Test
+ public final void testHSSFAddRemove() throws Exception {
+ HSSFWorkbook wb = HSSFITestDataProvider.instance.createWorkbook();
+ assertEquals(0, wb.getNumberOfNames());
+ Name name1 = wb.createName();
+ name1.setNameName("name1");
+ assertEquals(1, wb.getNumberOfNames());
+
+ Name name2 = wb.createName();
+ name2.setNameName("name2");
+ assertEquals(2, wb.getNumberOfNames());
+
+ Name name3 = wb.createName();
+ name3.setNameName("name3");
+ assertEquals(3, wb.getNumberOfNames());
+
+ wb.removeName(wb.getName("name2"));
+ assertEquals(2, wb.getNumberOfNames());
+
+ wb.removeName(0);
+ assertEquals(1, wb.getNumberOfNames());
+
+ wb.close();
+ }
}
diff --git a/src/testcases/org/apache/poi/ss/usermodel/BaseTestNamedRange.java b/src/testcases/org/apache/poi/ss/usermodel/BaseTestNamedRange.java
index a656ef38c1..db090b1782 100644
--- a/src/testcases/org/apache/poi/ss/usermodel/BaseTestNamedRange.java
+++ b/src/testcases/org/apache/poi/ss/usermodel/BaseTestNamedRange.java
@@ -117,25 +117,6 @@ public abstract class BaseTestNamedRange {
}
@Test
- public final void testUnicodeNamedRange() throws Exception {
- Workbook wb1 = _testDataProvider.createWorkbook();
- wb1.createSheet("Test");
- Name name = wb1.createName();
- name.setNameName("\u03B1");
- name.setRefersToFormula("Test!$D$3:$E$8");
-
-
- Workbook wb2 = _testDataProvider.writeOutAndReadBack(wb1);
- Name name2 = wb2.getNameAt(0);
-
- assertEquals("\u03B1", name2.getNameName());
- assertEquals("Test!$D$3:$E$8", name2.getRefersToFormula());
-
- wb2.close();
- wb1.close();
- }
-
- @Test
public final void testAddRemove() throws Exception {
Workbook wb = _testDataProvider.createWorkbook();
assertEquals(0, wb.getNumberOfNames());
@@ -151,12 +132,9 @@ public abstract class BaseTestNamedRange {
name3.setNameName("name3");
assertEquals(3, wb.getNumberOfNames());
- wb.removeName("name2");
+ wb.removeName(wb.getName("name2"));
assertEquals(2, wb.getNumberOfNames());
- wb.removeName(0);
- assertEquals(1, wb.getNumberOfNames());
-
wb.close();
}
@@ -460,10 +438,8 @@ public abstract class BaseTestNamedRange {
newNamedRange2.setNameName("AnotherTest");
newNamedRange2.setRefersToFormula(sheetName + "!$F$1:$G$6");
- wb1.getNameAt(0);
-
Workbook wb2 = _testDataProvider.writeOutAndReadBack(wb1);
- Name nm =wb2.getName("RangeTest");
+ Name nm = wb2.getName("RangeTest");
assertEquals("Name is " + nm.getNameName(), "RangeTest", nm.getNameName());
assertEquals("Reference is " + nm.getRefersToFormula(), (wb2.getSheetName(0) + "!$D$4:$E$8"), nm.getRefersToFormula());
@@ -474,6 +450,7 @@ public abstract class BaseTestNamedRange {
wb2.close();
wb1.close();
}
+
/**
* Verifies correct functioning for "single cell named range" (aka "named cell")
*/
@@ -666,7 +643,7 @@ public abstract class BaseTestNamedRange {
assertEquals("2", names.get(1).getRefersToFormula());
assertEquals("1", wb.getName("x").getRefersToFormula());
- wb.removeName("x");
+ wb.removeName(wb.getName("x"));
assertEquals("2", wb.getName("x").getRefersToFormula());
wb.close();