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: import org.apache.poi.hwpf.*;
22:
23: import java.lang.reflect.*;
24:
25: public class TestFileInformationBlock extends TestCase {
26: private FileInformationBlock _fileInformationBlock = null;
27: private HWPFDocFixture _hWPFDocFixture;
28:
29: public TestFileInformationBlock(String name) {
30: super (name);
31: }
32:
33: public void testReadWrite() throws Exception {
34: int size = _fileInformationBlock.getSize();
35: byte[] buf = new byte[size];
36:
37: _fileInformationBlock.serialize(buf, 0);
38:
39: FileInformationBlock newFileInformationBlock = new FileInformationBlock(
40: buf);
41:
42: Field[] fields = FileInformationBlock.class.getSuperclass()
43: .getDeclaredFields();
44: AccessibleObject.setAccessible(fields, true);
45:
46: for (int x = 0; x < fields.length; x++) {
47: assertEquals(fields[x].get(_fileInformationBlock),
48: fields[x].get(newFileInformationBlock));
49: }
50: }
51:
52: protected void setUp() throws Exception {
53: super .setUp();
54: /**@todo verify the constructors*/
55: _hWPFDocFixture = new HWPFDocFixture(this );
56:
57: _hWPFDocFixture.setUp();
58: _fileInformationBlock = _hWPFDocFixture._fib;
59: }
60:
61: protected void tearDown() throws Exception {
62: _fileInformationBlock = null;
63: _hWPFDocFixture.tearDown();
64:
65: _hWPFDocFixture = null;
66: super.tearDown();
67: }
68:
69: }
|