TestObjRecordpublic class TestObjRecord extends TestCase Tests the serialization and deserialization of the ObjRecord class works correctly.
Test data taken directly from a real Excel file. |
Fields Summary |
---|
public static byte[] | recdataOBJ record data containing two sub-records.
The data taken directly from a real Excel file.
[OBJ]
[ftCmo]
[ftEnd] |
Methods Summary |
---|
public void | testConstruct()
ObjRecord record = new ObjRecord();
CommonObjectDataSubRecord ftCmo = new CommonObjectDataSubRecord();
ftCmo.setObjectType( CommonObjectDataSubRecord.OBJECT_TYPE_COMMENT);
ftCmo.setObjectId( (short) 1024 );
ftCmo.setLocked( true );
ftCmo.setPrintable( true );
ftCmo.setAutofill( true );
ftCmo.setAutoline( true );
record.addSubRecord(ftCmo);
EndSubRecord ftEnd = new EndSubRecord();
record.addSubRecord(ftEnd);
//serialize and read again
byte [] recordBytes = record.serialize();
//cut off the record header
byte [] bytes = new byte[recordBytes.length-4];
System.arraycopy(recordBytes, 4, bytes, 0, bytes.length);
record = new ObjRecord(new TestcaseRecordInputStream(ObjRecord.sid, (short)bytes.length, bytes));
List subrecords = record.getSubRecords();
assertEquals( 2, subrecords.size() );
assertTrue( subrecords.get(0) instanceof CommonObjectDataSubRecord);
assertTrue( subrecords.get(1) instanceof EndSubRecord );
| public void | testLoad()
ObjRecord record = new ObjRecord(new TestcaseRecordInputStream(ObjRecord.sid, (short)recdata.length, recdata));
assertEquals( recdata.length, record.getRecordSize() - 4);
List subrecords = record.getSubRecords();
assertEquals( 2, subrecords.size() );
assertTrue( subrecords.get(0) instanceof CommonObjectDataSubRecord);
assertTrue( subrecords.get(1) instanceof EndSubRecord );
| public void | testStore()
ObjRecord record = new ObjRecord(new TestcaseRecordInputStream(ObjRecord.sid, (short)recdata.length, recdata));
byte [] recordBytes = record.serialize();
assertEquals(recdata.length, recordBytes.length - 4);
byte[] subData = new byte[recordBytes.length - 4];
System.arraycopy(recordBytes, 4, subData, 0, subData.length);
assertTrue(Arrays.equals(recdata, subData));
|
|