1 45 package org.openejb.test.stateless; 46 47 48 54 public class StatelessRemoteIntfcTests extends BasicStatelessTestClient{ 55 56 public StatelessRemoteIntfcTests(){ 57 super("RemoteIntfc."); 58 } 59 60 protected void setUp() throws Exception { 61 super.setUp(); 62 Object obj = initialContext.lookup("client/tests/stateless/BasicStatelessHome"); 63 ejbHome = (BasicStatelessHome)javax.rmi.PortableRemoteObject.narrow( obj, BasicStatelessHome.class); 64 ejbObject = ejbHome.create(); 65 } 66 67 public void test01_businessMethod(){ 71 try{ 72 String expected = "Success"; 73 String actual = ejbObject.businessMethod("sseccuS"); 74 assertEquals(expected, actual); 75 } catch (Exception e){ 76 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 77 } 78 } 79 80 84 public void test02_throwApplicationException(){ 85 try{ 86 ejbObject.throwApplicationException(); 87 } catch (org.openejb.test.ApplicationException e){ 88 return; 90 } catch (Throwable e){ 91 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 92 } 93 fail("An ApplicationException should have been thrown."); 94 } 95 96 100 public void test03_invokeAfterApplicationException(){ 101 try{ 102 String expected = "Success"; 103 String actual = ejbObject.businessMethod("sseccuS"); 104 assertEquals(expected, actual); 105 } catch (Throwable e){ 106 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 107 } 108 } 109 110 public void test04_throwSystemException(){ 111 try{ 112 ejbObject.throwSystemException_NullPointer(); 113 } catch (java.rmi.RemoteException e){ 114 Throwable n = e.detail; 116 assertNotNull("Nested exception should not be is null", n ); 117 assertTrue("Nested exception should be an instance of NullPointerException, but exception is "+n.getClass().getName(), (n instanceof NullPointerException )); 118 return; 119 } catch (Throwable e){ 120 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 121 } 122 fail("A NullPointerException should have been thrown."); 123 } 124 125 131 public void TODO_test05_invokeAfterSystemException(){ 132 try{ 133 ejbObject.businessMethod("This refernce is invalid"); 134 fail("A java.rmi.NoSuchObjectException should have been thrown."); 135 } catch (java.rmi.NoSuchObjectException e){ 136 } catch (Throwable e){ 138 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 139 } 140 } 141 145 protected void tearDown() throws Exception { 146 super.tearDown(); 147 } 148 } 149 | Popular Tags |