KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > management > monitor > BeanCacheMonitorTest


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23  
24 /*
25  * $Header: /cvs/glassfish/admin/mbeanapi-impl/tests/com/sun/enterprise/management/monitor/BeanCacheMonitorTest.java,v 1.4 2005/12/25 03:41:53 tcfujii Exp $
26  * $Revision: 1.4 $
27  * $Date: 2005/12/25 03:41:53 $
28  */

29 package com.sun.enterprise.management.monitor;
30
31 import javax.management.ObjectName JavaDoc;
32
33 import java.util.Set JavaDoc;
34 import java.util.Map JavaDoc;
35 import java.util.HashMap JavaDoc;
36 import java.util.Iterator JavaDoc;
37
38 import javax.management.j2ee.statistics.Statistic JavaDoc;
39 import javax.management.j2ee.statistics.Stats JavaDoc;
40 import javax.management.j2ee.statistics.CountStatistic JavaDoc;
41 import javax.management.j2ee.statistics.BoundaryStatistic JavaDoc;
42 import javax.management.j2ee.statistics.RangeStatistic JavaDoc;
43 import javax.management.j2ee.statistics.BoundedRangeStatistic JavaDoc;
44 import javax.management.j2ee.statistics.TimeStatistic JavaDoc;
45
46             
47 import com.sun.appserv.management.base.AMX;
48 import com.sun.appserv.management.base.XTypes;
49 import com.sun.appserv.management.base.QueryMgr;
50 import com.sun.appserv.management.monitor.BeanCacheMonitor;
51 import com.sun.appserv.management.monitor.statistics.EJBCacheStats;
52
53 import com.sun.appserv.management.j2ee.statistics.*;
54
55
56 import com.sun.enterprise.management.AMXTestBase;
57 import com.sun.enterprise.management.Capabilities;
58
59
60 public final class BeanCacheMonitorTest
61     extends AMXMonitorTestBase
62 {
63         public
64     BeanCacheMonitorTest()
65     {
66     }
67     
68   
69         public void
70     testStats()
71     {
72         final QueryMgr q = getQueryMgr();
73         
74         final Set JavaDoc beanCacheMonitors = q.queryJ2EETypeSet( XTypes.BEAN_CACHE_MONITOR );
75         
76         if ( beanCacheMonitors.size() == 0 )
77         {
78             warning( "BeanCacheMonitorTest: no MBeans found to test." );
79         }
80         else
81         {
82             final Iterator JavaDoc iter = beanCacheMonitors.iterator();
83             
84             while ( iter.hasNext() )
85             {
86                 final BeanCacheMonitor m = (BeanCacheMonitor)iter.next();
87                 final EJBCacheStats s = m.getEJBCacheStats();
88                 
89                 // verify that we can get each Statistic; there was a problem at one time
90
final BoundedRangeStatistic JavaDoc b1 = s.getCacheMisses();
91                 final BoundedRangeStatistic JavaDoc b2 = s.getCacheHits();
92                 final BoundedRangeStatistic JavaDoc b3 = s.getBeansInCache();
93                 
94                 // these were failing
95
final CountStatistic JavaDoc c4 = s.getPassivationSuccesses();
96                 final CountStatistic JavaDoc c3 = s.getExpiredSessionsRemoved();
97                 final CountStatistic JavaDoc c2 = s.getPassivationErrors();
98                 final CountStatistic JavaDoc c1 = s.getPassivations();
99
100             }
101         }
102     }
103  
104 }
105
106
107
108
109
110
111
Popular Tags