FileDocCategorySizeDatePackage
TestDocumentNode.javaAPI DocApache Poi 3.0.13250Mon Jan 01 12:39:44 GMT 2007org.apache.poi.poifs.filesystem

TestDocumentNode

public class TestDocumentNode extends TestCase
Class to test DocumentNode functionality
author
Marc Johnson

Fields Summary
Constructors Summary
public TestDocumentNode(String name)
Constructor TestDocumentNode

param
name

        super(name);
    
Methods Summary
public static voidmain(java.lang.String[] ignored_args)
main method to run the unit tests

param
ignored_args

        System.out
            .println("Testing org.apache.poi.poifs.filesystem.DocumentNode");
        junit.textui.TestRunner.run(TestDocumentNode.class);
    
public voidtestConstructor()
test constructor

exception
IOException

        DirectoryProperty    property1 = new DirectoryProperty("directory");
        RawDataBlock[]       rawBlocks = new RawDataBlock[ 4 ];
        ByteArrayInputStream stream    =
            new ByteArrayInputStream(new byte[ 2048 ]);

        for (int j = 0; j < 4; j++)
        {
            rawBlocks[ j ] = new RawDataBlock(stream);
        }
        POIFSDocument    document  = new POIFSDocument("document", rawBlocks,
                                         2000);
        DocumentProperty property2 = document.getDocumentProperty();
        DirectoryNode    parent    = new DirectoryNode(property1, null, null);
        DocumentNode     node      = new DocumentNode(property2, parent);

        // verify we can retrieve the document
        assertEquals(property2.getDocument(), node.getDocument());

        // verify we can get the size
        assertEquals(property2.getSize(), node.getSize());

        // verify isDocumentEntry returns true
        assertTrue(node.isDocumentEntry());

        // verify isDirectoryEntry returns false
        assertTrue(!node.isDirectoryEntry());

        // verify getName behaves correctly
        assertEquals(property2.getName(), node.getName());

        // verify getParent behaves correctly
        assertEquals(parent, node.getParent());