KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > petals > jbi > management > service > LifeCycleManagerImplTest


1 package org.objectweb.petals.jbi.management.service;
2
3 import javax.management.MBeanServer JavaDoc;
4 import javax.management.ObjectName JavaDoc;
5
6 import junit.framework.TestCase;
7
8 import org.objectweb.fractal.jmx.agent.AdminAttributes;
9 import org.objectweb.petals.jbi.component.lifecycle.ComponentLifeCycle;
10 import org.objectweb.petals.jbi.component.lifecycle.Installer;
11 import org.objectweb.petals.util.LoggingUtil;
12
13 import static org.easymock.EasyMock.createMock;
14 import static org.easymock.EasyMock.replay;
15 import static org.easymock.EasyMock.expect;
16 import static org.easymock.EasyMock.verify;
17
18 public class LifeCycleManagerImplTest extends TestCase {
19
20     AdminAttributes jmx = null;
21
22     LifeCycleManagerImpl manager = null;
23
24     MBeanNamesImpl mbnames = null;
25
26     ObjectName JavaDoc compName = null;
27
28     protected void setUp() throws Exception JavaDoc {
29         super.setUp();
30         manager = new LifeCycleManagerImpl();
31         manager.start();
32
33         jmx = createMock(AdminAttributes.class);
34         //replay(jmx);
35
manager.adminAttributes = jmx;
36
37         compName = new ObjectName JavaDoc("test:name=test");
38     }
39
40     /*
41      * Test method for
42      * 'org.objectweb.petals.jbi.management.service.LifeCycleManagerImpl.registerBindingComponent(ComponentLifeCycle)'
43      */

44     public void testRegisterBindingComponent() throws Exception JavaDoc {
45         ComponentLifeCycle comp = new ComponentLifeCycle(null, null, null,
46             null, compName, null, new LoggingUtil(null));
47
48         MBeanServer JavaDoc beanServer = createMock(MBeanServer JavaDoc.class);
49         // record scenario
50
expect(jmx.getRawMBeanServer()).andReturn(beanServer);
51         // play
52
replay(jmx);
53         manager.registerBindingComponent(comp);
54         verify(jmx);
55     }
56
57     /*
58      * Test method for
59      * 'org.objectweb.petals.jbi.management.service.LifeCycleManagerImpl.unregisterBindingComponent(ObjectName)'
60      */

61     public void testUnregisterBindingComponent() throws Exception JavaDoc {
62        MBeanServer JavaDoc beanServer = createMock(MBeanServer JavaDoc.class);
63         // record scenario
64
expect(jmx.getRawMBeanServer()).andReturn(beanServer);
65         // play
66
replay(jmx);
67         manager.unregisterBindingComponent(compName);
68         verify(jmx);
69     }
70
71     
72     /*
73      * Test method for
74      * 'org.objectweb.petals.jbi.management.service.LifeCycleManagerImpl.registerEngineComponent(ComponentLifeCycle)'
75      */

76     public void testRegisterEngineComponent() throws Exception JavaDoc {
77         ComponentLifeCycle comp = new ComponentLifeCycle(null, null, null,
78             null, compName, null, new LoggingUtil(null));
79         
80         MBeanServer JavaDoc beanServer = createMock(MBeanServer JavaDoc.class);
81         // record scenario
82
expect(jmx.getRawMBeanServer()).andReturn(beanServer);
83         // play
84
replay(jmx);
85         manager.registerEngineComponent(comp);
86         verify(jmx);
87     }
88
89     /*
90      * Test method for
91      * 'org.objectweb.petals.jbi.management.service.LifeCycleManagerImpl.unregisterEngineComponent(ObjectName)'
92      */

93     public void testUnregisterEngineComponent() throws Exception JavaDoc {
94         MBeanServer JavaDoc beanServer = createMock(MBeanServer JavaDoc.class);
95         // record scenario
96
expect(jmx.getRawMBeanServer()).andReturn(beanServer);
97         // play
98
replay(jmx);
99         manager.unregisterEngineComponent(compName);
100         verify(jmx);
101
102     }
103
104     /*
105      * Test method for
106      * 'org.objectweb.petals.jbi.management.service.LifeCycleManagerImpl.registerInstaller(Installer)'
107      */

108     public void testRegisterInstaller() throws Exception JavaDoc {
109         Installer comp = new Installer(null, null, null, null, null, null,
110             compName, null);
111         MBeanServer JavaDoc beanServer = createMock(MBeanServer JavaDoc.class);
112         // record scenario
113
expect(jmx.getRawMBeanServer()).andReturn(beanServer);
114         // play
115
replay(jmx);
116         manager.registerInstaller(comp);
117         verify(jmx);
118     }
119
120     /*
121      * Test method for
122      * 'org.objectweb.petals.jbi.management.service.LifeCycleManagerImpl.unregisterInstaller(ObjectName)'
123      */

124     public void testUnregisterInstaller() throws Exception JavaDoc {
125         MBeanServer JavaDoc beanServer = createMock(MBeanServer JavaDoc.class);
126         // record scenario
127
expect(jmx.getRawMBeanServer()).andReturn(beanServer);
128         // play
129
replay(jmx);
130         manager.unregisterEngineComponent(compName);
131         verify(jmx);
132     }
133
134 }
135
Popular Tags