public void testCardinalityCallbackReinstall() throws Throwable
{
callbackCardinalityReinstall();
ControllerContext context1 = assertInstall(0, "Name1", ControllerState.START);
BeanRepository repository = (BeanRepository)context1.getTarget();
assertNotNull(repository);
assertEmpty(repository.getBeans());
ControllerContext context2 = assertInstall(1, "Name2");
SimpleBean bean1 = (SimpleBean)context2.getTarget();
assertNotNull(bean1);
assertEmpty(repository.getBeans());
ControllerContext context3 = assertInstall(2, "Name3");
SimpleBean bean2 = (SimpleBean)context3.getTarget();
assertNotNull(bean2);
assertEquals(ControllerState.INSTALLED, context1.getState());
assertFalse(repository.getBeans().isEmpty());
assertEquals(2, repository.getBeans().size());
assertUninstall("Name1");
assertEquals(ControllerState.ERROR, context1.getState());
assertEmpty(repository.getBeans());
context1 = assertInstall(0, "Name1");
repository = (BeanRepository)context1.getTarget();
assertNotNull(repository);
assertFalse(repository.getBeans().isEmpty());
assertEquals(2, repository.getBeans().size());
assertUninstall("Name2");
assertEquals(ControllerState.ERROR, context2.getState());
assertEquals(ControllerState.START, context1.getState());
assertEmpty(repository.getBeans());
assertInstall(1, "Name2");
assertEquals(ControllerState.INSTALLED, context1.getState());
assertEquals(2, repository.getBeans().size());
assertUninstall("Name3");
assertEquals(ControllerState.ERROR, context3.getState());
assertEquals(ControllerState.START, context1.getState());
assertEmpty(repository.getBeans());
}