KickJava   Java API By Example, From Geeks To Geeks.

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


1         
2 /* ====================================================================
3    Copyright 2003-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 package org.apache.poi.hssf.record;
19
20 import junit.framework.TestCase;
21
22 /**
23  * Tests the NameRecord serializes/deserializes correctly
24  *
25  * @author Danny Mui (dmui at apache dot org)
26  */

27 public class TestNameRecord
28         extends TestCase
29 {
30
31     /**
32      * Makes sure that additional name information is parsed properly such as menu/description
33      */

34     public void testFillExtras()
35     {
36
37         byte[] examples = {
38             (byte) 0x88, (byte) 0x03, (byte) 0x67, (byte) 0x06,
39             (byte) 0x07, (byte) 0x00, (byte) 0x00, (byte) 0x00,
40             (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x23,
41             (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x4D,
42             (byte) 0x61, (byte) 0x63, (byte) 0x72, (byte) 0x6F,
43             (byte) 0x31, (byte) 0x3A, (byte) 0x01, (byte) 0x00,
44             (byte) 0x00, (byte) 0x00, (byte) 0x11, (byte) 0x00,
45             (byte) 0x00, (byte) 0x4D, (byte) 0x61, (byte) 0x63,
46             (byte) 0x72, (byte) 0x6F, (byte) 0x20, (byte) 0x72,
47             (byte) 0x65, (byte) 0x63, (byte) 0x6F, (byte) 0x72,
48             (byte) 0x64, (byte) 0x65, (byte) 0x64, (byte) 0x20,
49             (byte) 0x32, (byte) 0x37, (byte) 0x2D, (byte) 0x53,
50             (byte) 0x65, (byte) 0x70, (byte) 0x2D, (byte) 0x39,
51             (byte) 0x33, (byte) 0x20, (byte) 0x62, (byte) 0x79,
52             (byte) 0x20, (byte) 0x41, (byte) 0x4C, (byte) 0x4C,
53             (byte) 0x57, (byte) 0x4F, (byte) 0x52
54         };
55
56
57         NameRecord name = new NameRecord();
58         name.fillFields( examples, (short) examples.length );
59         String JavaDoc description = name.getDescriptionText();
60         assertNotNull( description );
61         assertTrue( "text contains ALLWOR", description.indexOf( "ALLWOR" ) > 0 );
62
63     }
64
65 }
66
67
68
Popular Tags