poi-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sack...@apache.org
Subject cvs commit: jakarta-poi/src/scratchpad/testcases/org/apache/poi/hwpf/model/hdftypes TestDocumentProperties.java TestFontTable.java
Date Tue, 15 Jul 2003 03:23:40 GMT
sackley     2003/07/14 20:23:40

  Added:       src/scratchpad/testcases/org/apache/poi/hwpf/model/hdftypes
                        TestDocumentProperties.java TestFontTable.java
  Log:
  Reached first milestone
  
  Revision  Changes    Path
  1.1                  jakarta-poi/src/scratchpad/testcases/org/apache/poi/hwpf/model/hdftypes/TestDocumentProperties.java
  
  Index: TestDocumentProperties.java
  ===================================================================
  package org.apache.poi.hwpf.model.hdftypes;
  
  import junit.framework.*;
  import org.apache.poi.hwpf.*;
  
  import java.lang.reflect.*;
  import java.util.Arrays;
  
  public class TestDocumentProperties
    extends TestCase
  {
    private DocumentProperties _documentProperties = null;
    private HWPFDocFixture _hWPFDocFixture;
  
    public TestDocumentProperties(String name)
    {
      super(name);
    }
  
  
    public void testReadWrite()
      throws Exception
    {
      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);
        }
      }
  
    }
  
    protected void setUp()
      throws Exception
    {
      super.setUp();
      /**@todo verify the constructors*/
  
      _hWPFDocFixture = new HWPFDocFixture(this);
  
      _hWPFDocFixture.setUp();
  
      _documentProperties = new DocumentProperties(_hWPFDocFixture._tableStream, _hWPFDocFixture._fib.getFcDop());
    }
  
    protected void tearDown()
      throws Exception
    {
      _documentProperties = null;
      _hWPFDocFixture.tearDown();
  
      _hWPFDocFixture = null;
      super.tearDown();
    }
  
  }
  
  
  
  1.1                  jakarta-poi/src/scratchpad/testcases/org/apache/poi/hwpf/model/hdftypes/TestFontTable.java
  
  Index: TestFontTable.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache POI" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache POI", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.poi.hwpf.model.hdftypes;
  
  import junit.framework.*;
  import org.apache.poi.hwpf.*;
  import org.apache.poi.hwpf.model.io.*;
  
  import java.io.*;
  import java.util.*;
  
  public class TestFontTable
    extends TestCase
  {
    private FontTable _fontTable = null;
    private HWPFDocFixture _hWPFDocFixture;
  
    public TestFontTable(String name)
    {
      super(name);
    }
  
    public void testReadWrite()
      throws Exception
    {
      FileInformationBlock fib = _hWPFDocFixture._fib;
      byte[] tableStream = _hWPFDocFixture._tableStream;
  
      int fcSttbfffn = fib.getFcSttbfffn();
      int lcbSttbfffn = fib.getLcbSttbfffn();
  
      _fontTable = new FontTable(tableStream, fcSttbfffn, lcbSttbfffn);
  
      HWPFFileSystem fileSys = new HWPFFileSystem();
  
      _fontTable.writeTo(fileSys);
      HWPFOutputStream  tableOut = fileSys.getStream("1Table");
  
  
      byte[] newTableStream = tableOut.toByteArray();
  
  
      FontTable newFontTable = new FontTable(newTableStream, 0, newTableStream.length);
  
  	  assertTrue(_fontTable.equals(newFontTable));
  
    }
  
    protected void setUp()
      throws Exception
    {
      super.setUp();
      /**@todo verify the constructors*/
      _hWPFDocFixture = new HWPFDocFixture(this);
  
      _hWPFDocFixture.setUp();
    }
  
    protected void tearDown()
      throws Exception
    {
      _hWPFDocFixture.tearDown();
  
      _hWPFDocFixture = null;
      super.tearDown();
    }
  
  }
  
  
  
  

Mime
View raw message