From 92134f34b1806867912bdd122f04099db145a4f6 Mon Sep 17 00:00:00 2001 From: PJ Fanning Date: Mon, 15 Feb 2021 00:34:12 +0000 Subject: add test for reading core properties from ooxml strict file git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1886514 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/poi/ooxml/TestPOIXMLProperties.java | 13 +++++++++++++ .../org/apache/poi/xssf/eventusermodel/TestXSSFReader.java | 1 - 2 files changed, 13 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/ooxml/testcases/org/apache/poi/ooxml/TestPOIXMLProperties.java b/src/ooxml/testcases/org/apache/poi/ooxml/TestPOIXMLProperties.java index d338faebc9..57306d1637 100644 --- a/src/ooxml/testcases/org/apache/poi/ooxml/TestPOIXMLProperties.java +++ b/src/ooxml/testcases/org/apache/poi/ooxml/TestPOIXMLProperties.java @@ -26,11 +26,14 @@ import static org.junit.jupiter.api.Assertions.assertTrue; import java.io.ByteArrayInputStream; import java.io.IOException; +import java.time.ZoneId; import java.util.Calendar; import java.util.Date; import java.util.Optional; +import org.apache.poi.POIDataSamples; import org.apache.poi.ooxml.POIXMLProperties.CoreProperties; +import org.apache.poi.openxml4j.opc.OPCPackage; import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.Row; import org.apache.poi.ss.usermodel.Sheet; @@ -319,6 +322,16 @@ public final class TestPOIXMLProperties { } } + @Test + void testOoxmlStrict() throws Exception { + POIDataSamples _ssTests = POIDataSamples.getSpreadSheetInstance(); + try (OPCPackage pkg = OPCPackage.open(_ssTests.openResourceAsStream("sample.strict.xlsx"))) { + POIXMLProperties props = new POIXMLProperties(pkg); + assertNotNull(props.getCoreProperties().getCreated()); + assertEquals(2007, props.getCoreProperties().getCreated().toInstant().atZone(ZoneId.of("UTC")).getYear()); + } + } + @Test void testBug60977() throws IOException { diff --git a/src/ooxml/testcases/org/apache/poi/xssf/eventusermodel/TestXSSFReader.java b/src/ooxml/testcases/org/apache/poi/xssf/eventusermodel/TestXSSFReader.java index 697af659c7..766ebeb0ef 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/eventusermodel/TestXSSFReader.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/eventusermodel/TestXSSFReader.java @@ -25,7 +25,6 @@ import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; -import static org.junit.jupiter.api.Assertions.fail; import java.io.IOException; import java.io.InputStream; -- cgit v1.2.3