1 2 17 18 19 20 package org.apache.poi.hssf.record; 21 22 23 import junit.framework.TestCase; 24 25 33 public class TestCommonObjectDataSubRecord 34 extends TestCase 35 { 36 byte[] data = new byte[] { 37 (byte)0x12,(byte)0x00,(byte)0x01,(byte)0x00, 38 (byte)0x01,(byte)0x00,(byte)0x11,(byte)0x60, 39 (byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00, 40 (byte)0x00,(byte)0x0D,(byte)0x26,(byte)0x01, 41 (byte)0x00,(byte)0x00, 42 }; 43 44 public TestCommonObjectDataSubRecord(String name) 45 { 46 super(name); 47 } 48 49 public void testLoad() 50 throws Exception 51 { 52 CommonObjectDataSubRecord record = new CommonObjectDataSubRecord((short)0x15, (short)data.length, data); 53 54 55 assertEquals( CommonObjectDataSubRecord.OBJECT_TYPE_LIST_BOX, record.getObjectType()); 56 assertEquals( (short)1, record.getObjectId()); 57 assertEquals( (short)1, record.getOption()); 58 assertEquals( true , record.isLocked() ); 59 assertEquals( false, record.isPrintable() ); 60 assertEquals( false, record.isAutofill() ); 61 assertEquals( false, record.isAutoline() ); 62 assertEquals( (int)24593, record.getReserved1()); 63 assertEquals( (int)218103808, record.getReserved2()); 64 assertEquals( (int)294, record.getReserved3()); 65 assertEquals( 22 , record.getRecordSize() ); 66 67 record.validateSid((short)0x15); 68 } 69 70 public void testStore() 71 { 72 CommonObjectDataSubRecord record = new CommonObjectDataSubRecord(); 73 74 record.setObjectType( CommonObjectDataSubRecord.OBJECT_TYPE_LIST_BOX ); 75 record.setObjectId( (short) 1); 76 record.setOption( (short) 1); 77 record.setLocked( true ); 78 record.setPrintable( false ); 79 record.setAutofill( false ); 80 record.setAutoline( false ); 81 record.setReserved1( (int) 24593); 82 record.setReserved2( (int) 218103808); 83 record.setReserved3( (int) 294); 84 85 byte [] recordBytes = record.serialize(); 86 assertEquals(recordBytes.length - 4, data.length); 87 for (int i = 0; i < data.length; i++) 88 assertEquals("At offset " + i, data[i], recordBytes[i+4]); 89 } 90 } 91 | Popular Tags |