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 in5 * 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 or9 * 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 by18 * 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 ;32 33 import java.util.Set ;34 import java.util.Map ;35 import java.util.HashMap ;36 import java.util.Iterator ;37 38 import javax.management.j2ee.statistics.Statistic ;39 import javax.management.j2ee.statistics.Stats ;40 import javax.management.j2ee.statistics.CountStatistic ;41 import javax.management.j2ee.statistics.BoundaryStatistic ;42 import javax.management.j2ee.statistics.RangeStatistic ;43 import javax.management.j2ee.statistics.BoundedRangeStatistic ;44 import javax.management.j2ee.statistics.TimeStatistic ;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 BeanCacheMonitorTest61 extends AMXMonitorTestBase62 {63 public64 BeanCacheMonitorTest()65 {66 }67 68 69 public void70 testStats()71 {72 final QueryMgr q = getQueryMgr();73 74 final Set beanCacheMonitors = q.queryJ2EETypeSet( XTypes.BEAN_CACHE_MONITOR );75 76 if ( beanCacheMonitors.size() == 0 )77 {78 warning( "BeanCacheMonitorTest: no MBeans found to test." );79 }80 else81 {82 final Iterator 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 time90 final BoundedRangeStatistic b1 = s.getCacheMisses();91 final BoundedRangeStatistic b2 = s.getCacheHits();92 final BoundedRangeStatistic b3 = s.getBeansInCache();93 94 // these were failing95 final CountStatistic c4 = s.getPassivationSuccesses();96 final CountStatistic c3 = s.getExpiredSessionsRemoved();97 final CountStatistic c2 = s.getPassivationErrors();98 final CountStatistic c1 = s.getPassivations();99 100 }101 }102 }103 104 }105 106 107 108 109 110 111