]> source.dussan.org Git - poi.git/commitdiff
Test cases updated/enhanced.
authorRainer Klute <klute@apache.org>
Sat, 13 Sep 2003 12:32:11 +0000 (12:32 +0000)
committerRainer Klute <klute@apache.org>
Sat, 13 Sep 2003 12:32:11 +0000 (12:32 +0000)
git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@353350 13f79535-47bb-0310-9956-ffa450edef68

src/testcases/org/apache/poi/hpsf/basic/TestBasic.java
src/testcases/org/apache/poi/hpsf/basic/TestEmptyProperties.java

index 53b1e885b1ffee4618876b507f449572d22734fb..5d7ff30e76215a1226b3a48cb36d9cddaab66347 100644 (file)
@@ -60,18 +60,21 @@ import java.io.FileFilter;
 import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.InputStream;
+import java.util.List;
 
 import junit.framework.Assert;
 import junit.framework.TestCase;
 
+import org.apache.poi.hpsf.ClassID;
 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.UnexpectedPropertySetTypeException;
+import org.apache.poi.hpsf.wellknown.SectionIDMap;
 
 
 
@@ -138,7 +141,6 @@ public class TestBasic extends TestCase
         final File dataDir =
             new File(System.getProperty("HPSF.testdata.path"));
         final File data = new File(dataDir, POI_FS);
-
         poiFiles = Util.readPOIFiles(data);
     }
 
@@ -192,10 +194,6 @@ public class TestBasic extends TestCase
             {
                 o = ex;
             }
-            catch (UnexpectedPropertySetTypeException ex)
-            {
-                o = ex;
-            }
             catch (MarkUnsupportedException ex)
             {
                 o = ex;
@@ -217,7 +215,6 @@ public class TestBasic extends TestCase
      */
     public void testPropertySetMethods() throws IOException, HPSFException
     {
-
         /* Loop over the two property sets. */
         for (int i = 0; i < 2; i++)
         {
@@ -239,6 +236,31 @@ public class TestBasic extends TestCase
 
 
 
+    /**
+     * <p>Tests the {@link Section} methods. The test file has two
+     * property sets: the first one is a {@link SummaryInformation},
+     * the second one is a {@link DocumentSummaryInformation}.</p>
+     * 
+     * @exception IOException if an I/O exception occurs
+     * @exception HPSFException if any HPSF exception occurs
+     */
+    public void testSectionMethods() throws IOException, HPSFException
+    {
+        final SummaryInformation si = (SummaryInformation)
+            PropertySetFactory.create(new ByteArrayInputStream
+                (poiFiles[0].getBytes()));
+        final List sections = si.getSections();
+        final Section s = (Section) sections.get(0);
+        Assert.assertTrue(org.apache.poi.hpsf.Util.equal
+            (s.getFormatID().getBytes(), SectionIDMap.SUMMARY_INFORMATION_ID));
+        Assert.assertNotNull(s.getProperties());
+        Assert.assertEquals(17, s.getPropertyCount());
+        Assert.assertEquals("Titel", s.getProperty(2));
+        Assert.assertEquals(1764, s.getSize());
+    }
+
+
+
     /**
      * <p>This test methods reads all property set streams from all POI
      * filesystems in the "data" directory.</p>
index fbe9fbf7f947cd6da254ff74684c55b604991d5f..9d8df67d8755331af2170fb9562c0d727edd25f9 100644 (file)
@@ -122,10 +122,6 @@ public class TestEmptyProperties extends TestCase
             {
                 o = ex;
             }
-            catch (UnexpectedPropertySetTypeException ex)
-            {
-                o = ex;
-            }
             catch (MarkUnsupportedException ex)
             {
                 o = ex;
@@ -159,7 +155,7 @@ public class TestEmptyProperties extends TestCase
         assertNotNull(s.getTemplate());
         assertNotNull(s.getLastAuthor());
         assertNotNull(s.getRevNumber());
-        assertNull(s.getEditTime());
+        assertEquals(s.getEditTime(), 0);
         assertNull(s.getLastPrinted());
         assertNull(s.getCreateDateTime());
         assertNull(s.getLastSaveDateTime());