1 2 17 18 package org.apache.poi.ddf; 19 20 import junit.framework.TestCase; 21 import org.apache.poi.util.HexDump; 22 import org.apache.poi.util.HexRead; 23 24 public class TestEscherDgRecord extends TestCase 25 { 26 public void testSerialize() throws Exception 27 { 28 EscherDgRecord r = createRecord(); 29 30 byte[] data = new byte[16]; 31 int bytesWritten = r.serialize( 0, data, new NullEscherSerializationListener() ); 32 assertEquals( 16, bytesWritten ); 33 assertEquals( "[10, 00, " + 34 "08, F0, " + 35 "08, 00, 00, 00, " + 36 "02, 00, 00, 00, " + "01, 04, 00, 00, ]", HexDump.toHex( data ) ); 39 } 40 41 public void testFillFields() throws Exception 42 { 43 String hexData = "10 00 " + 44 "08 F0 " + 45 "08 00 00 00 " + 46 "02 00 00 00 " + 47 "01 04 00 00 "; 48 byte[] data = HexRead.readFromString( hexData ); 49 EscherDgRecord r = new EscherDgRecord(); 50 int bytesWritten = r.fillFields( data, new DefaultEscherRecordFactory() ); 51 52 assertEquals( 16, bytesWritten ); 53 assertEquals( 2, r.getNumShapes() ); 54 assertEquals( 1025, r.getLastMSOSPID() ); 55 } 56 57 public void testToString() throws Exception 58 { 59 String nl = System.getProperty("line.separator"); 60 61 String expected = "org.apache.poi.ddf.EscherDgRecord:" + nl + 62 " RecordId: 0xF008" + nl + 63 " Options: 0x0010" + nl + 64 " NumShapes: 2" + nl + 65 " LastMSOSPID: 1025" + nl; 66 assertEquals( expected, createRecord().toString() ); 67 } 68 69 private EscherDgRecord createRecord() 70 { 71 EscherDgRecord r = new EscherDgRecord(); 72 r.setOptions( (short) 0x0010 ); 73 r.setRecordId( EscherDgRecord.RECORD_ID ); 74 r.setNumShapes(2); 75 r.setLastMSOSPID(1025); 76 return r; 77 } 78 79 } 80 | Popular Tags |