01: /*
02: * Copyright 2005-2007 the original author or authors.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
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.AbstractDozerTest;
23:
24: /**
25: * @author tierney.matt
26: */
27: public class CacheKeyFactoryTest extends AbstractDozerTest {
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
37: .createKey(new ArrayList(args).toArray());
38:
39: assertEquals("cache keys should have been equal", cacheKey,
40: cacheKey2);
41: assertEquals("cache key hash codes should have been equal",
42: cacheKey.hashCode(), cacheKey2.hashCode());
43: }
44:
45: public void testCreateKey2() throws Exception {
46: String arg1 = "test string";
47: Long arg2 = new Long(55);
48: List arg3 = new ArrayList();
49: arg3.add("list entry");
50: Class arg4 = Random.class;
51:
52: Object cacheKey = CacheKeyFactory.createKey(new Object[] {
53: arg1, arg2, arg3, arg4 });
54: Object cacheKey2 = CacheKeyFactory.createKey(new Object[] {
55: arg1, arg2, arg3, arg4 });
56:
57: assertEquals("cache keys should have been equal", cacheKey,
58: cacheKey2);
59: assertEquals("cache key hash codes should have been equal",
60: cacheKey.hashCode(), cacheKey2.hashCode());
61: }
62:
63: }
|