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;
final File dataDir =
new File(System.getProperty("HPSF.testdata.path"));
final File data = new File(dataDir, POI_FS);
-
poiFiles = Util.readPOIFiles(data);
}
{
o = ex;
}
- catch (UnexpectedPropertySetTypeException ex)
- {
- o = ex;
- }
catch (MarkUnsupportedException ex)
{
o = ex;
*/
public void testPropertySetMethods() throws IOException, HPSFException
{
-
/* Loop over the two property sets. */
for (int i = 0; i < 2; i++)
{
+ /**
+ * <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>