01: package com.mockrunner.test.jdbc;
02:
03: import junit.framework.TestCase;
04:
05: import com.mockrunner.mock.jdbc.MockRef;
06:
07: public class MockRefTest extends TestCase {
08: public void testClone() throws Exception {
09: MockRef ref = new MockRef(this );
10: MockRef copy = (MockRef) ref.clone();
11: assertNotSame(ref, copy);
12: assertSame(ref.getObject(), copy.getObject());
13: assertSame(this , copy.getObject());
14: }
15:
16: public void testEquals() throws Exception {
17: MockRef nullRef = new MockRef(null);
18: assertFalse(nullRef.equals(null));
19: assertTrue(nullRef.equals(nullRef));
20: MockRef ref = new MockRef("test");
21: assertFalse(ref.equals(nullRef));
22: assertFalse(nullRef.equals(ref));
23: MockRef other = new MockRef("test");
24: assertTrue(ref.equals(other));
25: assertTrue(other.equals(ref));
26: assertEquals(ref.hashCode(), other.hashCode());
27: other = new MockRef("test") {
28: };
29: assertFalse(other.equals(ref));
30: assertFalse(ref.equals(other));
31: other = new MockRef("test");
32: other.setBaseTypeName("baseTypeName");
33: assertFalse(other.equals(ref));
34: assertFalse(ref.equals(other));
35: ref.setBaseTypeName("baseTypeName");
36: assertTrue(ref.equals(other));
37: assertTrue(other.equals(ref));
38: assertEquals(ref.hashCode(), other.hashCode());
39: other = new MockRef(new Integer(3));
40: other.setBaseTypeName("baseTypeName");
41: assertFalse(ref.equals(other));
42: assertFalse(other.equals(ref));
43: ref = new MockRef(new Integer(3));
44: assertFalse(ref.equals(other));
45: assertFalse(other.equals(ref));
46: ref.setBaseTypeName("baseTypeName");
47: assertTrue(ref.equals(other));
48: assertTrue(other.equals(ref));
49: assertEquals(ref.hashCode(), other.hashCode());
50: }
51:
52: public void testToString() throws Exception {
53: MockRef ref = new MockRef("abc");
54: assertEquals("Ref data: abc", ref.toString());
55: }
56: }
|