1 25 26 27 package org.objectweb.jonas.jtests.clients.transaction; 28 29 import java.rmi.RemoteException ; 30 import javax.transaction.TransactionRequiredException ; 31 import org.objectweb.jonas.jtests.beans.transacted.Simple; 32 import org.objectweb.jonas.jtests.beans.transacted.SimpleEHome; 33 34 35 41 public abstract class A_TxAttributeEntity extends A_TxAttribute { 42 43 47 public A_TxAttributeEntity(String name) { 48 super(name); 49 } 50 51 54 protected abstract SimpleEHome getHome(); 55 56 60 65 public void testCreateRequired() throws Exception { 66 long i = 10; 67 Simple entity = getHome().createForRequired(i); 68 entity.remove(); 69 } 70 71 76 public void testCreateRequiredTx() throws Exception { 77 utx.begin(); 78 long i = 11; 79 Simple entity = null; 80 try { 81 entity = getHome().createForRequired(i); 82 } finally { 83 utx.rollback(); 84 } 85 86 } 87 92 public void testCreateNotSupported() throws Exception { 93 int i = 12; 94 Simple entity = getHome().create(i); 95 entity.remove(); 96 } 97 98 103 public void testCreateNotSupportedTx() throws Exception { 104 utx.begin(); 105 int i = 13; 106 Simple entity = null; 107 try { 108 entity = getHome().create(i); 109 } finally { 110 utx.rollback(); 111 entity.remove(); 112 } 113 } 114 115 120 public void testCreateNever() throws Exception { 121 short i = 14; 122 Simple entity = getHome().createForNever(i); 123 entity.remove(); 124 } 125 126 131 public void testCreateNeverTx() throws Exception { 132 utx.begin(); 133 short i = 15; 134 Simple entity = null; 135 try { 136 entity = getHome().createForNever(i); 137 entity.remove(); 138 fail("never: should raise exception"); 139 } catch (java.rmi.RemoteException e) { 140 } finally { 141 utx.rollback(); 142 143 } 144 145 } 146 147 152 public void testCreateRequiresNew() throws Exception { 153 String s = "16"; 154 Simple entity = getHome().createForRequiresNew(s); 155 entity.remove(); 156 } 157 158 163 public void testCreateRequiresNewTx() throws Exception { 164 utx.begin(); 165 String s = "17"; 166 Simple entity = null; 167 try { 168 entity = getHome().createForRequiresNew(s); 169 } finally { 170 utx.rollback(); 171 entity.remove(); 172 } 173 } 174 175 176 181 public void testCreateMandatory() throws Exception { 182 char c = 'a'; 183 try { 184 Simple entity = getHome().createForMandatory(c); 185 entity.remove(); 186 fail("mandatory: should raise exception"); 187 } catch (javax.transaction.TransactionRequiredException e) { 188 } catch (java.rmi.RemoteException e) { 189 assertTrue(e.detail instanceof javax.transaction.TransactionRequiredException ); 190 } 191 } 192 193 198 public void testCreateMandatoryTx() throws Exception { 199 utx.begin(); 200 char c = 'b'; 201 Simple entity = null; 202 try { 203 entity = getHome().createForMandatory(c); 204 } finally { 205 utx.rollback(); 206 207 } 208 } 209 210 211 216 public void testCreateSupports() throws Exception { 217 218 Simple entity = getHome().createForSupports(false); 219 entity.remove(); 220 } 221 222 227 public void testCreateSupportsTx() throws Exception { 228 utx.begin(); 229 Simple entity = null; 230 try { 231 entity = getHome().createForSupports(true); 232 } finally { 233 utx.rollback(); 234 235 } 236 } 237 238 242 249 public void testHomeNotSupported() throws Exception { 250 assertEquals(false, getHome().opwith_notsupported()); 251 } 252 253 260 public void testHomeRequiresNew() throws Exception { 261 assertEquals(true, getHome().opwith_requires_new()); 262 } 263 264 271 public void testHomeRequired() throws Exception { 272 assertEquals(true, getHome().opwith_required()); 273 } 274 275 282 283 public void testHomeMandatory() throws Exception { 284 try { 285 getHome().opwith_mandatory(); 286 fail("mandatory: should raise exception"); 287 } catch (javax.transaction.TransactionRequiredException e) { 288 } catch (RemoteException e) { 289 assertTrue(e.detail instanceof TransactionRequiredException ); 290 } 291 } 292 293 300 public void testHomeNever() throws Exception { 301 assertEquals(false, getHome().opwith_never()); 302 } 303 304 305 312 public void testHomeSupports() throws Exception { 313 assertEquals(false, getHome().opwith_supports()); 314 } 315 316 323 public void testHomeNotSupportedTx() throws Exception { 324 utx.begin(); 325 try { 326 assertEquals(false, getHome().opwith_notsupported()); 327 } finally { 328 utx.rollback(); 329 } 330 } 331 332 339 public void testHomeRequiresNewTx() throws Exception { 340 utx.begin(); 341 try { 342 assertEquals(true, getHome().opwith_requires_new()); 343 } finally { 344 utx.rollback(); 345 } 346 } 347 348 355 public void testHomeRequiredTx() throws Exception { 356 utx.begin(); 357 try { 358 assertEquals(true, getHome().opwith_required()); 359 } finally { 360 utx.rollback(); 361 } 362 363 } 364 365 372 public void testHomeMandatoryTx() throws Exception { 373 utx.begin(); 374 try { 375 assertEquals(true, getHome().opwith_mandatory()); 376 } finally { 377 utx.rollback(); 378 } 379 } 380 381 382 383 384 391 public void testHomeNeverTx() throws Exception { 392 utx.begin(); 393 try { 394 getHome().opwith_never(); 395 fail("never: should raise exception"); 396 } catch (RemoteException e) { 397 } finally { 398 utx.rollback(); 399 } 400 } 401 402 409 public void testHomeSupportsTx() throws Exception { 410 utx.begin(); 411 try { 412 assertEquals(true, getHome().opwith_supports()); 413 } finally { 414 utx.rollback(); 415 } 416 417 } 418 419 423 public void testHomeNoTx() throws Exception { 424 assertEquals(false, getHome().opwith_notsupported()); 425 assertEquals(true, getHome().opwith_requires_new()); 426 assertEquals(true, getHome().opwith_required()); 427 assertEquals(false, getHome().opwith_never()); 428 assertEquals(false, getHome().opwith_supports()); 429 } 430 431 432 } 433 | Popular Tags |