1 25 26 package org.objectweb.jonas.jtests.clients.jca15; 27 28 import junit.framework.*; 29 import java.io.BufferedReader ; 30 import java.io.FileInputStream ; 31 import java.io.InputStreamReader ; 32 import java.io.IOException ; 33 import java.lang.String ; 34 import java.rmi.RemoteException ; 35 import javax.rmi.PortableRemoteObject ; 36 import java.util.Collection ; 37 import java.util.Enumeration ; 38 import java.util.Hashtable ; 39 import java.util.Properties ; 40 import javax.ejb.FinderException ; 41 import javax.ejb.RemoveException ; 42 import javax.naming.Context ; 43 import javax.naming.InitialContext ; 44 import javax.naming.NamingException ; 45 46 import org.objectweb.jonas.jtests.beans.jca15.RuntimeCA; 47 import org.objectweb.jonas.jtests.beans.jca15.RuntimeCAHome; 48 import org.objectweb.jonas.jtests.util.JTestCase; 49 50 53 54 public class F_runtimeTest extends JTestCase { 55 56 static Context ctx = null; 57 58 60 protected static String BEAN_HOME = "RuntimeCAHome"; 61 protected static RuntimeCAHome home = null; 62 private static final String RAR_JNDI_NAME = "eis/ErsatzNolog"; 63 static RuntimeCA bean = null; 64 final private int CLOSE_HANDLE = 0; 65 final private int CLOSE_PHYSICAL = 1; 66 int CloseType = 0; 67 68 public F_runtimeTest(String name) { 69 super(name); 70 } 71 72 protected void setUp() { 73 super.setUp(); 74 75 77 try { 78 79 81 if (ctx == null) { 82 ctx = new InitialContext (); 83 } 84 85 if (home == null) { 86 useBeans("jca15", false); } 88 89 91 if (home == null) { 92 home = (RuntimeCAHome)PortableRemoteObject.narrow( 93 ctx.lookup(BEAN_HOME), 94 RuntimeCAHome.class); 95 bean = home.create(); 96 } 97 98 assertTrue (5 == 5); 99 100 } catch (Exception e) { 101 fail("Cannot do setUp: " +e); 102 } 103 } 104 105 protected void tearDown() throws Exception { 106 bean.closeUp(CloseType); 107 } 108 protected void startUp(String testName) { 109 try { 110 bean.method1(RAR_JNDI_NAME, testName); 111 } catch (Exception ee) { 112 ee.printStackTrace(); 113 System.exit(2); 114 } 115 } 116 138 public void testPrintWriterNull() throws Exception { 139 CloseType=CLOSE_PHYSICAL; 140 int isNull = 0; 141 int isNotNull = 1; 142 int isError = 2; 143 startUp("testPrintWriterNull"); 144 int x = bean.getMCF_Pwriter(); 145 assertEquals(isNull, x); 146 x = bean.getMC_Pwriter(); 147 assertEquals(isNull, x); 148 } 149 150 158 public void testSecurityContextApplication() throws Exception { 159 CloseType=CLOSE_PHYSICAL; 160 bean.setResAuth("Application"); 161 startUp("testSecurityContextApplication"); 162 String pw = bean.getSecurityPassword(); 164 String u = bean.getSecurityUserName(); 165 String realResAuth = bean.getResAuth(); 166 if (realResAuth.equals("Application")) { 167 assertEquals("__Jtest_Pass_word__", pw); 168 assertEquals("Ersatz_User_Name", u); 169 } else { 170 assertFalse(pw.equals("__Jtest_Pass_word__")); 171 } 172 173 } 174 176 public static Test suite() { 177 return new TestSuite(F_runtimeTest.class); 178 } 179 180 public static void main (String args[]) { 181 182 String testtorun = null; 183 184 186 for (int argn = 0; argn < args.length; argn++) { 187 188 String s_arg = args[argn]; 189 Integer i_arg; 190 191 if (s_arg.equals("-n")) { 192 testtorun = args[++argn]; 193 } 194 } 195 196 if (testtorun == null) { 197 junit.textui.TestRunner.run(suite()); 198 } else { 199 junit.textui.TestRunner.run(new F_runtimeTest(testtorun)); 200 } 201 } 202 } 203 | Popular Tags |