FileDocCategorySizeDatePackage
TestLinkedDataRecord.javaAPI DocApache Poi 3.0.18515Mon Jan 01 12:39:46 GMT 2007org.apache.poi.hssf.record

TestLinkedDataRecord

public class TestLinkedDataRecord extends TestCase
Tests the serialization and deserialization of the LinkedDataRecord class works correctly. Test data taken directly from a real Excel file.
author
Glen Stampoultzis (glens at apache.org)

Fields Summary
byte[]
data
Constructors Summary
public TestLinkedDataRecord(String name)


      
    
        super(name);
    
Methods Summary
public voidtestLoad()


        LinkedDataRecord record = new LinkedDataRecord(new TestcaseRecordInputStream((short)0x1051, (short)data.length, data));
        assertEquals( LinkedDataRecord.LINK_TYPE_VALUES, record.getLinkType());
        assertEquals( LinkedDataRecord.REFERENCE_TYPE_WORKSHEET, record.getReferenceType());
        assertEquals( 0, record.getOptions());
        assertEquals( false, record.isCustomNumberFormat() );
        assertEquals( 0, record.getIndexNumberFmtRecord());

        Area3DPtg ptg = new Area3DPtg();
        ptg.setExternSheetIndex((short)0);
        ptg.setFirstColumn((short)0);
        ptg.setLastColumn((short)0);
        ptg.setFirstRow((short)0);
        ptg.setLastRow((short)7936);
        ptg.setFirstColRelative(false);
        ptg.setLastColRelative(false);
        ptg.setFirstRowRelative(false);
        ptg.setLastRowRelative(false);
        Stack s = new Stack();
        s.push(ptg);
        assertEquals( s, record.getFormulaOfLink().getFormulaTokens() );

        assertEquals( data.length + 4, record.getRecordSize() );

        record.validateSid((short)0x1051);

    
public voidtestStore()

        LinkedDataRecord record = new LinkedDataRecord();
        record.setLinkType( LinkedDataRecord.LINK_TYPE_VALUES );
        record.setReferenceType( LinkedDataRecord.REFERENCE_TYPE_WORKSHEET );
        record.setOptions( (short)0 );
        record.setCustomNumberFormat( false );
        record.setIndexNumberFmtRecord( (short)0 );
        Area3DPtg ptg = new Area3DPtg();
        ptg.setExternSheetIndex((short)0);
        ptg.setFirstColumn((short)0);
        ptg.setLastColumn((short)0);
        ptg.setFirstRow((short)0);
        ptg.setLastRow((short)7936);
        ptg.setFirstColRelative(false);
        ptg.setLastColRelative(false);
        ptg.setFirstRowRelative(false);
        ptg.setLastRowRelative(false);
        Stack s = new Stack();
        s.push(ptg);
        LinkedDataFormulaField formulaOfLink = new LinkedDataFormulaField();
        formulaOfLink.setFormulaTokens(s);
        record.setFormulaOfLink(formulaOfLink );

        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]);