reset(); component.getLifeCycle(); componentMock.setReturnValue(lifecycle); component.getServiceUnitManager(); componentMock.setReturnValue(manager, MockControl.ONE_OR_MORE); lifecycle.stop(); manager.shutDown("su"); lifecycle.shutDown(); replay(); shutdownContainer();
    public void testDeploySAThenComponent() throws Exception {    	final Object lock = new Object();    	// configure mocks    	Bootstrap1.setDelegate(new BootstrapDelegate(bootstrap) {    		public void cleanUp() throws JBIException {    			super.cleanUp();    			synchronized (lock) {    				lock.notify();				}    		}    	});    	reset();        bootstrap.init(null);        bootstrapMock.setMatcher(MockControl.ALWAYS_MATCHER);        bootstrap.onInstall();        bootstrap.cleanUp();        component.getLifeCycle();        componentMock.setReturnValue(lifecycle);        lifecycle.init(null);        lifecycleMock.setMatcher(MockControl.ALWAYS_MATCHER);        lifecycle.start();        component.getServiceUnitManager();        componentMock.setReturnValue(manager, MockControl.ONE_OR_MORE);        manager.deploy(null, null);        managerMock.setMatcher(MockControl.ALWAYS_MATCHER);        managerMock.setReturnValue(null);        manager.init(null, null);        managerMock.setMatcher(MockControl.ALWAYS_MATCHER);        manager.start("su");        replay();        // test component installation        startContainer(true);        File saJarUrl = createServiceAssemblyArchive("sa", "su", "component1");        File hdSa = new File(container.getEnvironmentContext().getDeploymentDir(), saJarUrl.getName());    	FileUtil.copyInputStream(new FileInputStream(saJarUrl),     			new FileOutputStream(hdSa));        Thread.sleep(2000);                String installJarUrl = createInstallerArchive("component1").getAbsolutePath();        File hdInstaller =  new File(container.getEnvironmentContext().getInstallationDir(), new File(installJarUrl).getName());        synchronized (lock) {        	FileUtil.copyInputStream(new FileInputStream(installJarUrl),         			new FileOutputStream(hdInstaller));        	lock.wait(5000);        }        Thread.sleep(2000);        ObjectName lifecycleName = container.getRegistry().getComponentObjectName("component1");        assertNotNull(lifecycleName);        LifeCycleMBean lifecycleMBean = (LifeCycleMBean)  MBeanServerInvocationHandler.newProxyInstance(container.getMBeanServer(), lifecycleName, LifeCycleMBean.class, false);        assertEquals(LifeCycleMBean.RUNNING, lifecycleMBean.getCurrentState());        // check mocks        verify();    }