A BundleContext should not become reusable after
bundle.stop()
bundle.start()
public void testStopedBundleContext() throws Exception
{
Bundle bundle = addBundle("/bundles/simple/", "simple-bundle1");
try
{
bundle.start();
BundleContext bundleContext = bundle.getBundleContext();
assertNotNull(bundleContext);
// The context should be illegal to use.
bundle.stop();
try
{
bundleContext.getProperty(getClass().getName());
fail("Should not be here!");
}
catch (Throwable t)
{
checkThrowable(IllegalStateException.class, t);
}
// The context should not become reusable after we restart the bundle
bundle.start();
try
{
bundleContext.getProperty(getClass().getName());
fail("Should not be here!");
}
catch (Throwable t)
{
checkThrowable(IllegalStateException.class, t);
}
}
finally
{
uninstall(bundle);
}
}