KickJava   Java API By Example, From Geeks To Geeks.

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


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/JMXMonitorMgrTest.java,v 1.4 2005/12/25 03:41:55 tcfujii Exp $
26  * $Revision: 1.4 $
27  * $Date: 2005/12/25 03:41:55 $
28  */

29 package com.sun.enterprise.management.monitor;
30
31 import java.io.IOException JavaDoc;
32
33 import javax.management.ObjectName JavaDoc;
34
35 import com.sun.appserv.management.base.Util;
36 import com.sun.appserv.management.monitor.JMXMonitorMgr;
37 import com.sun.appserv.management.monitor.AMXStringMonitor;
38
39
40 import com.sun.enterprise.management.AMXTestBase;
41 import com.sun.enterprise.management.Capabilities;
42
43 /**
44  */

45 public final class JMXMonitorMgrTest extends AMXTestBase
46 {
47         public
48     JMXMonitorMgrTest( )
49     {
50     }
51     
52         public JMXMonitorMgr
53     getMgr()
54     {
55         return( getDomainRoot().getJMXMonitorMgr() );
56     }
57     
58         public void
59     testGetMgr()
60     {
61         final JMXMonitorMgr mgr = getMgr();
62         assert( mgr != null );
63     }
64     
65         public void
66     testCreateRemoveStringMonitor()
67         throws IOException JavaDoc
68     {
69         final JMXMonitorMgr mgr = getMgr();
70         
71         final AMXStringMonitor mon = mgr.createStringMonitor( getClass().getName() + "Test" );
72         final ObjectName JavaDoc objectName = Util.getObjectName( mon );
73         
74         mon.setObservedAttribute( "Group" );
75         final ObjectName JavaDoc observee = Util.getObjectName( mgr );
76         assert( observee != null );
77         mon.addObservedObject( observee );
78         assert mon.containsObservedObject( observee );
79         mon.removeObservedObject( observee );
80         
81         assert( getConnection().isRegistered( objectName ) );
82         mgr.remove( mon.getName() );
83         assert( ! getConnection().isRegistered( objectName ) );
84     }
85 }
86
87
88
Popular Tags