1 2 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 name) 32 { 33 super(name); 34 } 35 36 public void testReadWrite() 37 throws Exception 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 58 { 59 super.setUp(); 60 61 _hWPFDocFixture = new HWPFDocFixture(this); 62 63 _hWPFDocFixture.setUp(); 64 _fileInformationBlock = _hWPFDocFixture._fib; 65 } 66 67 protected void tearDown() 68 throws Exception 69 { 70 _fileInformationBlock = null; 71 _hWPFDocFixture.tearDown(); 72 73 _hWPFDocFixture = null; 74 super.tearDown(); 75 } 76 77 } 78 | Popular Tags |