1 23 24 29 package com.sun.enterprise.management.client; 30 31 import java.util.Set ; 32 import java.util.Map ; 33 import java.util.List ; 34 import java.util.ArrayList ; 35 import java.util.Collections ; 36 import java.util.logging.Level ; 37 38 import javax.management.ObjectName ; 39 import javax.management.MBeanServerConnection ; 40 import javax.management.AttributeList ; 41 import javax.management.MBeanInfo ; 42 import javax.management.MBeanAttributeInfo ; 43 import javax.management.MBeanOperationInfo ; 44 import javax.management.InstanceNotFoundException ; 45 import javax.management.Notification ; 46 import javax.management.NotificationListener ; 47 import javax.management.AttributeChangeNotification ; 48 49 import com.sun.appserv.management.base.AMX; 50 import com.sun.appserv.management.base.Util; 51 import com.sun.appserv.management.base.NotificationServiceMgr; 52 import com.sun.appserv.management.base.NotificationService; 53 import com.sun.appserv.management.helper.NotificationServiceHelper; 54 import com.sun.appserv.management.base.QueryMgr; 55 import com.sun.appserv.management.client.ProxyFactory; 56 import com.sun.appserv.management.util.misc.ExceptionUtil; 57 58 59 import com.sun.enterprise.management.AMXTestBase; 60 import com.sun.enterprise.management.Capabilities; 61 62 63 65 public final class ProxyFactoryTest extends AMXTestBase 66 { 67 public 68 ProxyFactoryTest( ) 69 { 70 } 71 public static Capabilities 72 getCapabilities() 73 { 74 return getOfflineCapableCapabilities( false ); 75 } 76 77 78 82 public void 83 testProxyFactoryDetectsMBeanRemoved() 84 throws InstanceNotFoundException 85 { 86 final NotificationServiceMgr mgr = getDomainRoot().getNotificationServiceMgr(); 89 final NotificationService ns = mgr.createNotificationService( "UserData", 10 ); 90 final ObjectName nsObjectName = Util.getObjectName( ns ); 91 assert( ns.getUserData().equals( "UserData" ) ); 92 93 final ProxyFactory factory = getProxyFactory(); 94 final NotificationService proxy = 95 factory.getProxy( nsObjectName, NotificationService.class, false ); 96 assert( proxy == ns ) : "proxies differ: " + ns + "\n" + proxy; 97 98 mgr.removeNotificationService( ns.getName() ); 99 100 int iterations = 0; 101 long sleepMillis = 10; 102 while( factory.getProxy( nsObjectName, NotificationService.class, false ) != null ) 103 { 104 mySleep( sleepMillis ); 105 if ( sleepMillis >= 400 ) 106 { 107 trace( "testProxyFactoryDetectsMBeanRemoved: waiting for proxy to be removed" ); 108 } 109 sleepMillis *= 2; 110 } 111 } 112 } 113 114 115 116 117 118 119 120 121 122 | Popular Tags |