1 23 24 29 package com.sun.enterprise.management.client; 30 31 import java.io.IOException ; 32 import java.util.Set ; 33 import java.util.Iterator ; 34 import java.util.Map ; 35 36 import javax.management.ObjectName ; 37 import javax.management.MBeanInfo ; 38 import javax.management.InstanceNotFoundException ; 39 40 import com.sun.appserv.management.base.AMX; 41 import com.sun.appserv.management.base.QueryMgr; 42 import com.sun.appserv.management.config.DASConfig; 43 import com.sun.appserv.management.base.XTypes; 44 import com.sun.appserv.management.base.Util; 45 import com.sun.appserv.management.base.NotificationService; 46 import com.sun.appserv.management.base.NotificationServiceMgr; 47 import com.sun.appserv.management.config.PropertiesAccess; 48 49 import com.sun.appserv.management.util.misc.ExceptionUtil; 50 51 52 import com.sun.enterprise.management.AMXTestBase; 53 import com.sun.enterprise.management.Capabilities; 54 55 56 58 public final class MiscTest extends AMXTestBase 59 { 60 public 61 MiscTest( ) 62 throws IOException 63 { 64 } 65 66 public void 67 testMBeanInfo() 68 { 69 final MBeanInfo info = new MBeanInfo ( 70 "foo.bar", 71 null, 72 null, 73 null, 74 null, 75 null ); 76 77 assert( info.getNotifications() != null ); 78 assert( info.getOperations() != null ); 79 assert( info.getAttributes() != null ); 80 assert( info.getConstructors() != null ); 81 } 82 83 public static Capabilities 84 getCapabilities() 85 { 86 return getOfflineCapableCapabilities( true ); 87 } 88 89 110 111 112 119 public void 120 testProxyDetectsMBeanRemoved() 121 throws InstanceNotFoundException 122 { 123 final NotificationServiceMgr mgr = getDomainRoot().getNotificationServiceMgr(); 126 127 final NotificationService ns = mgr.createNotificationService( "UserData", 10 ); 128 assert( ns.getUserData().equals( "UserData" ) ); 129 final ObjectName nsObjectName = Util.getObjectName( ns ); 130 131 mgr.removeNotificationService( ns.getName() ); 132 try 133 { 134 Util.getObjectName( ns ); 136 ns.getName(); 137 ns.getUserData(); 138 failure( "expecting exception due to missing MBean" ); 139 } 140 catch( Exception e ) 141 { 142 final Throwable t = ExceptionUtil.getRootCause( e ); 144 assert( t instanceof InstanceNotFoundException ); 145 final InstanceNotFoundException inf = (InstanceNotFoundException )t; 146 147 final String msg = inf.getMessage(); 148 final int objectNameStart = msg.indexOf( "amx:" ); 149 final String objectNameString = msg.substring( objectNameStart, msg.length() ); 150 151 final ObjectName on = Util.newObjectName( objectNameString ); 152 153 assert( on.equals( nsObjectName ) ); 154 } 155 } 156 157 158 159 } 160 161 162 | Popular Tags |