]> source.dussan.org Git - poi.git/commitdiff
add test for reading core properties from ooxml strict file
authorPJ Fanning <fanningpj@apache.org>
Mon, 15 Feb 2021 00:34:12 +0000 (00:34 +0000)
committerPJ Fanning <fanningpj@apache.org>
Mon, 15 Feb 2021 00:34:12 +0000 (00:34 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1886514 13f79535-47bb-0310-9956-ffa450edef68

src/ooxml/testcases/org/apache/poi/ooxml/TestPOIXMLProperties.java
src/ooxml/testcases/org/apache/poi/xssf/eventusermodel/TestXSSFReader.java

index d338faebc9670139c3a78ab11b9b42ad66c46fc6..57306d16373e0be9799d7ed8d4485141455b5ffd 100644 (file)
@@ -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 {
 
index 697af659c7388c98a5642c83f17899b217ec2a1e..766ebeb0ef31d71f88ff8731c06973f215a55f62 100644 (file)
@@ -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;