1 18 package net.sf.uitags.util; 19 20 import junit.framework.TestCase; 21 22 28 public class ObjectPairTest extends TestCase { 29 30 33 private ObjectPair pair; 34 35 40 public static void main(String [] args) { 41 junit.textui.TestRunner.run(ObjectPairTest.class); 42 } 43 44 45 protected void setUp() throws Exception { 46 super.setUp(); 47 this.pair = new ObjectPair("first1", "second1"); 48 } 49 50 51 protected void tearDown() throws Exception { 52 super.tearDown(); 53 this.pair = null; 54 } 55 56 59 public void testGetObjects() { 60 assertEquals("first1", this.pair.getFirstObject()); 61 assertEquals("second1", this.pair.getSecondObject()); 62 } 63 64 68 public void testEquals() { 69 ObjectPair pair1 = new ObjectPair("first1", "second2"); 71 ObjectPair pair2 = new ObjectPair("first2", "second1"); 73 ObjectPair pair3 = new ObjectPair("first1", "second1"); 75 ObjectPair pair4 = new ObjectPair("first2", "second2"); 77 78 assertTrue(!this.pair.equals(pair1)); 79 assertTrue(!this.pair.equals(pair2)); 80 assertTrue(this.pair.equals(pair3)); 81 assertTrue(!this.pair.equals(pair4)); 82 } 83 84 88 public void testHashCode() { 89 ObjectPair tempPair = new ObjectPair("first1", "second1"); 93 94 assertEquals(this.pair.hashCode(), tempPair.hashCode()); 95 } 96 } 97 | Popular Tags |