PageRenderTime 30ms CodeModel.GetById 15ms app.highlight 11ms RepoModel.GetById 2ms app.codeStats 0ms

/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/**
 3 * Copyright 2010-2011 Joseph Panico
 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 */
17package org.diffkit.diff.conf.tst
18
19
20import org.slf4j.Logger;
21import org.slf4j.LoggerFactory;
22import org.springframework.context.ApplicationContext 
23import org.springframework.context.support.ClassPathXmlApplicationContext;
24
25import org.diffkit.db.tst.DBTestSetup;
26import org.diffkit.diff.engine.DKColumnModel;
27import org.diffkit.diff.sns.DKDBSource 
28import org.diffkit.diff.sns.DKWriterSink 
29
30import groovy.util.GroovyTestCase;
31
32
33/**
34 * @author jpanico
35 */
36public class TestTool extends GroovyTestCase {
37   private final Logger _log = LoggerFactory.getLogger(this.getClass())
38   
39   public void testPlan(){
40      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')
41      ApplicationContext context = new ClassPathXmlApplicationContext('org/diffkit/diff/conf/tst/testtool.xml');
42      assert context
43      
44      def plan = context.getBean('plan')
45      println "plan->$plan"
46      assert plan
47      def lhsColumn1 = context.getBean('lhs.column1')
48      assert lhsColumn1
49      assert lhsColumn1._index == 0
50      assert lhsColumn1._name == 'column1'
51      assert lhsColumn1._type == DKColumnModel.Type.STRING
52      
53      def tableModel = context.getBean('lhs.table.model')
54      assert tableModel
55      assert tableModel.columns.length == 3
56      assert tableModel.columns[0].index == 0
57      assert tableModel.columns[0].name == 'column1'
58      assert tableModel.columns[0].type == DKColumnModel.Type.STRING
59      assert tableModel.columns[2].name == 'column3'
60      assert tableModel.columns[2].type == DKColumnModel.Type.INTEGER
61      
62      def lhsSource = plan.lhsSource
63      assert lhsSource
64      assert lhsSource instanceof DKDBSource
65      assert lhsSource.tableName == 'LHS_TABLE'
66      
67      def rhsSource = plan.rhsSource
68      assert rhsSource
69      assert rhsSource instanceof DKDBSource
70      assert rhsSource.tableName == 'RHS_TABLE'
71      
72      def sink = plan.sink
73      assert sink
74      assert sink instanceof DKWriterSink
75      
76      def tableComparison = plan.tableComparison
77      assert tableComparison
78      assert tableComparison.diffIndexes== [1,2]
79   }
80}
81