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.Test;
23 import junit.framework.TestCase;
24 import junit.framework.TestSuite;
25 import org.apache.commons.jcs.access.CacheAccess;
26
27
28
29
30 public class JCSLightLoadUnitTest
31 extends TestCase
32 {
33
34 private static int items = 20000;
35
36
37
38
39
40 @Override
41 public void setUp()
42 throws Exception
43 {
44 JCS.setConfigFilename( "/TestSimpleLoad.ccf" );
45 JCS.getInstance( "testCache1" );
46 }
47
48
49
50
51 public JCSLightLoadUnitTest( String testName )
52 {
53 super( testName );
54 }
55
56
57
58
59
60 public static void main( String args[] )
61 {
62 String[] testCaseName = { JCSLightLoadUnitTest.class.getName() };
63 junit.textui.TestRunner.main( testCaseName );
64 }
65
66
67
68
69
70 public static Test suite()
71 {
72 return new TestSuite( JCSLightLoadUnitTest.class );
73 }
74
75
76
77
78
79 public void testSimpleLoad()
80 throws Exception
81 {
82 CacheAccess<String, String> jcs = JCS.getInstance( "testCache1" );
83
84
85
86
87 for ( int i = 1; i <= items; i++ )
88 {
89 jcs.put( i + ":key", "data" + i );
90 }
91
92 for ( int i = items; i > 0; i-- )
93 {
94 String res = jcs.get( i + ":key" );
95 assertNotNull( "[" + i + ":key] should not be null", res );
96 }
97
98
99 jcs.remove( "300:key" );
100 assertNull( jcs.get( "300:key" ) );
101 }
102 }