KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > poi > hssf > record > TestDrawingGroupRecord


1 /* ====================================================================
2    Copyright 2003-2004 Apache Software Foundation
3
4    Licensed under the Apache License, Version 2.0 (the "License");
5    you may not use this file except in compliance with the License.
6    You may obtain a copy of the License at
7
8        http://www.apache.org/licenses/LICENSE-2.0
9
10    Unless required by applicable law or agreed to in writing, software
11    distributed under the License is distributed on an "AS IS" BASIS,
12    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13    See the License for the specific language governing permissions and
14    limitations under the License.
15 ==================================================================== */

16
17 package org.apache.poi.hssf.record;
18
19 import junit.framework.TestCase;
20 import org.apache.poi.ddf.EscherContainerRecord;
21 import org.apache.poi.ddf.EscherSpRecord;
22 import org.apache.poi.util.HexDump;
23
24 public class TestDrawingGroupRecord extends TestCase
25 {
26     public void testGetRecordSize()
27             throws Exception JavaDoc
28     {
29         DrawingGroupRecord r = new DrawingGroupRecord();
30         assertEquals(4, r.getRecordSize());
31
32         EscherSpRecord sp = new EscherSpRecord();
33         sp.setRecordId(EscherSpRecord.RECORD_ID);
34         sp.setOptions((short) 0x1111);
35         sp.setFlags(-1);
36         sp.setShapeId(-1);
37         EscherContainerRecord dggContainer = new EscherContainerRecord();
38         dggContainer.setOptions((short) 0x000F);
39         dggContainer.setRecordId((short) 0xF000);
40         dggContainer.addChildRecord(sp);
41
42         r.addEscherRecord(dggContainer);
43         assertEquals(28, r.getRecordSize());
44
45         byte[] data = new byte[28];
46         int size = r.serialize(0, data);
47         assertEquals("[EB, 00, 18, 00, 0F, 00, 00, F0, 10, 00, 00, 00, 11, 11, 0A, F0, 08, 00, 00, 00, FF, FF, FF, FF, FF, FF, FF, FF, ]", HexDump.toHex(data));
48         assertEquals(28, size);
49
50         assertEquals(24, dggContainer.getRecordSize());
51     }
52 }
53
Popular Tags