FileDocCategorySizeDatePackage
RefHelperTest.javaAPI DocGlassfish v2 API6844Fri May 04 22:24:04 BST 2007com.sun.enterprise.management.helper

RefHelperTest

public final class RefHelperTest extends com.sun.enterprise.management.AMXTestBase
This test should normally be run before the generic tests so that it can set up default items for many of the config elements so that the generic tests will actually test them. Otherwise, when the generic tests are run, they won't see any instances of many of the AMXConfig MBeans.

If there are errors doing this, disable this test in amxtest.classes, fix the error in the specific place it's occurring, then re-enabled this test.

Fields Summary
Constructors Summary
public RefHelperTest()

	
Methods Summary
public voidtestFindAllRefConfigs()

	    final Set<RefConfig>  all    =
	        RefHelper.findAllRefConfigs( getQueryMgr() );
	    
	    final Set<String>   referentJ2EETypes   = RefHelper.getReferentJ2EETypes();
	    assert( referentJ2EETypes.size() >= 4 );
	    
	    final Set<RefConfig>  allSeparately = new HashSet<RefConfig>();
	    
	    for( final String j2eeType : referentJ2EETypes )
	    {
	        final Set<RefConfig> refs    =
	            RefHelper.findAllRefConfigsByJ2EEType( getQueryMgr(), j2eeType ) ;
	        
	        for( final RefConfig ref : refs)
	        {
	            allSeparately.add( ref );
	        }
	    }
	    
	    assertEquals( all, allSeparately );
	
public voidtestFindAllRefConfigsByName()

	    final Set<RefConfig>  refs =
	        RefHelper.findAllRefConfigs( getQueryMgr() );
	    
	    final Set<String>   names   = Util.getNames( refs );
	    final Map<String,Set<RefConfig>> byName =
	        new HashMap<String, Set<RefConfig>>();
	    
	    // initialize map, keyed by name
	    for( final String name : names )
	    {
	        byName.put( name, new HashSet<RefConfig>() );
	    }
	    
	    // populate each Set with RefConfig of the same name
	    for( final RefConfig ref : refs )
	    {
	        final Set<RefConfig> s   = byName.get( ref.getName() );
	        
	        s.add( ref );
	    }
	    
	    // verify that the names all refer to the same type
	    for( final String name : byName.keySet() )
	    {
	        final Set<RefConfig>  s   = byName.get( name );
	        
	        final String  lastJ2EEType    = s.iterator().next().getJ2EEType();
	        for( final RefConfig ref : s )
	        {
	             assertEquals( ref.getJ2EEType(), lastJ2EEType );
	        }
	    }
	    
	    // now verify that we can get the same set another way
	    for( final String name : byName.keySet() )
	    {
	        final Set<RefConfig>  s   = byName.get( name );
	        
	        final String j2eeType   = s.iterator().next().getJ2EEType();
	        final Set<RefConfig>  s2   =
	            RefHelper.findAllRefConfigsWithName( getQueryMgr(), j2eeType, name );
	        
	        assertEquals( s, s2 );
	    }
	
public voidtestFindClusterRefs()

	    final Set<RefConfig>  refs1    =
	        RefHelper.findAllRefConfigsByJ2EEType( getQueryMgr(), XTypes.CLUSTER_REF_CONFIG);
	        
	    final Set<ClusterRefConfig>  refs2    =
	        RefHelper.findAllClusterRefConfigs( getQueryMgr() );
	    
	    assertEquals( refs1, refs2 );
	
public voidtestFindDeployedItemRefs()

	    final Set<RefConfig>  refs1    =
	        RefHelper.findAllRefConfigsByJ2EEType( getQueryMgr(), XTypes.DEPLOYED_ITEM_REF_CONFIG);
	        
	    final Set<DeployedItemRefConfig>  refs2    =
	        RefHelper.findAllDeployedItemRefConfigs( getQueryMgr() );
	    
	    assertEquals( refs1, refs2 );
	
public voidtestFindResourceRefs()

	    final Set<ResourceRefConfig>  refs1    =
	        RefHelper.findAllRefConfigsByJ2EEType( getQueryMgr(), XTypes.RESOURCE_REF_CONFIG);
	        
	    final Set<ResourceRefConfig>  refs2    =
	        RefHelper.findAllResourceRefConfigs( getQueryMgr() );
	    
	    assertEquals( refs1, refs2 );
	
public voidtestFindServerRefs()

	    final Set<RefConfig>  refs1    =
	        RefHelper.findAllRefConfigsByJ2EEType( getQueryMgr(), XTypes.SERVER_REF_CONFIG);
	        
	    final Set<ServerRefConfig>  refs2    =
	        RefHelper.findAllServerRefConfigs( getQueryMgr() );
	    
	    assertEquals( refs1, refs2 );