Verify that when an MBean is removed, the ProxyFactory
detects this, and removes any proxy from its cache.
// use the NotificationServiceMgr as a convenient way of making
// an MBean (a NotificationService) come and go.
final NotificationServiceMgr mgr = getDomainRoot().getNotificationServiceMgr();
final NotificationService ns = mgr.createNotificationService( "UserData", 10 );
final ObjectName nsObjectName = Util.getObjectName( ns );
assert( ns.getUserData().equals( "UserData" ) );
final ProxyFactory factory = getProxyFactory();
final NotificationService proxy =
factory.getProxy( nsObjectName, NotificationService.class, false );
assert( proxy == ns ) : "proxies differ: " + ns + "\n" + proxy;
mgr.removeNotificationService( ns.getName() );
int iterations = 0;
long sleepMillis = 10;
while( factory.getProxy( nsObjectName, NotificationService.class, false ) != null )
{
mySleep( sleepMillis );
if ( sleepMillis >= 400 )
{
trace( "testProxyFactoryDetectsMBeanRemoved: waiting for proxy to be removed" );
}
sleepMillis *= 2;
}