public void testInterceptorWithDependencyRedeploy() throws Exception
{
deploy(getFile1());
try
{
POJO pojo;
try
{
pojo = (POJO) getBean("Intercepted");
fail("Bean should not be installed until the dependency is");
}
catch (IllegalStateException expected)
{
KernelControllerContext context = getControllerContext("Intercepted", ControllerState.DESCRIBED);
assertNotNull(context);
}
deploy(getFile0());
try
{
validate();
Dependency dependency = (Dependency) getBean("Dependency");
assertNotNull(dependency);
pojo = (POJO) getBean("Intercepted");
assertNotNull(pojo);
pojo.method(2);
assertTrue(dependency == TestInterceptorWithDependency.invoked);
}
finally
{
undeploy(getFile0());
}
try
{
pojo = (POJO) getBean("Intercepted");
fail("Bean should not be installed after the dependency is undeployed");
}
catch (IllegalStateException expected)
{
KernelControllerContext context = getControllerContext("Intercepted", ControllerState.DESCRIBED);
assertNotNull(context);
}
deploy(getFile0());
try
{
validate();
Dependency dependency = (Dependency) getBean("Dependency");
assertNotNull(dependency);
pojo = (POJO) getBean("Intercepted");
assertNotNull(pojo);
int called = TestInterceptorWithDependency.called;
pojo.method(2);
assertTrue("Interceptor was not rebound", called + 1 == TestInterceptorWithDependency.called);
assertTrue("Should not be caching the interceptor/dependency across rebinding", dependency == TestInterceptorWithDependency.invoked);
}
finally
{