01: /*
02: * TableAliasTest.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.util;
13:
14: import junit.framework.*;
15:
16: public class TableAliasTest extends TestCase {
17:
18: public TableAliasTest(String name) {
19: super (name);
20: }
21:
22: public void testAlias() {
23: String value = "table1";
24: TableAlias ta = new TableAlias(value);
25:
26: assertEquals("Wrong table name", "table1", ta.getTable()
27: .getTableName());
28: assertEquals("Wrong value name", "table1", ta.getNameToUse());
29: assertNull("value is not null", ta.getAlias());
30:
31: value = "table2 t1";
32: ta = new TableAlias(value);
33:
34: assertEquals("Wrong table name", "table2", ta.getTable()
35: .getTableName());
36: assertEquals("Wrong value name", "t1", ta.getNameToUse());
37:
38: value = "table1 as t1";
39: ta = new TableAlias(value);
40:
41: assertEquals("Wrong table name", "table1", ta.getTable()
42: .getTableName());
43: assertEquals("Wrong value name", "t1", ta.getNameToUse());
44: }
45:
46: public void testCompare() {
47: String value = "table1";
48: TableAlias ta = new TableAlias(value);
49: assertEquals("Not recognized as the same", true, ta
50: .isTableOrAlias("table1"));
51:
52: value = "table1 t1";
53: ta = new TableAlias(value);
54: assertEquals("Not recognized as the same", true, ta
55: .isTableOrAlias("table1"));
56: assertEquals("Not recognized as the same", true, ta
57: .isTableOrAlias("t1"));
58:
59: }
60: }
|