01: /*
02: * Copyright (C) 2007 Rob Manning
03: * manningr@users.sourceforge.net
04: *
05: * This library is free software; you can redistribute it and/or
06: * modify it under the terms of the GNU Lesser General Public
07: * License as published by the Free Software Foundation; either
08: * version 2.1 of the License, or (at your option) any later version.
09: *
10: * This library is distributed in the hope that it will be useful,
11: * but WITHOUT ANY WARRANTY; without even the implied warranty of
12: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13: * Lesser General Public License for more details.
14: *
15: * You should have received a copy of the GNU Lesser General Public
16: * License along with this library; if not, write to the Free Software
17: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18: */
19: package net.sourceforge.squirrel_sql.plugins.dbdiff.gui;
20:
21: import java.awt.event.WindowAdapter;
22: import java.awt.event.WindowEvent;
23: import java.util.ArrayList;
24:
25: import javax.swing.JFrame;
26:
27: import net.sourceforge.squirrel_sql.client.ApplicationArguments;
28: import net.sourceforge.squirrel_sql.fw.sql.ISQLDatabaseMetaData;
29: import net.sourceforge.squirrel_sql.fw.sql.TableColumnInfo;
30: import net.sourceforge.squirrel_sql.plugins.dbdiff.ColumnDifference;
31: import net.sourceforge.squirrel_sql.test.TestUtil;
32:
33: import static java.sql.Types.*;
34:
35: public class ColumnDiffDialogTestUI {
36:
37: public static void main(String[] args) throws Exception {
38: ApplicationArguments.initialize(new String[] {});
39:
40: ISQLDatabaseMetaData md = TestUtil.getEasyMockSQLMetaData(
41: "oracle", "jdbc:oracle");
42: ColumnDifference diff = new ColumnDifference();
43: TableColumnInfo column1 = TestUtil
44: .getBigintColumnInfo(md, true);
45: TableColumnInfo column2 = TestUtil.getVarcharColumnInfo(md,
46: true, 100);
47: diff.setColumns(column1, column2);
48: diff.execute();
49:
50: ColumnDifference diff2 = new ColumnDifference();
51: TableColumnInfo column3 = TestUtil.getVarcharColumnInfo(md,
52: true, 200);
53: TableColumnInfo column4 = TestUtil.getVarcharColumnInfo(md,
54: true, 100);
55: diff2.setColumns(column3, column4);
56: diff2.execute();
57:
58: ColumnDifference diff3 = new ColumnDifference();
59: TableColumnInfo column5 = TestUtil.getTableColumnInfo(md,
60: "LongColumnNameThatIsUnreal", VARCHAR, 100, 0, false);
61: diff3.setColumn1(column5);
62: diff3.setCol2Exists(false);
63:
64: final ArrayList<ColumnDifference> diffs = new ArrayList<ColumnDifference>();
65: diffs.add(diff);
66: diffs.add(diff2);
67: diffs.add(diff3);
68:
69: java.awt.EventQueue.invokeLater(new Runnable() {
70: public void run() {
71: JFrame f = new JFrame();
72: ColumnDiffDialog cdd = new ColumnDiffDialog(f, true);
73: cdd.addWindowListener(new WindowAdapter() {
74: public void windowClosed(WindowEvent e) {
75: System.exit(0);
76: }
77: });
78: cdd.setSession1Label("Oracle1");
79: cdd.setSession2Label("Oracle2");
80: cdd.setColumnDifferences(diffs);
81: cdd.setVisible(true);
82: }
83: });
84: }
85:
86: }
|