01: /* ====================================================================
02: Licensed to the Apache Software Foundation (ASF) under one or more
03: contributor license agreements. See the NOTICE file distributed with
04: this work for additional information regarding copyright ownership.
05: The ASF licenses this file to You under the Apache License, Version 2.0
06: (the "License"); you may not use this file except in compliance with
07: the License. You may obtain a copy of the License at
08:
09: 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.aggregates;
19:
20: import junit.framework.TestCase;
21: import org.apache.poi.hssf.record.ColumnInfoRecord;
22:
23: /**
24: * @author Glen Stampoultzis
25: */
26: public class TestColumnInfoRecordsAggregate extends TestCase {
27: ColumnInfoRecordsAggregate columnInfoRecordsAggregate;
28:
29: public void testGetRecordSize() throws Exception {
30: columnInfoRecordsAggregate = new ColumnInfoRecordsAggregate();
31: columnInfoRecordsAggregate.insertColumn(createColumn((short) 1,
32: (short) 3));
33: columnInfoRecordsAggregate.insertColumn(createColumn((short) 4,
34: (short) 7));
35: columnInfoRecordsAggregate.insertColumn(createColumn((short) 8,
36: (short) 8));
37: // columnInfoRecordsAggregate.setColumn( (short)2, new Short( (short)200 ), new Integer( 1 ), new Boolean( true ), null);
38: columnInfoRecordsAggregate.groupColumnRange((short) 2,
39: (short) 5, true);
40: System.out.println("columnInfoRecordsAggregate = "
41: + columnInfoRecordsAggregate.getNumColumns());
42:
43: assertEquals(columnInfoRecordsAggregate.getRecordSize(),
44: columnInfoRecordsAggregate.serialize().length);
45:
46: columnInfoRecordsAggregate = new ColumnInfoRecordsAggregate();
47: columnInfoRecordsAggregate.groupColumnRange((short) 3,
48: (short) 6, true);
49:
50: assertEquals(columnInfoRecordsAggregate.getRecordSize(),
51: serializedSize());
52: }
53:
54: private int serializedSize() {
55: return columnInfoRecordsAggregate.serialize(0,
56: new byte[columnInfoRecordsAggregate.getRecordSize()]);
57: }
58:
59: private ColumnInfoRecord createColumn(short firstCol, short lastCol) {
60: ColumnInfoRecord columnInfoRecord = new ColumnInfoRecord();
61: columnInfoRecord.setFirstColumn(firstCol);
62: columnInfoRecord.setLastColumn(lastCol);
63: return columnInfoRecord;
64: }
65: }
|