diff options
author | Sergey Vladimirov <sergey@apache.org> | 2011-07-25 11:02:03 +0000 |
---|---|---|
committer | Sergey Vladimirov <sergey@apache.org> | 2011-07-25 11:02:03 +0000 |
commit | 9014b07d8f31c8f948a5a84aa771a434a076ef11 (patch) | |
tree | 7592fcfdbe17a2625cec1c2dd04b3138090ac0fc /src/scratchpad/testcases/org/apache/poi | |
parent | 3962b41951294e9b96039673477fab93190fea46 (diff) | |
download | poi-9014b07d8f31c8f948a5a84aa771a434a076ef11.tar.gz poi-9014b07d8f31c8f948a5a84aa771a434a076ef11.zip |
update assertion in PAPBinTable
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1150628 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/scratchpad/testcases/org/apache/poi')
-rw-r--r-- | src/scratchpad/testcases/org/apache/poi/hwpf/model/TestPAPBinTable.java | 94 |
1 files changed, 42 insertions, 52 deletions
diff --git a/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestPAPBinTable.java b/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestPAPBinTable.java index e34d563acb..95ed6f7ade 100644 --- a/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestPAPBinTable.java +++ b/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestPAPBinTable.java @@ -18,77 +18,67 @@ package org.apache.poi.hwpf.model; import java.io.ByteArrayOutputStream; -import java.util.ArrayList; +import java.util.List; import junit.framework.TestCase; import org.apache.poi.hwpf.HWPFDocFixture; +import org.apache.poi.hwpf.HWPFTestDataSamples; import org.apache.poi.hwpf.model.io.HWPFFileSystem; -public final class TestPAPBinTable - extends TestCase +public final class TestPAPBinTable extends TestCase { - private PAPBinTable _pAPBinTable = null; - private HWPFDocFixture _hWPFDocFixture; - private TextPieceTable fakeTPT = new TextPieceTable(); - - public void testReadWrite() - throws Exception - { - FileInformationBlock fib = _hWPFDocFixture._fib; - byte[] mainStream = _hWPFDocFixture._mainStream; - byte[] tableStream = _hWPFDocFixture._tableStream; - - _pAPBinTable = new PAPBinTable(mainStream, tableStream, null, fib.getFcPlcfbtePapx(), fib.getLcbPlcfbtePapx(), null, fakeTPT, false); - - HWPFFileSystem fileSys = new HWPFFileSystem(); - - _pAPBinTable.writeTo(fileSys, 0); - ByteArrayOutputStream tableOut = fileSys.getStream("1Table"); - ByteArrayOutputStream mainOut = fileSys.getStream("WordDocument"); - - byte[] newTableStream = tableOut.toByteArray(); - byte[] newMainStream = mainOut.toByteArray(); - - PAPBinTable newBinTable = new PAPBinTable(newMainStream, newTableStream, null,0, newTableStream.length, null, fakeTPT, false); + public void testObIs() + { + // shall not fail with assertions on + HWPFTestDataSamples.openSampleFile( "ob_is.doc" ); + } - ArrayList oldTextRuns = _pAPBinTable.getParagraphs(); - ArrayList newTextRuns = newBinTable.getParagraphs(); + public void testReadWrite() throws Exception + { + /** @todo verify the constructors */ + HWPFDocFixture _hWPFDocFixture = new HWPFDocFixture( this, + HWPFDocFixture.DEFAULT_TEST_FILE ); - assertEquals(oldTextRuns.size(), newTextRuns.size()); + _hWPFDocFixture.setUp(); + TextPieceTable fakeTPT = new TextPieceTable(); - int size = oldTextRuns.size(); - for (int x = 0; x < size; x++) - { - PropertyNode oldNode = (PropertyNode)oldTextRuns.get(x); - PropertyNode newNode = (PropertyNode)newTextRuns.get(x); + FileInformationBlock fib = _hWPFDocFixture._fib; + byte[] mainStream = _hWPFDocFixture._mainStream; + byte[] tableStream = _hWPFDocFixture._tableStream; - assertTrue(oldNode.equals(newNode)); - } + PAPBinTable _pAPBinTable = new PAPBinTable( mainStream, tableStream, + null, fib.getFcPlcfbtePapx(), fib.getLcbPlcfbtePapx(), null, + fakeTPT, false ); + HWPFFileSystem fileSys = new HWPFFileSystem(); + _pAPBinTable.writeTo( fileSys, 0 ); + ByteArrayOutputStream tableOut = fileSys.getStream( "1Table" ); + ByteArrayOutputStream mainOut = fileSys.getStream( "WordDocument" ); + byte[] newTableStream = tableOut.toByteArray(); + byte[] newMainStream = mainOut.toByteArray(); - } + PAPBinTable newBinTable = new PAPBinTable( newMainStream, + newTableStream, null, 0, newTableStream.length, null, fakeTPT, + false ); - protected void setUp() - throws Exception - { - super.setUp(); - /**@todo verify the constructors*/ - _hWPFDocFixture = new HWPFDocFixture(this, HWPFDocFixture.DEFAULT_TEST_FILE); + List<PAPX> oldTextRuns = _pAPBinTable.getParagraphs(); + List<PAPX> newTextRuns = newBinTable.getParagraphs(); - _hWPFDocFixture.setUp(); - } + assertEquals( oldTextRuns.size(), newTextRuns.size() ); - protected void tearDown() - throws Exception - { - _hWPFDocFixture.tearDown(); + int size = oldTextRuns.size(); + for ( int x = 0; x < size; x++ ) + { + PAPX oldNode = oldTextRuns.get( x ); + PAPX newNode = newTextRuns.get( x ); - _hWPFDocFixture = null; - super.tearDown(); - } + assertTrue( oldNode.equals( newNode ) ); + } + _hWPFDocFixture.tearDown(); + } } |