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