1 45 package org.openejb.test.stateful; 46 47 import javax.ejb.EJBHome ; 48 49 55 public class StatefulEjbMetaDataTests extends BasicStatefulTestClient{ 56 57 public StatefulEjbMetaDataTests(){ 58 super("EJBMetaData."); 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 ejbMetaData = ejbHome.getEJBMetaData(); 66 } 67 68 public void test01_getEJBHome(){ 72 try{ 73 EJBHome home = ejbMetaData.getEJBHome(); 74 assertNotNull( "The EJBHome is null", home ); 75 } catch (Exception e){ 76 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 77 } 78 } 79 80 public void test02_getHomeInterfaceClass(){ 81 try{ 82 Class clazz = ejbMetaData.getHomeInterfaceClass(); 83 assertNotNull( "The Home Interface class is null", clazz ); 84 assertEquals(clazz , BasicStatefulHome.class); 85 } catch (Exception e){ 86 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 87 } 88 } 89 90 103 public void test03_getPrimaryKeyClass(){ 104 try{ 105 Class clazz = ejbMetaData.getPrimaryKeyClass(); 106 assertNull("Should not return a primary key. Method should throw an java.lang.RuntimeException", clazz ); 107 } catch (UnsupportedOperationException e){ 108 assertTrue( true ); 109 return; 110 } catch (Exception e){ 111 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 112 } 113 assertTrue( "Method should throw an java.lang.RuntimeException", false ); 114 } 115 116 public void test04_getRemoteInterfaceClass(){ 117 try{ 118 Class clazz = ejbMetaData.getRemoteInterfaceClass(); 119 assertNotNull( "The Remote Interface class is null", clazz ); 120 assertEquals(clazz , BasicStatefulObject.class); 121 } catch (Exception e){ 122 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 123 } 124 } 125 126 public void test05_isSession(){ 127 try{ 128 assertTrue( "EJBMetaData says this is not a session bean", ejbMetaData.isSession() ); 129 } catch (Exception e){ 130 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 131 } 132 } 133 134 public void test06_isStatelessSession(){ 135 try{ 136 assertTrue( "EJBMetaData says this is a stateless session bean", !ejbMetaData.isStatelessSession() ); 137 } catch (Exception e){ 138 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 139 } 140 } 141 } 145 | Popular Tags |