Methods Summary |
---|
protected void | checkConnection(javax.management.MBeanServerConnection conn)
assert( getConnection() != null );
try
{
conn.isRegistered( JMXUtil.getMBeanServerDelegateObjectName() );
}
catch( Exception e )
{
fail( "Connection failed:\n" +
ExceptionUtil.getStackTrace( getRootCause( e ) ) );
}
|
protected void | checkConnection()
checkConnection( getConnection( ) );
|
protected boolean | checkNotOffline(java.lang.String testName)Check if we're testing in Offline mode, which means that
Config MBeans are loaded in-process. If so, issue a warning.
boolean offline = getTestOffline();
if ( offline )
{
//warning( "amxtest.testOffline=true, skipping test " + testName + "()" );
}
return ! offline;
|
com.sun.enterprise.management.support.AMXDebugSupportMBean | getAMXDebugSupportMBean()
final ObjectName objectName = Util.newObjectName( AMXDebugSupportMBean.OBJECT_NAME );
try
{
return (AMXDebugSupportMBean)newProxy( objectName, AMXDebugSupportMBean.class );
}
catch( Exception e )
{
assert false : "Can't get proxy to " + objectName;
}
return null;
|
protected java.util.Set | getAllAMX()
return getTestUtil().getAllAMX();
|
protected com.sun.appserv.management.base.BulkAccess | getBulkAccess()
return( getDomainRoot().getBulkAccess() );
|
protected com.sun.appserv.management.config.ConfigConfig | getConfigConfig(java.lang.String name)
final Map<String,ConfigConfig> configs = getDomainConfig().getConfigConfigMap();
return configs.get( name == null ? PE_CONFIG_NAME : name );
|
protected static com.sun.appserv.management.config.ConfigConfig | getConfigConfig(com.sun.appserv.management.config.AMXConfig any)
final ObjectName objectName = Util.getObjectName( any );
final String configName = objectName.getKeyProperty( XTypes.CONFIG_CONFIG );
return any.getDomainRoot().getDomainConfig().getConfigConfigMap().get( configName );
|
protected com.sun.appserv.management.config.ConfigConfig | getConfigConfig()
return( getConfigConfig( PE_CONFIG_NAME ) );
|
protected java.lang.String[] | getConfigNames()
final Map<String,ConfigConfig> configMap =
getDomainConfig().getConfigConfigMap();
return( GSetUtil.toStringArray( configMap.keySet() ) );
|
protected javax.management.MBeanServerConnection | getConnection()
return( getGlobalConnection() );
|
protected com.sun.appserv.management.client.ConnectionSource | getConnectionSource()
assert( mConnectionSource != null );
return( mConnectionSource );
|
protected com.sun.appserv.management.config.NodeAgentConfig | getDASNodeAgentConfig()
final String name = getDASNodeAgentName();
NodeAgentConfig config = null;
if ( name != null )
{
config = getDomainConfig().getNodeAgentConfigMap().get( name );
}
return config;
|
protected java.lang.String | getDASNodeAgentName()
return getEnvString( PropertyKeys.DAS_NODE_AGENT_NAME, null);
|
public static Capabilities | getDefaultCapabilities()
return getOfflineCapableCapabilities( true );
|
protected static java.lang.String | getDefaultInstanceName(java.lang.String qualifier)
String name = null;
if ( qualifier == null )
{
name = DEFAULT_INSTANCE_NAME;
}
else
{
name = qualifier + "." + DEFAULT_INSTANCE_NAME;
}
return name;
|
protected final com.sun.appserv.management.config.DomainConfig | getDomainConfig()
return( getDomainRoot().getDomainConfig() );
|
protected final com.sun.appserv.management.DomainRoot | getDomainRoot()
assert( mDomainRoot != null ) : "mDomainRoot is null";
return( mDomainRoot );
|
protected java.lang.Class | getInterfaceClass(com.sun.appserv.management.base.AMX proxy)
final String name = Util.getExtra( proxy ).getInterfaceName();
return( ClassUtil.getClassFromName( name ) );
|
protected final com.sun.appserv.management.j2ee.J2EEDomain | getJ2EEDomain()
return( getDomainRoot().getJ2EEDomain() );
|
protected com.sun.appserv.management.config.ModuleMonitoringLevelsConfig | getModuleMonitoringLevelsConfig(java.lang.String configName)
final ConfigConfig cc = configName == null ? getConfigConfig() : getConfigConfig( configName );
assert( cc != null );
final ModuleMonitoringLevelsConfig mon =
cc.getMonitoringServiceConfig().getModuleMonitoringLevelsConfig();
return( mon );
|
protected com.sun.appserv.management.config.ModuleMonitoringLevelsConfig | getModuleMonitoringLevelsConfig()
return getModuleMonitoringLevelsConfig( null );
|
protected java.util.Map | getNodeAgents()
final Map<?,?> m = Map.class.cast( getEnvValue( PropertyKeys.NODE_AGENTS_KEY ) );
return TypeCast.checkedMap( m,
String.class, AppserverConnectionSource.class);
|
protected final java.util.Set | getNotTestedSet()
return( mNotTested );
|
protected com.sun.appserv.management.base.NotificationServiceMgr | getNotificationServiceMgr()
return( getDomainRoot().getNotificationServiceMgr() );
|
protected static Capabilities | getOfflineCapableCapabilities(boolean offlineCapable)
final Capabilities c = new Capabilities( );
c.setOfflineCapable( offlineCapable );
return c;
|
protected final com.sun.appserv.management.base.AMX | getProxy(javax.management.ObjectName objectName)
final ProxyFactory factory = ProxyFactory.getInstance( getConnectionSource(), true);
final AMX proxy = factory.getProxy( objectName, AMX.class );
return( proxy );
|
protected final T | getProxy(javax.management.ObjectName objectName, java.lang.Class theClass)We don't have T extend AMX because not all mixin interfaces extend AMX.
return( theClass.cast( getProxy(objectName) ) );
|
protected com.sun.appserv.management.client.ProxyFactory | getProxyFactory()
return( mProxyFactory );
|
protected com.sun.appserv.management.base.QueryMgr | getQueryMgr()
assert( mDomainRoot != null );
final QueryMgr proxy = getDomainRoot().getQueryMgr();
assert( proxy != null );
return( proxy );
|
protected java.lang.Throwable | getRootCause(java.lang.Throwable t)
return ExceptionUtil.getRootCause( t );
|
protected java.lang.String | getRootCauseStackTrace(java.lang.Throwable t)
return getStackTrace( getRootCause( t ) );
|
protected java.lang.String | getStackTrace(java.lang.Throwable t)
return ExceptionUtil.getStackTrace( t );
|
protected boolean | getTestOffline()
return getEnvBoolean( PropertyKeys.TEST_OFFLINE_KEY, false );
|
protected TestUtil | getTestUtil()
return mTestUtil;
|
protected boolean | isRemoteIncomplete(javax.management.ObjectName objectName)
final AMX amx = getProxyFactory().getProxy( objectName, AMX.class );
final String j2eeType = amx.getJ2EEType();
final boolean isRemote = ! amx.isDAS();
if ( isRemote &&
! EXPECTED_REMOTE_INCOMPLETE_TYPES.contains( j2eeType ) )
{
warning( "isRemoteIncomplete: not expecting j2eeType=" + j2eeType +
", has the implementation changed?" );
}
return isRemote;
|
public static void | mySleep(long millis)
try
{
Thread.sleep( millis );
}
catch( InterruptedException e )
{
}
|
protected final void | notTested(javax.management.ObjectName objectName)
if ( isRemoteIncomplete( objectName ) )
{
trace( "remoteIncomplete (this is OK): " + objectName );
}
else
{
mNotTested.add( objectName );
}
|
public void | setUp()
super.setUp();
turnOnMonitoring();
|
protected boolean | shouldTest(javax.management.ObjectName objectName)
boolean shouldTest = ! isRemoteIncomplete( objectName );
return( shouldTest );
|
protected boolean | supportsClusters()
return getDomainRoot().getSystemInfo().supportsFeature( SystemInfo.CLUSTERS_FEATURE );
|
protected boolean | supportsMultipleServers()
return supportsMultipleServers( getDomainRoot() );
|
public static boolean | supportsMultipleServers(com.sun.appserv.management.DomainRoot domainRoot)
return domainRoot.getSystemInfo().supportsFeature( SystemInfo.MULTIPLE_SERVERS_FEATURE );
|
protected void | testAll(java.util.Collection objectNames, java.lang.String methodName)
final boolean success = testOnObjectNames( objectNames,
this.getClass().getMethod( methodName, OBJECTNAME_SIG ) );
assert( success );
|
protected void | testAll(java.lang.String methodName)
final Set<ObjectName> names = getTestUtil().getAllObjectNames();
testAll( names, methodName );
|
protected void | testAllProxies(java.util.Collection proxies, java.lang.String methodName)
final boolean success = testOnProxies( proxies,
this.getClass().getMethod( methodName, PROXY_SIG ) );
assert( success );
|
public void | testAssertsOn()
checkAssertsOn();
|
protected boolean | testOnObjectNames(java.util.Collection objectNames, java.lang.reflect.Method method)
boolean failed = false;
final Object[] args = new Object[ 1 ];
int testCount = 0;
final long start = now();
for( final ObjectName objectName : objectNames )
{
if ( ! shouldTest( objectName ) )
{
notTested( objectName );
continue;
}
++testCount;
try
{
args[ 0 ] = objectName;
method.invoke( this, args );
}
catch( Exception e )
{
final Throwable rootCause = getRootCause( e );
trace( method.getName() + " failed for: " +
quote( JMXUtil.toString( objectName ) ) + " with Exception of type " +
rootCause.getClass().getName() + ", msg = " + rootCause.getMessage() );
failed = true;
}
}
final long elapsed = now() - start;
printVerbose( "Ran test method " + method.getName() + " on " + testCount +
" candidates in " + elapsed + "ms");
warnNotTested();
return( ! failed );
|
protected boolean | testOnProxies(java.util.Collection proxies, java.lang.reflect.Method method)
final long start = now();
boolean failed = false;
int testCount = 0;
final Object[] args = new Object[ 1 ];
for( final T proxy : proxies )
{
final ObjectName objectName = Util.getExtra( proxy ).getObjectName();
if ( ! shouldTest( objectName ) )
{
notTested( objectName );
continue;
}
++testCount;
try
{
args[ 0 ] = proxy;
method.invoke( this, args );
}
catch( Exception e )
{
trace( method.getName() + " failed for proxy: " +
quote( JMXUtil.toString( objectName ) ) );
failed = true;
trace( ExceptionUtil.toString( e ) );
}
}
final long elapsed = now() - start;
printVerbose( "Ran test method " + method.getName() + " on " + testCount +
" candidates in " + elapsed + "ms");
warnNotTested();
warnNotTested();
return( ! failed );
|
protected synchronized void | turnOffMonitoring()
synchronized( AMXTestBase.class )
{
getModuleMonitoringLevelsConfig().changeAll( ModuleMonitoringLevelValues.OFF );
MONITORING_ENABLED = false;
}
|
protected synchronized void | turnOnMonitoring()Ensure that monitoring is enabled so that unit tests don't miss anything
if ( ! MONITORING_ENABLED )
{
synchronized( AMXTestBase.class )
{
final String[] configNames = getConfigNames();
for( int i = 0; i < configNames.length; ++i )
{
getModuleMonitoringLevelsConfig( configNames[ i ] ).changeAll( ModuleMonitoringLevelValues.HIGH );
}
MONITORING_ENABLED = true;
}
}
|
protected void | waitProxyGone(com.sun.appserv.management.client.ProxyFactory factory, javax.management.ObjectName objectName)Because proxies are cleaned up asynchronously, it's possible for one
to remain in the factory until the factory processes the Notification
that it's MBean has been unregistered.
long millis = 1;
while ( factory.getProxy( objectName, AMX.class, false ) != null )
{
mySleep( millis );
millis *= 2;
trace( "waitProxyGone: waiting for proxy to disappear: " + objectName );
}
|
protected void | waitUnregistered(javax.management.ObjectName objectName)
final MBeanServerConnection conn = getConnection();
if ( conn.isRegistered( objectName ) )
{
mySleep( 100 );
}
while ( conn.isRegistered( objectName ) )
{
trace( "waitUnregistered: " + objectName);
mySleep( 100 );
}
|
protected final void | warnNotTested()
final Set<ObjectName> notTested = getNotTestedSet();
if ( notTested.size() != 0 )
{
final Set j2eeTypes =
JMXUtil.getKeyPropertySet( AMX.J2EE_TYPE_KEY, notTested );
trace( "WARNING: DID NOT TEST: " + notTested.size() + " MBeans of types {" +
toString( j2eeTypes ) + "}" );
}
|