KickJava   Java API By Example, From Geeks To Geeks.

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


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

17         
18
19
20 package org.apache.poi.hssf.record;
21
22
23 import junit.framework.TestCase;
24
25 /**
26  * Tests the serialization and deserialization of the EndSubRecord
27  * class works correctly. Test data taken directly from a real
28  * Excel file.
29  *
30  * @author Glen Stampoultzis (glens at apache.org)
31  */

32 public class TestEndSubRecord
33         extends TestCase
34 {
35     byte[] data = new byte[] {
36     
37     };
38
39     public TestEndSubRecord(String JavaDoc name)
40     {
41         super(name);
42     }
43
44     public void testLoad()
45             throws Exception JavaDoc
46     {
47         EndSubRecord record = new EndSubRecord((short)0x00, (short)data.length, data);
48         
49
50
51         assertEquals( 4, record.getRecordSize() );
52
53         record.validateSid((short)0x00);
54     }
55
56     public void testStore()
57     {
58         EndSubRecord record = new EndSubRecord();
59
60         byte [] recordBytes = record.serialize();
61         assertEquals(recordBytes.length - 4, data.length);
62         for (int i = 0; i < data.length; i++)
63             assertEquals("At offset " + i, data[i], recordBytes[i+4]);
64     }
65 }
66
Popular Tags