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 43 public class BasePctxLifeCMTTester00 { 44 45 48 private ItfPCtxLifetime00 bean00; 49 50 53 private UserTransaction utx; 54 55 60 public void setBean(final ItfPCtxLifetime00 bean) throws Exception { 61 bean00 = bean; 62 bean00.initEntityManager(); 63 utx = getInternalUserTransaction(); 64 } 65 66 75 public void test00() throws Exception { 76 utx.begin(); 77 78 bean00.createCheckEntity00(); 79 80 utx.rollback(); 81 82 assertFalse(bean00.existsEntity(), "The bean must not exists, the transaction was rolled back."); 83 } 84 85 92 public void test01() throws Exception { 93 utx.begin(); 94 95 bean00.createCheckEntity00(); 96 97 utx.commit(); 98 99 bean00.checkDetached(); 101 } 102 103 112 public void test02() throws Exception { 113 utx.begin(); 114 115 bean00.createCheckEntity00(); 116 117 bean00.checkManaged(); 119 120 utx.rollback(); 121 122 assertFalse(bean00.existsEntity(), "The bean must not exists, the transaction was rolled back."); 123 } 124 125 133 public void test03() throws Exception { 134 bean00.createCheckEntity00(); 135 136 assertTrue(bean00.existsEntity(), "The bean must exists."); 137 138 bean00.checkDetached(); 139 } 140 141 149 public void test04() throws Exception { 150 bean00.createCheckEntity01(); 151 bean00.checkDetached(); 152 } 153 154 158 public void tearDown() throws Exception { 159 ItfPCtxLifetime00 beanRemove = getBeanRemoteInstance(SFSBPCtxLifeCMT00.class, ItfPCtxLifetime00.class); 160 beanRemove.initEntityManager(); 161 beanRemove.removeEntity(); 162 } 163 } 164 | Popular Tags |