diff --git a/src/testcases/org/apache/poi/hpsf/basic/TestBasic.java b/src/testcases/org/apache/poi/hpsf/basic/TestBasic.java index 53b1e885b..5d7ff30e7 100644 --- a/src/testcases/org/apache/poi/hpsf/basic/TestBasic.java +++ b/src/testcases/org/apache/poi/hpsf/basic/TestBasic.java @@ -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 + /** + *

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}.

+ * + * @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()); + } + + + /** *

This test methods reads all property set streams from all POI * filesystems in the "data" directory.

diff --git a/src/testcases/org/apache/poi/hpsf/basic/TestEmptyProperties.java b/src/testcases/org/apache/poi/hpsf/basic/TestEmptyProperties.java index fbe9fbf7f..9d8df67d8 100644 --- a/src/testcases/org/apache/poi/hpsf/basic/TestEmptyProperties.java +++ b/src/testcases/org/apache/poi/hpsf/basic/TestEmptyProperties.java @@ -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());