diff options
author | Yegor Kozlov <yegor@apache.org> | 2012-02-29 07:50:10 +0000 |
---|---|---|
committer | Yegor Kozlov <yegor@apache.org> | 2012-02-29 07:50:10 +0000 |
commit | afaf6472d0c580f06598bb2ea55c55cd3d1fcf16 (patch) | |
tree | 24a5ec4adf74e81a1f736f859277824a23e5a071 /src/ooxml/testcases/org/apache/poi/openxml4j/opc | |
parent | 938646fd24a304d75d706072e586655ab3c92f89 (diff) | |
download | poi-afaf6472d0c580f06598bb2ea55c55cd3d1fcf16.tar.gz poi-afaf6472d0c580f06598bb2ea55c55cd3d1fcf16.zip |
Bugzilla 51780 - support replacement of content types in OPC packages
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1294998 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/ooxml/testcases/org/apache/poi/openxml4j/opc')
-rw-r--r-- | src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestPackage.java | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestPackage.java b/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestPackage.java index 35e87ec00d..b6bc97c185 100644 --- a/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestPackage.java +++ b/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestPackage.java @@ -17,12 +17,7 @@ package org.apache.poi.openxml4j.opc; -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.OutputStream; +import java.io.*; import java.lang.reflect.Field; import java.net.URI; import java.util.*; @@ -528,4 +523,23 @@ public final class TestPackage extends TestCase { assertTrue(selected.containsKey("/word/theme/theme1.xml")); assertTrue(selected.containsKey("/word/webSettings.xml")); } + + public void testReplaceContentType() throws Exception { + InputStream is = OpenXML4JTestDataSamples.openSampleStream("sample.xlsx"); + OPCPackage p = OPCPackage.open(is); + + ContentTypeManager mgr = getContentTypeManager(p); + + assertTrue(mgr.isContentTypeRegister("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml")); + assertFalse(mgr.isContentTypeRegister("application/vnd.ms-excel.sheet.macroEnabled.main+xml")); + + assertTrue( + p.replaceContentType( + "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml", + "application/vnd.ms-excel.sheet.macroEnabled.main+xml") + ); + + assertFalse(mgr.isContentTypeRegister("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml")); + assertTrue(mgr.isContentTypeRegister("application/vnd.ms-excel.sheet.macroEnabled.main+xml")); + } } |