1 22 package org.jboss.test.jca.test; 23 24 import javax.resource.cci.Connection ; 25 26 32 public class RecyclingStickyWithPoisonThreadStressTestCase extends AbstractRecyclingPoolingStressTest 33 { 34 public boolean isSticky() 35 { 36 return true; 37 } 38 39 public void testIt() throws Throwable 40 { 41 tm.setTransactionTimeout(0); 42 RecyclingPoolingRunnable[] runnables = new RecyclingPoolingRunnable[getThreadCount()]; 43 runnables[0] = new RecyclingPoolingRunnable() 44 { 45 public void doRun() throws Throwable 46 { 47 tm.begin(); 48 tm.setRollbackOnly(); 49 try 50 { 51 doRun1(); 52 } 53 finally 54 { 55 tm.rollback(); 56 } 57 } 58 public void doRun1() throws Throwable 59 { 60 boolean thrown = false; 61 try 62 { 63 cf.getConnection(); 64 } 65 catch (Throwable expected) 66 { 67 thrown = true; 68 } 69 if (thrown == false) 70 throw new Exception ("Expected exception for rolled back tx"); 71 } 72 }; 73 for (int i = 1; i < runnables.length; ++i) 74 { 75 runnables[i] = new RecyclingPoolingRunnable() 76 { 77 public void doRun1() throws Throwable 78 { 79 Connection c = cf.getConnection(); 80 c.close(); 81 } 82 }; 83 } 84 85 runConcurrentTest(runnables, null); 86 } 87 88 public RecyclingStickyWithPoisonThreadStressTestCase(String name) 89 { 90 super(name); 91 } 92 } 93 | Popular Tags |