1 25 package org.objectweb.easybeans.tests.transaction.containermanaged.base; 26 27 import static org.testng.Assert.assertFalse; 28 import static org.testng.Assert.fail; 29 30 import javax.transaction.UserTransaction ; 31 32 import org.objectweb.easybeans.log.JLog; 33 import org.objectweb.easybeans.log.JLogFactory; 34 import org.objectweb.easybeans.tests.common.ejbs.base.transaction.ItfContainerTransaction; 35 import org.objectweb.easybeans.tests.common.exception.TransactionException; 36 37 52 public class TestMandatory extends TestContainerTransactionBase { 53 54 57 private static JLog logger = JLogFactory.getLog(TestMandatory.class); 58 59 67 @Override 68 public void testUsingClientTrans() throws Exception { 69 super.testUsingClientTrans(); 70 } 71 72 81 public void testSetRollbackOnlyWithUserTransaction() throws Exception { 82 UserTransaction utx = getUserTransaction(); 83 utx.begin(); 84 try { 85 ItfContainerTransaction sfsbContainerTransaction = getBean(); 86 try { 88 sfsbContainerTransaction.setRollbackOnly(DATABASE_1, DATABASE_2); 89 } catch (TransactionException e) { 90 throw e.getParentException(); 91 } 92 try { 94 utx.commit(); 95 fail("The transaction is marked as rollback. The client cannot make the commit."); 96 } catch (Exception e) { 97 logger.debug("Expected exception {0}", e); 98 } 99 } finally { 100 assertFalse(transactionIsActive(), 101 "There was an exception in the server side. The container is using the same transaction " 102 + "that the client, so the cointainer should rollback the transaction."); 103 } 104 } 105 106 116 public void testSetRollbackOnlyWithoutUserTransaction() throws Exception { 117 try { 118 testSetRollbackOnly(); 119 } finally { 120 assertFalse(transactionIsActive(), 121 "There was an exception in the server side. The container is using the same transaction " 122 + "that the client, so the cointainer should rollback the transaction."); 123 } 124 } 125 126 133 public void testGetRollbackOnlyWithUserTransaction() throws Exception { 134 UserTransaction utx = getUserTransaction(); 135 136 utx.begin(); 137 testGetRollbackOnly(); 138 utx.commit(); 139 } 140 141 151 public void testGetRollbackOnlyWithoutUserTransaction() throws Exception { 152 testGetRollbackOnly(); 153 154 } 155 156 160 @Override 161 public void testGetUserTransactionWithEJBContext() throws Exception { 162 UserTransaction utx = getUserTransaction(); 163 utx.begin(); 164 try { 165 super.testGetUserTransactionWithEJBContext(); 166 } finally { 167 utx.rollback(); 168 } 169 } 170 171 175 @Override 176 public void testGetUserTransactionWithLookup() throws Exception { 177 UserTransaction utx = getUserTransaction(); 178 utx.begin(); 179 try { 180 super.testGetUserTransactionWithLookup(); 181 } finally { 182 utx.rollback(); 183 } 184 } 185 186 } 187 | Popular Tags |