1 25 26 package org.objectweb.jonas.jtests.clients.distribution; 27 28 import javax.naming.NamingException ; 29 import javax.rmi.PortableRemoteObject ; 30 31 import junit.framework.Test; 32 import junit.framework.TestSuite; 33 34 import org.objectweb.jonas.jtests.beans.jdbc.Manager; 35 import org.objectweb.jonas.jtests.beans.jdbc.ManagerHome; 36 import org.objectweb.jonas.jtests.util.JTestCase; 37 38 43 public class F_Jdbc extends JTestCase { 44 45 protected static ManagerHome mhome = null; 46 protected Manager manager = null; 47 48 public F_Jdbc(String name) { 49 super(name); 50 } 51 52 protected void tearDown() throws Exception { 53 if (manager != null) { 54 manager.remove(); 55 } 56 } 57 58 protected void setUp() { 59 super.setUp(); 60 if (mhome == null) { 61 useBeans("jdbc", false); 62 try { 63 mhome = (ManagerHome) PortableRemoteObject.narrow(ictx.lookup("jdbcManagerSYHome"), ManagerHome.class); 64 assertNotNull(mhome); 65 } catch (NamingException e) { 66 fail("Cannot get bean home"); 67 } 68 } 69 if (manager == null) { 70 try { 71 manager = mhome.create(); 72 assertNotNull(manager); 73 } catch (Exception e) { 74 fail("Cannot create manager session"); 75 } 76 } 77 } 78 79 82 public void testOpenConnection() throws Exception { 83 int cnb = manager.openConnection(); 84 assertTrue(cnb > 0); 85 } 86 87 90 public void testCloseConnection() throws Exception { 91 int cnb = manager.openConnection(); 92 assertTrue("open connection failed", cnb > 0); 93 assertTrue("isClosed() should return true after close()", manager.closeConnection(cnb)); 94 } 95 96 99 public void testOpenCloseConnection() throws Exception { 100 assertTrue(manager.openCloseConnection()); 101 } 102 103 public static Test suite() { 104 return new TestSuite(F_Jdbc.class); 105 } 106 107 public static void main (String args[]) { 108 String testtorun = null; 109 for (int argn = 0; argn < args.length; argn++) { 111 String s_arg = args[argn]; 112 Integer i_arg; 113 if (s_arg.equals("-n")) { 114 testtorun = args[++argn]; 115 } 116 } 117 if (testtorun == null) { 118 junit.textui.TestRunner.run(suite()); 119 } else { 120 junit.textui.TestRunner.run(new F_Jdbc(testtorun)); 121 } 122 } 123 } 124 | Popular Tags |