1 45 package org.openejb.test.stateful; 46 47 import org.openejb.test.ApplicationException; 48 49 50 56 public class StatefulRemoteIntfcTests extends BasicStatefulTestClient{ 57 58 public StatefulRemoteIntfcTests(){ 59 super("RemoteIntfc."); 60 } 61 62 protected void setUp() throws Exception { 63 super.setUp(); 64 Object obj = initialContext.lookup("client/tests/stateful/BasicStatefulHome"); 65 ejbHome = (BasicStatefulHome)javax.rmi.PortableRemoteObject.narrow( obj, BasicStatefulHome.class); 66 ejbObject = ejbHome.create("Third Bean"); 67 } 68 69 public void test01_businessMethod(){ 73 try{ 74 String expected = "Success"; 75 String actual = ejbObject.businessMethod("sseccuS"); 76 assertEquals(expected, actual); 77 } catch (Throwable e){ 78 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 79 } 80 } 81 82 83 87 public void test02_throwApplicationException(){ 88 try{ 89 ejbObject.throwApplicationException(); 90 } catch (ApplicationException e){ 91 return; 93 } catch (Throwable e){ 94 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 95 } 96 fail("An ApplicationException should have been thrown."); 97 } 98 99 103 public void test03_invokeAfterApplicationException(){ 104 try{ 105 String expected = "Success"; 106 String actual = ejbObject.businessMethod("sseccuS"); 107 assertEquals(expected, actual); 108 } catch (Throwable e){ 109 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 110 } 111 } 112 113 public void test04_throwSystemException(){ 114 try{ 115 ejbObject.throwSystemException_NullPointer(); 116 } catch (java.rmi.RemoteException e){ 117 Throwable n = e.detail; 119 assertNotNull("Nested exception should not be is null", n ); 120 assertTrue("Nested exception should be an instance of NullPointerException, but exception is "+n.getClass().getName(), (n instanceof NullPointerException )); 121 return; 122 } catch (Throwable e){ 123 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 124 } 125 fail("A NullPointerException should have been thrown."); 126 } 127 128 132 public void test05_invokeAfterSystemException(){ 133 try{ 134 ejbObject.businessMethod("This refernce is invalid"); 135 fail("A java.rmi.NoSuchObjectException should have been thrown."); 136 } catch (java.rmi.NoSuchObjectException e){ 137 } catch (Throwable e){ 139 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 140 } 141 } 142 143 147 protected void tearDown() throws Exception { 148 super.tearDown(); 149 } 150 } 151 | Popular Tags |