JCSAdminBean admin = new JCSAdminBean(); LinkedList linkedList = admin.buildCacheInfo(); ListIterator iterator = linkedList.listIterator(); while (iterator.hasNext()) { CacheRegionInfo info = (CacheRegionInfo)iterator.next(); CompositeCache compCache = info.getCache(); System.out.println("Cache Name: " + compCache.getCacheName()); System.out.println("Cache Type: " + compCache.getCacheType()); System.out.println("Cache Misses (not found): " + compCache.getMissCountNotFound()); System.out.println("Cache Misses (expired): " + compCache.getMissCountExpired()); System.out.println("Cache Hits (memory): " + compCache.getHitCountRam()); System.out.println("Cache value: " + compCache.get(propId));
JCSAdminBean adminBean = new JCSAdminBean(this); try
JCSAdminBean adminBean = new JCSAdminBean(this); try
protected Template handleRequest( HttpServletRequest request, HttpServletResponse response, Context context ) JCSAdminBean admin = new JCSAdminBean();
protected Template handleRequest( HttpServletRequest request, HttpServletResponse response, Context context ) JCSAdminBean admin = new JCSAdminBean();
/** * Add an item to a region. Call clear all and verify that it doesn't exist. * * @throws Exception */ public void testClearAll() throws Exception { JCSAdminBean admin = new JCSAdminBean(); String regionName = "myRegion"; CacheAccess<String, String> cache = JCS.getInstance( regionName ); String key = "myKey"; cache.put( key, "value" ); admin.clearAllRegions(); CacheElementInfo[] elements2 = admin.buildElementInfo( regionName ); assertEquals( "Wrong number of elements in the region after remove.", 0, elements2.length ); } }
/** * Add an item to a region. Call clear all and verify that it doesn't exist. * * @throws Exception */ public void testClearAll() throws Exception { JCSAdminBean admin = new JCSAdminBean(); String regionName = "myRegion"; CacheAccess<String, String> cache = JCS.getInstance( regionName ); String key = "myKey"; cache.put( key, "value" ); admin.clearAllRegions(); CacheElementInfo[] elements2 = admin.buildElementInfo( regionName ); assertEquals( "Wrong number of elements in the region after remove.", 0, elements2.length ); } }
/** * Put a value in a region and verify that it shows up. * * @throws Exception */ public void testGetElementForRegionInfo() throws Exception { String regionName = "myRegion"; CacheAccess<String, String> cache = JCS.getInstance( regionName ); // clear the region cache.clear(); String key = "myKey"; cache.put( key, "value" ); JCSAdminBean admin = new JCSAdminBean(); CacheElementInfo[] elements = admin.buildElementInfo( regionName ); assertEquals( "Wrong number of elements in the region.", 1, elements.length ); CacheElementInfo elementInfo = elements[0]; assertEquals( "Wrong key." + elementInfo, key, elementInfo.getKey() ); }
/** * Put a value in a region and verify that it shows up. * * @throws Exception */ public void testGetElementForRegionInfo() throws Exception { String regionName = "myRegion"; CacheAccess<String, String> cache = JCS.getInstance( regionName ); // clear the region cache.clear(); String key = "myKey"; cache.put( key, "value" ); JCSAdminBean admin = new JCSAdminBean(); CacheElementInfo[] elements = admin.buildElementInfo( regionName ); assertEquals( "Wrong number of elements in the region.", 1, elements.length ); CacheElementInfo elementInfo = elements[0]; assertEquals( "Wrong key." + elementInfo, key, elementInfo.getKey() ); }
/** * Create a test region and then verify that we get it from the list. * * @throws Exception * */ public void testGetRegionInfo() throws Exception { String regionName = "myRegion"; CacheAccess<String, String> cache = JCS.getInstance( regionName ); cache.put( "key", "value" ); JCSAdminBean admin = new JCSAdminBean(); CacheRegionInfo[] regions = admin.buildCacheInfo(); boolean foundRegion = false; for (CacheRegionInfo info : regions) { if ( info.getCacheName().equals( regionName ) ) { foundRegion = true; assertTrue( "Byte count should be greater than 5.", info.getByteCount() > 5 ); assertNotNull( "Should have stats.", info.getCacheStatistics() ); } } assertTrue( "Should have found the region we just created.", foundRegion ); }
/** * Create a test region and then verify that we get it from the list. * * @throws Exception * */ public void testGetRegionInfo() throws Exception { String regionName = "myRegion"; CacheAccess<String, String> cache = JCS.getInstance( regionName ); cache.put( "key", "value" ); JCSAdminBean admin = new JCSAdminBean(); CacheRegionInfo[] regions = admin.buildCacheInfo(); boolean foundRegion = false; for (CacheRegionInfo info : regions) { if ( info.getCacheName().equals( regionName ) ) { foundRegion = true; assertTrue( "Byte count should be greater than 5.", info.getByteCount() > 5 ); assertNotNull( "Should have stats.", info.getCacheStatistics() ); } } assertTrue( "Should have found the region we just created.", foundRegion ); }
/** * Remove an item via the remove method. * * @throws Exception */ public void testRemove() throws Exception { JCSAdminBean admin = new JCSAdminBean(); String regionName = "myRegion"; CacheAccess<String, String> cache = JCS.getInstance( regionName ); // clear the region cache.clear(); admin.clearRegion( regionName ); String key = "myKey"; cache.put( key, "value" ); CacheElementInfo[] elements = admin.buildElementInfo( regionName ); assertEquals( "Wrong number of elements in the region.", 1, elements.length ); CacheElementInfo elementInfo = elements[0]; assertEquals( "Wrong key.", key, elementInfo.getKey() ); admin.removeItem( regionName, key ); CacheElementInfo[] elements2 = admin.buildElementInfo( regionName ); assertEquals( "Wrong number of elements in the region after remove.", 0, elements2.length ); }
/** * Remove an item via the remove method. * * @throws Exception */ public void testRemove() throws Exception { JCSAdminBean admin = new JCSAdminBean(); String regionName = "myRegion"; CacheAccess<String, String> cache = JCS.getInstance( regionName ); // clear the region cache.clear(); admin.clearRegion( regionName ); String key = "myKey"; cache.put( key, "value" ); CacheElementInfo[] elements = admin.buildElementInfo( regionName ); assertEquals( "Wrong number of elements in the region.", 1, elements.length ); CacheElementInfo elementInfo = elements[0]; assertEquals( "Wrong key.", key, elementInfo.getKey() ); admin.removeItem( regionName, key ); CacheElementInfo[] elements2 = admin.buildElementInfo( regionName ); assertEquals( "Wrong number of elements in the region after remove.", 0, elements2.length ); }