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/ext/wsmgmt/WebServiceMonitorTest.java,v 1.6 2006/03/09 20:30:57 llc Exp $26 * $Revision: 1.6 $27 * $Date: 2006/03/09 20:30:57 $28 */29 package com.sun.enterprise.management.ext.wsmgmt;30 31 import java.util.Set ;32 import java.util.Iterator ;33 import java.io.IOException ;34 import java.util.Map ;35 import java.util.HashMap ;36 37 38 import javax.management.ObjectName ;39 import javax.management.AttributeList ;40 import javax.management.MBeanServerConnection ;41 import javax.management.NotCompliantMBeanException ;42 43 import com.sun.appserv.management.j2ee.J2EEDomain;44 45 46 import com.sun.appserv.management.util.jmx.MBeanServerConnectionConnectionSource;47 48 import com.sun.enterprise.management.support.AMXNonConfigImplBase;49 import com.sun.enterprise.management.support.QueryMgrImpl;50 import com.sun.appserv.management.ext.wsmgmt.WebServiceMgr;51 import com.sun.appserv.management.util.misc.ExceptionUtil;52 53 import com.sun.appserv.management.base.QueryMgr;54 import com.sun.appserv.management.base.XTypes;55 import com.sun.enterprise.management.AMXTestBase;56 import com.sun.enterprise.management.Capabilities;57 58 import javax.management.j2ee.statistics.Statistic ;59 import javax.management.j2ee.statistics.Stats ;60 import javax.management.j2ee.statistics.CountStatistic ;61 import javax.management.j2ee.statistics.BoundaryStatistic ;62 import javax.management.j2ee.statistics.RangeStatistic ;63 import javax.management.j2ee.statistics.BoundedRangeStatistic ;64 import javax.management.j2ee.statistics.TimeStatistic ;65 import com.sun.appserv.management.j2ee.statistics.NumberStatistic;66 import com.sun.appserv.management.ext.wsmgmt.WebServiceEndpointInfo;67 68 69 import com.sun.appserv.management.monitor.WebServiceEndpointMonitor;70 import com.sun.appserv.management.monitor.statistics.WebServiceEndpointAggregateStats;71 72 /**73 */74 public final class WebServiceMonitorTest extends AMXTestBase75 {76 77 public WebServiceMonitorTest() throws IOException {78 }79 80 public static Capabilities81 getCapabilities()82 {83 return getOfflineCapableCapabilities( false );84 }85 86 public void testMonitorMBeans() {87 assert (getDomainRoot().getWebServiceMgr() != null);88 89 final Set <WebServiceEndpointMonitor> ms =90 getDomainRoot().getQueryMgr().queryJ2EETypeSet( XTypes.WEBSERVICE_ENDPOINT_MONITOR);91 92 for( final WebServiceEndpointMonitor m : ms )93 {94 System.out.println("\n \n Name of web service is " + m.getName());95 96 final WebServiceEndpointAggregateStats s =97 m.getWebServiceEndpointAggregateStats();98 99 // verify that we can get each Statistic;100 // there was a problem at one time101 102 103 final CountStatistic r1 = s.getTotalFaults();104 assert( r1 != null );105 System.out.println(" total num fault is "+ r1.getCount());106 107 final CountStatistic r2 = s.getTotalNumSuccess() ;108 assert( r2 != null );109 System.out.println(" total num success is "+ r2.getCount());110 111 final CountStatistic r3 = s.getAverageResponseTime();112 assert( r3 != null );113 System.out.println("avg resp is "+ r3.getCount());114 115 final NumberStatistic c1 = s.getThroughput() ;116 assert( c1 != null );117 System.out.println(" through put is "+ c1.getCurrent());118 119 final CountStatistic c2 = s.getTotalAuthFailures();120 assert( c2 != null );121 System.out.println(" total num auth success is "+ c2.getCount());122 123 final CountStatistic c3 = s.getTotalAuthSuccesses();124 assert( c3 != null );125 System.out.println(" total num auth failure is "+ c3.getCount());126 127 }128 } 129 }130 131 132