1 package org.apache.commons.jcs;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import junit.framework.TestCase;
23 import org.apache.commons.jcs.access.CacheAccess;
24
25
26
27
28
29
30 public class ZeroSizeCacheUnitTest
31 extends TestCase
32 {
33
34 private static int items = 20000;
35
36
37
38
39
40
41 @Override
42 public void setUp()
43 throws Exception
44 {
45 JCS.setConfigFilename( "/TestZeroSizeCache.ccf" );
46 JCS.getInstance( "testCache1" );
47 }
48
49
50
51
52
53
54
55 public void testPutGetRemove()
56 throws Exception
57 {
58 CacheAccess<String, String> jcs = JCS.getInstance( "testCache1" );
59
60 for ( int i = 0; i <= items; i++ )
61 {
62 jcs.put( i + ":key", "data" + i );
63 }
64
65
66 for ( int i = items; i >= 0; i-- )
67 {
68 String res = jcs.get( i + ":key" );
69 assertNull( "[" + i + ":key] should be null", res );
70 }
71
72
73 jcs.remove( "300:key" );
74
75
76 Thread.sleep( 500 );
77
78
79 for ( int i = 0; i <= items; i++ )
80 {
81 jcs.put( i + ":key", "data" + i );
82 }
83
84 for ( int i = items; i >= 0; i-- )
85 {
86 String res = jcs.get( i + ":key" );
87 assertNull( "[" + i + ":key] should be null", res );
88 }
89 }
90 }