1 package org.objectweb.petals.jbi.management.service; 2 3 import javax.management.MBeanServer ; 4 import javax.management.ObjectName ; 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 compName = null; 27 28 protected void setUp() throws Exception { 29 super.setUp(); 30 manager = new LifeCycleManagerImpl(); 31 manager.start(); 32 33 jmx = createMock(AdminAttributes.class); 34 manager.adminAttributes = jmx; 36 37 compName = new ObjectName ("test:name=test"); 38 } 39 40 44 public void testRegisterBindingComponent() throws Exception { 45 ComponentLifeCycle comp = new ComponentLifeCycle(null, null, null, 46 null, compName, null, new LoggingUtil(null)); 47 48 MBeanServer beanServer = createMock(MBeanServer .class); 49 expect(jmx.getRawMBeanServer()).andReturn(beanServer); 51 replay(jmx); 53 manager.registerBindingComponent(comp); 54 verify(jmx); 55 } 56 57 61 public void testUnregisterBindingComponent() throws Exception { 62 MBeanServer beanServer = createMock(MBeanServer .class); 63 expect(jmx.getRawMBeanServer()).andReturn(beanServer); 65 replay(jmx); 67 manager.unregisterBindingComponent(compName); 68 verify(jmx); 69 } 70 71 72 76 public void testRegisterEngineComponent() throws Exception { 77 ComponentLifeCycle comp = new ComponentLifeCycle(null, null, null, 78 null, compName, null, new LoggingUtil(null)); 79 80 MBeanServer beanServer = createMock(MBeanServer .class); 81 expect(jmx.getRawMBeanServer()).andReturn(beanServer); 83 replay(jmx); 85 manager.registerEngineComponent(comp); 86 verify(jmx); 87 } 88 89 93 public void testUnregisterEngineComponent() throws Exception { 94 MBeanServer beanServer = createMock(MBeanServer .class); 95 expect(jmx.getRawMBeanServer()).andReturn(beanServer); 97 replay(jmx); 99 manager.unregisterEngineComponent(compName); 100 verify(jmx); 101 102 } 103 104 108 public void testRegisterInstaller() throws Exception { 109 Installer comp = new Installer(null, null, null, null, null, null, 110 compName, null); 111 MBeanServer beanServer = createMock(MBeanServer .class); 112 expect(jmx.getRawMBeanServer()).andReturn(beanServer); 114 replay(jmx); 116 manager.registerInstaller(comp); 117 verify(jmx); 118 } 119 120 124 public void testUnregisterInstaller() throws Exception { 125 MBeanServer beanServer = createMock(MBeanServer .class); 126 expect(jmx.getRawMBeanServer()).andReturn(beanServer); 128 replay(jmx); 130 manager.unregisterEngineComponent(compName); 131 verify(jmx); 132 } 133 134 } 135 | Popular Tags |