Here's an example of the test stub that gets generated.  It's basically just
a case of filling in the blanks.


/* ====================================================================
 * The Apache Software License, Version 1.1
 *
 * Copyright (c) 2002 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 [EMAIL PROTECTED]
 *
 * 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.hssf.record;


import junit.framework.TestCase;

/**
 * Tests the serialization and deserialization of the LegendRecord
 * class works correctly.  Test data taken directly from a real
 * Excel file.
 *

 * @author Glen Stampoultzis (gstamp at iprimus dot com dot au)
 */
public class TestLegendRecord
        extends TestCase
{
    byte[] data = new byte[] {
        // PASTE DATA HERE
    };

    public TestLegendRecord(String name)
    {
        super(name);
    }

    public void testLoad()
            throws Exception
    {

        LegendRecord record = new LegendRecord((short)0x1015,
(short)data.length, data);
        assertEquals( XXX, record.getXPosition());
        assertEquals( XXX, record.getYPosition());
        assertEquals( XXX, record.getXSize());
        assertEquals( XXX, record.getYSize());
        assertEquals( XXX, record.getType());
        assertEquals( XXX, record.getSpacing());
        assertEquals( XXX, record.getOptions());
        assertEquals( XXX, record.isAutoPosition() );
        assertEquals( XXX, record.isAutoSeries() );
        assertEquals( XXX, record.isAutoPosX() );
        assertEquals( XXX, record.isAutoPosY() );
        assertEquals( XXX, record.isVert() );
        assertEquals( XXX, record.isContainsDataTable() );


        assertEquals( XXX, record.getRecordSize() );

        record.validateSid((short)0x1015);
    }

    public void testStore()
    {
        LegendRecord record = new LegendRecord();
        record.setXPosition( XXXX );
        record.setYPosition( XXXX );
        record.setXSize( XXXX );
        record.setYSize( XXXX );
        record.setType( XXXX );
        record.setSpacing( XXXX );
        record.setOptions( XXXX );
        record.setAutoPosition( XXX );
        record.setAutoSeries( XXX );
        record.setAutoPosX( XXX );
        record.setAutoPosY( XXX );
        record.setVert( XXX );
        record.setContainsDataTable( XXX );


        byte [] recordBytes = record.serialize();
        assertEquals(recordBytes.length - 4, data.length);
        for (int i = 0; i < data.length; i++)
            assertEquals("At offset " + i, data[i], recordBytes[i+4]);
    }
}


----- Original Message -----
From: "Marc" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, February 05, 2002 1:46 PM
Subject: Re: POI Record Generator


> Glen Stampoultzis wrote:
>
> >Hrrm, very quiet around here at the moment.  Just wanted to let you know
> >I've also written a test stub generator for records.  It just creates a
test
> >stub for you, you then take that and fill it out to complete your test
case.
> >Also started on a generator for documentation.  Now that I'm getting
better
> >with XSL I can churn these out fairly quickly.
> >
> Generating test stubs is interesting. Even more interesting would be if
> you can take a class and generate test methods for every package-scope
> and public method ...
>
> As for the quiet ... now that I'm working again, Monday is a bad time
> for me ... but I'll be back crankin' out code later this week.
>
> Also, still puzzling out formula stuff when I can spare the time.
>
>
>

Reply via email to