1 package test.mockobjects; 2 3 import com.mockobjects.MapEntry; 4 import com.mockobjects.util.TestCaseMo; 5 import junit.framework.Test; 6 import junit.framework.TestSuite; 7 8 11 12 public class TestMapEntry extends TestCaseMo { 13 14 public TestMapEntry(String name) { 15 super(name); 16 } 17 18 public static void main(String [] args) { 19 start(new String []{TestMapEntry.class.getName()}); 20 } 21 22 public static Test suite() { 23 return new TestSuite(TestMapEntry.class); 24 } 25 26 public void testEquals() { 27 assertEquals( 28 "Should be expected value", 29 new MapEntry("A", "2"), 30 new MapEntry("A", "2")); 31 32 assertTrue( 33 "Should not be equal", 34 !new MapEntry("A", "2").equals(new MapEntry("A", "1"))); 35 36 assertTrue( 37 "Should not be equal", 38 !new MapEntry("A", "2").equals(new MapEntry("B", "2"))); 39 40 assertEquals( 41 "Should be equal with null value", 42 new MapEntry("A", null), 43 new MapEntry("A", null)); 44 45 assertEquals( 46 "Should be equal with null key", 47 new MapEntry(null, "A"), 48 new MapEntry(null, "A")); 49 50 assertEquals( 51 "Should be equal byte arrays", 52 new MapEntry("A", "A".getBytes()), 53 new MapEntry("A", "A".getBytes())); 54 55 assertTrue( 56 "Should not be equal byte arrays", 57 !new MapEntry("A", "AB".getBytes()).equals(new MapEntry("A", "A".getBytes()))); 58 59 assertTrue( 60 "Should not be equal byte arrays", 61 !new MapEntry("A", "A".getBytes()).equals(new MapEntry("A", "AB".getBytes()))); 62 63 assertTrue( 64 "Should not be equal byte arrays", 65 !new MapEntry("A", null).equals(new MapEntry("A", "AB".getBytes()))); 66 } 67 68 public void testHashCode() { 69 assertEquals( 70 "Should be equal hashcodes", 71 new MapEntry("A", "A".getBytes()).hashCode(), 72 new MapEntry("A", "A".getBytes()).hashCode()); 73 74 } 75 } 76 | Popular Tags |