This test fails :
public void testWriteSimplePropertySet()
throws IOException, UnsupportedVariantTypeException
{
final String AUTHOR = "Rainer Klute";
final String TITLE = "Test Document";
final File filename = new File(POI_FS);
filename.deleteOnExit();
final OutputStream out = new FileOutputStream(filename);
final POIFSFileSystem poiFs = new POIFSFileSystem();
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet xlsSheet = wb.createSheet("Page 1");
wb.write(out);
final MutablePropertySet ps = new MutablePropertySet();
final MutableSection si = new MutableSection();
si.setFormatID(SectionIDMap.SUMMARY_INFORMATION_ID);
ps.getSections().set(0, si);
final MutableProperty p = new MutableProperty();
p.setID(PropertyIDMap.PID_AUTHOR);
p.setType(Variant.VT_LPWSTR);
p.setValue(AUTHOR);
si.setProperty(p);
si.setProperty(PropertyIDMap.PID_TITLE, Variant.VT_LPSTR,
TITLE);
poiFs.createDocument(ps.toInputStream(),
SummaryInformation.DEFAULT_STREAM_NAME);
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();
//fail(org.apache.poi.hpsf.Util.toString(ex));
}
}
},
SummaryInformation.DEFAULT_STREAM_NAME);
r.read(new FileInputStream(filename));
Assert.assertNotNull(psa[0]);
Assert.assertTrue(psa[0].isSummaryInformation());
final Section s = (Section) (psa[0].getSections().get(0));
Object p1 = s.getProperty(PropertyIDMap.PID_AUTHOR);
Object p2 = s.getProperty(PropertyIDMap.PID_TITLE);
Assert.assertEquals(AUTHOR, p1);
Assert.assertEquals(TITLE, p2);
}
--
View this message in context:
http://old.nabble.com/SummaryInformation-tp26497648p26525410.html
Sent from the POI - Dev mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]