1 23 24 package com.sun.enterprise.management.monitor; 25 26 import java.util.Set ; 27 import java.util.List ; 28 import java.util.Map ; 29 30 import com.sun.appserv.management.base.XTypes; 31 32 import com.sun.appserv.management.DomainRoot; 33 34 import com.sun.appserv.management.monitor.ServerRootMonitor; 35 import com.sun.appserv.management.monitor.CallFlowMonitor; 36 37 import com.sun.enterprise.management.AMXTestBase; 38 import com.sun.enterprise.management.Capabilities; 39 40 public final class CallFlowMonitorTest extends AMXMonitorTestBase 41 { 42 private String IP_FILTER_NAME = "129.129.129.129"; 43 private String PRINCIPAL_FILTER_NAME = "Harry"; 44 public CallFlowMonitorTest() 45 { 46 } 47 48 public void testCallFlowOn() 49 { 50 final CallFlowMonitor cfm = getCallFlowMonitor(); 51 try 52 { 53 cfm.setEnabled ( true ); 54 assertTrue( cfm.getEnabled() ); 55 } 56 catch( Throwable t ) 57 { 58 warning( "testCallFlowOn: " + 59 "Can't enable callflow...has the callflow database been started?" ); 60 } 61 } 62 63 public void testIPFilter () { 64 final CallFlowMonitor cfm = getCallFlowMonitor(); 65 cfm.setCallerIPFilter(IP_FILTER_NAME); 66 final String filter = cfm.getCallerIPFilter(); 67 boolean val = filter.equals(IP_FILTER_NAME); 68 assertTrue(val); 69 } 70 71 public void testPrincipalFilter () { 72 final CallFlowMonitor cfm = getCallFlowMonitor(); 73 cfm.setCallerPrincipalFilter(PRINCIPAL_FILTER_NAME); 74 final String filter = cfm.getCallerPrincipalFilter(); 75 boolean val = filter.equals(PRINCIPAL_FILTER_NAME); 76 assertTrue(val); 77 } 78 79 82 public void testCallFlowOff() { 83 final CallFlowMonitor cfm = getCallFlowMonitor(); 84 cfm.setEnabled( false ); 85 assertFalse( cfm.getEnabled() ); 86 } 87 88 public void testQueryRequestInformation (){ 89 final CallFlowMonitor cfm = getCallFlowMonitor(); 90 final List <Map <String , String >> list = cfm.queryRequestInformation (); 91 if(list == null) 92 assertTrue (true); 96 } 97 public void testQueryCallStackInformation(){ 98 final CallFlowMonitor cfm = getCallFlowMonitor(); 99 final List <Map <String , String >> list = cfm.queryCallStackForRequest ("RequestID_1"); 100 if(list == null) 101 assertTrue (true); 105 } 106 public void testQueryPieInformation(){ 107 final CallFlowMonitor cfm = getCallFlowMonitor(); 108 final Map <String , String > map = cfm.queryPieInformation ("RequestID_1"); 109 if(map != null) 110 assertTrue (true); 114 } 115 116 117 public void testClearData () { 118 final CallFlowMonitor cfm = getCallFlowMonitor(); 119 cfm.clearData(); 120 } 121 122 public void testQueryRequestTypeKeys (){ 123 final CallFlowMonitor cfm = getCallFlowMonitor(); 124 final String [] rT = cfm.queryRequestTypeKeys(); 125 if (rT.length == 5) 126 assertTrue(true); 127 else 128 assertTrue (false); 129 } 130 public void testQueryComponentTypeKeys (){ 131 final CallFlowMonitor cfm = getCallFlowMonitor(); 132 final String [] rT = cfm.queryComponentTypeKeys(); 133 assert rT.length == 7; 134 } 135 public void testQueryContainerTypeOrApplicationTypeKeys (){ 136 final CallFlowMonitor cfm = getCallFlowMonitor(); 137 final String [] rT = cfm.queryContainerTypeOrApplicationTypeKeys(); 138 assert rT.length == 6; 139 } 140 141 142 143 private CallFlowMonitor getCallFlowMonitor() { 144 Map <String ,ServerRootMonitor> serverRootMonitorMap = 145 getDomainRoot().getMonitoringRoot().getServerRootMonitorMap(); 146 ServerRootMonitor serverRootMonitor = serverRootMonitorMap.get("server"); 148 return serverRootMonitor.getCallFlowMonitor(); 149 } 150 151 public void testExactlyOneDASCallFlowMonitor() 152 { 153 final Set <CallFlowMonitor> cfms = 154 getQueryMgr().queryJ2EETypeSet( XTypes.CALL_FLOW_MONITOR ); 155 156 int numDAS = 0; 157 int numNonDAS = 0; 158 for( final CallFlowMonitor cfm : cfms ) 159 { 160 if ( cfm.isDAS() ) 161 { 162 ++numDAS; 163 } 164 else 165 { 166 ++numNonDAS; 167 } 168 } 169 170 if ( numNonDAS == 0 ) 171 { 172 warning( "testExactlyOneDASCallFlowMonitor: no instances other than DAS are running" ); 173 } 174 175 assert numDAS == 1 : 176 "There must be exactly one CallFlowMonitor in the DAS, but there are " + numDAS + 177 " and there are " + numNonDAS + " non-DAS CallFlowMonitor."; 178 179 } 180 } 181 182 183 184 | Popular Tags |