1 25 26 package org.objectweb.jonas.jtests.clients.transaction; 27 28 import javax.naming.NamingException ; 29 import javax.rmi.PortableRemoteObject ; 30 import junit.framework.Test; 31 import junit.framework.TestSuite; 32 import org.objectweb.jonas.jtests.beans.transacted.Simple; 33 import org.objectweb.jonas.jtests.beans.transacted.SimpleEHome; 34 35 38 public class F_TxAttributeEB extends A_TxAttributeEntity { 39 40 private static String BEAN_HOME = "transactedSimpleEBHome"; 41 protected static SimpleEHome home = null; 42 43 public F_TxAttributeEB(String name) { 44 super(name); 45 } 46 47 48 54 58 public void testFinderNotSupported() throws Exception { 59 60 getHome().finder_notsupported(); 61 } 62 63 67 public void testFinderNotSupportedTx() throws Exception { 68 69 utx.begin(); 70 try { 71 getHome().finder_notsupported(); 72 } finally { 73 utx.rollback(); 74 } 75 } 76 77 78 82 public void testFinderRequired() throws Exception { 83 84 getHome().finder_required(); 85 } 86 87 91 public void testFinderRequiredTx() throws Exception { 92 93 utx.begin(); 94 try { 95 getHome().finder_required(); 96 } finally { 97 utx.rollback(); 98 } 99 } 100 101 107 public void testFinderSupports() throws Exception { 108 109 getHome().finder_supports(false); 110 } 111 112 113 119 public void testFinderSupportsTx() throws Exception { 120 utx.begin(); 121 try { 122 getHome().finder_supports(true); 123 } finally { 124 utx.rollback(); 125 } 126 } 127 128 132 public void testFinderRequiresNew() throws Exception { 133 134 getHome().finder_requiresnew(); 135 } 136 137 141 public void testFinderRequiresNewTx() throws Exception { 142 143 utx.begin(); 144 try { 145 getHome().finder_requiresnew(); 146 } finally { 147 utx.rollback(); 148 } 149 } 150 151 152 157 public void testFinderMandatory() throws Exception { 158 try { 159 getHome().finder_mandatory(); 160 fail("mandatory: should raise exception"); 161 } catch (javax.transaction.TransactionRequiredException e) { 162 } catch (java.rmi.RemoteException e) { 163 assertTrue(e.detail instanceof javax.transaction.TransactionRequiredException ); 164 } 165 } 166 167 171 public void testFinderMandatoryTx() throws Exception { 172 173 utx.begin(); 174 try { 175 getHome().finder_mandatory(); 176 } finally { 177 utx.rollback(); 178 } 179 } 180 181 185 public void testFinderNever() throws Exception { 186 187 getHome().finder_never(); 188 } 189 190 194 public void testFinderNeverTx() throws Exception { 195 utx.begin(); 196 try { 197 getHome().finder_never(); 198 fail("never: should raise exception"); 199 } catch (java.rmi.RemoteException e) { 200 } finally { 201 utx.rollback(); 202 } 203 } 204 205 206 210 protected SimpleEHome getHome() { 211 if (home == null) { 212 try { 213 home = (SimpleEHome) PortableRemoteObject.narrow(ictx.lookup(BEAN_HOME), SimpleEHome.class); 214 } catch (NamingException e) { 215 fail("Cannot get bean home"); 216 } 217 } 218 return home; 219 } 220 221 222 225 public Simple getSimple(int i) throws Exception { 226 return getHome().create(i); 227 } 228 229 232 public static Test suite() { 233 return new TestSuite(F_TxAttributeEB.class); 234 } 235 236 public static void main (String args[]) { 237 String testtorun = null; 238 for (int argn = 0; argn < args.length; argn++) { 240 String sarg = args[argn]; 241 if (sarg.equals("-n")) { 242 testtorun = args[++argn]; 243 } 244 } 245 if (testtorun == null) { 246 junit.textui.TestRunner.run(suite()); 247 } else { 248 junit.textui.TestRunner.run(new F_TxAttributeEB(testtorun)); 249 } 250 } 251 } 252 | Popular Tags |