1 22 package org.jboss.test.jca.ejb; 23 24 import javax.ejb.EJBException ; 25 import javax.ejb.SessionBean ; 26 import javax.ejb.SessionContext ; 27 import javax.ejb.TransactionRolledbackLocalException ; 28 import javax.naming.InitialContext ; 29 import javax.transaction.TransactionRolledbackException ; 30 31 import org.jboss.logging.Logger; 32 import org.jboss.test.jca.interfaces.XAExceptionSession; 33 import org.jboss.test.jca.interfaces.XAExceptionSessionHome; 34 import org.jboss.test.jca.interfaces.XAExceptionSessionLocal; 35 import org.jboss.test.jca.interfaces.XAExceptionSessionLocalHome; 36 37 49 public class XAExceptionTestSessionBean implements SessionBean 50 { 51 52 53 private static final long serialVersionUID = 1L; 54 55 private Logger log = Logger.getLogger(getClass()); 56 57 61 public void ejbCreate() 62 { 63 } 64 65 69 public void testXAExceptionToTransactionRolledbackException() 70 { 71 try 72 { 73 XAExceptionSessionHome xh = (XAExceptionSessionHome) new InitialContext () 74 .lookup("test/XAExceptionSessionHome"); 75 XAExceptionSession x = xh.create(); 76 try 77 { 78 x.testXAExceptionToTransactionRolledbackException(); 79 } 80 catch (TransactionRolledbackException tre) 81 { 82 log.info("Test worked"); 83 return; 84 } 85 } 86 catch (Exception e) 87 { 88 log.info("unexpected exception", e); 89 throw new EJBException ("Unexpected exception: " + e); 90 } 91 throw new EJBException ("No exception"); 92 } 93 94 98 public void testXAExceptionToTransactionRolledbackLocalException() 99 { 100 try 101 { 102 XAExceptionSessionLocalHome xh = (XAExceptionSessionLocalHome) new InitialContext () 103 .lookup("test/XAExceptionSessionLocalHome"); 104 XAExceptionSessionLocal x = xh.create(); 105 try 106 { 107 x.testXAExceptionToTransactionRolledbackException(); 108 } 109 catch (TransactionRolledbackLocalException tre) 110 { 111 log.info("Test worked"); 112 return; 113 } 114 } 115 catch (Exception e) 116 { 117 log.info("unexpected exception", e); 118 throw new EJBException ("Unexpected exception: " + e); 119 } 120 throw new EJBException ("No exception"); 121 } 122 123 127 public void testRMERRInOnePCToTransactionRolledbackException() 128 { 129 try 130 { 131 XAExceptionSessionHome xh = (XAExceptionSessionHome) new InitialContext () 132 .lookup("test/XAExceptionSessionHome"); 133 XAExceptionSession x = xh.create(); 134 try 135 { 136 x.testRMERRInOnePCToTransactionRolledbackException(); 137 } 138 catch (TransactionRolledbackException tre) 139 { 140 log.info("Test worked"); 141 return; 142 } 143 } 144 catch (Exception e) 145 { 146 log.info("unexpected exception", e); 147 throw new EJBException ("Unexpected exception: " + e); 148 } 149 throw new EJBException ("No exception"); 150 } 151 152 156 public void testXAExceptionToTransactionRolledbacLocalkException() 157 { 158 try 159 { 160 XAExceptionSessionLocalHome xh = (XAExceptionSessionLocalHome) new InitialContext () 161 .lookup("test/XAExceptionSessionLocalHome"); 162 XAExceptionSessionLocal x = xh.create(); 163 try 164 { 165 x.testRMERRInOnePCToTransactionRolledbackException(); 166 } 167 catch (TransactionRolledbackLocalException tre) 168 { 169 log.info("Test worked"); 170 return; 171 } 172 } 173 catch (Exception e) 174 { 175 log.info("unexpected exception", e); 176 throw new EJBException ("Unexpected exception: " + e); 177 } 178 throw new EJBException ("No exception"); 179 } 180 181 public void ejbActivate() 182 { 183 } 184 185 public void ejbPassivate() 186 { 187 } 188 189 public void ejbRemove() 190 { 191 } 192 193 public void setSessionContext(SessionContext ctx) 194 { 195 } 196 197 public void unsetSessionContext() 198 { 199 } 200 201 } 202 | Popular Tags |