1 45 package org.openejb.test.entity.cmp; 46 47 import javax.ejb.EJBHome ; 48 49 55 public class CmpEjbObjectTests extends BasicCmpTestClient{ 56 57 public CmpEjbObjectTests(){ 58 super("EJBObject."); 59 } 60 61 protected void setUp() throws Exception { 62 super.setUp(); 63 Object obj = initialContext.lookup("client/tests/entity/cmp/BasicCmpHome"); 64 ejbHome = (BasicCmpHome)javax.rmi.PortableRemoteObject.narrow( obj, BasicCmpHome.class); 65 ejbObject = ejbHome.create("Third Bean"); 66 } 67 68 protected void tearDown() throws Exception { 69 if(ejbObject!=null){ try{ 71 ejbObject.remove(); 72 }catch(Exception e){ 73 throw e; 74 } 75 } 76 super.tearDown(); 77 } 78 79 public void test01_getHandle(){ 83 try{ 84 ejbHandle = ejbObject.getHandle(); 85 assertNotNull( "The Handle is null", ejbHandle ); 86 } catch (Exception e){ 87 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 88 } 89 } 90 91 public void test02_getPrimaryKey(){ 92 try{ 93 ejbPrimaryKey = (Integer )ejbObject.getPrimaryKey(); 94 assertNotNull( "The primary key is null", ejbPrimaryKey ); 95 } catch (Exception e){ 96 e.printStackTrace(); 97 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 98 } 99 } 100 101 public void test03_isIdentical(){ 102 try{ 103 assertTrue("The EJBObjects are not equal", ejbObject.isIdentical(ejbObject) ); 104 } catch (Exception e){ 105 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 106 } 107 } 108 109 public void test04_getEjbHome(){ 110 try{ 111 EJBHome home = ejbObject.getEJBHome(); 112 assertNotNull( "The EJBHome is null", home ); 113 } catch (Exception e){ 114 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 115 } 116 } 117 118 public void test05_remove(){ 119 try{ 120 ejbObject.remove(); 121 try{ 122 ejbObject.businessMethod("Should throw an exception"); 123 assertTrue( "Calling business method after removing the EJBObject does not throw an exception", false ); 124 } catch (Exception e){ 125 assertTrue( true ); 126 return; 127 } 128 } catch (Exception e){ 129 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 130 } finally{ 131 ejbObject = null; 132 } 133 } 134 138 139 } 140 | Popular Tags |