FileDocCategorySizeDatePackage
LBTest.javaAPI DocGlassfish v2 API6668Fri May 04 22:23:56 BST 2007com.sun.enterprise.management.config

LBTest

public final class LBTest extends com.sun.enterprise.management.AMXTestBase implements com.sun.enterprise.management.ClusterSupportRequired
Unit test class to create-delete lb-config and load-balancer elements

Fields Summary
final boolean
runDels
final boolean
runCreates
final boolean
testGetLoadBalancerConfigMap
Constructors Summary
public LBTest()

    
      
Methods Summary
public voidtestCreateLBConfig()

        if ( checkNotOffline( "testDeleteLBConfig" ) ) {
            if (!runCreates) return;
            String name = "test-lb-config";
            boolean monitoringEnabled = true;
            boolean routeCookieEnabled = false;
            boolean httpsRouting = false;
            String responseTimeout = "130";
            String reloadInterval = "380";        

            Map<String,String> params = new HashMap<String,String>();
            //params.put("name", name);
            params.put("route-cookie-enabled", "" + routeCookieEnabled);
            params.put("monitoring-enabled", "" + monitoringEnabled);
            params.put("https-routing", "" + httpsRouting);
            params.put("response-timeout-in-seconds", responseTimeout);
            params.put("reload-poll-interval-in-seconds", reloadInterval);

            try {
                getDomainConfig().createLBConfig(name, params);
            } catch (Throwable t) {
                t.printStackTrace();
            }
        }
    
public voidtestCreateLoadBalancerConfig()

	if ( checkNotOffline( "testDeleteLBConfig" ) ) {
            if (!runCreates) return;
            String name = "test-load-balancer";
            String lbConfigName = "test-lb-config";
            boolean autoApplyEnabled = true;
            Map<String,String> optional = null;
            try {
                getDomainConfig().createLoadBalancerConfig(name, lbConfigName, autoApplyEnabled, optional);
            } catch (Throwable t) {
                t.printStackTrace();
            }
        }
    
public voidtestDeleteLBConfig()

        if ( checkNotOffline( "testDeleteLBConfig" ) ) {
            
            if (!runDels) return;
            String name = "test-lb-config";
            try {
                getDomainConfig().removeLBConfig(name);
            } catch (Throwable t) {
                t.printStackTrace();
            }
        }
    
public voidtestDeleteLoadBalancerConfig()

        if ( checkNotOffline( "testDeleteLBConfig" ) ) {
            
            if (!runDels) return;
            String name = "test-load-balancer";
            try {
                getDomainConfig().removeLoadBalancerConfig(name);
            } catch (Throwable t) {
                t.printStackTrace();
            }
        }
    
public voidtestGetLBConfigMap()

        try {
            Map map = getDomainConfig().getLBConfigMap();
            //System.out.println("Here is a list of Load Balancer Config MBeans in DAS: ");
            //System.out.println(map);
        } catch (Throwable t) {
            t.printStackTrace();
        }   
    
public voidtestGetLoadBalancerConfigMap()

	if (testGetLoadBalancerConfigMap==false) return;
        try {
            Map map = getDomainConfig().getLoadBalancerConfigMap();
            //System.out.println("Here is a list of Load Balancer Config MBeans in DAS: ");
            //System.out.println(map);
            ObjectName objName = new ObjectName("amx:j2eeType=X-LoadBalancerConfig,name=test-load-balancer");
            MBeanInfo minfo = getConnection().getMBeanInfo(objName);
            MBeanAttributeInfo[] mattrsinfo = minfo.getAttributes();
            /*
            for (MBeanAttributeInfo mattrinfo : mattrsinfo) 
            {
                System.out.println("Attribute Name is : " + mattrinfo.getName());
            }
            */
            
            String[] attrsNames = (String[]) getConnection().getAttribute(objName, "AttributeNames");
            /*for (String attrName : attrsNames) 
                System.out.println("Actual Attribute Name is : " + attrName);            
            System.out.println("AttributeNames are : " + attrsNames);
            System.out.println("MBeanInfo is \n"+minfo);*/
            
            String attrName = (String) getConnection().getAttribute(objName, "LbConfigName");
            System.out.println("attrName is = "+attrName);
	} catch (Throwable t) {
            t.printStackTrace();
        }