KickJava   Java API By Example, From Geeks To Geeks.

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


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