public void testReadWrite() throws Exception { FileInformationBlock fib = _hWPFDocFixture._fib; byte[] mainStream = _hWPFDocFixture._mainStream; byte[] tableStream = _hWPFDocFixture._tableStream; int fcMin = fib.getFibBase().getFcMin(); _cHPBinTable = new CHPBinTable( mainStream, tableStream, fib.getFcPlcfbteChpx(), fib.getLcbPlcfbteChpx(), fakeTPT); HWPFFileSystem fileSys = new HWPFFileSystem(); _cHPBinTable.writeTo(fileSys, 0, fakeTPT); ByteArrayOutputStream tableOut = fileSys.getStream("1Table"); ByteArrayOutputStream mainOut = fileSys.getStream("WordDocument"); byte[] newTableStream = tableOut.toByteArray(); byte[] newMainStream = mainOut.toByteArray(); CHPBinTable newBinTable = new CHPBinTable(newMainStream, newTableStream, 0, newTableStream.length, fakeTPT); List<CHPX> oldTextRuns = _cHPBinTable._textRuns; List<CHPX> newTextRuns = newBinTable._textRuns; assertEquals(oldTextRuns.size(), newTextRuns.size()); int size = oldTextRuns.size(); for (int x = 0; x < size; x++) { CHPX oldNode = oldTextRuns.get(x); CHPX newNode = newTextRuns.get(x); assertTrue(oldNode.equals(newNode)); } }
protected void setUp() throws Exception { super.setUp(); /** @todo verify the constructors */ _hWPFDocFixture = new HWPFDocFixture(this); _hWPFDocFixture.setUp(); FileInformationBlock fib = _hWPFDocFixture._fib; byte[] mainStream = _hWPFDocFixture._mainStream; byte[] tableStream = _hWPFDocFixture._tableStream; _hWPFDocFixture.setUp(); _styleSheet = new StyleSheet(tableStream, fib.getFcStshf()); }