1 package org.apache.commons.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 junit.framework.TestCase;
23 import org.apache.commons.jcs.JCS;
24 import org.apache.commons.jcs.access.CacheAccess;
25 import org.apache.commons.jcs.engine.stats.behavior.ICacheStats;
26
27
28
29
30
31 public class CacheManagerStatsUnitTest
32 extends TestCase
33 {
34
35
36
37
38
39
40 public void testSimpleGetStats() throws Exception
41 {
42 CacheAccess<String, String> 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
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
65 for ( int i = 0; i < statsLen; i++ )
66 {
67
68 }
69 }
70
71 }