01: /*
02: * Copyright (C) 2007 Rob Manning
03: * manningr@users.sourceforge.net
04: *
05: * This library is free software; you can redistribute it and/or
06: * modify it under the terms of the GNU Lesser General Public
07: * License as published by the Free Software Foundation; either
08: * version 2.1 of the License, or (at your option) any later version.
09: *
10: * This library is distributed in the hope that it will be useful,
11: * but WITHOUT ANY WARRANTY; without even the implied warranty of
12: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13: * Lesser General Public License for more details.
14: *
15: * You should have received a copy of the GNU Lesser General Public
16: * License along with this library; if not, write to the Free Software
17: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18: */
19: package net.sourceforge.squirrel_sql.client.session;
20:
21: import static org.easymock.EasyMock.expect;
22: import static org.easymock.classextension.EasyMock.replay;
23: import net.sourceforge.squirrel_sql.fw.sql.TableColumnInfo;
24:
25: import org.easymock.classextension.EasyMock;
26: import org.junit.After;
27: import org.junit.Before;
28: import org.junit.Test;
29:
30: import com.gargoylesoftware.base.testing.EqualsTester;
31:
32: public class ExtendedColumnInfoTest {
33:
34: TableColumnInfo tcinfo1 = EasyMock
35: .createMock(TableColumnInfo.class);
36: TableColumnInfo tcinfo2 = EasyMock
37: .createMock(TableColumnInfo.class);
38:
39: @Before
40: public void setUp() throws Exception {
41: expect(tcinfo1.getCatalogName()).andReturn("testCatalog1")
42: .anyTimes();
43: expect(tcinfo1.getSchemaName()).andReturn("testSchema1")
44: .anyTimes();
45: expect(tcinfo1.getTableName()).andReturn("testTable1")
46: .anyTimes();
47: expect(tcinfo1.getColumnName()).andReturn("testColumn1")
48: .anyTimes();
49: expect(tcinfo1.getTypeName()).andReturn("integer").anyTimes();
50: expect(tcinfo1.getColumnSize()).andReturn(10).anyTimes();
51: expect(tcinfo1.getDecimalDigits()).andReturn(0).anyTimes();
52: expect(tcinfo1.isNullable()).andReturn("YES").anyTimes();
53:
54: expect(tcinfo2.getCatalogName()).andReturn("testCatalog2")
55: .anyTimes();
56: expect(tcinfo2.getSchemaName()).andReturn("testSchema2")
57: .anyTimes();
58: expect(tcinfo2.getTableName()).andReturn("testTable2")
59: .anyTimes();
60: expect(tcinfo2.getColumnName()).andReturn("testColumn2")
61: .anyTimes();
62: expect(tcinfo2.getTypeName()).andReturn("integer").anyTimes();
63: expect(tcinfo2.getColumnSize()).andReturn(10).anyTimes();
64: expect(tcinfo2.getDecimalDigits()).andReturn(0).anyTimes();
65: expect(tcinfo2.isNullable()).andReturn("YES").anyTimes();
66:
67: }
68:
69: @After
70: public void tearDown() throws Exception {
71: }
72:
73: @Test
74: public final void testEqualsAndHashcode() {
75:
76: replay(tcinfo1);
77: replay(tcinfo2);
78:
79: ExtendedColumnInfo info1 = new ExtendedColumnInfo(tcinfo1,
80: "table1");
81: ExtendedColumnInfo info2 = new ExtendedColumnInfo(tcinfo1,
82: "table1");
83: ExtendedColumnInfo info3 = new ExtendedColumnInfo(tcinfo2,
84: "table2");
85: ExtendedColumnInfo info4 = new ExtendedColumnInfo(tcinfo1,
86: "table1") {
87: private static final long serialVersionUID = 1L;
88: };
89:
90: new EqualsTester(info1, info2, info3, info4);
91: }
92:
93: }
|