diff options
Diffstat (limited to 'src/ooxml/testcases/org')
-rwxr-xr-x | src/ooxml/testcases/org/apache/poi/TestPOIXMLProperties.java | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/src/ooxml/testcases/org/apache/poi/TestPOIXMLProperties.java b/src/ooxml/testcases/org/apache/poi/TestPOIXMLProperties.java index 4349600ad6..c27619cec0 100755 --- a/src/ooxml/testcases/org/apache/poi/TestPOIXMLProperties.java +++ b/src/ooxml/testcases/org/apache/poi/TestPOIXMLProperties.java @@ -18,15 +18,20 @@ package org.apache.poi; -import org.apache.poi.xssf.usermodel.XSSFWorkbook; -import org.apache.poi.xssf.XSSFTestDataSamples; +import java.io.File; import junit.framework.TestCase; +import org.apache.poi.openxml4j.opc.OPCPackage; +import org.apache.poi.xssf.XSSFTestDataSamples; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import org.apache.poi.xwpf.usermodel.XWPFDocument; + /** * Test setting extended and custom OOXML properties */ public class TestPOIXMLProperties extends TestCase { + public void testWorkbookExtendedProperties() throws Exception { XSSFWorkbook workbook = new XSSFWorkbook(); POIXMLProperties props = workbook.getProperties(); @@ -131,4 +136,24 @@ public class TestPOIXMLProperties extends TestCase { } + + public void testDocumentProperties() throws Exception { + File sampleFile = new File( + System.getProperty("HWPF.testdata.path") + + File.separator + "documentProperties.docx" + ); + assertTrue(sampleFile.exists()); + XWPFDocument sampleDoc; + sampleDoc = new XWPFDocument( + POIXMLDocument.openPackage(sampleFile.toString()) + ); + POIXMLProperties props = sampleDoc.getProperties(); + assertNotNull(props); + String title = props.getCoreProperties().getTitle(); + assertEquals("Hello World", title); + String creator = props.getCoreProperties().getCreator(); + assertEquals("Paolo Mottadelli", creator); + String subject = props.getCoreProperties().getSubject(); + assertEquals("Greetings", subject); + } }
\ No newline at end of file |