01: /*
02: * ColumnDropperTest.java
03: *
04: * This file is part of SQL Workbench/J, http://www.sql-workbench.net
05: *
06: * Copyright 2002-2008, Thomas Kellerer
07: * No part of this code maybe reused without the permission of the author
08: *
09: * To contact the author please send an email to: support@sql-workbench.net
10: *
11: */
12: package workbench.db;
13:
14: import java.sql.Statement;
15: import java.util.ArrayList;
16: import java.util.List;
17: import junit.framework.TestCase;
18: import workbench.TestUtil;
19:
20: /**
21: *
22: * @author support@sql-workbench.net
23: */
24: public class ColumnDropperTest extends TestCase {
25: public ColumnDropperTest(String testName) {
26: super (testName);
27: }
28:
29: public void testDropObjects() throws Exception {
30: TestUtil util = new TestUtil("dropColumn");
31: WbConnection con = util.getConnection();
32:
33: try {
34: Statement stmt = con.createStatement();
35: stmt
36: .executeUpdate("create table person (nr integer, firstname varchar(20), lastname varchar(20), dummy1 integer, dummy2 date)");
37: con.commit();
38: TableIdentifier table = con.getMetadata().findTable(
39: new TableIdentifier("PERSON"));
40: List<ColumnIdentifier> cols = new ArrayList<ColumnIdentifier>();
41: cols.add(new ColumnIdentifier("DUMMY1"));
42: cols.add(new ColumnIdentifier("DUMMY2"));
43:
44: ColumnDropper dropper = new ColumnDropper(con, table, cols);
45: dropper.dropObjects();
46:
47: List<ColumnIdentifier> tableCols = con.getMetadata()
48: .getTableColumns(table);
49: assertEquals(3, tableCols.size());
50: } catch (Exception e) {
51: e.printStackTrace();
52: fail(e.getMessage());
53: }
54: }
55: }
|