KickJava   Java API By Example, From Geeks To Geeks.

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


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 CategorySeriesAxisRecord
27  * class works correctly. Test data taken directly from a real
28  * Excel file.
29  *
30
31  * @author Glen Stampoultzis (glens at apache.org)
32  */

33 public class TestCategorySeriesAxisRecord
34         extends TestCase
35 {
36     byte[] data = new byte[] {
37         (byte)0x01,(byte)0x00, // crossing point
38
(byte)0x01,(byte)0x00, // label frequency
39
(byte)0x01,(byte)0x00, // tick mark frequency
40
(byte)0x01,(byte)0x00 // options
41
};
42
43     public TestCategorySeriesAxisRecord(String JavaDoc name)
44     {
45         super(name);
46     }
47
48     public void testLoad()
49             throws Exception JavaDoc
50     {
51
52         CategorySeriesAxisRecord record = new CategorySeriesAxisRecord((short)0x1020, (short)data.length, data);
53         assertEquals( 1, record.getCrossingPoint());
54         assertEquals( 1, record.getLabelFrequency());
55         assertEquals( 1, record.getTickMarkFrequency());
56         assertEquals( 1, record.getOptions());
57         assertEquals( true, record.isValueAxisCrossing() );
58         assertEquals( false, record.isCrossesFarRight() );
59         assertEquals( false, record.isReversed() );
60
61
62         assertEquals( 4 + 8, record.getRecordSize() );
63
64         record.validateSid((short)0x1020);
65     }
66
67     public void testStore()
68     {
69         CategorySeriesAxisRecord record = new CategorySeriesAxisRecord();
70         record.setCrossingPoint( (short)1 );
71         record.setLabelFrequency( (short)1 );
72         record.setTickMarkFrequency( (short)1 );
73         record.setValueAxisCrossing( true );
74         record.setCrossesFarRight( false );
75         record.setReversed( false );
76
77
78         byte [] recordBytes = record.serialize();
79         assertEquals(recordBytes.length - 4, data.length);
80         for (int i = 0; i < data.length; i++)
81             assertEquals("At offset " + i, data[i], recordBytes[i+4]);
82     }
83 }
84
Popular Tags