1 22 package org.jboss.test.system.controller.lifecycle.seperated.test; 23 24 import java.util.List ; 25 26 import javax.management.ObjectName ; 27 28 import org.jboss.mx.util.ObjectNameFactory; 29 import org.jboss.test.system.controller.AbstractControllerTest; 30 31 37 public abstract class DependsBrokenTest extends AbstractControllerTest 38 { 39 private static ObjectName NAME_ONE = ObjectNameFactory.create("test:name=1"); 40 private static ObjectName NAME_TWO = ObjectNameFactory.create("test:name=2"); 41 42 private String resourceName1; 43 private String resourceName2; 44 45 public DependsBrokenTest(String name) 46 { 47 super(name); 48 49 String resourceName = getClass().getName(); 50 int index= resourceName.lastIndexOf('.'); 51 if (index != -1) 52 resourceName= resourceName.substring(index + 1, resourceName.length()); 53 index = resourceName.indexOf("NewUnitTestCase"); 54 if (index != -1) 55 resourceName = resourceName.substring(0, index); 56 index = resourceName.indexOf("OldUnitTestCase"); 57 if (index != -1) 58 resourceName = resourceName.substring(0, index); 59 60 resourceName1 = resourceName + "_bad.xml"; 61 resourceName2 = resourceName + "_good.xml"; 62 } 63 64 public void deployBrokenFirstMaybeDeployFailure(int expectedState, Class <? extends Throwable > expected) throws Exception 65 { 66 boolean error = false; 67 68 List <ObjectName > mbeans1 = assertMaybeDeployFailure(resourceName1, NAME_ONE, expected); 69 try 70 { 71 List <ObjectName > mbeans2 = deploy(resourceName2); 72 try 73 { 74 assertServiceState(NAME_TWO, expectedState); 75 } 76 catch (Exception e) 77 { 78 error = true; 79 throw e; 80 } 81 catch (Error e) 82 { 83 error = true; 84 throw e; 85 } 86 finally 87 { 88 undeploy(mbeans2); 89 90 if (error == false) 91 { 92 assertNoService(NAME_TWO); 93 assertNotRegistered(NAME_TWO); 94 } 95 } 96 } 97 catch (Exception e) 98 { 99 error = true; 100 throw e; 101 } 102 catch (Error e) 103 { 104 error = true; 105 throw e; 106 } 107 finally 108 { 109 undeploy(mbeans1); 110 111 if (error == false) 112 { 113 assertNoService(NAME_ONE); 114 assertNotRegistered(NAME_ONE); 115 assertNoService(NAME_TWO); 116 assertNotRegistered(NAME_TWO); 117 } 118 } 119 } 120 121 public void deployBrokenSecondMaybeDeployFailure(int expectedState, Class <? extends Throwable > expected) throws Exception 122 { 123 boolean error = false; 124 125 List <ObjectName > mbeans2 = deploy(resourceName2); 126 try 127 { 128 assertServiceState(NAME_TWO, expectedState); 129 assertRegistered(NAME_TWO); 130 131 List <ObjectName > mbeans1 = assertMaybeDeployFailure(resourceName1, NAME_ONE, expected); 132 try 133 { 134 assertServiceState(NAME_TWO, expectedState); 135 assertRegistered(NAME_TWO); 136 } 137 catch (Exception e) 138 { 139 error = true; 140 throw e; 141 } 142 catch (Error e) 143 { 144 error = true; 145 throw e; 146 } 147 finally 148 { 149 undeploy(mbeans1); 150 151 if (error == false) 152 { 153 assertServiceState(NAME_TWO, expectedState); 154 assertRegistered(NAME_TWO); 155 } 156 } 157 } 158 catch (Exception e) 159 { 160 error = true; 161 throw e; 162 } 163 catch (Error e) 164 { 165 error = true; 166 throw e; 167 } 168 finally 169 { 170 undeploy(mbeans2); 171 172 if (error == false) 173 { 174 assertNoService(NAME_ONE); 175 assertNotRegistered(NAME_ONE); 176 assertNoService(NAME_TWO); 177 assertNotRegistered(NAME_TWO); 178 } 179 } 180 } 181 182 public void deployBrokenFirstDeployFailure(int expectedState, Class <? extends Throwable > expected) throws Exception 183 { 184 boolean error = false; 185 186 List <ObjectName > mbeans1 = assertDeployFailure(resourceName1, NAME_ONE, expected); 187 try 188 { 189 List <ObjectName > mbeans2 = deploy(resourceName2); 190 try 191 { 192 assertServiceState(NAME_TWO, expectedState); 193 } 194 catch (Exception e) 195 { 196 error = true; 197 throw e; 198 } 199 catch (Error e) 200 { 201 error = true; 202 throw e; 203 } 204 finally 205 { 206 undeploy(mbeans2); 207 208 if (error == false) 209 { 210 assertNoService(NAME_TWO); 211 assertNotRegistered(NAME_TWO); 212 } 213 } 214 } 215 catch (Exception e) 216 { 217 error = true; 218 throw e; 219 } 220 catch (Error e) 221 { 222 error = true; 223 throw e; 224 } 225 finally 226 { 227 undeploy(mbeans1); 228 229 if (error == false) 230 { 231 assertNoService(NAME_ONE); 232 assertNotRegistered(NAME_ONE); 233 assertNoService(NAME_TWO); 234 assertNotRegistered(NAME_TWO); 235 } 236 } 237 } 238 239 public void deployBrokenSecondDeployFailure(int expectedState, Class <? extends Throwable > expected) throws Exception 240 { 241 deployBrokenSecondDeployFailure(expectedState, expectedState, expectedState, expected); 242 } 243 244 public void deployBrokenSecondDeployFailure(int expectedState, int brokenExpectedState, Class <? extends Throwable > expected) throws Exception 245 { 246 deployBrokenSecondDeployFailure(expectedState, expectedState, brokenExpectedState, expected); 247 } 248 249 public void deployBrokenSecondDeployFailure(int beforeExpectedState, int afterExpectedState, int brokenExpectedState, Class <? extends Throwable > expected) throws Exception 250 { 251 boolean error = false; 252 253 List <ObjectName > mbeans2 = deploy(resourceName2); 254 try 255 { 256 assertServiceState(NAME_TWO, beforeExpectedState); 257 assertRegistered(NAME_TWO); 258 259 List <ObjectName > mbeans1 = assertDeployFailure(resourceName1, NAME_ONE, expected); 260 try 261 { 262 assertServiceState(NAME_TWO, afterExpectedState); 263 assertRegistered(NAME_TWO); 264 } 265 catch (Exception e) 266 { 267 error = true; 268 throw e; 269 } 270 catch (Error e) 271 { 272 error = true; 273 throw e; 274 } 275 finally 276 { 277 undeploy(mbeans1); 278 279 if (error == false) 280 { 281 assertServiceState(NAME_TWO, brokenExpectedState); 282 assertRegistered(NAME_TWO); 283 } 284 } 285 } 286 catch (Exception e) 287 { 288 error = true; 289 throw e; 290 } 291 catch (Error e) 292 { 293 error = true; 294 throw e; 295 } 296 finally 297 { 298 undeploy(mbeans2); 299 300 if (error == false) 301 { 302 assertNoService(NAME_ONE); 303 assertNotRegistered(NAME_ONE); 304 assertNoService(NAME_TWO); 305 assertNotRegistered(NAME_TWO); 306 } 307 } 308 } 309 310 public void deployBrokenSecondInitialDeployFailure(int expectedState, Class <? extends Throwable > expected) throws Exception 311 { 312 boolean error = false; 313 314 List <ObjectName > mbeans2 = deploy(resourceName2); 315 try 316 { 317 assertServiceState(NAME_TWO, expectedState); 318 assertRegistered(NAME_TWO); 319 320 assertInitialDeployFailure(resourceName1, NAME_ONE, expected); 321 try 322 { 323 assertServiceState(NAME_TWO, expectedState); 324 assertRegistered(NAME_TWO); 325 } 326 catch (Exception e) 327 { 328 error = true; 329 throw e; 330 } 331 catch (Error e) 332 { 333 error = true; 334 throw e; 335 } 336 finally 337 { 338 if (error == false) 339 { 340 assertServiceState(NAME_TWO, expectedState); 341 assertRegistered(NAME_TWO); 342 } 343 } 344 } 345 catch (Exception e) 346 { 347 error = true; 348 throw e; 349 } 350 catch (Error e) 351 { 352 error = true; 353 throw e; 354 } 355 finally 356 { 357 undeploy(mbeans2); 358 359 if (error == false) 360 { 361 assertNoService(NAME_ONE); 362 assertNotRegistered(NAME_ONE); 363 assertNoService(NAME_TWO); 364 assertNotRegistered(NAME_TWO); 365 } 366 } 367 } 368 } 369 | Popular Tags |