1 16 package net.sf.dozer.util.mapping.cache; 17 18 import java.util.ArrayList ; 19 import java.util.List ; 20 import java.util.Random ; 21 22 import net.sf.dozer.util.mapping.DozerTestBase; 23 24 27 public class CacheKeyFactoryTest extends DozerTestBase { 28 29 public void testCreateKey() throws Exception { 30 List args = new ArrayList (); 31 args.add(String .class); 32 args.add(Long .class); 33 args.add(new String ("hello")); 34 35 Object cacheKey = CacheKeyFactory.createKey(args.toArray()); 36 Object cacheKey2 = CacheKeyFactory.createKey(new ArrayList (args).toArray()); 37 38 assertEquals("cache keys should have been equal", cacheKey, cacheKey2); 39 assertEquals("cache key hash codes should have been equal", cacheKey.hashCode(), cacheKey2.hashCode()); 40 } 41 42 public void testCreateKey2() throws Exception { 43 String arg1 = "test string"; 44 Long arg2 = new Long (55); 45 List arg3 = new ArrayList (); 46 arg3.add("list entry"); 47 Class arg4 = Random .class; 48 49 Object cacheKey = CacheKeyFactory.createKey(new Object [] {arg1, arg2, arg3, arg4}); 50 Object cacheKey2 = CacheKeyFactory.createKey(new Object [] {arg1, arg2, arg3, arg4}); 51 52 assertEquals("cache keys should have been equal", cacheKey, cacheKey2); 53 assertEquals("cache key hash codes should have been equal", cacheKey.hashCode(), cacheKey2.hashCode()); 54 } 55 56 } 57 | Popular Tags |