From 70365497bbe77945907c3e4aacb72964a77c8ef0 Mon Sep 17 00:00:00 2001 From: Nick Burch Date: Tue, 4 Nov 2014 16:20:05 +0000 Subject: [PATCH] Add unit test for bug #57176 git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1636634 13f79535-47bb-0310-9956-ffa450edef68 --- .../poi/xssf/usermodel/TestXSSFBugs.java | 47 +++++++++++++++++- test-data/spreadsheet/57176.xlsx | Bin 0 -> 8157 bytes 2 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 test-data/spreadsheet/57176.xlsx diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java index 658d03e501..d7f4af1e86 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java @@ -18,7 +18,13 @@ package org.apache.poi.xssf.usermodel; import static org.hamcrest.core.IsEqual.equalTo; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; @@ -46,7 +52,26 @@ import org.apache.poi.ss.formula.eval.ErrorEval; import org.apache.poi.ss.formula.eval.NumberEval; import org.apache.poi.ss.formula.eval.ValueEval; import org.apache.poi.ss.formula.functions.Function; -import org.apache.poi.ss.usermodel.*; +import org.apache.poi.ss.usermodel.BaseTestBugzillaIssues; +import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.CellStyle; +import org.apache.poi.ss.usermodel.CellValue; +import org.apache.poi.ss.usermodel.ClientAnchor; +import org.apache.poi.ss.usermodel.Comment; +import org.apache.poi.ss.usermodel.CreationHelper; +import org.apache.poi.ss.usermodel.DataFormatter; +import org.apache.poi.ss.usermodel.DateUtil; +import org.apache.poi.ss.usermodel.Drawing; +import org.apache.poi.ss.usermodel.Font; +import org.apache.poi.ss.usermodel.FormulaError; +import org.apache.poi.ss.usermodel.FormulaEvaluator; +import org.apache.poi.ss.usermodel.Hyperlink; +import org.apache.poi.ss.usermodel.IndexedColors; +import org.apache.poi.ss.usermodel.Name; +import org.apache.poi.ss.usermodel.Row; +import org.apache.poi.ss.usermodel.Sheet; +import org.apache.poi.ss.usermodel.Workbook; +import org.apache.poi.ss.usermodel.WorkbookFactory; import org.apache.poi.ss.util.AreaReference; import org.apache.poi.ss.util.CellRangeAddress; import org.apache.poi.ss.util.CellReference; @@ -60,6 +85,8 @@ import org.apache.poi.xssf.usermodel.extensions.XSSFCellFill; import org.junit.Ignore; import org.junit.Test; import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCols; +import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTDefinedName; +import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTDefinedNames; import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorksheet; import org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.CTFontImpl; @@ -1860,6 +1887,22 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues { assertEquals(3, wb.getNumberOfSheets()); } + /** + * CTDefinedNamesImpl should be included in the smaller + * poi-ooxml-schemas jar + */ + @Test + public void bug57176() throws Exception { + XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("57176.xlsx"); + CTDefinedNames definedNames = wb.getCTWorkbook().getDefinedNames(); + List definedNameList = definedNames.getDefinedNameList(); + for (CTDefinedName defName : definedNameList) { + assertNotNull(defName.getName()); + assertNotNull(defName.getStringValue()); + } + assertEquals("TestDefinedName", definedNameList.get(0).getName()); + } + /** * .xlsb files are not supported, but we should generate a helpful * error message if given one diff --git a/test-data/spreadsheet/57176.xlsx b/test-data/spreadsheet/57176.xlsx new file mode 100644 index 0000000000000000000000000000000000000000..c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