1 25 package org.objectweb.easybeans.tests.transaction.containermanaged.base; 26 27 import static org.testng.Assert.fail; 28 29 import java.sql.SQLException ; 30 31 import javax.ejb.EJBException ; 32 import javax.transaction.UserTransaction ; 33 34 import org.objectweb.easybeans.log.JLog; 35 import org.objectweb.easybeans.log.JLogFactory; 36 import org.objectweb.easybeans.tests.common.ejbs.base.transaction.ItfContainerTransaction; 37 import org.objectweb.easybeans.tests.common.ejbs.stateless.containermanaged.ItfDatabaseManager; 38 import org.objectweb.easybeans.tests.common.ejbs.stateless.containermanaged.SLSBDatabaseManager; 39 import org.objectweb.easybeans.tests.common.ejbs.stateless.containermanaged.transaction.ItfTransactionMisc00; 40 import org.objectweb.easybeans.tests.common.helper.EJBHelper; 41 42 62 public abstract class TestRequiredNewException extends TestContainerTransactionException { 63 64 67 private static JLog logger = JLogFactory.getLog(TestRequiredNewException.class); 68 69 76 @Override 77 public void testCallOtherBeanNotSup() throws Exception { 78 super.testCallOtherBeanNotSup(); 79 try { 81 ExceptionHandleUtil.verifyTable(DATABASE_1, ItfContainerTransaction.TABLE); 82 fail("The container did not make a rollback in the transaction."); 83 } catch (SQLException e) { 84 logger.debug("The test threw an expected exception {0}", e); 85 } 86 try { 90 ExceptionHandleUtil.verifyTable(DATABASE_2, ItfTransactionMisc00.TABLE); 91 } catch (SQLException e) { 92 fail("The container made a rollback in the transaction."); 93 } 94 } 95 96 104 @Override 105 public void testCallOtherBeanReq() throws Exception { 106 super.testCallOtherBeanReq(); 107 try { 109 ExceptionHandleUtil.verifyTable(DATABASE_1, ItfContainerTransaction.TABLE); 110 fail("The container did not make a rollback in the transaction."); 111 } catch (SQLException e) { 112 logger.debug("The test threw an expected exception {0}", e); 113 } 114 try { 118 ExceptionHandleUtil.verifyTable(DATABASE_2, ItfTransactionMisc00.TABLE); 119 fail("The container did not make a rollback in the transaction."); 120 } catch (SQLException e) { 121 logger.debug("The test threw an expected exception {0}", e); 122 } 123 } 124 125 131 public void testUsingClientTrans() throws Exception { 132 UserTransaction utx = ExceptionHandleUtil.getUserTransaction(); 134 utx.begin(); 136 ItfDatabaseManager slsbDatabaseManager = EJBHelper.getBeanRemoteInstance(SLSBDatabaseManager.class, 138 ItfDatabaseManager.class); 139 slsbDatabaseManager.insertTable(DATABASE_2, ItfContainerTransaction.TABLE); 140 145 try { 146 getRuntimeBean().insertCorrectFirstErrorSecond(DATABASE_1, DATABASE_2); 147 } catch (EJBException e) { 148 logger.debug("The bean threw an expected exception {0}", e); 149 } 150 utx.commit(); 152 158 ExceptionHandleUtil.verifyTable(DATABASE_2, ItfContainerTransaction.TABLE); 159 } 160 161 } 162 | Popular Tags |