ControllerContext context1 = assertInstall(0, "Name1", ControllerState.DESCRIBED);
ControllerContext context2 = assertInstall(1, "Name2");
assertContext("Name1");
GenericBeanFactory factory1 = (GenericBeanFactory) context1.getTarget();
SimpleBean bean1 = (SimpleBean) factory1.createBean();
assertNotNull(bean1);
assertEquals("String1", bean1.getString());
GenericBeanFactory factory2 = (GenericBeanFactory) context2.getTarget();
SimpleBeanWithDependency bean2 = (SimpleBeanWithDependency) factory2.createBean();
assertNotNull(bean2);
assertEquals("String2", bean2.getString());
assertEquals(factory1, bean2.getFactory());
assertUninstall("Name1");
assertEquals(ControllerState.ERROR, context1.getState());
assertEquals(ControllerState.INSTANTIATED, context2.getState());
assertNotInstalled("Name2");
context2 = assertContext("Name2", ControllerState.INSTANTIATED);
context1 = assertInstall(0, "Name1");
assertEquals(ControllerState.INSTALLED, context2.getState());
factory1 = (GenericBeanFactory) context1.getTarget();
bean1 = (SimpleBean) factory1.createBean();
assertNotNull(bean1);
assertEquals("String1", bean1.getString());
factory2 = (GenericBeanFactory) context2.getTarget();
bean2 = (SimpleBeanWithDependency) factory2.createBean();
assertNotNull(bean2);
assertEquals("String2", bean2.getString());
assertEquals(factory1, bean2.getFactory());
assertUninstall("Name2");
context1 = assertContext("Name1");
factory1 = (GenericBeanFactory) context1.getTarget();
bean1 = (SimpleBean) factory1.createBean();
assertNotNull(bean1);
assertEquals("String1", bean1.getString());
context2 = assertInstall(1, "Name2");
factory1 = (GenericBeanFactory) context1.getTarget();
bean1 = (SimpleBean) factory1.createBean();
assertNotNull(bean1);
assertEquals("String1", bean1.getString());
factory2 = (GenericBeanFactory) context2.getTarget();
bean2 = (SimpleBeanWithDependency) factory2.createBean();
assertNotNull(bean2);
assertEquals("String2", bean2.getString());