1 2 17 18 19 package org.apache.poi.poifs.filesystem; 20 21 import java.io.*; 22 23 import junit.framework.*; 24 25 import org.apache.poi.poifs.property.DirectoryProperty; 26 import org.apache.poi.poifs.property.DocumentProperty; 27 import org.apache.poi.poifs.storage.RawDataBlock; 28 29 34 35 public class TestDocumentNode 36 extends TestCase 37 { 38 39 44 45 public TestDocumentNode(String name) 46 { 47 super(name); 48 } 49 50 55 56 public void testConstructor() 57 throws IOException 58 { 59 DirectoryProperty property1 = new DirectoryProperty("directory"); 60 RawDataBlock[] rawBlocks = new RawDataBlock[ 4 ]; 61 ByteArrayInputStream stream = 62 new ByteArrayInputStream(new byte[ 2048 ]); 63 64 for (int j = 0; j < 4; j++) 65 { 66 rawBlocks[ j ] = new RawDataBlock(stream); 67 } 68 POIFSDocument document = new POIFSDocument("document", rawBlocks, 69 2000); 70 DocumentProperty property2 = document.getDocumentProperty(); 71 DirectoryNode parent = new DirectoryNode(property1, null, null); 72 DocumentNode node = new DocumentNode(property2, parent); 73 74 assertEquals(property2.getDocument(), node.getDocument()); 76 77 assertEquals(property2.getSize(), node.getSize()); 79 80 assertTrue(node.isDocumentEntry()); 82 83 assertTrue(!node.isDirectoryEntry()); 85 86 assertEquals(property2.getName(), node.getName()); 88 89 assertEquals(parent, node.getParent()); 91 } 92 93 98 99 public static void main(String [] ignored_args) 100 { 101 System.out 102 .println("Testing org.apache.poi.poifs.filesystem.DocumentNode"); 103 junit.textui.TestRunner.run(TestDocumentNode.class); 104 } 105 } 106 | Popular Tags |