Search in sources :

Example 6 with NPropertyTable

use of org.apache.poi.poifs.property.NPropertyTable in project poi by apache.

the class TestNPOIFSFileSystem method readZeroLengthEntries.

@Test
public void readZeroLengthEntries() throws IOException {
    NPOIFSFileSystem fs = new NPOIFSFileSystem(_inst.getFile("only-zero-byte-streams.ole2"));
    DirectoryNode testDir = fs.getRoot();
    assertEquals(3, testDir.getEntryCount());
    DocumentEntry entry;
    entry = (DocumentEntry) testDir.getEntry("test-zero-1");
    assertNotNull(entry);
    assertEquals(0, entry.getSize());
    entry = (DocumentEntry) testDir.getEntry("test-zero-2");
    assertNotNull(entry);
    assertEquals(0, entry.getSize());
    entry = (DocumentEntry) testDir.getEntry("test-zero-3");
    assertNotNull(entry);
    assertEquals(0, entry.getSize());
    // Check properties, all have zero length, no blocks
    NPropertyTable props = fs._get_property_table();
    assertEquals(POIFSConstants.END_OF_CHAIN, props.getRoot().getStartBlock());
    for (Property prop : props.getRoot()) {
        assertEquals("test-zero-", prop.getName().substring(0, 10));
        assertEquals(POIFSConstants.END_OF_CHAIN, prop.getStartBlock());
    }
    // All done
    fs.close();
}
Also used : NPropertyTable(org.apache.poi.poifs.property.NPropertyTable) Property(org.apache.poi.poifs.property.Property) DirectoryProperty(org.apache.poi.poifs.property.DirectoryProperty) RootProperty(org.apache.poi.poifs.property.RootProperty) Test(org.junit.Test)

Aggregations

NPropertyTable (org.apache.poi.poifs.property.NPropertyTable)6 Test (org.junit.Test)4 DirectoryProperty (org.apache.poi.poifs.property.DirectoryProperty)3 Property (org.apache.poi.poifs.property.Property)3 RootProperty (org.apache.poi.poifs.property.RootProperty)3 File (java.io.File)2 FileInputStream (java.io.FileInputStream)2 NPOIFSFileSystem (org.apache.poi.poifs.filesystem.NPOIFSFileSystem)2 IOException (java.io.IOException)1 ByteBuffer (java.nio.ByteBuffer)1 ArrayList (java.util.ArrayList)1 DirectoryEntry (org.apache.poi.poifs.filesystem.DirectoryEntry)1 BATBlock (org.apache.poi.poifs.storage.BATBlock)1 HeaderBlock (org.apache.poi.poifs.storage.HeaderBlock)1 TempFile (org.apache.poi.util.TempFile)1