From 8f6ea0f8a855a3fffa50eb023db48eeeddfa6291 Mon Sep 17 00:00:00 2001 From: Nick Burch Date: Thu, 20 Feb 2014 00:06:34 +0000 Subject: [PATCH] Another content types test, for #55026 git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1570002 13f79535-47bb-0310-9956-ffa450edef68 --- .../poi/xwpf/usermodel/XWPFRelation.java | 6 ++++ .../poi/openxml4j/opc/TestContentType.java | 26 ++++++++++++++++-- .../openxml4j/ContentTypeHasEntities.ooxml | Bin 0 -> 10995 bytes 3 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 test-data/openxml4j/ContentTypeHasEntities.ooxml diff --git a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFRelation.java b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFRelation.java index e20052b68d..06642faaab 100644 --- a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFRelation.java +++ b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFRelation.java @@ -107,6 +107,12 @@ public final class XWPFRelation extends POIXMLRelation { "/word/footer#.xml", XWPFFooter.class ); + public static final XWPFRelation THEME = new XWPFRelation( + "application/vnd.openxmlformats-officedocument.theme+xml", + "http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme", + "/word/theme/theme#.xml", + null + ); public static final XWPFRelation HYPERLINK = new XWPFRelation( null, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink", diff --git a/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestContentType.java b/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestContentType.java index 22660ddbf3..e77e4f8482 100644 --- a/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestContentType.java +++ b/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestContentType.java @@ -24,6 +24,7 @@ import junit.framework.TestCase; import org.apache.poi.openxml4j.OpenXML4JTestDataSamples; import org.apache.poi.openxml4j.exceptions.InvalidFormatException; import org.apache.poi.openxml4j.opc.internal.ContentType; +import org.apache.poi.xwpf.usermodel.XWPFRelation; /** * Tests for content type (ContentType class). @@ -142,8 +143,29 @@ public final class TestContentType extends TestCase { * OOXML content types don't need entities, but we shouldn't * barf if we get one from a third party system that added them */ - public void testFileWithContentTypeEntities() { - // TODO + public void testFileWithContentTypeEntities() throws Exception { + InputStream is = OpenXML4JTestDataSamples.openSampleStream("ContentTypeHasEntities.ooxml"); + OPCPackage p = OPCPackage.open(is); + + // Check we found the contents of it + boolean foundCoreProps = false, foundDocument = false, foundTheme1 = false; + for (PackagePart part : p.getParts()) { + if (part.getPartName().toString().equals("/docProps/core.xml")) { + assertEquals(ContentTypes.CORE_PROPERTIES_PART, part.getContentType()); + foundCoreProps = true; + } + if (part.getPartName().toString().equals("/word/document.xml")) { + assertEquals(XWPFRelation.DOCUMENT.getContentType(), part.getContentType()); + foundDocument = true; + } + if (part.getPartName().toString().equals("/word/theme/theme1.xml")) { + assertEquals(XWPFRelation.THEME.getContentType(), part.getContentType()); + foundTheme1 = true; + } + } + assertTrue("Core not found in " + p.getParts(), foundCoreProps); + assertTrue("Document not found in " + p.getParts(), foundDocument); + assertTrue("Theme1 not found in " + p.getParts(), foundTheme1); } /** diff --git a/test-data/openxml4j/ContentTypeHasEntities.ooxml b/test-data/openxml4j/ContentTypeHasEntities.ooxml new file mode 100644 index 0000000000000000000000000000000000000000..9581a2e77a3da91e9f77f9360ba93e5e9f7db6b9 GIT binary patch literal 10995 zcmaJ{1z1#D*B(krxnPD}`je~p6! zu-eLq_RI=3c0m9D6HovE>cepc_V$eKHr5E~aV@s9%#TBMp^lM5b|PZmO@#<5vAoB9 zH8lZnm}R3H3uo3uC+9FfKFrzbbeTzC9UIcaJPMB=KXO_tgvzrH)C=#hW~4o&WS`ho zTWY*^-4jzuZsuGJ=t|%+#GX7~hW#W(Vn_=7yoAnQ+MYqpnA>j}Mfe?$$y3)tWW$e3 z_Br0n1b#jI>IV^peMkNq^1b9?&Z(E}&d%K^2`%omrO2mw%~U3K5Km8t*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