]> source.dussan.org Git - poi.git/commitdiff
nother test
authorSaid Ryan Ackley <sackley@apache.org>
Thu, 10 Jul 2003 12:25:46 +0000 (12:25 +0000)
committerSaid Ryan Ackley <sackley@apache.org>
Thu, 10 Jul 2003 12:25:46 +0000 (12:25 +0000)
git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@353203 13f79535-47bb-0310-9956-ffa450edef68

src/scratchpad/testcases/org/apache/poi/hwpf/model/hdftypes/TestTextPieceTable.java [new file with mode: 0644]

diff --git a/src/scratchpad/testcases/org/apache/poi/hwpf/model/hdftypes/TestTextPieceTable.java b/src/scratchpad/testcases/org/apache/poi/hwpf/model/hdftypes/TestTextPieceTable.java
new file mode 100644 (file)
index 0000000..1898778
--- /dev/null
@@ -0,0 +1,69 @@
+package org.apache.poi.hwpf.model.hdftypes;
+
+import junit.framework.*;
+
+import java.io.ByteArrayOutputStream;
+import java.util.ArrayList;
+
+import org.apache.poi.hwpf.*;
+import org.apache.poi.hwpf.model.io.*;
+
+
+public class TestTextPieceTable
+  extends TestCase
+{
+  private HWPFDocFixture _hWPFDocFixture;
+
+  public TestTextPieceTable(String name)
+  {
+    super(name);
+  }
+
+  public void testReadWrite()
+    throws Exception
+  {
+    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);
+
+
+  }
+  protected void setUp()
+    throws Exception
+  {
+    super.setUp();
+
+    _hWPFDocFixture = new HWPFDocFixture(this);
+    _hWPFDocFixture.setUp();
+  }
+
+  protected void tearDown()
+    throws Exception
+  {
+    _hWPFDocFixture.tearDown();
+
+    _hWPFDocFixture = null;
+    super.tearDown();
+  }
+
+}