Author: fanningpj
Date: Mon Dec 13 17:48:47 2021
New Revision: 1895911
URL: http://svn.apache.org/viewvc?rev=1895911&view=rev
Log:
add some tests
Modified:
poi/trunk/poi-ooxml/src/test/java/org/apache/poi/ooxml/TestPOIXMLProperties.java
Modified:
poi/trunk/poi-ooxml/src/test/java/org/apache/poi/ooxml/TestPOIXMLProperties.java
URL:
http://svn.apache.org/viewvc/poi/trunk/poi-ooxml/src/test/java/org/apache/poi/ooxml/TestPOIXMLProperties.java?rev=1895911&r1=1895910&r2=1895911&view=diff
==============================================================================
---
poi/trunk/poi-ooxml/src/test/java/org/apache/poi/ooxml/TestPOIXMLProperties.java
(original)
+++
poi/trunk/poi-ooxml/src/test/java/org/apache/poi/ooxml/TestPOIXMLProperties.java
Mon Dec 13 17:48:47 2021
@@ -33,6 +33,7 @@ import java.util.Optional;
import org.apache.poi.POIDataSamples;
import org.apache.poi.ooxml.POIXMLProperties.CoreProperties;
+import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.openxml4j.opc.OPCPackage;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
@@ -370,4 +371,28 @@ public final class TestPOIXMLProperties
assertEquals(propValue,
wbBack.getProperties().getCustomProperties().getProperty(propName +
"1").getLpwstr(), "Third prop check1");
}
}
+
+ @Test
+ void testSetInvalidCreatedDate() throws IOException {
+ try (XWPFDocument doc = new XWPFDocument()) {
+ CoreProperties cp = doc.getProperties().getCoreProperties();
+ assertThrows(InvalidFormatException.class, () ->
cp.setCreated("not a date"));
+ }
+ }
+
+ @Test
+ void testSetInvalidLastPrintedDate() throws IOException {
+ try (XWPFDocument doc = new XWPFDocument()) {
+ CoreProperties cp = doc.getProperties().getCoreProperties();
+ assertThrows(InvalidFormatException.class, () ->
cp.setLastPrinted("not a date"));
+ }
+ }
+
+ @Test
+ void testSetInvalidModifiedDate() throws IOException {
+ try (XWPFDocument doc = new XWPFDocument()) {
+ CoreProperties cp = doc.getProperties().getCoreProperties();
+ assertThrows(InvalidFormatException.class, () ->
cp.setModified("not a date"));
+ }
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]