Methods Summary |
---|
public long | elapsed(long start)
return( System.currentTimeMillis() - start );
|
public javax.management.MBeanServerConnection | getMBeanServerConnection()
return( mConn == null ? null : mConn.getMBeanServerConnection( false ) );
|
private void | print(java.lang.Object o)
System.out.print( toString( o ) );
|
protected void | printVerbose(java.lang.Object o)
if ( mVerbose )
{
println( o );
}
|
private void | println(java.lang.Object o)
System.out.println( toString( o ) );
|
protected void | runAll(java.util.List testClasses, boolean threaded, java.util.Map env)
mVerbose = Boolean.valueOf( (String)env.get( PropertyKeys.VERBOSE_KEY ) ).booleanValue();
//testSpeed();
// use the current connection which must contain the AMX MBeans
final MBeanServerConnection conn = getMBeanServerConnection();
JMXTestBase.setGlobalConnection( conn );
JMXTestBase.setEnvValues( env );
println( "\n--- " + testClasses.size() + " TEST CLASSES ---" );
for( final Class<junit.framework.TestCase> theClass : testClasses )
{
println( theClass.getName() );
}
println( "\n--- BEGIN TESTS ---" );
runTests( testClasses, threaded );
|
public int | runSuite(java.lang.String name, junit.framework.TestSuite suite)
System.out.println( "*** testing " + name + " ***");
junit.textui.TestRunner runner = new junit.textui.TestRunner();
junit.framework.TestResult result = runner.doRun( suite, false );
return( result.failureCount() );
|
public void | runTests(java.util.List testClasses, boolean threaded)
for( final Class<junit.framework.TestCase> theClass : testClasses )
{
final int failureCount = threaded ?
testClassThreaded( theClass ) :
testClass( theClass );
if ( failureCount != 0 )
{
println( "Test " + theClass.getName() + " had failures: " + failureCount );
}
}
|
private void | testAppserverConnectionSource(java.lang.String host, java.lang.String user, java.lang.String password)Comment in call to this for hard-coded test.
MBeanServerConnection conn = null;
final TestClientTrustStoreTrustManager tm = new TestClientTrustStoreTrustManager();
final HandshakeCompletedListenerImpl hcl = new HandshakeCompletedListenerImpl();
tm.setPrompt( true );
final TLSParams tlsParams =
new TLSParams( new X509TrustManager[] { tm }, hcl );
println( "\ntestAppserverConnectionSource: testing: " + AppserverConnectionSource.PROTOCOL_RMI);
final ConnectionSource rmiSource =
new AppserverConnectionSource( AppserverConnectionSource.PROTOCOL_RMI,
host, 8686, user, password, null);
conn = rmiSource.getMBeanServerConnection( true );
conn.isRegistered( JMXUtil.getMBeanServerDelegateObjectName() );
println( AppserverConnectionSource.PROTOCOL_RMI + " OK using " + rmiSource );
println( "\ntestAppserverConnectionSource: testing: " + AppserverConnectionSource.PROTOCOL_HTTP );
final Map<String,String> env = Collections.emptyMap();
final ConnectionSource httpSource =
new AppserverConnectionSource( AppserverConnectionSource.PROTOCOL_HTTP,
host, 1234, user, password, tlsParams, env);
conn = httpSource.getMBeanServerConnection( true );
assert conn.isRegistered( JMXUtil.getMBeanServerDelegateObjectName() );
println( AppserverConnectionSource.PROTOCOL_HTTP + " OK using " + httpSource );
|
public int | testClass(java.lang.Class theClass)
final TestSuite suite = new TestSuite( theClass );
return( runSuite( theClass.getName(), suite ) );
|
public int | testClassThreaded(java.lang.Class theClass)
final TestSuite suite = new ActiveTestSuite( theClass );
return( runSuite( theClass.getName(), suite ) );
|
private void | testGetMBeanInfoSpeed(javax.management.MBeanServerConnection conn, java.lang.String domain, java.lang.String props)
final ObjectName pattern = Util.newObjectNamePattern( domain, props );
final Set<ObjectName> objectNameSet = JMXUtil.queryNames( conn, pattern, null);
final ObjectName[] objectNames = new ObjectName[ objectNameSet.size() ];
objectNameSet.toArray( objectNames );
final long elapsed = testGetMBeanInfoSpeed( conn, objectNames );
println( "Time to getMBeanInfo on " + domain + ":" + props + " (" + objectNames.length + " MBeans)" +
" = " + elapsed + "ms" );
|
private long | testGetMBeanInfoSpeed(javax.management.MBeanServerConnection conn, javax.management.ObjectName[] objectNames)
// sorting provides consistent, ordered output
Arrays.sort( objectNames, ObjectNameComparator.INSTANCE );
final long startAll = System.currentTimeMillis();
for( int i = 0; i < objectNames.length; ++i )
{
final ObjectName objectName = objectNames[ i ];
final long start = System.currentTimeMillis();
final MBeanInfo mbeanInfo = conn.getMBeanInfo( objectName );
final long elapsed = elapsed( start );
String id = objectName.toString();
String value;
if ( (value = objectName.getKeyProperty( "type" )) != null )
{
id = value;
}
else if ( (value = objectName.getKeyProperty( "j2eeType" )) != null )
{
id = value;
}
if ( (value = objectName.getKeyProperty( "name" )) != null )
{
id = Util.concatenateProps( id, Util.makeNameProp( value ) );
}
//printVerbose( "GetMBeanInfo time for " + id + " = " + elapsed );
}
final long elapsed = System.currentTimeMillis() - startAll;
return( elapsed );
|
public void | testSpeed()
final DomainRoot domainRootProxy = ProxyFactory.getInstance( mConn ).
createDomainRoot();
final MBeanServerConnection conn = getMBeanServerConnection();
testGetMBeanInfoSpeed( conn, Util.getObjectName( domainRootProxy ).getDomain(), JMXUtil.WILD_ALL );
|
public static java.lang.String | toString(java.lang.Object o)
return( SmartStringifier.toString( o ) );
|