/tst/org/diffkit/diff/conf/tst/TestTool.groovy

http://diffkit.googlecode.com/ · Groovy · 81 lines · 48 code · 15 blank · 18 comment · 11 complexity · 23e7cd71a1648b4242a5345121497aaa 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.conf.tst
  17. import org.slf4j.Logger;
  18. import org.slf4j.LoggerFactory;
  19. import org.springframework.context.ApplicationContext
  20. import org.springframework.context.support.ClassPathXmlApplicationContext;
  21. import org.diffkit.db.tst.DBTestSetup;
  22. import org.diffkit.diff.engine.DKColumnModel;
  23. import org.diffkit.diff.sns.DKDBSource
  24. import org.diffkit.diff.sns.DKWriterSink
  25. import groovy.util.GroovyTestCase;
  26. /**
  27. * @author jpanico
  28. */
  29. public class TestTool extends GroovyTestCase {
  30. private final Logger _log = LoggerFactory.getLogger(this.getClass())
  31. public void testPlan(){
  32. DBTestSetup.setupDB(new File('org/diffkit/diff/conf/tst/test.dbsetup.xml'), (File[])[new File('org/diffkit/diff/conf/tst/dbConnectionInfo.xml')], 'org/diffkit/diff/conf/tst/test.lhs.csv', 'org/diffkit/diff/conf/tst/test.rhs.csv')
  33. ApplicationContext context = new ClassPathXmlApplicationContext('org/diffkit/diff/conf/tst/testtool.xml');
  34. assert context
  35. def plan = context.getBean('plan')
  36. println "plan->$plan"
  37. assert plan
  38. def lhsColumn1 = context.getBean('lhs.column1')
  39. assert lhsColumn1
  40. assert lhsColumn1._index == 0
  41. assert lhsColumn1._name == 'column1'
  42. assert lhsColumn1._type == DKColumnModel.Type.STRING
  43. def tableModel = context.getBean('lhs.table.model')
  44. assert tableModel
  45. assert tableModel.columns.length == 3
  46. assert tableModel.columns[0].index == 0
  47. assert tableModel.columns[0].name == 'column1'
  48. assert tableModel.columns[0].type == DKColumnModel.Type.STRING
  49. assert tableModel.columns[2].name == 'column3'
  50. assert tableModel.columns[2].type == DKColumnModel.Type.INTEGER
  51. def lhsSource = plan.lhsSource
  52. assert lhsSource
  53. assert lhsSource instanceof DKDBSource
  54. assert lhsSource.tableName == 'LHS_TABLE'
  55. def rhsSource = plan.rhsSource
  56. assert rhsSource
  57. assert rhsSource instanceof DKDBSource
  58. assert rhsSource.tableName == 'RHS_TABLE'
  59. def sink = plan.sink
  60. assert sink
  61. assert sink instanceof DKWriterSink
  62. def tableComparison = plan.tableComparison
  63. assert tableComparison
  64. assert tableComparison.diffIndexes== [1,2]
  65. }
  66. }