KickJava   Java API By Example, From Geeks To Geeks.

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


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
19 package org.apache.poi.hwpf.model;
20
21 import junit.framework.*;
22
23 import org.apache.poi.hwpf.*;
24 import org.apache.poi.hwpf.model.io.*;
25 import java.io.*;
26
27 public class TestStyleSheet
28   extends TestCase
29 {
30   private StyleSheet _styleSheet = null;
31   private HWPFDocFixture _hWPFDocFixture;
32
33
34   public TestStyleSheet(String JavaDoc name)
35   {
36     super(name);
37   }
38
39   public void testReadWrite()
40     throws Exception JavaDoc
41   {
42     HWPFFileSystem fileSys = new HWPFFileSystem();
43
44
45     HWPFOutputStream tableOut = fileSys.getStream("1Table");
46     HWPFOutputStream mainOut = fileSys.getStream("WordDocument");
47
48     _styleSheet.writeTo(tableOut);
49
50     byte[] newTableStream = tableOut.toByteArray();
51
52     StyleSheet newStyleSheet = new StyleSheet(newTableStream, 0);
53     assertEquals(newStyleSheet, _styleSheet);
54
55   }
56
57   protected void setUp()
58     throws Exception JavaDoc
59   {
60     super.setUp();
61     /**@todo verify the constructors*/
62     _hWPFDocFixture = new HWPFDocFixture(this);
63     _hWPFDocFixture.setUp();
64     FileInformationBlock fib = _hWPFDocFixture._fib;
65     byte[] mainStream = _hWPFDocFixture._mainStream;
66     byte[] tableStream = _hWPFDocFixture._tableStream;
67
68     _hWPFDocFixture.setUp();
69     _styleSheet = new StyleSheet(tableStream, fib.getFcStshf());
70   }
71
72   protected void tearDown()
73     throws Exception JavaDoc
74   {
75     _styleSheet = null;
76     _hWPFDocFixture.tearDown();
77
78     _hWPFDocFixture = null;
79     super.tearDown();
80   }
81
82 }
83
Popular Tags