1 package org.apache.jcs.engine.control;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import org.apache.jcs.JCS;
23 import org.apache.jcs.engine.stats.behavior.ICacheStats;
24
25 import junit.framework.TestCase;
26
27 /***
28 * @author Aaron Smuts
29 *
30 */
31 public class CacheManagerStatsUnitTest
32 extends TestCase
33 {
34
35 /***
36 * Just get the stats after putting a couple entries in the cache.
37 *
38 * @throws Exception
39 */
40 public void testSimpleGetStats() throws Exception
41 {
42 JCS cache = JCS.getInstance( "testCache1" );
43
44
45 cache.get( "testKey" );
46 cache.put( "testKey", "testdata" );
47
48 cache.get( "testKey" );
49 cache.get( "testKey" );
50 cache.get( "testKey" );
51 cache.get( "testKey" );
52
53 CompositeCacheManager mgr = CompositeCacheManager.getInstance();
54 String statsString = mgr.getStats();
55
56 System.out.println( statsString );
57
58 assertTrue( "Should have the cacheName in here.", statsString.indexOf("testCache1") != -1 );
59 assertTrue( "Should have the HitCountRam in here.", statsString.indexOf("HitCountRam") != -1 );
60 assertTrue( "Should have the 4 in here.", statsString.indexOf("4") != -1 );
61
62 ICacheStats[] stats = mgr.getStatistics();
63 int statsLen = stats.length;
64 System.out.println( "statsLen = " + statsLen );
65 for ( int i = 0; i < statsLen; i++ )
66 {
67
68 }
69 }
70
71 }