1 22 package org.jboss.test.tm.test; 23 24 import javax.transaction.Transaction ; 25 26 32 public class SimpleTransactionLocalStressTestCase extends AbstractTransactionLocalStressTest 33 { 34 public void testSimpleTransactionLocalStressTestcase() throws Throwable 35 { 36 tm.setTransactionTimeout(0); 37 tm.begin(); 38 final Transaction tx = tm.suspend(); 39 SimpleTransactionLocalRunnable[] runnables = new SimpleTransactionLocalRunnable[getThreadCount()]; 40 for (int i = 0; i < runnables.length; ++i) 41 runnables[i] = new SimpleTransactionLocalRunnable(tx); 42 43 runConcurrentTest(runnables, new ConcurrentTestCallback() 44 { 45 public void finished() throws Throwable 46 { 47 tm.resume(tx); 48 tm.commit(); 49 } 50 }); 51 } 52 53 public class SimpleTransactionLocalRunnable extends ConcurrentTransactionLocalRunnable 54 { 55 public SimpleTransactionLocalRunnable(Transaction tx) 56 { 57 super(tx); 58 } 59 60 public void doRun() 61 { 62 try 63 { 64 local.lock(tx); 65 try 66 { 67 local.set(this); 68 local.get(); 69 } 70 finally 71 { 72 local.unlock(tx); 73 } 74 } 75 catch (Throwable t) 76 { 77 failure = t; 78 } 79 } 80 } 81 82 public SimpleTransactionLocalStressTestCase(String name) 83 { 84 super(name); 85 } 86 } 87 | Popular Tags |