01: /*
02: * WbDefinePkTest.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.sql.wbcommands;
13:
14: import java.util.Map;
15: import junit.framework.*;
16: import workbench.TestUtil;
17: import workbench.sql.DefaultStatementRunner;
18: import workbench.sql.SqlCommand;
19: import workbench.storage.PkMapping;
20:
21: /**
22: *
23: * @author support@sql-workbench.net
24: */
25: public class WbDefinePkTest extends TestCase {
26:
27: public WbDefinePkTest(String testName) {
28: super (testName);
29: }
30:
31: public void testExecute() throws Exception {
32: DefaultStatementRunner runner;
33:
34: try {
35: TestUtil util = new TestUtil(getClass().getName()
36: + "_testExecute");
37: util.prepareEnvironment();
38: runner = util.createConnectedStatementRunner();
39:
40: String sql = "--define a new PK for a view\nwbdefinepk junitpk=id,name";
41: SqlCommand command = runner.getCommandToUse(sql);
42: assertTrue(command instanceof WbDefinePk);
43: runner.runStatement(sql, -1, -1);
44:
45: Map mapping = PkMapping.getInstance().getMapping();
46: String cols = (String) mapping.get("junitpk");
47: assertEquals("Wrong pk mapping stored", "id,name", cols);
48: } catch (Exception e) {
49: e.printStackTrace();
50: fail(e.getMessage());
51: }
52: }
53:
54: }
|