FileDocCategorySizeDatePackage
TestDocumentProperties.javaAPI DocApache Poi 3.0.12619Mon Jan 01 18:55:36 GMT 2007org.apache.poi.hwpf.model

TestDocumentProperties

public class TestDocumentProperties extends TestCase

Fields Summary
private DocumentProperties
_documentProperties
private HWPFDocFixture
_hWPFDocFixture
Constructors Summary
public TestDocumentProperties(String name)


    
  
    super(name);
  
Methods Summary
protected voidsetUp()

    super.setUp();
    /**@todo verify the constructors*/

    _hWPFDocFixture = new HWPFDocFixture(this);

    _hWPFDocFixture.setUp();

    _documentProperties = new DocumentProperties(_hWPFDocFixture._tableStream, _hWPFDocFixture._fib.getFcDop());
  
protected voidtearDown()

    _documentProperties = null;
    _hWPFDocFixture.tearDown();

    _hWPFDocFixture = null;
    super.tearDown();
  
public voidtestReadWrite()

    int size = _documentProperties.getSize();
    byte[] buf = new byte[size];

    _documentProperties.serialize(buf, 0);

    DocumentProperties newDocProperties =
      new DocumentProperties(buf, 0);

    Field[] fields = DocumentProperties.class.getSuperclass().getDeclaredFields();
    AccessibleObject.setAccessible(fields, true);

    for (int x = 0; x < fields.length; x++)
    {
      if (!fields[x].getType().isArray())
      {
        assertEquals(fields[x].get(_documentProperties),
                     fields[x].get(newDocProperties));
      }
      else
      {
        byte[] buf1 = (byte[])fields[x].get(_documentProperties);
        byte[] buf2 = (byte[])fields[x].get(newDocProperties);
        Arrays.equals(buf1, buf2);
      }
    }