1 25 26 package org.objectweb.jonas.jtests.clients.transaction; 27 28 import java.rmi.RemoteException ; 29 30 import org.objectweb.jonas.jtests.beans.transacted.Simple; 31 import org.objectweb.jonas.jtests.util.JTestCase; 32 33 39 public abstract class B_TxAttribute extends JTestCase { 40 41 45 public B_TxAttribute(String name) { 46 super(name); 47 } 48 49 53 protected void setUp() { 54 super.setUp(); 55 useBeans("transacted", true); 56 } 57 58 64 public abstract Simple getSimple(int i) throws Exception ; 65 66 67 71 78 public void testSimpleOptNotSupportedRemove() throws Exception { 79 80 Simple s = getSimple(10); 81 assertEquals(false, s.opwith_notsupported()); 82 s.remove(); 83 84 85 } 86 87 94 public void testGetSimpleOptRequiresNewRemove() throws Exception { 95 96 Simple s = getSimple(11); 97 assertEquals(true, s.opwith_requires_new()); 98 s.remove(); 99 100 } 101 102 109 public void testGetSimpleOptRequiredRemove() throws Exception { 110 111 Simple s = getSimple(12); 112 assertEquals(true, s.opwith_required()); 113 s.remove(); 114 } 115 116 117 124 public void testGetSimpleOptRequiresNewRemoveInTx() throws Exception { 125 Simple s = getSimple(21); 126 utx.begin(); 127 try { 128 assertEquals(true, s.opwith_requires_new()); 129 } finally { 130 utx.rollback(); 131 s.remove(); 132 } 133 } 134 135 142 public void testGetSimpleOptRequiredRemoveInTx() throws Exception { 143 144 Simple s = getSimple(22); 145 utx.begin(); 146 try { 147 assertEquals(true, s.opwith_required()); 148 } finally { 149 utx.rollback(); 150 s.remove(); 151 } 152 153 } 154 155 162 public void testMandatoryTx() throws Exception { 163 164 Simple s = getSimple(23); 165 utx.begin(); 166 try { 167 assertEquals(true, s.opwith_mandatory()); 168 } finally { 169 utx.rollback(); 170 s.remove(); 171 } 172 } 173 174 175 176 177 184 public void testNeverTx() throws Exception { 185 186 Simple s = getSimple(24); 187 utx.begin(); 188 try { 189 s.opwith_never(); 190 fail("never: should raise exception"); 191 } catch (RemoteException e) { 192 } finally { 193 utx.rollback(); 194 s.remove(); 195 } 196 } 197 198 205 public void testSupportsTx() throws Exception { 206 207 Simple s = getSimple(25); 208 utx.begin(); 209 try { 210 assertEquals(true, s.opwith_supports()); 211 } finally { 212 utx.rollback(); 213 s.remove(); 214 } 215 216 } 217 218 222 public void testNoTx() throws Exception { 223 224 Simple s = getSimple(1); 225 assertEquals(false, s.opwith_notsupported()); 226 assertEquals(true, s.opwith_requires_new()); 227 assertEquals(true, s.opwith_required()); 228 assertEquals(false, s.opwith_never()); 229 assertEquals(false, s.opwith_supports()); 230 s.remove(); 231 } 232 233 } 234 | Popular Tags |