1 package org.jboss.test.cluster.test; 2 3 import junit.framework.Test; 4 5 import org.apache.commons.httpclient.HttpClient; 6 import org.jboss.jmx.adaptor.rmi.RMIAdaptor; 7 import org.jboss.test.JBossClusteredTestCase; 8 9 18 public class UndeployTestCase extends BaseTest 19 { 20 protected String setUrl_; 21 protected String getUrl_; 22 protected String setUrlBase_; 23 protected String getUrlBase_; 24 25 protected boolean deployed0_ = true; 26 protected boolean deployed1_ = true; 27 28 public UndeployTestCase(String name) 29 { 30 super(name); 31 setUrlBase_ = "setSession.jsp"; 32 getUrlBase_ = "getAttribute.jsp"; 33 34 concatenate(); 35 } 36 37 protected String getContextPath() 38 { 39 return "/http-scoped/"; 40 } 41 42 protected String getWarName() 43 { 44 return "http-scoped.war"; 45 } 46 47 public static Test suite() throws Exception 48 { 49 Test t1 = JBossClusteredTestCase.getDeploySetup(UndeployTestCase.class, 50 "http-scoped.war"); 51 return t1; 52 } 53 54 59 public void testNonPrimitiveGet() 60 throws Exception 61 { 62 String attr = ""; 63 getLog().info("Enter testNonPrimitiveGet"); 64 65 getLog().debug(setUrl_ + ":::::::" + getUrl_); 66 67 HttpClient client = new HttpClient(); 69 70 makeGet(client, baseURL0_ +setUrl_); 72 73 attr = makeGetWithState(client, baseURL0_ +getUrl_); 76 77 reconfigureCluster(); 78 79 sleepThread(DEFAULT_SLEEP); 80 81 setCookieDomainToThisServer(client, servers_[1]); 83 String attr2 = makeGetWithState(client, baseURL1_ + getUrl_); 84 85 assertEquals("Get attribute should be but is ", attr, attr2); 86 getLog().debug("Exit testNonPrimitiveGet"); 87 } 88 89 94 public void XtestSessionPassivationActivation() throws Exception 95 { 96 getLog().info("Enter testSessionPassivationActivation"); 97 98 getLog().debug(setUrl_ + ":::::::" + getUrl_); 99 100 RMIAdaptor[] adaptors = getAdaptors(); 102 String warName = getWarName(); 103 deploy(adaptors[0], warName); 104 deploy(adaptors[1], warName); 105 106 sleep(2000); 107 108 111 HttpClient client = new HttpClient(); 113 114 makeGet(client, baseURL0_ +setUrl_); 116 117 sleepThread(DEFAULT_SLEEP); 119 120 String attr = makeGetWithState(client, baseURL0_ +getUrl_); 122 123 setCookieDomainToThisServer(client, servers_[1]); 125 String attr2 = makeGetWithState(client, baseURL1_ + getUrl_); 126 127 assertEquals("attribute match", attr, attr2); 128 129 130 131 undeploy(adaptors[0], warName); 133 134 135 sleep(2000); 136 deploy(adaptors[0], warName); 138 139 sleep(2000); 140 141 setCookieDomainToThisServer(client, servers_[0]); 143 String attr0 = makeGet(client, baseURL0_ +getUrl_); 144 145 assertEquals("attributeMatches after activation", attr0, attr); 146 147 getLog().debug("Exit testSessionPassivationActivation"); 148 149 } 150 151 protected void concatenate() 152 { 153 setUrl_ = getContextPath() +setUrlBase_; 154 getUrl_ = getContextPath() +getUrlBase_; 155 } 156 157 protected void setUp() throws Exception 158 { 159 super.setUp(); 160 configureCluster(); 161 } 162 163 protected void configureCluster() throws Exception 164 { 165 RMIAdaptor[] adaptors = getAdaptors(); 166 String warName = getWarName(); 167 if (!deployed0_) 168 { 169 deploy(adaptors[0], warName); 170 getLog().debug("Deployed " + warName + " on server0"); 171 deployed0_ = true; 172 } 173 if (!deployed1_) 174 { 175 deploy(adaptors[1], warName); 176 getLog().debug("Deployed " + warName + " on server1"); 177 deployed1_ = true; 178 } 179 180 sleep(2000); 181 } 182 183 protected void reconfigureCluster() throws Exception 184 { 185 RMIAdaptor[] adaptors = getAdaptors(); 186 deploy(adaptors[1], getWarName()); 187 deployed1_ = true; 188 189 sleep(2000); 190 191 undeploy(adaptors[0], getWarName()); 192 deployed0_ = false; 193 194 sleep(2000); 195 } 196 197 } 198 | Popular Tags |