1 23 24 package com.sun.enterprise.management.config; 25 26 import java.util.Set ; 27 import java.util.Map ; 28 import java.util.HashMap ; 29 import javax.management.*; 30 31 import com.sun.enterprise.management.AMXTestBase; 32 import com.sun.enterprise.management.Capabilities; 33 import com.sun.enterprise.management.ClusterSupportRequired; 34 35 38 public final class LBTest extends AMXTestBase 39 implements ClusterSupportRequired 40 { 41 42 final boolean runDels = true; 43 final boolean runCreates = true; 44 final boolean testGetLoadBalancerConfigMap = false; 45 46 public LBTest() {} 47 48 public void testCreateLBConfig() { 49 if ( checkNotOffline( "testDeleteLBConfig" ) ) { 50 if (!runCreates) return; 51 String name = "test-lb-config"; 52 boolean monitoringEnabled = true; 53 boolean routeCookieEnabled = false; 54 boolean httpsRouting = false; 55 String responseTimeout = "130"; 56 String reloadInterval = "380"; 57 58 Map <String ,String > params = new HashMap <String ,String >(); 59 params.put("route-cookie-enabled", "" + routeCookieEnabled); 61 params.put("monitoring-enabled", "" + monitoringEnabled); 62 params.put("https-routing", "" + httpsRouting); 63 params.put("response-timeout-in-seconds", responseTimeout); 64 params.put("reload-poll-interval-in-seconds", reloadInterval); 65 66 try { 67 getDomainConfig().createLBConfig(name, params); 68 } catch (Throwable t) { 69 t.printStackTrace(); 70 } 71 } 72 } 73 74 public void testCreateLoadBalancerConfig() { 75 if ( checkNotOffline( "testDeleteLBConfig" ) ) { 76 if (!runCreates) return; 77 String name = "test-load-balancer"; 78 String lbConfigName = "test-lb-config"; 79 boolean autoApplyEnabled = true; 80 Map <String ,String > optional = null; 81 try { 82 getDomainConfig().createLoadBalancerConfig(name, lbConfigName, autoApplyEnabled, optional); 83 } catch (Throwable t) { 84 t.printStackTrace(); 85 } 86 } 87 } 88 89 public void testGetLBConfigMap() { 90 try { 91 Map map = getDomainConfig().getLBConfigMap(); 92 } catch (Throwable t) { 95 t.printStackTrace(); 96 } 97 } 98 99 public void testGetLoadBalancerConfigMap() { 100 if (testGetLoadBalancerConfigMap==false) return; 101 try { 102 Map map = getDomainConfig().getLoadBalancerConfigMap(); 103 ObjectName objName = new ObjectName("amx:j2eeType=X-LoadBalancerConfig,name=test-load-balancer"); 106 MBeanInfo minfo = getConnection().getMBeanInfo(objName); 107 MBeanAttributeInfo[] mattrsinfo = minfo.getAttributes(); 108 114 115 String [] attrsNames = (String []) getConnection().getAttribute(objName, "AttributeNames"); 116 120 121 String attrName = (String ) getConnection().getAttribute(objName, "LbConfigName"); 122 System.out.println("attrName is = "+attrName); 123 } catch (Throwable t) { 124 t.printStackTrace(); 125 } 126 } 127 128 public void testDeleteLoadBalancerConfig() { 129 if ( checkNotOffline( "testDeleteLBConfig" ) ) { 130 131 if (!runDels) return; 132 String name = "test-load-balancer"; 133 try { 134 getDomainConfig().removeLoadBalancerConfig(name); 135 } catch (Throwable t) { 136 t.printStackTrace(); 137 } 138 } 139 } 140 141 public void testDeleteLBConfig() { 142 if ( checkNotOffline( "testDeleteLBConfig" ) ) { 143 144 if (!runDels) return; 145 String name = "test-lb-config"; 146 try { 147 getDomainConfig().removeLBConfig(name); 148 } catch (Throwable t) { 149 t.printStackTrace(); 150 } 151 } 152 } 153 } 154 | Popular Tags |