1 45 package org.openejb.test.stateless; 46 47 import javax.ejb.EJBHome ; 48 49 55 public class StatelessEjbObjectTests extends BasicStatelessTestClient{ 56 57 public StatelessEjbObjectTests(){ 58 super("EJBObject."); 59 } 60 61 protected void setUp() throws Exception { 62 super.setUp(); 63 Object obj = initialContext.lookup("client/tests/stateless/BasicStatelessHome"); 64 ejbHome = (BasicStatelessHome)javax.rmi.PortableRemoteObject.narrow( obj, BasicStatelessHome.class); 65 ejbObject = ejbHome.create(); 66 } 67 68 protected void tearDown() throws Exception { 69 try { 70 } catch (Exception e){ 72 throw e; 73 } finally { 74 super.tearDown(); 75 } 76 } 77 78 public void test01_getHandle(){ 82 try{ 83 ejbHandle = ejbObject.getHandle(); 84 assertNotNull( "The Handle is null", ejbHandle ); 85 } catch (Exception e){ 86 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 87 } 88 } 89 90 public void test02_isIdentical(){ 91 try{ 92 assertTrue( "The EJBObjects are not identical", ejbObject.isIdentical(ejbObject) ); 93 } catch (Exception e){ 94 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 95 } 96 } 97 98 public void test03_getEjbHome(){ 99 try{ 100 EJBHome home = ejbObject.getEJBHome(); 101 assertNotNull( "The EJBHome is null", home ); 102 } catch (Exception e){ 103 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 104 } 105 } 106 107 120 public void test04_getPrimaryKey(){ 121 try{ 122 Object key = ejbObject.getPrimaryKey(); 123 } catch (java.rmi.RemoteException e){ 124 assertTrue(true); 125 return; 126 } catch (Exception e){ 127 fail("A RuntimeException should have been thrown. Received Exception "+e.getClass()+ " : "+e.getMessage()); 128 } 129 fail("A RuntimeException should have been thrown."); 130 } 131 132 public void test05_remove(){ 133 try{ 134 ejbObject.remove(); 135 try{ 136 ejbObject.businessMethod("Should throw an exception"); 137 assertTrue( "Calling business method after removing the EJBObject does not throw an exception", false ); 138 } catch (Exception e){ 139 assertTrue( true ); 140 return; 141 } 142 } catch (Exception e){ 143 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 144 } 145 } 146 } 150 | Popular Tags |