KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > hivemind > management > TestPerformanceMonitorFactory


1 // Copyright 2005 The Apache Software Foundation
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
//
7
// http://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14

15 package org.apache.hivemind.management;
16
17 import javax.management.MBeanServer JavaDoc;
18 import javax.management.ObjectInstance JavaDoc;
19 import javax.management.ObjectName JavaDoc;
20
21 import org.apache.hivemind.Registry;
22 import org.apache.hivemind.xml.XmlTestCase;
23
24 /**
25  * Test of {@link org.apache.hivemind.management.impl.PerformanceMonitorFactory}.
26  *
27  * @author Achim Huegen
28  * @since 1.1
29  */

30 public class TestPerformanceMonitorFactory extends XmlTestCase
31 {
32     /**
33      * Tests the creation of a performance interceptor via the registry
34      */

35     public void testIntegration() throws Exception JavaDoc
36     {
37         Registry registry = buildFrameworkRegistry("testPerformanceMonitorFactory.xml");
38
39         // Get Calculator service so that interceptor gets created
40
Calculator calculator = (Calculator) registry.getService(Calculator.class);
41         calculator.getSum();
42
43         // Look for the mbean that collects the performance data
44
MBeanServer JavaDoc mbeanServer = (MBeanServer JavaDoc) registry.getService(MBeanServer JavaDoc.class);
45         ObjectName JavaDoc objectName = new ObjectName JavaDoc(
46                 "hivemind:module=test.management,type=service,id=Calculator,decorator=PerformanceCollector");
47         ObjectInstance JavaDoc instance = mbeanServer.getObjectInstance(objectName);
48         assertNotNull(instance);
49
50         // Execute some operations for code coverage
51
calculator.add(123);
52         
53         
54         // Shutdown the registry, to make sure the JMX server is shutdown
55

56         registry.shutdown();
57     }
58
59 }
Popular Tags