FileDocCategorySizeDatePackage
TestTextPieceTable.javaAPI DocApache Poi 3.0.12555Mon Jan 01 18:55:36 GMT 2007org.apache.poi.hwpf.model

TestTextPieceTable

public class TestTextPieceTable extends TestCase

Fields Summary
private HWPFDocFixture
_hWPFDocFixture
Constructors Summary
public TestTextPieceTable(String name)

    super(name);
  
Methods Summary
protected voidsetUp()

    super.setUp();

    _hWPFDocFixture = new HWPFDocFixture(this);
    _hWPFDocFixture.setUp();
  
protected voidtearDown()

    _hWPFDocFixture.tearDown();

    _hWPFDocFixture = null;
    super.tearDown();
  
public voidtestReadWrite()

    FileInformationBlock fib = _hWPFDocFixture._fib;
    byte[] mainStream = _hWPFDocFixture._mainStream;
    byte[] tableStream = _hWPFDocFixture._tableStream;
    int fcMin = fib.getFcMin();

    ComplexFileTable cft = new ComplexFileTable(mainStream, tableStream, fib.getFcClx(), fcMin);


    HWPFFileSystem fileSys = new HWPFFileSystem();

    cft.writeTo(fileSys);
    ByteArrayOutputStream tableOut = fileSys.getStream("1Table");
    ByteArrayOutputStream mainOut =  fileSys.getStream("WordDocument");

    byte[] newTableStream = tableOut.toByteArray();
    byte[] newMainStream = mainOut.toByteArray();

    ComplexFileTable newCft = new ComplexFileTable(newMainStream, newTableStream, 0,0);

    TextPieceTable oldTextPieceTable = cft.getTextPieceTable();
    TextPieceTable newTextPieceTable = newCft.getTextPieceTable();

    assertEquals(oldTextPieceTable, newTextPieceTable);