diff options
author | Nick Burch <nick@apache.org> | 2015-02-28 17:37:11 +0000 |
---|---|---|
committer | Nick Burch <nick@apache.org> | 2015-02-28 17:37:11 +0000 |
commit | 4327905c99187a506555593d9c625f92cc794ec9 (patch) | |
tree | 2f6d08db6a7fd5d6b9483891e0d6bf1e9ac74a59 /src/ooxml/testcases/org/apache/poi/openxml4j/opc | |
parent | e43ab85691f6ad606038ed9269c2064880b3be84 (diff) | |
download | poi-4327905c99187a506555593d9c625f92cc794ec9.tar.gz poi-4327905c99187a506555593d9c625f92cc794ec9.zip |
More missing core properties unit tests, covering read-write without checks, and encryption
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1662972 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/compliance/TestOPCComplianceCoreProperties.java | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/src/ooxml/testcases/org/apache/poi/openxml4j/opc/compliance/TestOPCComplianceCoreProperties.java b/src/ooxml/testcases/org/apache/poi/openxml4j/opc/compliance/TestOPCComplianceCoreProperties.java index cc6f7ca83d..b9517ba2ef 100644 --- a/src/ooxml/testcases/org/apache/poi/openxml4j/opc/compliance/TestOPCComplianceCoreProperties.java +++ b/src/ooxml/testcases/org/apache/poi/openxml4j/opc/compliance/TestOPCComplianceCoreProperties.java @@ -237,14 +237,9 @@ public final class TestOPCComplianceCoreProperties extends TestCase { */ public void testNoCoreProperties_saveNew() throws Exception { String sampleFileName = "OPCCompliance_NoCoreProperties.xlsx"; - OPCPackage pkg = null; - try { - pkg = OPCPackage.open(POIDataSamples.getOpenXML4JInstance().getFile(sampleFileName).getPath()); - } catch (Exception e) { - throw new RuntimeException(e); - } + OPCPackage pkg = OPCPackage.open(POIDataSamples.getOpenXML4JInstance().getFile(sampleFileName).getPath()); - // Empty properties + // Verify it has empty properties assertEquals(0, pkg.getPartsByContentType(ContentTypes.CORE_PROPERTIES_PART).size()); assertNotNull(pkg.getPackageProperties()); assertNotNull(pkg.getPackageProperties().getLanguageProperty()); @@ -262,6 +257,22 @@ public final class TestOPCComplianceCoreProperties extends TestCase { assertNotNull(pkg.getPackageProperties()); assertNotNull(pkg.getPackageProperties().getLanguageProperty()); assertNull(pkg.getPackageProperties().getLanguageProperty().getValue()); + + + // Open a new copy of it + pkg = OPCPackage.open(POIDataSamples.getOpenXML4JInstance().getFile(sampleFileName).getPath()); + + // Save and re-load, without having touched the properties yet + baos = new ByteArrayOutputStream(); + pkg.save(baos); + bais = new ByteArrayInputStream(baos.toByteArray()); + pkg = OPCPackage.open(bais); + + // Check that this too added empty properties without error + assertEquals(1, pkg.getPartsByContentType(ContentTypes.CORE_PROPERTIES_PART).size()); + assertNotNull(pkg.getPackageProperties()); + assertNotNull(pkg.getPackageProperties().getLanguageProperty()); + assertNull(pkg.getPackageProperties().getLanguageProperty().getValue()); } /** |