deploy("CreatedBeansLifecycleCallbackWithDependencyTestCaseNotAutomatic0.xml");
try
{
validate();
Object dependency = getCheckBeanExists("Dependency");
LifecycleCallbackWithBeanDependency lifecycle = (LifecycleCallbackWithBeanDependency)getCheckBeanExists("LifecycleCallback");
getCheckBeanExists("Intercepted");
assertEquals(1, LifecycleCallbackWithBeanDependency.interceptions.size());
LifecycleCallbackWithBeanDependency.Handled handled = LifecycleCallbackWithBeanDependency.interceptions.get(0);
assertEquals("Intercepted", handled.contextName);
assertEquals(ControllerState.CONFIGURED, handled.toState);
assertNotNull(lifecycle.getDependency());
assertEquals(dependency, lifecycle.getDependency());
itworked = true;
}
finally
{
LifecycleCallbackWithBeanDependency.interceptions.clear();
undeploy("CreatedBeansLifecycleCallbackWithDependencyTestCaseNotAutomatic0.xml");
if (itworked)
{
assertEquals(1, LifecycleCallbackWithBeanDependency.interceptions.size());
LifecycleCallbackWithBeanDependency.Handled handled = LifecycleCallbackWithBeanDependency.interceptions.get(0);
assertEquals("Intercepted", handled.contextName);
assertEquals(ControllerState.CONFIGURED, handled.toState);
}
try
{
bean = (SimpleBean) getBean("Intercepted");
fail("'Interceped' should not be installed yet");
}
catch (IllegalStateException expected)
{
}
bean = (SimpleBean) getBean("Intercepted", ControllerState.DESCRIBED);
assertNull("This should not be deployed until the interceptor is", bean);
}
try
{
bean = (SimpleBean) getBean("Intercepted");
fail("'Interceped' should not be installed yet");
}
catch (IllegalStateException expected)
{
KernelControllerContext context = getControllerContext("Intercepted", ControllerState.DESCRIBED);
assertNotNull(context);
}
itworked = false;
LifecycleCallbackWithBeanDependency.interceptions.clear();
deploy("CreatedBeansLifecycleCallbackWithDependencyTestCaseNotAutomatic0.xml");
try
{
validate();
Object dependency = getCheckBeanExists("Dependency");
LifecycleCallbackWithBeanDependency lifecycle = (LifecycleCallbackWithBeanDependency)getCheckBeanExists("LifecycleCallback");
getCheckBeanExists("Intercepted");
assertEquals(1, LifecycleCallbackWithBeanDependency.interceptions.size());
LifecycleCallbackWithBeanDependency.Handled handled = LifecycleCallbackWithBeanDependency.interceptions.get(0);
assertEquals("Intercepted", handled.contextName);
assertEquals(ControllerState.CONFIGURED, handled.toState);
assertNotNull(lifecycle.getDependency());
assertTrue("Should not be caching the lifecycle's callback across rebinding", dependency == lifecycle.getDependency());
itworked = true;
}
finally
{