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