1 2 17 18 package org.apache.poi.hwpf.model; 19 20 import junit.framework.*; 21 22 import java.io.ByteArrayOutputStream ; 23 import java.util.ArrayList ; 24 25 import org.apache.poi.hwpf.*; 26 import org.apache.poi.hwpf.model.io.*; 27 28 29 public class TestTextPieceTable 30 extends TestCase 31 { 32 private HWPFDocFixture _hWPFDocFixture; 33 34 public TestTextPieceTable(String name) 35 { 36 super(name); 37 } 38 39 public void testReadWrite() 40 throws Exception 41 { 42 FileInformationBlock fib = _hWPFDocFixture._fib; 43 byte[] mainStream = _hWPFDocFixture._mainStream; 44 byte[] tableStream = _hWPFDocFixture._tableStream; 45 int fcMin = fib.getFcMin(); 46 47 ComplexFileTable cft = new ComplexFileTable(mainStream, tableStream, fib.getFcClx(), fcMin); 48 49 50 HWPFFileSystem fileSys = new HWPFFileSystem(); 51 52 cft.writeTo(fileSys); 53 ByteArrayOutputStream tableOut = fileSys.getStream("1Table"); 54 ByteArrayOutputStream mainOut = fileSys.getStream("WordDocument"); 55 56 byte[] newTableStream = tableOut.toByteArray(); 57 byte[] newMainStream = mainOut.toByteArray(); 58 59 ComplexFileTable newCft = new ComplexFileTable(newMainStream, newTableStream, 0,0); 60 61 TextPieceTable oldTextPieceTable = cft.getTextPieceTable(); 62 TextPieceTable newTextPieceTable = newCft.getTextPieceTable(); 63 64 assertEquals(oldTextPieceTable, newTextPieceTable); 65 66 67 } 68 protected void setUp() 69 throws Exception 70 { 71 super.setUp(); 72 73 _hWPFDocFixture = new HWPFDocFixture(this); 74 _hWPFDocFixture.setUp(); 75 } 76 77 protected void tearDown() 78 throws Exception 79 { 80 _hWPFDocFixture.tearDown(); 81 82 _hWPFDocFixture = null; 83 super.tearDown(); 84 } 85 86 } 87 | Popular Tags |