1 25 package org.objectweb.easybeans.tests.transaction.containermanaged.base; 26 27 import static org.testng.Assert.fail; 28 29 import javax.ejb.EJBException ; 30 31 import org.objectweb.easybeans.log.JLog; 32 import org.objectweb.easybeans.log.JLogFactory; 33 import org.objectweb.easybeans.tests.common.ejbs.base.transaction.ItfContainerTransaction; 34 import org.objectweb.easybeans.tests.common.ejbs.stateless.containermanaged.transaction.ItfTransactionMisc00; 35 import org.objectweb.easybeans.tests.common.helper.EJBHelper; 36 import org.objectweb.easybeans.tests.common.helper.EmbeddedHelper; 37 38 43 public abstract class TestContainerTransactionException { 44 45 48 protected static final String DATABASE_1 = "jdbc_1"; 49 50 53 protected static final String DATABASE_2 = "jdbc_2"; 54 55 58 private ItfContainerTransaction sfsbContainerTransactionRuntime = null; 59 60 61 64 private static JLog logger = JLogFactory.getLog(TestContainerTransactionException.class); 65 66 67 71 public void setup() throws Exception { 72 EmbeddedHelper.bindDatasource(); 75 ExceptionHandleUtil.cleanTransaction(); 78 createBeanRuntime(); 80 deleteTable(); 82 } 83 84 85 90 public void createBeanRuntime(final Class beanClass) throws Exception { 91 sfsbContainerTransactionRuntime = EJBHelper.getBeanRemoteInstance(beanClass, ItfContainerTransaction.class); 92 } 93 94 98 public abstract void createBeanRuntime() throws Exception ; 99 100 101 111 public void testCallOtherBeanReq() throws Exception { 112 try { 113 sfsbContainerTransactionRuntime.insertTablesUsingAuxBeanReq(DATABASE_1, DATABASE_2); 114 fail("The container did not throw the EJBException."); 115 } catch (EJBException e) { 116 logger.debug("The bean threw an expected error during the execution {0}", e); 117 } 118 if (!ExceptionHandleUtil.isDiscarded(sfsbContainerTransactionRuntime)) { 120 fail("The bean was not discarded."); 121 } 122 123 } 125 126 136 public void testCallOtherBeanNotSup() throws Exception { 137 try { 138 sfsbContainerTransactionRuntime.insertTablesUsingAuxBeanNotSup(DATABASE_1, DATABASE_2); 139 fail("The container did not throw the EJBException."); 140 } catch (EJBException e) { 141 logger.debug("The bean threw an expected error during the execution {0}", e); 142 } 143 if (!ExceptionHandleUtil.isDiscarded(sfsbContainerTransactionRuntime)) { 145 fail("The bean was not discarded."); 146 } 147 148 } 150 151 155 public ItfContainerTransaction getRuntimeBean(){ 156 return sfsbContainerTransactionRuntime; 157 } 158 159 164 public void deleteTable() throws Exception { 165 ExceptionHandleUtil.deleteTable(DATABASE_1, ItfContainerTransaction.TABLE); 167 ExceptionHandleUtil.deleteTable(DATABASE_2, ItfContainerTransaction.TABLE); 168 ExceptionHandleUtil.deleteTable(DATABASE_1, ItfTransactionMisc00.TABLE); 170 ExceptionHandleUtil.deleteTable(DATABASE_2, ItfTransactionMisc00.TABLE); 171 } 172 173 174 } 175 | Popular Tags |