KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > poi > hwpf > model > TestListTables


1
2 /* ====================================================================
3    Copyright 2002-2004 Apache Software Foundation
4
5    Licensed under the Apache License, Version 2.0 (the "License");
6    you may not use this file except in compliance with the License.
7    You may obtain a copy of the License at
8
9        http://www.apache.org/licenses/LICENSE-2.0
10
11    Unless required by applicable law or agreed to in writing, software
12    distributed under the License is distributed on an "AS IS" BASIS,
13    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14    See the License for the specific language governing permissions and
15    limitations under the License.
16 ==================================================================== */

17         
18 package org.apache.poi.hwpf.model;
19
20 import junit.framework.*;
21 import org.apache.poi.hwpf.*;
22 import org.apache.poi.hwpf.model.io.*;
23
24 import java.io.*;
25 import java.util.*;
26
27
28 public class TestListTables
29   extends HWPFTestCase
30 {
31
32   public TestListTables()
33   {
34   }
35
36   public void testReadWrite()
37     throws Exception JavaDoc
38   {
39     FileInformationBlock fib = _hWPFDocFixture._fib;
40     byte[] tableStream = _hWPFDocFixture._tableStream;
41
42     int listOffset = fib.getFcPlcfLst();
43     int lfoOffset = fib.getFcPlfLfo();
44     if (listOffset != 0 && fib.getLcbPlcfLst() != 0)
45     {
46       ListTables listTables = new ListTables (tableStream, fib.getFcPlcfLst (),
47                                               fib.getFcPlfLfo ());
48       HWPFFileSystem fileSys = new HWPFFileSystem ();
49
50       HWPFOutputStream tableOut = fileSys.getStream ("1Table");
51
52       listTables.writeListDataTo (tableOut);
53       int offset = tableOut.getOffset ();
54       listTables.writeListOverridesTo (tableOut);
55
56       ListTables newTables = new ListTables (tableOut.toByteArray (), 0, offset);
57
58       assertEquals(listTables, newTables);
59
60     }
61   }
62
63 }
64
Popular Tags