1 25 26 package org.objectweb.jonas.jtests.clients.exception; 27 28 import java.rmi.RemoteException ; 29 import javax.naming.NamingException ; 30 import javax.rmi.PortableRemoteObject ; 31 import junit.framework.Test; 32 import junit.framework.TestSuite; 33 import org.objectweb.jonas.jtests.beans.beanexc.AccountS; 34 import org.objectweb.jonas.jtests.beans.beanexc.AccountSHome; 35 import org.objectweb.jonas.jtests.beans.beanexc.AppException; 36 import org.objectweb.jonas.jtests.util.JTestCase; 37 38 44 public class F_CatcherBMT extends JTestCase { 45 46 private static String BEAN_HOME = "BTAccountSLHome"; 49 protected static AccountSHome home = null; 50 51 public F_CatcherBMT(String name) { 52 super(name); 53 } 54 55 protected void setUp() { 56 super.setUp(); 57 useBeans("beanexc", true); 58 } 59 60 public AccountSHome getHome() { 61 if (home == null) { 62 try { 63 home = (AccountSHome) PortableRemoteObject.narrow(ictx.lookup(BEAN_HOME), AccountSHome.class); 64 } catch (NamingException e) { 65 fail("Cannot get bean home"); 66 } 67 } 68 return home; 69 } 70 71 74 public AccountS getAccountS(int i) { 75 AccountS acs = null; 76 try { 77 acs = getHome().create(); 78 } catch (Exception e) { 79 fail("Exception in getAccountS should never occur:"+e); 81 } 82 return acs; 83 } 84 85 91 public void testApplicationBMT() throws Exception { 92 AccountS acs = getAccountS(83); 93 try { 94 acs.doAppException_3(); 95 fail("No AppException"); 96 } catch (AppException e) { 97 } 98 } 99 100 106 public void testUncheckedBMT() throws Exception { 107 AccountS acs = getAccountS(84); 108 try { 109 acs.doUncheckedException_3(); 110 fail("No RemoteException"); 111 } catch (RemoteException e) { 112 } 113 114 } 115 116 public static Test suite() { 117 return new TestSuite(F_CatcherBMT.class); 118 } 119 120 public static void main (String args[]) { 121 String testtorun = null; 122 for (int argn = 0; argn < args.length; argn++) { 124 String s_arg = args[argn]; 125 Integer i_arg; 126 if (s_arg.equals("-n")) { 127 testtorun = args[++argn]; 128 } 129 } 130 if (testtorun == null) { 131 junit.textui.TestRunner.run(suite()); 132 } else { 133 junit.textui.TestRunner.run(new F_CatcherBMT(testtorun)); 134 } 135 } 136 137 } 138 | Popular Tags |