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.PermissionCacheEntry;
25 import org.apache.commons.ognl.internal.entry.PermissionCacheEntryFactory;
26 import org.apache.commons.ognl.test.objects.Bean2;
27 import org.junit.Test;
28
29 import java.security.Permission;
30
31 import static junit.framework.Assert.assertNotNull;
32
33
34
35
36
37
38 public class PermissionCacheTest
39 {
40 ConcurrentHashMapCache<PermissionCacheEntry, Permission> cache =
41 new ConcurrentHashMapCache<PermissionCacheEntry, Permission>( new PermissionCacheEntryFactory());
42
43 @Test
44 public void testGet( )
45 throws Exception
46 {
47
48 getPermission( new PermissionCacheEntry( Bean2.class.getMethod( "getBean3" ) ) );
49 getPermission( new PermissionCacheEntry( Bean2.class.getMethod( "getId" ) ) );
50 }
51
52 private void getPermission( PermissionCacheEntry entry )
53 throws CacheException
54 {
55 Permission permission = cache.get( entry );
56 assertNotNull( permission );
57 }
58 }