/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. */
  16. package org.diffkit.diff.sns.tst
  17. import org.diffkit.diff.sns.DKAbstractSheet;
  18. import org.diffkit.diff.sns.DKPoiSheet
  19. import groovy.util.GroovyTestCase;
  20. /**
  21. * @author jpanico
  22. */
  23. public class TestAbstractSheet extends GroovyTestCase {
  24. public void testConstructSheet(){
  25. Class[] handlerClasses = (Class[])[DKPoiSheet.class]
  26. shouldFail(IllegalArgumentException) {
  27. def sheet = DKAbstractSheet.constructSheet( new File('./test.txt'), 'test', false, false, true, handlerClasses)
  28. }
  29. def sheet = DKAbstractSheet.constructSheet( new File('./test.xls'), 'test', false, false, true, handlerClasses)
  30. assert sheet
  31. }
  32. public void testGetHandlerClassForFile(){
  33. Class[] handlerClasses = (Class[])[DKPoiSheet.class]
  34. assert !DKAbstractSheet.getHandlerClassForFile( new File("./test.txt"), handlerClasses)
  35. DKAbstractSheet.getHandlerClassForFile( new File("./test.xls"), handlerClasses) == DKPoiSheet.class
  36. }
  37. public void testClassHandlesExtension(){
  38. shouldFail(IllegalArgumentException) {
  39. DKAbstractSheet.classHandlesExtension( this.getClass(), 'tst')
  40. }
  41. assert !DKAbstractSheet.classHandlesExtension( DKPoiSheet.class, 'tst')
  42. assert DKAbstractSheet.classHandlesExtension( DKPoiSheet.class, 'xls')
  43. }
  44. public void testDefaultColumnName(){
  45. assert ! DKAbstractSheet.getDefaultColumnName(-1)
  46. assert DKAbstractSheet.getDefaultColumnName(0) == "A"
  47. assert DKAbstractSheet.getDefaultColumnName(1) == "B"
  48. assert DKAbstractSheet.getDefaultColumnName(25) == "Z"
  49. assert DKAbstractSheet.getDefaultColumnName(26) == "AA"
  50. assert DKAbstractSheet.getDefaultColumnName(51) == "AZ"
  51. assert DKAbstractSheet.getDefaultColumnName(52) == "BA"
  52. assert DKAbstractSheet.getDefaultColumnName(77) == "BZ"
  53. }
  54. }