1 package com.thoughtworks.xstream.core.util; 2 3 import junit.framework.TestCase; 4 5 public class ObjectIdDictionaryTest extends TestCase { 6 7 public void testMapsIdsToObjectReferences() { 8 ObjectIdDictionary dict = new ObjectIdDictionary(); 9 Object a = new Object (); 10 Object b = new Object (); 11 Object c = new Object (); 12 dict.associateId(a, "id a"); 13 dict.associateId(b, "id b"); 14 dict.associateId(c, "id c"); 15 assertEquals("id a", dict.lookupId(a)); 16 assertEquals("id b", dict.lookupId(b)); 17 assertEquals("id c", dict.lookupId(c)); 18 } 19 20 public void testTreatsObjectsThatAreEqualButNotSameInstanceAsDifferentReference() { 21 ObjectIdDictionary dict = new ObjectIdDictionary(); 22 Integer a = new Integer (3); 23 Integer b = new Integer (3); 24 dict.associateId(a, "id a"); 25 dict.associateId(b, "id b"); 26 assertEquals("id a", dict.lookupId(a)); 27 assertEquals("id b", dict.lookupId(b)); 28 } 29 } 30 | Popular Tags |