1 25 26 package org.objectweb.jonas.jtests.clients.transaction; 27 28 import java.rmi.RemoteException ; 29 30 import javax.transaction.TransactionRequiredException ; 31 32 import org.objectweb.jonas.jtests.beans.transacted.Simple; 33 import org.objectweb.jonas.jtests.util.JTestCase; 34 35 41 public abstract class A_TxAttribute extends JTestCase { 42 43 47 public A_TxAttribute(String name) { 48 super(name); 49 } 50 51 55 protected void setUp() { 56 super.setUp(); 57 useBeans("transacted", true); 58 } 59 60 66 public abstract Simple getSimple(int i) throws Exception ; 67 68 69 73 80 public void testNotSupported() throws Exception { 81 82 Simple s = getSimple(10); 83 assertEquals(false, s.opwith_notsupported()); 84 s.remove(); 85 } 86 87 94 public void testRequiresNew() throws Exception { 95 96 Simple s = getSimple(11); 97 assertEquals(true, s.opwith_requires_new()); 98 s.remove(); 99 } 100 101 108 public void testRequired() throws Exception { 109 110 Simple s = getSimple(12); 111 assertEquals(true, s.opwith_required()); 112 s.remove(); 113 } 114 115 119 public void testRequiredRequiresNew() throws Exception { 120 121 Simple s = getSimple(12); 122 assertEquals(true, s.required_call_requires_new()); 123 s.remove(); 124 } 125 126 131 public void testRequiredRequiresNew2() throws Exception { 132 133 Simple s = getSimple(20); 134 Simple s2 = getSimple(21); 135 assertEquals(true, s.call_requires_new_on(s2)); 136 s2.remove(); 137 s.remove(); 138 } 139 140 147 148 public void testMandatory() throws Exception { 149 150 Simple s = getSimple(13); 151 try { 152 s.opwith_mandatory(); 153 fail("mandatory: should raise exception"); 154 } catch (javax.transaction.TransactionRequiredException e) { 155 } catch (RemoteException e) { 156 assertTrue(e.detail instanceof TransactionRequiredException ); 157 } 158 s.remove(); 159 } 160 161 168 public void testNever() throws Exception { 169 170 Simple s = getSimple(14); 171 assertEquals(false, s.opwith_never()); 172 s.remove(); 173 } 174 175 176 183 public void testSupports() throws Exception { 184 185 Simple s = getSimple(15); 186 assertEquals(false, s.opwith_supports()); 187 s.remove(); 188 } 189 190 197 public void testNotSupportedTx() throws Exception { 198 199 Simple s = getSimple(20); 200 utx.begin(); 201 try { 202 assertEquals(false, s.opwith_notsupported()); 203 } finally { 204 utx.rollback(); 205 s.remove(); 206 } 207 } 208 209 216 public void testRequiresNewTx() throws Exception { 217 Simple s = getSimple(21); 218 utx.begin(); 219 try { 220 assertEquals(true, s.opwith_requires_new()); 221 } finally { 222 utx.rollback(); 223 s.remove(); 224 } 225 } 226 227 234 public void testRequiredTx() throws Exception { 235 236 Simple s = getSimple(22); 237 utx.begin(); 238 try { 239 assertEquals(true, s.opwith_required()); 240 } finally { 241 utx.rollback(); 242 s.remove(); 243 } 244 245 } 246 247 254 public void testMandatoryTx() throws Exception { 255 256 Simple s = getSimple(23); 257 utx.begin(); 258 try { 259 assertEquals(true, s.opwith_mandatory()); 260 } finally { 261 utx.rollback(); 262 s.remove(); 263 } 264 } 265 266 267 268 269 276 public void testNeverTx() throws Exception { 277 278 Simple s = getSimple(24); 279 utx.begin(); 280 try { 281 s.opwith_never(); 282 fail("never: should raise exception"); 283 } catch (RemoteException e) { 284 } finally { 285 utx.rollback(); 286 s.remove(); 287 } 288 } 289 290 297 public void testSupportsTx() throws Exception { 298 299 Simple s = getSimple(25); 300 utx.begin(); 301 try { 302 assertEquals(true, s.opwith_supports()); 303 } finally { 304 utx.rollback(); 305 s.remove(); 306 } 307 308 } 309 310 314 public void testNoTx() throws Exception { 315 316 Simple s = getSimple(1); 317 assertEquals(false, s.opwith_notsupported()); 318 assertEquals(true, s.opwith_requires_new()); 319 assertEquals(true, s.opwith_required()); 320 assertEquals(false, s.opwith_never()); 321 assertEquals(false, s.opwith_supports()); 322 s.remove(); 323 } 324 325 } 326 | Popular Tags |