summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNick Burch <nick@apache.org>2014-02-20 00:06:34 +0000
committerNick Burch <nick@apache.org>2014-02-20 00:06:34 +0000
commit8f6ea0f8a855a3fffa50eb023db48eeeddfa6291 (patch)
treef98b77ce9a5a025c25eaf11cedfa77a3aad1342a
parent6c24cb70205e783a6441e86c8fdd4c87103d3c2b (diff)
downloadpoi-8f6ea0f8a855a3fffa50eb023db48eeeddfa6291.tar.gz
poi-8f6ea0f8a855a3fffa50eb023db48eeeddfa6291.zip
Another content types test, for #55026
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1570002 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFRelation.java6
-rw-r--r--src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestContentType.java26
-rw-r--r--test-data/openxml4j/ContentTypeHasEntities.ooxmlbin0 -> 10995 bytes
3 files changed, 30 insertions, 2 deletions
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 0000000000..9581a2e77a
--- /dev/null
+++ b/test-data/openxml4j/ContentTypeHasEntities.ooxml
Binary files differ