1 45 package org.openejb.test.entity.bmp; 46 47 import java.rmi.RemoteException ; 48 49 import javax.ejb.EJBException ; 50 import javax.ejb.EntityContext ; 51 import javax.ejb.RemoveException ; 52 import javax.naming.InitialContext ; 53 54 import junit.framework.Assert; 55 import junit.framework.AssertionFailedError; 56 57 import org.openejb.test.TestFailureException; 58 import org.openejb.test.stateful.BasicStatefulHome; 59 import org.openejb.test.stateful.BasicStatefulObject; 60 import org.openejb.test.stateless.BasicStatelessHome; 61 import org.openejb.test.stateless.BasicStatelessObject; 62 63 68 public class EncBmpBean implements javax.ejb.EntityBean { 69 70 private int primaryKey; 71 private String firstName; 72 private String lastName; 73 private EntityContext ejbContext; 74 75 76 80 88 public java.util.Collection ejbFindEmptyCollection() 89 throws javax.ejb.FinderException , java.rmi.RemoteException { 90 return new java.util.Vector (); 91 } 92 93 101 public Integer ejbFindByPrimaryKey(Integer primaryKey) 102 throws javax.ejb.FinderException { 103 return new Integer (-1); 104 } 105 106 114 public Integer ejbCreate(String name) 115 throws javax.ejb.CreateException { 116 return new Integer (-1); 117 } 118 119 public void ejbPostCreate(String name) 120 throws javax.ejb.CreateException { 121 } 122 123 124 128 129 133 134 public void lookupEntityBean() throws TestFailureException{ 135 try{ 136 try{ 137 InitialContext ctx = new InitialContext (); 138 Assert.assertNotNull("The InitialContext is null", ctx ); 139 140 BasicBmpHome home = (BasicBmpHome) javax.rmi.PortableRemoteObject.narrow( ctx.lookup("java:comp/env/entity/bmp/beanReferences/bmp_entity"), BasicBmpHome.class ); 141 Assert.assertNotNull("The EJBHome looked up is null",home); 142 143 BasicBmpObject object = home.create("Enc Bean"); 144 Assert.assertNotNull("The EJBObject is null", object ); 145 } catch (Exception e){ 146 Assert.fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 147 } 148 } catch (AssertionFailedError afe){ 149 throw new TestFailureException(afe); 150 } 151 } 152 153 public void lookupStatefulBean() throws TestFailureException{ 154 try{ 155 try{ 156 InitialContext ctx = new InitialContext (); 157 Assert.assertNotNull("The InitialContext is null", ctx ); 158 159 BasicStatefulHome home = (BasicStatefulHome) javax.rmi.PortableRemoteObject.narrow( ctx.lookup("java:comp/env/entity/bmp/beanReferences/stateful"), BasicStatefulHome.class ); 160 Assert.assertNotNull("The EJBHome looked up is null",home); 161 162 BasicStatefulObject object = home.create("Enc Bean"); 163 Assert.assertNotNull("The EJBObject is null", object ); 164 } catch (Exception e){ 165 Assert.fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 166 } 167 } catch (AssertionFailedError afe){ 168 throw new TestFailureException(afe); 169 } 170 } 171 172 public void lookupStatelessBean() throws TestFailureException{ 173 try{ 174 try{ 175 InitialContext ctx = new InitialContext (); 176 Assert.assertNotNull("The InitialContext is null", ctx ); 177 178 BasicStatelessHome home = (BasicStatelessHome) javax.rmi.PortableRemoteObject.narrow( ctx.lookup("java:comp/env/entity/bmp/beanReferences/stateless"), BasicStatelessHome.class ); 179 Assert.assertNotNull("The EJBHome looked up is null",home); 180 181 BasicStatelessObject object = home.create(); 182 Assert.assertNotNull("The EJBObject is null", object ); 183 } catch (Exception e){ 184 Assert.fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 185 } 186 } catch (AssertionFailedError afe){ 187 throw new TestFailureException(afe); 188 } 189 } 190 191 public void lookupStringEntry() throws TestFailureException{ 192 try{ 193 try{ 194 InitialContext ctx = new InitialContext (); 195 Assert.assertNotNull("The InitialContext is null", ctx ); 196 197 String expected = new String ("1"); 198 String actual = (String )ctx.lookup("java:comp/env/entity/bmp/references/String"); 199 200 Assert.assertNotNull("The String looked up is null", actual ); 201 Assert.assertEquals(expected, actual ); 202 203 } catch (Exception e){ 204 Assert.fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 205 } 206 } catch (AssertionFailedError afe){ 207 throw new TestFailureException(afe); 208 } 209 } 210 211 public void lookupDoubleEntry() throws TestFailureException{ 212 try{ 213 try{ 214 InitialContext ctx = new InitialContext (); 215 Assert.assertNotNull("The InitialContext is null", ctx ); 216 217 Double expected = new Double (1.0D); 218 Double actual = (Double )ctx.lookup("java:comp/env/entity/bmp/references/Double"); 219 220 Assert.assertNotNull("The Double looked up is null", actual ); 221 Assert.assertEquals(expected, actual ); 222 223 } catch (Exception e){ 224 Assert.fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 225 } 226 } catch (AssertionFailedError afe){ 227 throw new TestFailureException(afe); 228 } 229 } 230 231 public void lookupLongEntry() throws TestFailureException{ 232 try{ 233 try{ 234 InitialContext ctx = new InitialContext (); 235 Assert.assertNotNull("The InitialContext is null", ctx ); 236 237 Long expected = new Long (1L); 238 Long actual = (Long )ctx.lookup("java:comp/env/entity/bmp/references/Long"); 239 240 Assert.assertNotNull("The Long looked up is null", actual ); 241 Assert.assertEquals(expected, actual ); 242 243 } catch (Exception e){ 244 Assert.fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 245 } 246 } catch (AssertionFailedError afe){ 247 throw new TestFailureException(afe); 248 } 249 } 250 251 public void lookupFloatEntry() throws TestFailureException{ 252 try{ 253 try{ 254 InitialContext ctx = new InitialContext (); 255 Assert.assertNotNull("The InitialContext is null", ctx ); 256 257 Float expected = new Float (1.0F); 258 Float actual = (Float )ctx.lookup("java:comp/env/entity/bmp/references/Float"); 259 260 Assert.assertNotNull("The Float looked up is null", actual ); 261 Assert.assertEquals(expected, actual ); 262 263 } catch (Exception e){ 264 Assert.fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 265 } 266 } catch (AssertionFailedError afe){ 267 throw new TestFailureException(afe); 268 } 269 } 270 271 public void lookupIntegerEntry() throws TestFailureException{ 272 try{ 273 try{ 274 InitialContext ctx = new InitialContext (); 275 Assert.assertNotNull("The InitialContext is null", ctx ); 276 277 Integer expected = new Integer (1); 278 Integer actual = (Integer )ctx.lookup("java:comp/env/entity/bmp/references/Integer"); 279 280 Assert.assertNotNull("The Integer looked up is null", actual ); 281 Assert.assertEquals(expected, actual ); 282 283 } catch (Exception e){ 284 Assert.fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 285 } 286 } catch (AssertionFailedError afe){ 287 throw new TestFailureException(afe); 288 } 289 } 290 291 public void lookupShortEntry() throws TestFailureException{ 292 try{ 293 try{ 294 InitialContext ctx = new InitialContext (); 295 Assert.assertNotNull("The InitialContext is null", ctx ); 296 297 Short expected = new Short ((short)1); 298 Short actual = (Short )ctx.lookup("java:comp/env/entity/bmp/references/Short"); 299 300 Assert.assertNotNull("The Short looked up is null", actual ); 301 Assert.assertEquals(expected, actual ); 302 303 } catch (Exception e){ 304 Assert.fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 305 } 306 } catch (AssertionFailedError afe){ 307 throw new TestFailureException(afe); 308 } 309 } 310 311 public void lookupBooleanEntry() throws TestFailureException{ 312 try{ 313 try{ 314 InitialContext ctx = new InitialContext (); 315 Assert.assertNotNull("The InitialContext is null", ctx ); 316 317 Boolean expected = new Boolean (true); 318 Boolean actual = (Boolean )ctx.lookup("java:comp/env/entity/bmp/references/Boolean"); 319 320 Assert.assertNotNull("The Boolean looked up is null", actual ); 321 Assert.assertEquals(expected, actual ); 322 323 } catch (Exception e){ 324 Assert.fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 325 } 326 } catch (AssertionFailedError afe){ 327 throw new TestFailureException(afe); 328 } 329 } 330 331 public void lookupByteEntry() throws TestFailureException{ 332 try{ 333 try{ 334 InitialContext ctx = new InitialContext (); 335 Assert.assertNotNull("The InitialContext is null", ctx ); 336 337 Byte expected = new Byte ((byte)1); 338 Byte actual = (Byte )ctx.lookup("java:comp/env/entity/bmp/references/Byte"); 339 340 Assert.assertNotNull("The Byte looked up is null", actual ); 341 Assert.assertEquals(expected, actual ); 342 343 } catch (Exception e){ 344 Assert.fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 345 } 346 } catch (AssertionFailedError afe){ 347 throw new TestFailureException(afe); 348 } 349 } 350 351 public void lookupResource() throws TestFailureException{ 352 try{ 353 try{ 354 InitialContext ctx = new InitialContext (); 355 Assert.assertNotNull("The InitialContext is null", ctx ); 356 } catch (Exception e){ 357 Assert.fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 358 } 359 } catch (AssertionFailedError afe){ 360 throw new TestFailureException(afe); 361 } 362 } 363 367 368 372 377 public void ejbLoad() throws EJBException ,RemoteException { 378 } 379 380 384 public void setEntityContext(EntityContext ctx) throws EJBException ,RemoteException { 385 ejbContext = ctx; 386 } 387 388 392 public void unsetEntityContext() throws EJBException ,RemoteException { 393 } 394 395 400 public void ejbStore() throws EJBException ,RemoteException { 401 } 402 403 411 public void ejbRemove() throws RemoveException ,EJBException ,RemoteException { 412 } 413 414 420 public void ejbActivate() throws EJBException ,RemoteException { 421 } 422 423 429 public void ejbPassivate() throws EJBException ,RemoteException { 430 } 431 } 435 | Popular Tags |