KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > poi > hssf > usermodel > TestHSSFHeaderFooter


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 package org.apache.poi.hssf.usermodel;
20
21 import junit.framework.TestCase;
22 import org.apache.poi.hssf.usermodel.HSSFHeader;
23 import org.apache.poi.hssf.usermodel.HSSFFooter;
24 import org.apache.poi.hssf.usermodel.HSSFSheet;
25 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
26
27 import java.io.File JavaDoc;
28 import java.io.FileInputStream JavaDoc;
29 import java.io.FileOutputStream JavaDoc;
30
31 /**
32  * Tests row shifting capabilities.
33  *
34  *
35  * @author Shawn Laubach (slaubach at apache dot com)
36  */

37
38 public class TestHSSFHeaderFooter extends TestCase {
39
40     /**
41      * Constructor for TestHeaderFooter.
42      * @param arg0
43      */

44     public TestHSSFHeaderFooter(String JavaDoc arg0) {
45     super(arg0);
46     }
47
48     /**
49      * Tests that get header retreives the proper values.
50      *
51      * @author Shawn Laubach (slaubach at apache dot org)
52      */

53     public void testRetrieveCorrectHeader() throws Exception JavaDoc
54     {
55         // Read initial file in
56
String JavaDoc filename = System.getProperty( "HSSF.testdata.path" );
57         filename = filename + "/EmbeddedChartHeaderTest.xls";
58         FileInputStream JavaDoc fin = new FileInputStream JavaDoc( filename );
59         HSSFWorkbook wb = new HSSFWorkbook( fin );
60         fin.close();
61         HSSFSheet s = wb.getSheetAt( 0 );
62     HSSFHeader head = s.getHeader();
63
64     assertEquals("Top Left", head.getLeft());
65     assertEquals("Top Center", head.getCenter());
66     assertEquals("Top Right", head.getRight());
67     }
68
69     /**
70      * Tests that get header retreives the proper values.
71      *
72      * @author Shawn Laubach (slaubach at apache dot org)
73      */

74     public void testRetrieveCorrectFooter() throws Exception JavaDoc
75     {
76         // Read initial file in
77
String JavaDoc filename = System.getProperty( "HSSF.testdata.path" );
78         filename = filename + "/EmbeddedChartHeaderTest.xls";
79         FileInputStream JavaDoc fin = new FileInputStream JavaDoc( filename );
80         HSSFWorkbook wb = new HSSFWorkbook( fin );
81         fin.close();
82         HSSFSheet s = wb.getSheetAt( 0 );
83     HSSFFooter foot = s.getFooter();
84
85     assertEquals("Bottom Left", foot.getLeft());
86     assertEquals("Bottom Center", foot.getCenter());
87     assertEquals("Bottom Right", foot.getRight());
88     }
89 }
90
91
Popular Tags