KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > admin > monitor > registry > spi > ManagedResourceIntrospectorTest


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  * Copyright 2004-2005 Sun Microsystems, Inc. All rights reserved.
26  * Use is subject to license terms.
27  */

28
29 /*
30  * ManagedResourceIntrospectorTest.java
31  *
32  * Created on August 7, 2003, 10:48 AM
33  */

34
35 package com.sun.enterprise.admin.monitor.registry.spi;
36
37 import junit.framework.*;
38 import javax.management.j2ee.statistics.Stats JavaDoc;
39 import javax.management.j2ee.statistics.Statistic JavaDoc;
40 import javax.management.*;
41
42
43 /**
44  * Unit Test for ManagedResourceIntrospector to test appropriateness of
45  * introspection for the purposes of generating an MBeanInfo Object
46  * @author sg112326
47  */

48 public class ManagedResourceIntrospectorTest extends TestCase {
49     public void testIntrospection(){
50         MBeanInfo info = mri.introspect(stats);
51         assertNotNull(info);
52         assertEquals(mbean.getClass().getName(), info.getClassName());
53     }
54
55     public void testGetParameterInfoWithNull(){
56         Class JavaDoc[] paramTypes = new Class JavaDoc[]{};
57         MBeanParameterInfo[] info = mri.getParameterInfo(paramTypes);
58         assertEquals(paramTypes.length, info.length);
59     }
60     
61     public void testGetParameterInfo(){
62         Class JavaDoc[] paramTypes = new Class JavaDoc[]{java.lang.String JavaDoc.class, java.lang.Integer JavaDoc.class,
63             javax.management.j2ee.statistics.Statistic JavaDoc.class};
64         MBeanParameterInfo[] info = mri.getParameterInfo(paramTypes);
65         assertEquals(paramTypes.length, info.length);
66     }
67     
68     public void testGetAttributeInfoWithNull(){
69         MBeanAttributeInfo[] info = mri.getAttributeInfo(null);
70         this.assertNull(info);
71     }
72     
73     public void testGetAttributeInfo(){
74         MBeanAttributeInfo[] info = mri.getAttributeInfo(stats);
75         assertNotNull(info);
76         assertEquals(28, info.length);
77     }
78     
79     public void testCreation(){
80         assertNotNull(mbean);
81         assertNotNull(mri);
82         assertNotNull(stats);
83     }
84
85     /** Creates a new instance of ManagedResourceIntrospectorTest */
86     public ManagedResourceIntrospectorTest(java.lang.String JavaDoc testName) {
87         super(testName);
88     }
89
90     DynamicMBean mbean=null;
91     ManagedResourceIntrospector mri=null;
92     Stats JavaDoc stats;
93     protected void setUp() {
94         stats = new S1ASJVMStatsImplMock();
95         mbean = new GeneratedMonitoringMBeanImpl(stats);
96         mri = new ManagedResourceIntrospector(mbean);
97     }
98     
99     protected void tearDown() {
100         
101     }
102     public static Test suite() {
103         TestSuite suite = new TestSuite(ManagedResourceIntrospectorTest.class);
104         return suite;
105     }
106     
107     public static void main(String JavaDoc[] args){
108         junit.textui.TestRunner.run(suite());
109     }
110 }
111
Popular Tags