]> source.dussan.org Git - poi.git/commitdiff
Add unit test to show that the behaviour in bug #48923 is as expected
authorNick Burch <nick@apache.org>
Wed, 26 May 2010 14:51:49 +0000 (14:51 +0000)
committerNick Burch <nick@apache.org>
Wed, 26 May 2010 14:51:49 +0000 (14:51 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@948462 13f79535-47bb-0310-9956-ffa450edef68

src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java
test-data/spreadsheet/48923.xlsx [new file with mode: 0644]

index f521cb53ba0556ba85b63011f36ccc39cb901619..ea2c8fd59fbc0742832f502e78262eceb5befc3f 100644 (file)
@@ -24,6 +24,7 @@ import org.apache.poi.openxml4j.opc.OPCPackage;
 import org.apache.poi.openxml4j.opc.PackagePart;
 import org.apache.poi.openxml4j.opc.PackagingURIHelper;
 import org.apache.poi.ss.usermodel.BaseTestBugzillaIssues;
+import org.apache.poi.ss.usermodel.Name;
 import org.apache.poi.xssf.XSSFITestDataProvider;
 import org.apache.poi.xssf.XSSFTestDataSamples;
 import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorksheet;
@@ -158,4 +159,38 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
         CTWorksheet sh = wb.getSheetAt(0).getCTWorksheet();
         assertNotNull(sh.getPhoneticPr());
     }
+    
+    /**
+     * Names which are defined with a Sheet
+     *  should return that sheet index properly 
+     */
+    public void test48923() throws Exception {
+       XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("48923.xlsx");
+       assertEquals(4, wb.getNumberOfNames());
+       
+       Name b1 = wb.getName("NameB1");
+       Name b2 = wb.getName("NameB2");
+       Name sheet2 = wb.getName("NameSheet2");
+       Name test = wb.getName("Test");
+       
+       assertNotNull(b1);
+       assertEquals("NameB1", b1.getNameName());
+       assertEquals("Sheet1", b1.getSheetName());
+       assertEquals(-1, b1.getSheetIndex());
+       
+       assertNotNull(b2);
+       assertEquals("NameB2", b2.getNameName());
+       assertEquals("Sheet1", b2.getSheetName());
+       assertEquals(-1, b2.getSheetIndex());
+       
+       assertNotNull(sheet2);
+       assertEquals("NameSheet2", sheet2.getNameName());
+       assertEquals("Sheet2", sheet2.getSheetName());
+       assertEquals(-1, sheet2.getSheetIndex());
+       
+       assertNotNull(test);
+       assertEquals("Test", test.getNameName());
+       assertEquals("Sheet1", test.getSheetName());
+       assertEquals(-1, test.getSheetIndex());
+    }
 }
diff --git a/test-data/spreadsheet/48923.xlsx b/test-data/spreadsheet/48923.xlsx
new file mode 100644 (file)
index 0000000..34aba59
Binary files /dev/null and b/test-data/spreadsheet/48923.xlsx differ