1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 package org.apache.commons.ognl.internal;
23
24 import org.apache.commons.ognl.internal.entry.PropertyDescriptorCacheEntryFactory;
25 import org.apache.commons.ognl.test.objects.Bean2;
26 import org.junit.Test;
27
28 import java.beans.PropertyDescriptor;
29 import java.util.Map;
30
31 import static junit.framework.Assert.assertNotNull;
32 import static junit.framework.Assert.assertTrue;
33
34
35
36
37
38
39 public class PropertyDescriptorCacheTest
40 {
41 ConcurrentHashMapCache<Class<?>, Map<String,PropertyDescriptor>> cache =
42 new ConcurrentHashMapCache<Class<?>, Map<String,PropertyDescriptor>>( new PropertyDescriptorCacheEntryFactory());
43
44 @Test
45 public void testGet( )
46 throws Exception
47 {
48 Map<String, PropertyDescriptor> d = getPropertyDescriptor( Bean2.class );
49 assertTrue( d.containsKey( "id" ) );
50 assertTrue( d.containsKey( "bean3" ) );
51 assertTrue( d.containsKey( "carrier" ) );
52 }
53
54 private Map<String, PropertyDescriptor> getPropertyDescriptor( Class<?> entry )
55 throws CacheException
56 {
57 Map<String, PropertyDescriptor> descriptor = cache.get( entry );
58 assertNotNull( descriptor );
59 return descriptor;
60 }
61 }