FileDocCategorySizeDatePackage
QueryMgrTest.javaAPI DocGlassfish v2 API11416Fri May 04 22:23:54 BST 2007com.sun.enterprise.management.base

QueryMgrTest

public final class QueryMgrTest extends com.sun.enterprise.management.AMXTestBase

Fields Summary
final com.sun.appserv.management.base.QueryMgr
mQM
private static final Set
RESOURCE_TYPES
Constructors Summary
public QueryMgrTest()

		mQM	 = getQueryMgr();
	
Methods Summary
private voidcheckAMXWithObjectNames(java.lang.String msg, java.util.Set set1, java.util.Set set2)

	    if ( set1.size() != set2.size() )
	    {
	        failure( msg + "set sizes don't match: " + set1.size() + " != " + set2.size() );
	    }
	    
	    final Set<ObjectName>   set1ObjectNames = new HashSet<ObjectName>();
	    for( final AMX item : set1 )
	    {
	        final ObjectName    objectName  = Util.getObjectName( item );
	        
	        if ( set1ObjectNames.contains( objectName ) )
	        {
	            failure( "set1 contains the same proxy twice with ObjectName: " + objectName );
	        }
	        set1ObjectNames.add( objectName );
	    }
	    
	    checkSetsEqual( msg, set1ObjectNames, set2 );
	
private voidcheckSetsEqual(java.lang.String msg, java.util.Set set1, java.util.Set set2)

		if ( ! set1.equals( set2 ) )
		{
			final Set<T>	conflict	= GSetUtil.newNotCommonSet( set1, set2 );
			final String	values	= CollectionUtil.toString( conflict, "\n" );
			failure( msg + ", mismatch =\n" + values );
		}
	
private java.util.SetgetAllInterfaceNames(java.util.Set amxSet)

		final Set<String> interfaceNames	= new HashSet<String>();
		for( final T amx : amxSet )
		{
			interfaceNames.add( Util.getExtra( amx ).getInterfaceName() );
		}
		
		return( interfaceNames );
	
public static com.sun.enterprise.management.CapabilitiesgetCapabilities()

	    return getOfflineCapableCapabilities( true );
	
public voidtestGetJ2EETypeObjectNames()

		final long	start	= now();
		
		final Set<String>	j2eeTypes	= getTestUtil().getAvailJ2EETypes();
		for( final String j2eeType : j2eeTypes )
		{
			final Set<AMX> results	=
				getQueryMgr().queryJ2EETypeSet(j2eeType );
			assert( results.size() >= 1 );
		}
		
		printElapsed( "testGetJ2EETypeObjectNames", start );
	
public voidtestGetJ2EETypeProxies()

		final long	start	= now();
		final Set<String>	j2eeTypes	= getTestUtil().getAvailJ2EETypes();

		for( final String j2eeType : j2eeTypes )
		{
			final Set<AMX> proxies	=
				getQueryMgr().queryJ2EETypeSet( j2eeType );
				
			assert( proxies != null );
		}
		
		printElapsed( "testGetJ2EETypeProxies", start );
	
public voidtestGetQueryMgr()

		assert(  getQueryMgr() != null );
	
public voidtestQueryAll()

		final long	start	= now();
		final Set	result	= getQueryMgr().queryAllSet();
		
		assert( result.size() > 1 );
		
		printElapsed( "testQueryAll", start );
	
public voidtestQueryAll_AMXMatchesObjectName()

		final long	start	= now();

        final Set<AMX> allSet          = mQM.queryAllSet();
        final Set<ObjectName> allObjectNameSet   = mQM.queryAllObjectNameSet();
        
        assert( allSet.size() == allObjectNameSet.size() );
        
		checkAMXWithObjectNames(
			"queryAllSet() != queryAllObjectNameSet()",
			allSet, allObjectNameSet );
		
		printElapsed( "testQueryAll_AMXMatchesObjectName", start );
	
public voidtestQueryInterfaceObjectNames()
Final all available interfaces, then for each type of interface, query for all items that have the interface and verify that's the interface they return from getInterfaceName().

		final long	start	= now();
		
		final QueryMgr queryMgr	= getQueryMgr();
		final Set<AMX> allAMX	= getQueryMgr().queryAllSet();
		final Set<ObjectName> allAMXObjectNames	= Util.toObjectNames( allAMX );
		final Set<String> interfaceNames	= getAllInterfaceNames( allAMX );
		
		for( final String interfaceName : interfaceNames )
		{
			final Set	amxs	= queryMgr.queryInterfaceSet( interfaceName, allAMXObjectNames );

			final Iterator	amxIter	= amxs.iterator();
			while ( amxIter.hasNext() )
			{
				final AMX	amx	= Util.asAMX(amxIter.next());
				assert( interfaceName.equals( Util.getExtra( amx ).getInterfaceName() ) );
			}
		}
		
		printElapsed( "testQueryInterfaceObjectNames", start );
	
public voidtestQueryInterfacePvsON()

		final long	start	= now();

		final Set<AMX> candidates			= mQM.queryAllSet();
		final Set<ObjectName> candidateObjectNames	= Util.toObjectNames( candidates );
		final String interfaceName	= DomainRoot.class.getName();
		checkAMXWithObjectNames(
			"queryInterfaceSet() != queryInterfaceObjectNameSet()",
			mQM.queryInterfaceSet( interfaceName, candidateObjectNames ),
			mQM.queryInterfaceObjectNameSet( interfaceName, candidateObjectNames ) );
		printElapsed( "testQueryInterfacePvsON", start );
	
public voidtestQueryJ2EENamePvsON()

		final long	start	= now();

		final String	name	= getDomainRoot().getName();
		checkAMXWithObjectNames(
			"queryJ2EENameSet() != queryJ2EENameObjectNameSet()",
			mQM.queryJ2EENameSet( name ),
			mQM.queryJ2EENameObjectNameSet( name ) );
		printElapsed( "testQueryJ2EENamePvsON", start );
	
public voidtestQueryJ2EETypePvsON()

		final long	start	= now();
		
		final String	testType1	= XTypes.DOMAIN_CONFIG;
		checkAMXWithObjectNames(
				"queryJ2EETypeSet(XTypes.DOMAIN_CONFIG) != queryJ2EETypeObjectNameSet(XTypes.DOMAIN_CONFIG)",
				mQM.queryJ2EETypeSet( testType1 ),
				mQM.queryJ2EETypeObjectNameSet( testType1 ) );
		printElapsed( "testQueryJ2EETypePvsON", start );
	
public voidtestQueryJ2EETypesSet()

        
		 
	
		 
	
		final long	start	= now();

        final Set<ResourceConfig>   resources = mQM.queryJ2EETypesSet( RESOURCE_TYPES );
        final Set<ObjectName>       resourcesObjectNames = mQM.queryJ2EETypesObjectNameSet( RESOURCE_TYPES );
        
		assert( resourcesObjectNames.size() >= 1 ) : "testQueryJ2EETypesSet: no resources found for " + CollectionUtil.toString( RESOURCE_TYPES, ", ");
		assert( resources.size() >= 1 )  : "testQueryJ2EETypesSet: no resource ObjectNames found!";;
        
		checkAMXWithObjectNames(
				"queryJ2EETypesSet(...) != queryJ2EETypesObjectNameSet(...)",
				resources, resourcesObjectNames );
        
        //println( resourcesObjectNames );

		printElapsed( "testQueryJ2EETypesSet", start );
	
public voidtestQueryPatternProxies()

		final long	start	= now();
		
		final Set	proxies		= getQueryMgr().queryPropsSet( "*" );

		assert proxies != null;
		
		printElapsed( "testQueryPatternProxies", start );
	
public voidtestQueryPatternPvsON()

		final long	start	= now();
		
		final String	domain	= Util.getObjectName( mQM ).getDomain();
		final ObjectName	pat	= JMXUtil.newObjectNamePattern( domain, "*" );
		checkAMXWithObjectNames(
			"queryPatternSet() != queryPatternObjectNameSet()",
			mQM.queryPatternSet( pat ),
			mQM.queryPatternObjectNameSet( pat ) );
					
		checkAMXWithObjectNames(
			"queryPatternSet() != queryPatternObjectNameSet()",
			mQM.queryPatternSet( domain, "*" ),
			mQM.queryPatternObjectNameSet( domain, "*" ) );
		printElapsed( "testQueryPatternPvsON", start );
	
public voidtestQueryPropsPvsON()

		final long	start	= now();

		final String	domain	= Util.getObjectName( mQM ).getDomain();
		final String	props	= Util.makeRequiredProps( XTypes.DOMAIN_ROOT, domain );
		checkAMXWithObjectNames(
			"queryPropsSet() != queryPropsObjectNameSet()",
			mQM.queryPropsSet( props ),
			mQM.queryPropsObjectNameSet( props ) );
		printElapsed( "testQueryPropsPvsON", start );
	
public voidtestQueryWildPvsON()

		final long	start	= now();
		
		final String[]	wildNames	= new String[]	{ "*" };
		final String[]	wildValues	= new String[]	{ "*" };
		checkAMXWithObjectNames(
			"queryWildSet() != queryWildObjectNameSet()",
			mQM.queryWildSet( wildNames, wildValues ),
			mQM.queryWildObjectNameSet( wildNames, wildValues ) );
		printElapsed( "testQueryWildPvsON", start );