Methods Summary |
---|
protected java.lang.String | createMissingString(java.lang.String msg)
String result = "";
final Set<String> missing = findMissingJ2EETypes();
if ( missing.size() != 0 )
{
final Set<String> missingConfig = new HashSet<String>();
final Set<String> missingMonitors = new HashSet<String>();
final Set<String> missingOthers = new HashSet<String>();
groupMissingJ2EETypes( missing, missingConfig, missingMonitors, missingOthers );
result = msg + NEWLINE +
"Config: " + NEWLINE +
setToSortedString( missingConfig, NEWLINE) + NEWLINE + NEWLINE +
"Monitor: " + NEWLINE +
setToSortedString( missingMonitors, NEWLINE) + NEWLINE + NEWLINE +
"J2EE/Other: " + NEWLINE +
setToSortedString( missingOthers, NEWLINE);
}
return result;
|
protected java.util.Set | findMissingJ2EETypes()
final Set<String> missing = new HashSet<String>();
missing.addAll( XTypesMapper.getInstance().getJ2EETypes() );
missing.addAll( J2EETypesMapper.getInstance().getJ2EETypes() );
missing.removeAll( mTestUtil.findRegisteredJ2EETypes() );
final Set<ObjectName> registered =
Observer.getInstance().getRegistrationListener().getRegistered();
for( final ObjectName objectName : registered )
{
final String j2eeType = Util.getJ2EEType( objectName );
if ( j2eeType != null )
{
missing.remove( j2eeType );
}
}
return missing;
|
public java.util.Map | getCoverage(java.util.Set candidates)
final Map<String,CoverageInfo> coverageMap = new HashMap<String,CoverageInfo>();
for( final AMX amx: candidates )
{
final AMXDebugStuff debug = mTestUtil.asAMXDebugStuff( amx );
final CoverageInfo coverageInfo = debug.getCoverageInfo();
assert( coverageInfo != null );
handleSpecialCases( coverageInfo );
final String j2eeType = amx.getJ2EEType();
final CoverageInfo existing = coverageMap.get( j2eeType );
if ( existing != null )
{
existing.merge( coverageInfo );
}
else
{
coverageMap.put( j2eeType, coverageInfo );
}
}
return coverageMap;
|
public java.lang.String | getCoverageSummary()
final Set<AMX> amx = mTestUtil.getAllAMX();
final Map<String,CoverageInfo> coverage = getCoverage( amx );
final String[] j2eeTypes = GSetUtil.toStringArray( coverage.keySet() );
Arrays.sort( j2eeTypes );
final String LINE_SEP = System.getProperty( "line.separator" );
final StringBuilder builder = new StringBuilder();
for( final String j2eeType : j2eeTypes )
{
final CoverageInfo info = coverage.get( j2eeType );
final String infoString =
"Coverage for j2eeType = " + j2eeType +
": " + (info.getFullCoverage() ? "100%" : "INCOMPLETE COVERAGE" ) +
LINE_SEP +
info.toString( false ) + LINE_SEP + LINE_SEP;
builder.append( infoString );
}
final String msg =
"No AMX MBeans having the following types " +
"were ever present, and so were NEVER TESTED:" + NEWLINE;
builder.append( createMissingString( msg ) );
return builder.toString();
|
protected void | groupMissingJ2EETypes(java.util.Set allMissing, java.util.Set missingConfigs, java.util.Set missingMonitors, java.util.Set missingOthers)
for( final String j2eeType : allMissing )
{
if ( j2eeType.endsWith( "Config" ) )
{
missingConfigs.add( j2eeType );
}
else if ( j2eeType.endsWith( "Monitor" ) )
{
missingMonitors.add( j2eeType );
}
else
{
missingOthers.add( j2eeType );
}
}
|
private void | handleSpecialCases(com.sun.enterprise.management.support.CoverageInfo coverageInfo)Certain methods will never be called via remote access due to
the JMX implementation. removeNotificationListener() in particular
is only invoked in one way by the MBeanServer in response to
remote clients registering listeners. Omit these cases, since
they will never be invoked.
final Set<String> notInvoked = coverageInfo.getOperationsNotInvoked();
for( final String op : notInvoked )
{
for( final String prefix : IGNORE_METHODS )
{
if ( op.startsWith( prefix ) )
{
coverageInfo.markAsInvoked( op );
}
}
}
// make a copy, we'll be modifying it
final Set<String> unknown =coverageInfo.getUnknownAttributes().keySet();
for( final String s : unknown )
{
if ( s.startsWith( "bogus" ) ||
IGNORE_UNKNOWN.contains( s ) )
{
coverageInfo.ignoreUnknownAttribute( s );
}
}
|
private java.lang.String | setToSortedString(java.util.Set s, java.lang.String delim)
final String[] a = GSetUtil.toStringArray( s );
Arrays.sort( a );
return StringUtil.toString( NEWLINE, (Object[])a );
|