Search in sources :

Example 6 with DocumentSummaryInformation

use of org.apache.poi.hpsf.DocumentSummaryInformation in project poi by apache.

the class TestEmptyProperties method testPropertySetMethods.

/**
     * <p>Tests the {@link PropertySet} 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 an HPSF operation fails
     */
@Test
public void testPropertySetMethods() throws IOException, HPSFException {
    byte[] b = poiFiles.get(1).getBytes();
    PropertySet ps = PropertySetFactory.create(new ByteArrayInputStream(b));
    SummaryInformation s = (SummaryInformation) ps;
    assertNull(s.getTitle());
    assertNull(s.getSubject());
    assertNotNull(s.getAuthor());
    assertNull(s.getKeywords());
    assertNull(s.getComments());
    assertNotNull(s.getTemplate());
    assertNotNull(s.getLastAuthor());
    assertNotNull(s.getRevNumber());
    assertEquals(s.getEditTime(), 0);
    assertNull(s.getLastPrinted());
    assertNull(s.getCreateDateTime());
    assertNull(s.getLastSaveDateTime());
    assertEquals(s.getPageCount(), 0);
    assertEquals(s.getWordCount(), 0);
    assertEquals(s.getCharCount(), 0);
    assertNull(s.getThumbnail());
    assertNull(s.getApplicationName());
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) SummaryInformation(org.apache.poi.hpsf.SummaryInformation) DocumentSummaryInformation(org.apache.poi.hpsf.DocumentSummaryInformation) PropertySet(org.apache.poi.hpsf.PropertySet) Test(org.junit.Test)

Example 7 with DocumentSummaryInformation

use of org.apache.poi.hpsf.DocumentSummaryInformation in project poi by apache.

the class TestWriteWellKnown method testGetCustomerProperties.

/**
     * Tests reading custom properties from a section including reading
     * custom properties which are not pure.
     */
@Test
public void testGetCustomerProperties() {
    final int ID_1 = 2;
    final int ID_2 = 3;
    final String NAME_1 = "Schlüssel ä";
    final String VALUE_1 = "Wert 1";
    final Map<Long, String> dictionary = new HashMap<Long, String>();
    DocumentSummaryInformation dsi = PropertySetFactory.newDocumentSummaryInformation();
    CustomProperties cps;
    MutableSection s;
    /* A document summary information set stream by default does have custom properties. */
    cps = dsi.getCustomProperties();
    assertNull(cps);
    /* Test an empty custom properties set. */
    s = new MutableSection();
    s.setFormatID(SectionIDMap.DOCUMENT_SUMMARY_INFORMATION_ID[1]);
    // s.setCodepage(CodePageUtil.CP_UNICODE);
    dsi.addSection(s);
    cps = dsi.getCustomProperties();
    assertEquals(0, cps.size());
    /* Add a custom property. */
    MutableProperty p = new MutableProperty();
    p.setID(ID_1);
    p.setType(Variant.VT_LPWSTR);
    p.setValue(VALUE_1);
    s.setProperty(p);
    dictionary.put(Long.valueOf(ID_1), NAME_1);
    s.setDictionary(dictionary);
    cps = dsi.getCustomProperties();
    assertEquals(1, cps.size());
    assertTrue(cps.isPure());
    /* Add another custom property. */
    s.setProperty(ID_2, Variant.VT_LPWSTR, VALUE_1);
    dictionary.put(Long.valueOf(ID_2), NAME_1);
    s.setDictionary(dictionary);
    cps = dsi.getCustomProperties();
    assertEquals(1, cps.size());
    assertFalse(cps.isPure());
}
Also used : MutableProperty(org.apache.poi.hpsf.MutableProperty) HashMap(java.util.HashMap) MutableSection(org.apache.poi.hpsf.MutableSection) DocumentSummaryInformation(org.apache.poi.hpsf.DocumentSummaryInformation) CustomProperties(org.apache.poi.hpsf.CustomProperties) Test(org.junit.Test)

Example 8 with DocumentSummaryInformation

use of org.apache.poi.hpsf.DocumentSummaryInformation in project poi by apache.

the class TestWriteWellKnown method write2ndFile.

/*
     * Open <em>doc2</em> for reading and check summary information and
     * document summary information. All properties written before must be
     * found in the property streams of <em>doc2</em> and have the correct
     * values.
     */
private static CustomProperties write2ndFile(File fileIn, File fileOut) throws Exception {
    NPOIFSFileSystem poifs = new NPOIFSFileSystem(fileIn, false);
    SummaryInformation si = getSummaryInformation(poifs);
    DocumentSummaryInformation dsi = getDocumentSummaryInformation(poifs);
    assertEquals(P_APPLICATION_NAME, si.getApplicationName());
    assertEquals(P_AUTHOR, si.getAuthor());
    assertEquals(P_CHAR_COUNT, si.getCharCount());
    assertEquals(P_COMMENTS, si.getComments());
    assertEquals(P_CREATE_DATE_TIME, si.getCreateDateTime());
    assertEquals(P_EDIT_TIME, si.getEditTime());
    assertEquals(P_KEYWORDS, si.getKeywords());
    assertEquals(P_LAST_AUTHOR, si.getLastAuthor());
    assertEquals(P_LAST_PRINTED, si.getLastPrinted());
    assertEquals(P_LAST_SAVE_DATE_TIME, si.getLastSaveDateTime());
    assertEquals(P_PAGE_COUNT, si.getPageCount());
    assertEquals(P_REV_NUMBER, si.getRevNumber());
    assertEquals(P_SECURITY, si.getSecurity());
    assertEquals(P_SUBJECT, si.getSubject());
    assertEquals(P_TEMPLATE, si.getTemplate());
    // FIXME (byte array properties not yet implemented): assertEquals(P_THUMBNAIL, si.getThumbnail());
    assertEquals(P_TITLE, si.getTitle());
    assertEquals(P_WORD_COUNT, si.getWordCount());
    assertEquals(P_BYTE_COUNT, dsi.getByteCount());
    assertEquals(P_CATEGORY, dsi.getCategory());
    assertEquals(P_COMPANY, dsi.getCompany());
    // FIXME (byte array properties not yet implemented): assertEquals(P_, dsi.getDocparts());
    // FIXME (byte array properties not yet implemented): assertEquals(P_, dsi.getHeadingPair());
    assertEquals(P_HIDDEN_COUNT, dsi.getHiddenCount());
    assertEquals(P_LINE_COUNT, dsi.getLineCount());
    assertEquals(P_LINKS_DIRTY, dsi.getLinksDirty());
    assertEquals(P_MANAGER, dsi.getManager());
    assertEquals(P_MM_CLIP_COUNT, dsi.getMMClipCount());
    assertEquals(P_NOTE_COUNT, dsi.getNoteCount());
    assertEquals(P_PAR_COUNT, dsi.getParCount());
    assertEquals(P_PRESENTATION_FORMAT, dsi.getPresentationFormat());
    assertEquals(P_SCALE, dsi.getScale());
    assertEquals(P_SLIDE_COUNT, dsi.getSlideCount());
    final CustomProperties cps = dsi.getCustomProperties();
    assertNotNull(cps);
    assertNull(cps.get("No value available"));
    assertEquals("Wert ä", cps.get("Schlüssel ä"));
    assertEquals("Wert äö", cps.get("Schlüssel äö"));
    assertEquals("Wert äöü", cps.get("Schlüssel äöü"));
    assertEquals("Wert äöüÖ", cps.get("Schlüssel äöüÖ"));
    assertEquals(POSITIVE_INTEGER, cps.get("positive_Integer"));
    assertEquals(POSITIVE_LONG, cps.get("positive_Long"));
    assertEquals(POSITIVE_DOUBLE, cps.get("positive_Double"));
    assertEquals(NEGATIVE_INTEGER, cps.get("negative_Integer"));
    assertEquals(NEGATIVE_LONG, cps.get("negative_Long"));
    assertEquals(NEGATIVE_DOUBLE, cps.get("negative_Double"));
    assertEquals(Boolean.TRUE, cps.get("Boolean"));
    assertEquals(now, cps.get("Date"));
    assertEquals(MAX_INTEGER, cps.get("max_Integer"));
    assertEquals(MIN_INTEGER, cps.get("min_Integer"));
    assertEquals(MAX_LONG, cps.get("max_Long"));
    assertEquals(MIN_LONG, cps.get("min_Long"));
    assertEquals(MAX_DOUBLE, cps.get("max_Double"));
    assertEquals(MIN_DOUBLE, cps.get("min_Double"));
    /* Remove all properties supported by HPSF from the summary
         * information (e.g. author, edit date, application name) and from the
         * document summary information (e.g. company, manager). */
    si.removeApplicationName();
    si.removeAuthor();
    si.removeCharCount();
    si.removeComments();
    si.removeCreateDateTime();
    si.removeEditTime();
    si.removeKeywords();
    si.removeLastAuthor();
    si.removeLastPrinted();
    si.removeLastSaveDateTime();
    si.removePageCount();
    si.removeRevNumber();
    si.removeSecurity();
    si.removeSubject();
    si.removeTemplate();
    si.removeThumbnail();
    si.removeTitle();
    si.removeWordCount();
    dsi.removeByteCount();
    dsi.removeCategory();
    dsi.removeCompany();
    dsi.removeCustomProperties();
    dsi.removeDocparts();
    dsi.removeHeadingPair();
    dsi.removeHiddenCount();
    dsi.removeLineCount();
    dsi.removeLinksDirty();
    dsi.removeManager();
    dsi.removeMMClipCount();
    dsi.removeNoteCount();
    dsi.removeParCount();
    dsi.removePresentationFormat();
    dsi.removeScale();
    dsi.removeSlideCount();
    // Write the summary information stream and the document summary
    // information stream to the POI filesystem.
    si.write(poifs.getRoot(), SummaryInformation.DEFAULT_STREAM_NAME);
    dsi.write(poifs.getRoot(), DocumentSummaryInformation.DEFAULT_STREAM_NAME);
    // Write the POI filesystem to a (temporary) file doc3 and close the latter.
    FileOutputStream out = new FileOutputStream(fileOut);
    poifs.writeFilesystem(out);
    out.close();
    poifs.close();
    return cps;
}
Also used : NPOIFSFileSystem(org.apache.poi.poifs.filesystem.NPOIFSFileSystem) SummaryInformation(org.apache.poi.hpsf.SummaryInformation) DocumentSummaryInformation(org.apache.poi.hpsf.DocumentSummaryInformation) FileOutputStream(java.io.FileOutputStream) DocumentSummaryInformation(org.apache.poi.hpsf.DocumentSummaryInformation) CustomProperties(org.apache.poi.hpsf.CustomProperties)

Example 9 with DocumentSummaryInformation

use of org.apache.poi.hpsf.DocumentSummaryInformation in project poi by apache.

the class TestNPOIFSFileSystem method getDocumentEntry.

/**
    * Tests that we can get the correct contents for
    *  a document in the filesystem 
    */
@Test
public void getDocumentEntry() throws Exception {
    for (NPOIFSFileSystem fs : get512and4kFileAndInput()) {
        DirectoryEntry root = fs.getRoot();
        Entry si = root.getEntry("SummaryInformation");
        assertEquals(true, si.isDocumentEntry());
        DocumentNode doc = (DocumentNode) si;
        // Check we can read it
        assertContentsMatches(null, doc);
        // Now try to build the property set
        DocumentInputStream inp = new NDocumentInputStream(doc);
        PropertySet ps = PropertySetFactory.create(inp);
        SummaryInformation inf = (SummaryInformation) ps;
        // Check some bits in it
        assertEquals(null, inf.getApplicationName());
        assertEquals(null, inf.getAuthor());
        assertEquals(null, inf.getSubject());
        assertEquals(131333, inf.getOSVersion());
        // Finish with this one
        inp.close();
        // Try the other summary information
        si = root.getEntry("DocumentSummaryInformation");
        assertEquals(true, si.isDocumentEntry());
        doc = (DocumentNode) si;
        assertContentsMatches(null, doc);
        inp = new NDocumentInputStream(doc);
        ps = PropertySetFactory.create(inp);
        DocumentSummaryInformation dinf = (DocumentSummaryInformation) ps;
        assertEquals(131333, dinf.getOSVersion());
        fs.close();
    }
}
Also used : SummaryInformation(org.apache.poi.hpsf.SummaryInformation) DocumentSummaryInformation(org.apache.poi.hpsf.DocumentSummaryInformation) PropertySet(org.apache.poi.hpsf.PropertySet) DocumentSummaryInformation(org.apache.poi.hpsf.DocumentSummaryInformation) Test(org.junit.Test)

Example 10 with DocumentSummaryInformation

use of org.apache.poi.hpsf.DocumentSummaryInformation in project poi by apache.

the class TestNPOIFSFileSystem method readWriteRead.

/**
    * Read a file, write it and read it again.
    * Then, alter+add some streams, write and read
    */
@Test
public void readWriteRead() throws Exception {
    SummaryInformation sinf;
    DocumentSummaryInformation dinf;
    DirectoryEntry root, testDir;
    for (NPOIFSFileSystem fs1 : get512and4kFileAndInput()) {
        // Check we can find the entries we expect
        root = fs1.getRoot();
        assertEquals(5, root.getEntryCount());
        assertThat(root.getEntryNames(), hasItem("Thumbnail"));
        assertThat(root.getEntryNames(), hasItem("Image"));
        assertThat(root.getEntryNames(), hasItem("Tags"));
        assertThat(root.getEntryNames(), hasItem("DocumentSummaryInformation"));
        assertThat(root.getEntryNames(), hasItem("SummaryInformation"));
        // Write out, re-load
        NPOIFSFileSystem fs2 = writeOutAndReadBack(fs1);
        fs1.close();
        // Check they're still there
        root = fs2.getRoot();
        assertEquals(5, root.getEntryCount());
        assertThat(root.getEntryNames(), hasItem("Thumbnail"));
        assertThat(root.getEntryNames(), hasItem("Image"));
        assertThat(root.getEntryNames(), hasItem("Tags"));
        assertThat(root.getEntryNames(), hasItem("DocumentSummaryInformation"));
        assertThat(root.getEntryNames(), hasItem("SummaryInformation"));
        // Check the contents of them - parse the summary block and check
        sinf = (SummaryInformation) PropertySetFactory.create(new NDocumentInputStream((DocumentEntry) root.getEntry(SummaryInformation.DEFAULT_STREAM_NAME)));
        assertEquals(131333, sinf.getOSVersion());
        dinf = (DocumentSummaryInformation) PropertySetFactory.create(new NDocumentInputStream((DocumentEntry) root.getEntry(DocumentSummaryInformation.DEFAULT_STREAM_NAME)));
        assertEquals(131333, dinf.getOSVersion());
        // Add a test mini stream
        testDir = root.createDirectory("Testing 123");
        testDir.createDirectory("Testing 456");
        testDir.createDirectory("Testing 789");
        byte[] mini = new byte[] { 42, 0, 1, 2, 3, 4, 42 };
        testDir.createDocument("Mini", new ByteArrayInputStream(mini));
        // Write out, re-load
        NPOIFSFileSystem fs3 = writeOutAndReadBack(fs2);
        fs2.close();
        root = fs3.getRoot();
        testDir = (DirectoryEntry) root.getEntry("Testing 123");
        assertEquals(6, root.getEntryCount());
        assertThat(root.getEntryNames(), hasItem("Thumbnail"));
        assertThat(root.getEntryNames(), hasItem("Image"));
        assertThat(root.getEntryNames(), hasItem("Tags"));
        assertThat(root.getEntryNames(), hasItem("Testing 123"));
        assertThat(root.getEntryNames(), hasItem("DocumentSummaryInformation"));
        assertThat(root.getEntryNames(), hasItem("SummaryInformation"));
        // Check old and new are there
        sinf = (SummaryInformation) PropertySetFactory.create(new NDocumentInputStream((DocumentEntry) root.getEntry(SummaryInformation.DEFAULT_STREAM_NAME)));
        assertEquals(131333, sinf.getOSVersion());
        dinf = (DocumentSummaryInformation) PropertySetFactory.create(new NDocumentInputStream((DocumentEntry) root.getEntry(DocumentSummaryInformation.DEFAULT_STREAM_NAME)));
        assertEquals(131333, dinf.getOSVersion());
        assertContentsMatches(mini, (DocumentEntry) testDir.getEntry("Mini"));
        // Write out and read once more, just to be sure
        NPOIFSFileSystem fs4 = writeOutAndReadBack(fs3);
        fs3.close();
        root = fs4.getRoot();
        testDir = (DirectoryEntry) root.getEntry("Testing 123");
        assertEquals(6, root.getEntryCount());
        assertThat(root.getEntryNames(), hasItem("Thumbnail"));
        assertThat(root.getEntryNames(), hasItem("Image"));
        assertThat(root.getEntryNames(), hasItem("Tags"));
        assertThat(root.getEntryNames(), hasItem("Testing 123"));
        assertThat(root.getEntryNames(), hasItem("DocumentSummaryInformation"));
        assertThat(root.getEntryNames(), hasItem("SummaryInformation"));
        sinf = (SummaryInformation) PropertySetFactory.create(new NDocumentInputStream((DocumentEntry) root.getEntry(SummaryInformation.DEFAULT_STREAM_NAME)));
        assertEquals(131333, sinf.getOSVersion());
        dinf = (DocumentSummaryInformation) PropertySetFactory.create(new NDocumentInputStream((DocumentEntry) root.getEntry(DocumentSummaryInformation.DEFAULT_STREAM_NAME)));
        assertEquals(131333, dinf.getOSVersion());
        assertContentsMatches(mini, (DocumentEntry) testDir.getEntry("Mini"));
        // Add a full stream, delete a full stream
        byte[] main4096 = new byte[4096];
        main4096[0] = -10;
        main4096[4095] = -11;
        testDir.createDocument("Normal4096", new ByteArrayInputStream(main4096));
        root.getEntry("Tags").delete();
        // Write out, re-load
        NPOIFSFileSystem fs5 = writeOutAndReadBack(fs4);
        fs4.close();
        // Check it's all there
        root = fs5.getRoot();
        testDir = (DirectoryEntry) root.getEntry("Testing 123");
        assertEquals(5, root.getEntryCount());
        assertThat(root.getEntryNames(), hasItem("Thumbnail"));
        assertThat(root.getEntryNames(), hasItem("Image"));
        assertThat(root.getEntryNames(), hasItem("Testing 123"));
        assertThat(root.getEntryNames(), hasItem("DocumentSummaryInformation"));
        assertThat(root.getEntryNames(), hasItem("SummaryInformation"));
        // Check old and new are there
        sinf = (SummaryInformation) PropertySetFactory.create(new NDocumentInputStream((DocumentEntry) root.getEntry(SummaryInformation.DEFAULT_STREAM_NAME)));
        assertEquals(131333, sinf.getOSVersion());
        dinf = (DocumentSummaryInformation) PropertySetFactory.create(new NDocumentInputStream((DocumentEntry) root.getEntry(DocumentSummaryInformation.DEFAULT_STREAM_NAME)));
        assertEquals(131333, dinf.getOSVersion());
        assertContentsMatches(mini, (DocumentEntry) testDir.getEntry("Mini"));
        assertContentsMatches(main4096, (DocumentEntry) testDir.getEntry("Normal4096"));
        // Delete a directory, and add one more
        testDir.getEntry("Testing 456").delete();
        testDir.createDirectory("Testing ABC");
        // Save
        NPOIFSFileSystem fs6 = writeOutAndReadBack(fs5);
        fs5.close();
        // Check
        root = fs6.getRoot();
        testDir = (DirectoryEntry) root.getEntry("Testing 123");
        assertEquals(5, root.getEntryCount());
        assertThat(root.getEntryNames(), hasItem("Thumbnail"));
        assertThat(root.getEntryNames(), hasItem("Image"));
        assertThat(root.getEntryNames(), hasItem("Testing 123"));
        assertThat(root.getEntryNames(), hasItem("DocumentSummaryInformation"));
        assertThat(root.getEntryNames(), hasItem("SummaryInformation"));
        assertEquals(4, testDir.getEntryCount());
        assertThat(testDir.getEntryNames(), hasItem("Mini"));
        assertThat(testDir.getEntryNames(), hasItem("Normal4096"));
        assertThat(testDir.getEntryNames(), hasItem("Testing 789"));
        assertThat(testDir.getEntryNames(), hasItem("Testing ABC"));
        // Add another mini stream
        byte[] mini2 = new byte[] { -42, 0, -1, -2, -3, -4, -42 };
        testDir.createDocument("Mini2", new ByteArrayInputStream(mini2));
        // Save, load, check
        NPOIFSFileSystem fs7 = writeOutAndReadBack(fs6);
        fs6.close();
        root = fs7.getRoot();
        testDir = (DirectoryEntry) root.getEntry("Testing 123");
        assertEquals(5, root.getEntryCount());
        assertThat(root.getEntryNames(), hasItem("Thumbnail"));
        assertThat(root.getEntryNames(), hasItem("Image"));
        assertThat(root.getEntryNames(), hasItem("Testing 123"));
        assertThat(root.getEntryNames(), hasItem("DocumentSummaryInformation"));
        assertThat(root.getEntryNames(), hasItem("SummaryInformation"));
        assertEquals(5, testDir.getEntryCount());
        assertThat(testDir.getEntryNames(), hasItem("Mini"));
        assertThat(testDir.getEntryNames(), hasItem("Mini2"));
        assertThat(testDir.getEntryNames(), hasItem("Normal4096"));
        assertThat(testDir.getEntryNames(), hasItem("Testing 789"));
        assertThat(testDir.getEntryNames(), hasItem("Testing ABC"));
        assertContentsMatches(mini, (DocumentEntry) testDir.getEntry("Mini"));
        assertContentsMatches(mini2, (DocumentEntry) testDir.getEntry("Mini2"));
        assertContentsMatches(main4096, (DocumentEntry) testDir.getEntry("Normal4096"));
        // Delete a mini stream, add one more
        testDir.getEntry("Mini").delete();
        byte[] mini3 = new byte[] { 42, 0, 42, 0, 42, 0, 42 };
        testDir.createDocument("Mini3", new ByteArrayInputStream(mini3));
        // Save, load, check
        NPOIFSFileSystem fs8 = writeOutAndReadBack(fs7);
        fs7.close();
        root = fs8.getRoot();
        testDir = (DirectoryEntry) root.getEntry("Testing 123");
        assertEquals(5, root.getEntryCount());
        assertThat(root.getEntryNames(), hasItem("Thumbnail"));
        assertThat(root.getEntryNames(), hasItem("Image"));
        assertThat(root.getEntryNames(), hasItem("Testing 123"));
        assertThat(root.getEntryNames(), hasItem("DocumentSummaryInformation"));
        assertThat(root.getEntryNames(), hasItem("SummaryInformation"));
        assertEquals(5, testDir.getEntryCount());
        assertThat(testDir.getEntryNames(), hasItem("Mini2"));
        assertThat(testDir.getEntryNames(), hasItem("Mini3"));
        assertThat(testDir.getEntryNames(), hasItem("Normal4096"));
        assertThat(testDir.getEntryNames(), hasItem("Testing 789"));
        assertThat(testDir.getEntryNames(), hasItem("Testing ABC"));
        assertContentsMatches(mini2, (DocumentEntry) testDir.getEntry("Mini2"));
        assertContentsMatches(mini3, (DocumentEntry) testDir.getEntry("Mini3"));
        assertContentsMatches(main4096, (DocumentEntry) testDir.getEntry("Normal4096"));
        // Change some existing streams
        NPOIFSDocument mini2Doc = new NPOIFSDocument((DocumentNode) testDir.getEntry("Mini2"));
        mini2Doc.replaceContents(new ByteArrayInputStream(mini));
        byte[] main4106 = new byte[4106];
        main4106[0] = 41;
        main4106[4105] = 42;
        NPOIFSDocument mainDoc = new NPOIFSDocument((DocumentNode) testDir.getEntry("Normal4096"));
        mainDoc.replaceContents(new ByteArrayInputStream(main4106));
        // Re-check
        NPOIFSFileSystem fs9 = writeOutAndReadBack(fs8);
        fs8.close();
        root = fs9.getRoot();
        testDir = (DirectoryEntry) root.getEntry("Testing 123");
        assertEquals(5, root.getEntryCount());
        assertThat(root.getEntryNames(), hasItem("Thumbnail"));
        assertThat(root.getEntryNames(), hasItem("Image"));
        assertThat(root.getEntryNames(), hasItem("Testing 123"));
        assertThat(root.getEntryNames(), hasItem("DocumentSummaryInformation"));
        assertThat(root.getEntryNames(), hasItem("SummaryInformation"));
        assertEquals(5, testDir.getEntryCount());
        assertThat(testDir.getEntryNames(), hasItem("Mini2"));
        assertThat(testDir.getEntryNames(), hasItem("Mini3"));
        assertThat(testDir.getEntryNames(), hasItem("Normal4096"));
        assertThat(testDir.getEntryNames(), hasItem("Testing 789"));
        assertThat(testDir.getEntryNames(), hasItem("Testing ABC"));
        assertContentsMatches(mini, (DocumentEntry) testDir.getEntry("Mini2"));
        assertContentsMatches(mini3, (DocumentEntry) testDir.getEntry("Mini3"));
        assertContentsMatches(main4106, (DocumentEntry) testDir.getEntry("Normal4096"));
        // All done
        fs9.close();
    }
}
Also used : SummaryInformation(org.apache.poi.hpsf.SummaryInformation) DocumentSummaryInformation(org.apache.poi.hpsf.DocumentSummaryInformation) DocumentSummaryInformation(org.apache.poi.hpsf.DocumentSummaryInformation) Test(org.junit.Test)

Aggregations

DocumentSummaryInformation (org.apache.poi.hpsf.DocumentSummaryInformation)22 SummaryInformation (org.apache.poi.hpsf.SummaryInformation)15 Test (org.junit.Test)10 NPOIFSFileSystem (org.apache.poi.poifs.filesystem.NPOIFSFileSystem)9 ByteArrayInputStream (java.io.ByteArrayInputStream)6 CustomProperties (org.apache.poi.hpsf.CustomProperties)6 PropertySet (org.apache.poi.hpsf.PropertySet)5 InputStream (java.io.InputStream)4 DirectoryEntry (org.apache.poi.poifs.filesystem.DirectoryEntry)4 FileOutputStream (java.io.FileOutputStream)3 IOException (java.io.IOException)3 DocumentInputStream (org.apache.poi.poifs.filesystem.DocumentInputStream)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 File (java.io.File)2 FileNotFoundException (java.io.FileNotFoundException)2 OutputStream (java.io.OutputStream)2 HPSFPropertiesOnlyDocument (org.apache.poi.hpsf.HPSFPropertiesOnlyDocument)2 FileInputStream (java.io.FileInputStream)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1