01: /* ====================================================================
02: Licensed to the Apache Software Foundation (ASF) under one or more
03: contributor license agreements. See the NOTICE file distributed with
04: this work for additional information regarding copyright ownership.
05: The ASF licenses this file to You under the Apache License, Version 2.0
06: (the "License"); you may not use this file except in compliance with
07: the License. You may obtain a copy of the License at
08:
09: 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:
22: import org.apache.poi.hwpf.*;
23: import org.apache.poi.hwpf.model.io.*;
24:
25: public class TestStyleSheet extends TestCase {
26: private StyleSheet _styleSheet = null;
27: private HWPFDocFixture _hWPFDocFixture;
28:
29: public TestStyleSheet(String name) {
30: super (name);
31: }
32:
33: public void testReadWrite() throws Exception {
34: HWPFFileSystem fileSys = new HWPFFileSystem();
35:
36: HWPFOutputStream tableOut = fileSys.getStream("1Table");
37: HWPFOutputStream mainOut = fileSys.getStream("WordDocument");
38:
39: _styleSheet.writeTo(tableOut);
40:
41: byte[] newTableStream = tableOut.toByteArray();
42:
43: StyleSheet newStyleSheet = new StyleSheet(newTableStream, 0);
44: assertEquals(newStyleSheet, _styleSheet);
45:
46: }
47:
48: protected void setUp() throws Exception {
49: super .setUp();
50: /**@todo verify the constructors*/
51: _hWPFDocFixture = new HWPFDocFixture(this );
52: _hWPFDocFixture.setUp();
53: FileInformationBlock fib = _hWPFDocFixture._fib;
54: byte[] mainStream = _hWPFDocFixture._mainStream;
55: byte[] tableStream = _hWPFDocFixture._tableStream;
56:
57: _hWPFDocFixture.setUp();
58: _styleSheet = new StyleSheet(tableStream, fib.getFcStshf());
59: }
60:
61: protected void tearDown() throws Exception {
62: _styleSheet = null;
63: _hWPFDocFixture.tearDown();
64:
65: _hWPFDocFixture = null;
66: super.tearDown();
67: }
68:
69: }
|