1 25 26 package org.objectweb.jonas.jtests.clients.transaction; 27 28 import javax.naming.NamingException ; 29 import javax.rmi.PortableRemoteObject ; 30 import javax.transaction.RollbackException ; 31 import junit.framework.Test; 32 import junit.framework.TestSuite; 33 import org.objectweb.jonas.jtests.beans.transacted.Simple; 34 import org.objectweb.jonas.jtests.beans.transacted.SimpleSHome; 35 import org.objectweb.jonas.jtests.beans.transacted.SynchroSimple; 36 import org.objectweb.jonas.jtests.util.JTestCase; 37 38 41 public class F_ContManagedTx extends JTestCase { 42 43 private static String BEAN_HOME = "transactedSimpleSYHome"; 44 protected static SimpleSHome home = null; 45 46 public F_ContManagedTx(String name) { 47 super(name); 48 } 49 50 protected void setUp() { 51 super.setUp(); 52 useBeans("transacted", true); 53 if (home == null) { 54 try { 55 home = (SimpleSHome) PortableRemoteObject.narrow(ictx.lookup(BEAN_HOME), SimpleSHome.class); 56 } catch (NamingException e) { 57 fail("Cannot get Home:" + e); 58 } 59 } 60 } 61 62 66 public void testRollBackInBeforeCompletion() throws Exception { 67 SynchroSimple ss = (SynchroSimple) PortableRemoteObject.narrow(home.create(), SynchroSimple.class); 68 69 utx.begin(); 70 ss.setRollbackOnly(); 71 try { 72 utx.commit(); 73 fail("transaction should be rolled back"); 74 } catch (RollbackException e) { 75 } finally { 76 ss.remove(); } 78 } 79 80 public static Test suite() { 81 return new TestSuite(F_ContManagedTx.class); 82 } 83 84 public static void main (String args[]) { 85 String testtorun = null; 86 for (int argn = 0; argn < args.length; argn++) { 88 String sarg = args[argn]; 89 if (sarg.equals("-n")) { 90 testtorun = args[++argn]; 91 } 92 } 93 if (testtorun == null) { 94 junit.textui.TestRunner.run(suite()); 95 } else { 96 junit.textui.TestRunner.run(new F_ContManagedTx(testtorun)); 97 } 98 } 99 } 100 | Popular Tags |