aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNick Burch <nick@apache.org>2010-05-26 15:11:33 +0000
committerNick Burch <nick@apache.org>2010-05-26 15:11:33 +0000
commit4b102e53244439481ce524ac9b8ca8017b2bb95d (patch)
treec6672003d1ee3a57fb53ce935054b7049146abd5
parent93449602c572ecd8008053a1d4c19c7e7294779f (diff)
downloadpoi-4b102e53244439481ce524ac9b8ca8017b2bb95d.tar.gz
poi-4b102e53244439481ce524ac9b8ca8017b2bb95d.zip
Add test which shows that bug #48832 is invalid
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@948473 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--src/testcases/org/apache/poi/hpsf/basic/AllPOIHPSFBasicTests.java1
-rw-r--r--src/testcases/org/apache/poi/hpsf/basic/TestHPSFBugs.java111
2 files changed, 112 insertions, 0 deletions
diff --git a/src/testcases/org/apache/poi/hpsf/basic/AllPOIHPSFBasicTests.java b/src/testcases/org/apache/poi/hpsf/basic/AllPOIHPSFBasicTests.java
index 5954c9ca5f..f71193644c 100644
--- a/src/testcases/org/apache/poi/hpsf/basic/AllPOIHPSFBasicTests.java
+++ b/src/testcases/org/apache/poi/hpsf/basic/AllPOIHPSFBasicTests.java
@@ -30,6 +30,7 @@ public final class AllPOIHPSFBasicTests {
result.addTestSuite(TestBasic.class);
result.addTestSuite(TestClassID.class);
result.addTestSuite(TestEmptyProperties.class);
+ result.addTestSuite(TestHPSFBugs.class);
result.addTestSuite(TestMetaDataIPI.class);
result.addTestSuite(TestUnicode.class);
result.addTestSuite(TestWrite.class);
diff --git a/src/testcases/org/apache/poi/hpsf/basic/TestHPSFBugs.java b/src/testcases/org/apache/poi/hpsf/basic/TestHPSFBugs.java
new file mode 100644
index 0000000000..5c15497299
--- /dev/null
+++ b/src/testcases/org/apache/poi/hpsf/basic/TestHPSFBugs.java
@@ -0,0 +1,111 @@
+/* ====================================================================
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+==================================================================== */
+
+package org.apache.poi.hpsf.basic;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
+import java.util.Date;
+import java.util.List;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.apache.poi.hpsf.DocumentSummaryInformation;
+import org.apache.poi.hpsf.HPSFException;
+import org.apache.poi.hpsf.MarkUnsupportedException;
+import org.apache.poi.hpsf.NoPropertySetStreamException;
+import org.apache.poi.hpsf.PropertySet;
+import org.apache.poi.hpsf.PropertySetFactory;
+import org.apache.poi.hpsf.Section;
+import org.apache.poi.hpsf.SummaryInformation;
+import org.apache.poi.hpsf.wellknown.SectionIDMap;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
+import org.apache.poi.POIDataSamples;
+
+/**
+ * Tests various bugs have been fixed
+ */
+public final class TestHPSFBugs extends TestCase {
+ /**
+ * Ensure that we can create a new HSSF Workbook,
+ * then add some properties to it, save +
+ * reload, and still access & change them.
+ */
+ public void test48832() throws Exception {
+ HSSFWorkbook wb = new HSSFWorkbook();
+
+ // Starts empty
+ assertNull(wb.getDocumentSummaryInformation());
+ assertNull(wb.getSummaryInformation());
+
+ // Add new properties
+ wb.createInformationProperties();
+
+ assertNotNull(wb.getDocumentSummaryInformation());
+ assertNotNull(wb.getSummaryInformation());
+
+ // Set initial values
+ wb.getSummaryInformation().setAuthor("Apache POI");
+ wb.getSummaryInformation().setKeywords("Testing POI");
+ wb.getSummaryInformation().setCreateDateTime(new Date(12345));
+
+ wb.getDocumentSummaryInformation().setCompany("Apache");
+
+
+ // Save and reload
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ wb.write(baos);
+ ByteArrayInputStream bais =
+ new ByteArrayInputStream(baos.toByteArray());
+ wb = new HSSFWorkbook(bais);
+
+
+ // Ensure changes were taken
+ assertNotNull(wb.getDocumentSummaryInformation());
+ assertNotNull(wb.getSummaryInformation());
+
+ assertEquals("Apache POI", wb.getSummaryInformation().getAuthor());
+ assertEquals("Testing POI", wb.getSummaryInformation().getKeywords());
+ assertEquals(12345, wb.getSummaryInformation().getCreateDateTime().getTime());
+ assertEquals("Apache", wb.getDocumentSummaryInformation().getCompany());
+
+
+ // Set some more, save + reload
+ wb.getSummaryInformation().setComments("Resaved");
+
+ baos = new ByteArrayOutputStream();
+ wb.write(baos);
+ bais = new ByteArrayInputStream(baos.toByteArray());
+ wb = new HSSFWorkbook(bais);
+
+ // Check again
+ assertNotNull(wb.getDocumentSummaryInformation());
+ assertNotNull(wb.getSummaryInformation());
+
+ assertEquals("Apache POI", wb.getSummaryInformation().getAuthor());
+ assertEquals("Testing POI", wb.getSummaryInformation().getKeywords());
+ assertEquals("Resaved", wb.getSummaryInformation().getComments());
+ assertEquals(12345, wb.getSummaryInformation().getCreateDateTime().getTime());
+ assertEquals("Apache", wb.getDocumentSummaryInformation().getCompany());
+ }
+}