1 25 26 package org.objectweb.jonas.jtests.clients.jca15; 27 28 import junit.framework.*; 29 import java.io.BufferedReader ; 30 import java.io.FileInputStream ; 31 import java.io.InputStreamReader ; 32 import java.io.IOException ; 33 import java.lang.String ; 34 import java.rmi.RemoteException ; 35 import javax.rmi.PortableRemoteObject ; 36 import java.util.Collection ; 37 import java.util.Enumeration ; 38 import java.util.Hashtable ; 39 import java.util.Properties ; 40 import javax.ejb.FinderException ; 41 import javax.ejb.RemoveException ; 42 import javax.naming.Context ; 43 import javax.naming.InitialContext ; 44 import javax.naming.NamingException ; 45 46 import org.objectweb.jonas.jtests.beans.jca15.TransactedCA; 47 import org.objectweb.jonas.jtests.beans.jca15.TransactedCAHome; 48 import org.objectweb.jonas.jtests.util.JTestCase; 49 import org.objectweb.jonas.jtests.clients.jca15.F_securityTest; 50 51 55 56 public class F_transactionTest extends JTestCase { 57 58 static Context ctx = null; 59 60 62 protected static String BEAN_HOME = "TransactedCAHome"; 63 protected static TransactedCAHome home = null; 64 private static final String RAR_JNDI_NAME = "eis/ErsatzLoTransaction"; 65 final public int CLOSE_HANDLE = 0; 66 final public int CLOSE_PHYSICAL = 1; 67 public int CloseType = 0; 68 static TransactedCA bean = null; 69 public String UseBeans="jca15"; 70 71 public F_transactionTest(String name) { 72 super(name); 73 } 74 75 protected void setUp() { 76 super.setUp(); 77 try { 78 80 if (ctx == null) { 81 ctx = new InitialContext (); 82 } 83 84 if (home == null) { 85 useBeans(UseBeans, false); 86 } 87 getBean(); 88 assertTrue (6 == 6); 89 90 } catch (Exception e) { 91 fail("Cannot do setUp: " +e); 92 } 93 } 94 private void getBean() throws Exception { 95 97 if (home == null) { 98 home = (TransactedCAHome)PortableRemoteObject.narrow( 99 ctx.lookup(BEAN_HOME), 100 TransactedCAHome.class); 101 bean = home.create(); 102 } 103 } 104 protected void tearDown() throws Exception { 105 } 107 protected void startUp(String testName) { 108 try { 109 bean.method1(RAR_JNDI_NAME, testName); 110 } catch (Exception ee) { 111 ee.printStackTrace(); 112 System.exit(2); 113 } 114 } 115 116 118 127 public void testTransaction1() { 128 CloseType=CLOSE_PHYSICAL; 129 startUp("testTransaction1"); 130 try { 131 bean.beginLoTransaction(); 132 assertTrue (6 == 6); 133 bean.closeUp(CloseType); 134 bean.commitLoTransaction(); 135 assertTrue (6 == 6); 136 } catch (Exception e) { 137 assertTrue(6==7); 138 } 139 } 140 141 public void testTransaction2() { 142 CloseType=CLOSE_PHYSICAL; 143 startUp("testTransaction2"); 144 try { 145 bean.closeUp(CloseType); 146 bean.commitLoTransaction(); 147 assertTrue (6 == 7); 148 } catch (Exception e) { 149 assertTrue(6==6); } 151 } 152 153 public static Test suite() { 154 return new TestSuite(F_transactionTest.class); 155 } 156 157 public static void main (String args[]) { 158 159 String testtorun = null; 160 161 163 for (int argn = 0; argn < args.length; argn++) { 164 165 String s_arg = args[argn]; 166 Integer i_arg; 167 168 if (s_arg.equals("-n")) { 169 testtorun = args[++argn]; 170 } 171 } 172 173 if (testtorun == null) { 174 junit.textui.TestRunner.run(suite()); 175 } else { 176 junit.textui.TestRunner.run(new F_transactionTest(testtorun)); 177 } 178 } 179 } 180 | Popular Tags |