KickJava   Java API By Example, From Geeks To Geeks.

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


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 package org.apache.poi.hssf.record;
19
20 import junit.framework.TestCase;
21
22 import org.apache.poi.hssf.record.MergeCellsRecord.MergedRegion;
23
24 /**
25  * Make sure the merge cells record behaves
26  * @author Danny Mui (dmui at apache dot org)
27  *
28  */

29 public class TestMergeCellsRecord extends TestCase {
30    
31    /**
32     * Make sure when a clone is called, we actually clone it.
33     * @throws Exception
34     */

35    public void testCloneReferences() throws Exception JavaDoc {
36       MergeCellsRecord merge = new MergeCellsRecord();
37       merge.addArea(0, (short)0, 1, (short)2);
38       MergeCellsRecord clone = (MergeCellsRecord)merge.clone();
39       
40       assertNotSame("Merged and cloned objects are the same", merge, clone);
41       
42       MergedRegion mergeRegion = merge.getAreaAt(0);
43       MergedRegion cloneRegion = clone.getAreaAt(0);
44       assertNotSame("Should not point to same objects when cloning", mergeRegion, cloneRegion);
45       assertEquals("New Clone Row From doesnt match", mergeRegion.row_from, cloneRegion.row_from);
46       assertEquals("New Clone Row To doesnt match", mergeRegion.row_to, cloneRegion.row_to);
47       assertEquals("New Clone Col From doesnt match", mergeRegion.col_from, cloneRegion.col_from);
48       assertEquals("New Clone Col To doesnt match", mergeRegion.col_to, cloneRegion.col_to);
49       
50       merge.removeAreaAt(0);
51       assertNotNull("Clone's item not removed", clone.getAreaAt(0));
52    }
53 }
54
Popular Tags