01: /*
02: * ResultInfoTest.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.storage;
13:
14: import junit.framework.*;
15: import workbench.db.ColumnIdentifier;
16:
17: /**
18: *
19: * @author support@sql-workbench.net
20: */
21: public class ResultInfoTest extends TestCase {
22:
23: public ResultInfoTest(String testName) {
24: super (testName);
25: }
26:
27: public void testFindColumn() {
28: try {
29: ColumnIdentifier col1 = new ColumnIdentifier("\"KEY\"",
30: java.sql.Types.VARCHAR, true);
31: ColumnIdentifier col2 = new ColumnIdentifier(
32: "\"Main Cat\"", java.sql.Types.VARCHAR, false);
33: ColumnIdentifier col3 = new ColumnIdentifier("firstname",
34: java.sql.Types.VARCHAR, false);
35: ResultInfo info = new ResultInfo(new ColumnIdentifier[] {
36: col1, col2, col3 });
37: assertEquals(3, info.getColumnCount());
38: assertEquals(true, info.hasPkColumns());
39:
40: int index = info.findColumn("key");
41: assertEquals(0, index);
42:
43: index = info.findColumn("\"KEY\"");
44: assertEquals(0, index);
45:
46: index = info.findColumn("\"key\"");
47: assertEquals(0, index);
48:
49: index = info.findColumn("\"Main Cat\"");
50: assertEquals(1, index);
51:
52: index = info.findColumn("firstname");
53: assertEquals(2, index);
54: } catch (Exception e) {
55: e.printStackTrace();
56: }
57: }
58:
59: }
|