01: package com.mockrunner.test.connector;
02:
03: import junit.framework.TestCase;
04:
05: import com.mockrunner.mock.connector.cci.MockRecord;
06:
07: public class MockRecordTest extends TestCase {
08: private MockRecord record;
09:
10: protected void setUp() throws Exception {
11: record = new MockRecord();
12: }
13:
14: protected void tearDown() throws Exception {
15: record = null;
16: }
17:
18: public void testEquals() {
19: assertFalse(record.equals(null));
20: assertFalse(record.equals("abc"));
21: assertTrue(record.equals(record));
22: MockRecord other = new MockRecord();
23: assertTrue(record.equals(other));
24: assertTrue(other.equals(record));
25: assertEquals(record.hashCode(), other.hashCode());
26: record.setRecordName(null);
27: assertFalse(record.equals(other));
28: other.setRecordName(null);
29: assertTrue(record.equals(other));
30: assertTrue(other.equals(record));
31: assertEquals(record.hashCode(), other.hashCode());
32: record.setRecordShortDescription(null);
33: assertFalse(record.equals(other));
34: other.setRecordShortDescription(null);
35: assertTrue(record.equals(other));
36: assertTrue(other.equals(record));
37: assertEquals(record.hashCode(), other.hashCode());
38: record.setRecordName("aRecordName");
39: other.setRecordName("anotherRecordName");
40: assertFalse(record.equals(other));
41: record.setRecordName("anotherRecordName");
42: assertTrue(record.equals(other));
43: assertTrue(other.equals(record));
44: assertEquals(record.hashCode(), other.hashCode());
45: record.setRecordShortDescription("shortDescription");
46: other.setRecordShortDescription("otherShortDescription");
47: assertFalse(record.equals(other));
48: other.setRecordShortDescription("shortDescription");
49: assertTrue(record.equals(other));
50: assertTrue(other.equals(record));
51: assertEquals(record.hashCode(), other.hashCode());
52: }
53:
54: public void testToString() {
55: record.setRecordName("recordName");
56: record.setRecordShortDescription("shortDescription");
57: String string = record.toString();
58: assertTrue(-1 != string.indexOf(MockRecord.class.getName()));
59: assertTrue(-1 != string.indexOf("recordName"));
60: assertTrue(-1 != string.indexOf("shortDescription"));
61: }
62:
63: public void testClone() throws Exception {
64: record.setRecordName("recordName");
65: record.setRecordShortDescription("shortDescription");
66: MockRecord clone = (MockRecord) record.clone();
67: assertNotSame(clone, record);
68: assertEquals("recordName", clone.getRecordName());
69: assertEquals("shortDescription", clone
70: .getRecordShortDescription());
71: }
72: }
|