1 25 package org.objectweb.easybeans.tests.common.ejbs.base.persistencectxlife; 26 27 import static org.objectweb.easybeans.tests.common.helper.EJBHelper.getBeanRemoteInstance; 28 import static org.objectweb.easybeans.tests.common.helper.TransactionHelper.getInternalUserTransaction; 29 import static org.testng.Assert.assertFalse; 30 import static org.testng.Assert.assertTrue; 31 32 import javax.transaction.UserTransaction ; 33 34 import org.objectweb.easybeans.tests.common.ejbs.stateful.containermanaged.persistencectxlife.SFSBPCtxLifeCMT00; 35 36 42 public class BasePctxLifeCMETester00 { 43 44 47 private ItfPCtxLifetime00 bean00; 48 49 52 private UserTransaction utx; 53 54 59 public void setBean(final ItfPCtxLifetime00 bean) throws Exception { 60 bean00 = bean; 61 bean00.initEntityManager(); 62 utx = getInternalUserTransaction(); 63 } 64 65 74 public void test00() throws Exception { 75 utx.begin(); 76 77 bean00.createCheckEntity00(); 78 79 utx.rollback(); 80 81 assertFalse(bean00.existsEntity(), "The bean must not exists, the transaction was rolled back."); 82 bean00.checkDetached(); 83 } 84 85 92 public void test01() throws Exception { 93 utx.begin(); 94 95 bean00.createCheckEntity00(); 96 97 utx.commit(); 98 99 bean00.checkManaged(); 101 } 102 103 111 public void test02() throws Exception { 112 utx.begin(); 113 114 bean00.createCheckEntity00(); 115 116 bean00.checkManaged(); 118 119 utx.rollback(); 120 121 bean00.checkDetached(); 123 } 124 125 133 public void test03() throws Exception { 134 bean00.createCheckEntity00(); 135 136 assertTrue(bean00.existsEntity(), "The bean must exists."); 137 138 bean00.checkManaged(); 139 } 140 141 149 public void test04() throws Exception { 150 bean00.createCheckEntity00(); 152 bean00.persistEntity(); 154 155 bean00.checkManaged(); 156 } 157 158 162 public void tearDown() throws Exception { 163 ItfPCtxLifetime00 beanRemove = getBeanRemoteInstance(SFSBPCtxLifeCMT00.class, ItfPCtxLifetime00.class); 164 beanRemove.initEntityManager(); 165 beanRemove.removeEntity(); 166 } 167 168 } 169 | Popular Tags |