poiFs.writeFilesystem(out);
out.close();
/* Read the POIFS: */
final PropertySet[] psa = new PropertySet[1];
final POIFSReader r = new POIFSReader();
r.registerListener(new POIFSReaderListener()
{
public void processPOIFSReaderEvent
(final POIFSReaderEvent event)
{
try
{
psa[0] = PropertySetFactory.create(event.getStream());
}
catch (Exception ex)
{
ex.printStackTrace();
throw new RuntimeException(ex.toString());
/* FIXME (2): Replace the previous line by the following
* one once we no longer need JDK 1.3 compatibility. */
// throw new RuntimeException(ex);
}
}
},
STREAM_NAME);
r.read(new FileInputStream(filename));
Assert.assertNotNull(psa[0]);
Section s = (Section) (psa[0].getSections().get(0));
assertEquals(s.getFormatID(), formatID);
Object p = s.getProperty(2);
Assert.assertEquals(SECTION1, p);