// Create mocks
ExtMockControl bootstrapMock = ExtMockControl.createControl(Bootstrap.class);
Bootstrap bootstrap = (Bootstrap) bootstrapMock.getMock();
Bootstrap1.setDelegate(bootstrap);
ExtMockControl componentMock = ExtMockControl.createControl(Component.class);
Component component = (Component) componentMock.getMock();
Component1.setDelegate(component);
ExtMockControl lifecycleMock = ExtMockControl.createControl(ComponentLifeCycle.class);
ComponentLifeCycle lifecycle = (ComponentLifeCycle) lifecycleMock.getMock();
// configure bootstrap
bootstrapMock.reset();
bootstrap.init(null);
bootstrapMock.setMatcher(MockControl.ALWAYS_MATCHER);
bootstrap.onInstall();
bootstrap.getExtensionMBeanName();
bootstrapMock.setReturnValue(null);
bootstrap.cleanUp();
bootstrapMock.replay();
// configure component
componentMock.reset();
componentMock.replay();
// configure lifecycle
lifecycleMock.reset();
lifecycleMock.replay();
// test component installation
startContainer(true);
String installJarUrl = createInstallerArchive("component1").getAbsolutePath();
ObjectName installerName = getInstallationService().loadNewInstaller(installJarUrl);
InstallerMBean installer = (InstallerMBean) MBeanServerInvocationHandler.newProxyInstance(container.getMBeanServer(), installerName, InstallerMBean.class, false);
assertFalse(installer.isInstalled());
ObjectName lifecycleName = installer.install();
LifeCycleMBean lifecycleMBean = (LifeCycleMBean) MBeanServerInvocationHandler.newProxyInstance(container.getMBeanServer(), lifecycleName, LifeCycleMBean.class, false);
assertEquals(LifeCycleMBean.SHUTDOWN, lifecycleMBean.getCurrentState());
// check mocks
bootstrapMock.verify();
componentMock.verify();
lifecycleMock.verify();
// configure bootstrap
bootstrapMock.reset();
bootstrapMock.replay();
// configure component
componentMock.reset();
component.getLifeCycle();
componentMock.setReturnValue(lifecycle);
componentMock.replay();
// configure lifecycle
lifecycleMock.reset();
lifecycle.init(null);
lifecycleMock.setMatcher(MockControl.ALWAYS_MATCHER);
lifecycle.start();
lifecycleMock.replay();
// test component installation
lifecycleMBean.start();
assertEquals(LifeCycleMBean.STARTED, lifecycleMBean.getCurrentState());
// check mocks
bootstrapMock.verify();
componentMock.verify();
lifecycleMock.verify();
// configure bootstrap
bootstrapMock.reset();
bootstrapMock.replay();
// configure component
componentMock.reset();
componentMock.replay();
// configure lifecycle
lifecycleMock.reset();
lifecycle.stop();
lifecycle.shutDown();
lifecycleMock.replay();
// shutdown container
shutdownContainer();
// check mocks
bootstrapMock.verify();
componentMock.verify();
lifecycleMock.verify();
// configure bootstrap
bootstrapMock.reset();
bootstrap.init(null);
bootstrapMock.setMatcher(MockControl.ALWAYS_MATCHER);
bootstrap.getExtensionMBeanName();
bootstrapMock.setReturnValue(null);
bootstrapMock.replay();
// configure component
componentMock.reset();
component.getLifeCycle();
componentMock.setDefaultReturnValue(lifecycle);
componentMock.replay();
// configure lifecycle
lifecycleMock.reset();
lifecycle.getExtensionMBeanName();