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