ExoContainer currentContainer = new ExoContainer();
ExoContainerContext.setCurrentContainer(currentContainer);
try
{
ExoContainerFinder proxyObject =
MBeanServerInvocationHandler.newProxyInstance(server, oi.getObjectName(),
ExoContainerFinder.class, false);
assertTrue("We expect to get the current exo container", oldContainer == proxyObject.getCurrentExoContainer());
assertTrue("We expect to get the previous exo container", ExoContainerContext.getCurrentContainerIfPresent() == currentContainer);
ExoContainerContext.setCurrentContainer(oldContainer);
assertTrue("We expect to get the current exo container", oldContainer == proxyObject.getCurrentExoContainer());
assertTrue("We expect to get the previous exo container", ExoContainerContext.getCurrentContainerIfPresent() == oldContainer);
ExoContainerContext.setCurrentContainer(null);
assertTrue("We expect to get the current exo container", oldContainer == proxyObject.getCurrentExoContainer());
assertTrue("We expect to get the previous exo container", ExoContainerContext.getCurrentContainerIfPresent() == oldContainer);
}
finally
{
ExoContainerContext.setCurrentContainer(oldContainer);