001: /*
002: * $Id: TestTableIdentifier.java,v 1.11 2005/12/20 18:32:44 ahimanikya Exp $
003: * =======================================================================
004: * Copyright (c) 2002-2004 Axion Development Team. All rights reserved.
005: *
006: * Redistribution and use in source and binary forms, with or without
007: * modification, are permitted provided that the following conditions
008: * are met:
009: *
010: * 1. Redistributions of source code must retain the above
011: * copyright notice, this list of conditions and the following
012: * disclaimer.
013: *
014: * 2. Redistributions in binary form must reproduce the above copyright
015: * notice, this list of conditions and the following disclaimer in
016: * the documentation and/or other materials provided with the
017: * distribution.
018: *
019: * 3. The names "Tigris", "Axion", nor the names of its contributors may
020: * not be used to endorse or promote products derived from this
021: * software without specific prior written permission.
022: *
023: * 4. Products derived from this software may not be called "Axion", nor
024: * may "Tigris" or "Axion" appear in their names without specific prior
025: * written permission.
026: *
027: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
028: * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
029: * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
030: * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
031: * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
032: * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
033: * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
034: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
035: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
036: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
037: * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
038: * =======================================================================
039: */
040:
041: package org.axiondb;
042:
043: import java.io.Serializable;
044:
045: import junit.framework.Test;
046: import junit.framework.TestSuite;
047:
048: /**
049: * @version $Revision: 1.11 $ $Date: 2005/12/20 18:32:44 $
050: * @author Rodney Waldhoff
051: */
052: public class TestTableIdentifier extends BaseSerializableTest {
053:
054: //------------------------------------------------------------ Conventional
055:
056: public TestTableIdentifier(String testName) {
057: super (testName);
058: }
059:
060: public static Test suite() {
061: TestSuite suite = new TestSuite(TestTableIdentifier.class);
062: return suite;
063: }
064:
065: //--------------------------------------------------------------- Lifecycle
066:
067: protected Serializable makeSerializable() {
068: return new TableIdentifier("NAME", "ALIAS");
069: }
070:
071: //------------------------------------------------------------------- Tests
072:
073: public void testEqualsColumnIdentifier1() throws Exception {
074: TableIdentifier table = new TableIdentifier("NAME", "ALIAS");
075: ColumnIdentifier column = new ColumnIdentifier(table,
076: "COLNAME", "COLALIAS");
077: assertEquals(table, column.getTableIdentifier());
078: }
079:
080: public void testEquals() throws Exception {
081: TableIdentifier table1 = new TableIdentifier("NAME", "ALIAS");
082: TableIdentifier table2 = new TableIdentifier("NAME", "ALIAS2");
083: TableIdentifier table3 = new TableIdentifier("NAME");
084: assertTrue(table1.equals(table1));
085: assertTrue(table2.equals(table2));
086: assertTrue(table3.equals(table3));
087: assertTrue(!table1.equals(table2));
088: assertTrue(!table2.equals(table1));
089: assertTrue(!table1.equals(table3));
090: assertTrue(!table3.equals(table1));
091: assertTrue(table1.hashCode() != table2.hashCode());
092: assertTrue(table1.hashCode() != table3.hashCode());
093: assertTrue(table2.hashCode() != table3.hashCode());
094: }
095:
096: public void testCanonicalIdentifier() {
097: TableIdentifier table = new TableIdentifier("NAME", "ALIAS");
098: assertNull(table.getCanonicalIdentifier().getTableAlias());
099: }
100:
101: public void testToString() throws Exception {
102: {
103: TableIdentifier table = new TableIdentifier("NAME", "ALIAS");
104: assertEquals("NAME AS ALIAS", table.toString());
105: }
106: {
107: TableIdentifier table = new TableIdentifier("NAME", null);
108: assertEquals("NAME", table.toString());
109: }
110: }
111:
112: public void testGetTableName() throws Exception {
113: {
114: TableIdentifier table = new TableIdentifier("NAME", "ALIAS");
115: assertEquals("NAME", table.getTableName());
116: }
117: {
118: TableIdentifier table = new TableIdentifier("NAME", null);
119: assertEquals("NAME", table.getTableName());
120: }
121: {
122: TableIdentifier table = new TableIdentifier(null, "ALIAS");
123: assertNull(table.getTableName());
124: }
125: {
126: TableIdentifier table = new TableIdentifier(null, null);
127: assertNull(table.getTableName());
128: }
129: }
130:
131: public void testGetTableAlias() throws Exception {
132: {
133: TableIdentifier table = new TableIdentifier("NAME", "ALIAS");
134: assertEquals("ALIAS", table.getTableAlias());
135: }
136: {
137: TableIdentifier table = new TableIdentifier("NAME", null);
138: assertNull(table.getTableAlias());
139: }
140: {
141: TableIdentifier table = new TableIdentifier(null, "ALIAS");
142: assertEquals("ALIAS", table.getTableAlias());
143: }
144: {
145: TableIdentifier table = new TableIdentifier(null, null);
146: assertNull(table.getTableAlias());
147: }
148: }
149:
150: }
|