PageRenderTime 29ms CodeModel.GetById 18ms app.highlight 7ms RepoModel.GetById 2ms app.codeStats 0ms

/tst/org/diffkit/diff/sns/tst/TestAbstractSheet.groovy

http://diffkit.googlecode.com/
Groovy | 67 lines | 36 code | 13 blank | 18 comment | 8 complexity | d73a2978b95e5d5eaff73a74e97dd5b6 MD5 | raw file
 1/**
 2 * Copyright 2010-2011 Joseph Panico
 3 *
 4 * Licensed under the Apache License, Version 2.0 (the "License");
 5 * you may not use this file except in compliance with the License.
 6 * You may obtain a copy of the License at
 7 *
 8 *   http://www.apache.org/licenses/LICENSE-2.0
 9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package org.diffkit.diff.sns.tst
17
18
19
20import org.diffkit.diff.sns.DKAbstractSheet;
21import org.diffkit.diff.sns.DKPoiSheet 
22
23import groovy.util.GroovyTestCase;
24
25
26/**
27 * @author jpanico
28 */
29public class TestAbstractSheet extends GroovyTestCase {
30   
31   public void testConstructSheet(){
32      Class[] handlerClasses = (Class[])[DKPoiSheet.class]
33      
34      shouldFail(IllegalArgumentException) {
35         def sheet = DKAbstractSheet.constructSheet( new File('./test.txt'), 'test', false, false, true, handlerClasses)
36      }
37      def sheet = DKAbstractSheet.constructSheet( new File('./test.xls'), 'test', false, false, true, handlerClasses)
38      assert sheet
39   }
40   
41   public void testGetHandlerClassForFile(){
42      Class[] handlerClasses = (Class[])[DKPoiSheet.class]
43      
44      assert !DKAbstractSheet.getHandlerClassForFile( new File("./test.txt"), handlerClasses)
45      DKAbstractSheet.getHandlerClassForFile( new File("./test.xls"), handlerClasses) == DKPoiSheet.class
46   }
47   
48   public void testClassHandlesExtension(){
49      
50      shouldFail(IllegalArgumentException) {
51         DKAbstractSheet.classHandlesExtension( this.getClass(), 'tst')
52      }
53      assert !DKAbstractSheet.classHandlesExtension( DKPoiSheet.class, 'tst')
54      assert DKAbstractSheet.classHandlesExtension( DKPoiSheet.class, 'xls')
55   }
56   
57   public void testDefaultColumnName(){
58      assert ! DKAbstractSheet.getDefaultColumnName(-1)
59      assert DKAbstractSheet.getDefaultColumnName(0) == "A"
60      assert DKAbstractSheet.getDefaultColumnName(1) == "B"
61      assert DKAbstractSheet.getDefaultColumnName(25) == "Z"
62      assert DKAbstractSheet.getDefaultColumnName(26) == "AA"
63      assert DKAbstractSheet.getDefaultColumnName(51) == "AZ"
64      assert DKAbstractSheet.getDefaultColumnName(52) == "BA"
65      assert DKAbstractSheet.getDefaultColumnName(77) == "BZ"
66   }
67}