1 2 17 18 19 package org.apache.poi.poifs.storage; 20 21 import java.io.*; 22 23 import java.util.*; 24 25 import junit.framework.*; 26 27 import org.apache.poi.poifs.filesystem.POIFSDocument; 28 import org.apache.poi.poifs.property.PropertyTable; 29 import org.apache.poi.poifs.property.RootProperty; 30 31 36 37 public class TestSmallBlockTableWriter 38 extends TestCase 39 { 40 41 46 47 public TestSmallBlockTableWriter(String name) 48 { 49 super(name); 50 } 51 52 57 58 public void testWritingConstructor() 59 throws IOException 60 { 61 List documents = new ArrayList(); 62 63 documents.add( 64 new POIFSDocument( 65 "doc340", new ByteArrayInputStream(new byte[ 340 ]))); 66 documents.add( 67 new POIFSDocument( 68 "doc5000", new ByteArrayInputStream(new byte[ 5000 ]))); 69 documents 70 .add(new POIFSDocument("doc0", 71 new ByteArrayInputStream(new byte[ 0 ]))); 72 documents 73 .add(new POIFSDocument("doc1", 74 new ByteArrayInputStream(new byte[ 1 ]))); 75 documents 76 .add(new POIFSDocument("doc2", 77 new ByteArrayInputStream(new byte[ 2 ]))); 78 documents 79 .add(new POIFSDocument("doc3", 80 new ByteArrayInputStream(new byte[ 3 ]))); 81 documents 82 .add(new POIFSDocument("doc4", 83 new ByteArrayInputStream(new byte[ 4 ]))); 84 documents 85 .add(new POIFSDocument("doc5", 86 new ByteArrayInputStream(new byte[ 5 ]))); 87 documents 88 .add(new POIFSDocument("doc6", 89 new ByteArrayInputStream(new byte[ 6 ]))); 90 documents 91 .add(new POIFSDocument("doc7", 92 new ByteArrayInputStream(new byte[ 7 ]))); 93 documents 94 .add(new POIFSDocument("doc8", 95 new ByteArrayInputStream(new byte[ 8 ]))); 96 documents 97 .add(new POIFSDocument("doc9", 98 new ByteArrayInputStream(new byte[ 9 ]))); 99 RootProperty root = new PropertyTable().getRoot(); 100 SmallBlockTableWriter sbtw = new SmallBlockTableWriter(documents, 101 root); 102 BlockAllocationTableWriter bat = sbtw.getSBAT(); 103 104 assertEquals(15 * 64, root.getSize()); 107 108 assertEquals(2, sbtw.countBlocks()); 110 int start_block = 1000 + root.getStartBlock(); 111 112 sbtw.setStartBlock(start_block); 113 assertEquals(start_block, root.getStartBlock()); 114 } 115 116 121 122 public static void main(String [] ignored_args) 123 { 124 System.out.println( 125 "Testing org.apache.poi.poifs.storage.SmallBlockTableWriter"); 126 junit.textui.TestRunner.run(TestSmallBlockTableWriter.class); 127 } 128 } 129 | Popular Tags |