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