1 23 24 30 31 package com.sun.enterprise.admin.monitor.callflow; 32 33 import java.sql.DriverManager ; 34 import java.sql.PreparedStatement ; 35 import junit.framework.*; 36 import java.sql.Connection ; 37 import com.sun.enterprise.admin.monitor.callflow.TableInfo; 38 import com.sun.enterprise.admin.monitor.callflow.AbstractTableAccessObject; 39 import org.omg.CORBA.MARSHAL ; 40 41 45 public class MethodEndAccessObjectImplTest extends TestCase { 46 Connection con = null; 47 TableAccessObject me = null; 48 PreparedStatement pstmt = null; 49 MethodEndTO[] methodEnd = new MethodEndTO[10]; 50 51 public MethodEndAccessObjectImplTest(String testName) { 52 super(testName); 53 } 54 55 protected void setUp() throws Exception { 56 try{ 57 String url="jdbc:derby://localhost:1527/sun-callflow;retrieveMessagesFromServerOnGetMessage=true;create=true;"; 59 Class.forName("org.apache.derby.jdbc.ClientDriver").newInstance(); 60 con = DriverManager.getConnection(url, "APP", "APP"); 61 me = MethodEndAccessObjectImpl.getInstance(); 63 } catch (Exception e){ 64 e.printStackTrace(); 65 } 66 67 } 68 69 protected void tearDown() throws Exception { 70 try{ 71 con.close(); 72 } finally{ 73 con = null; 74 } 75 } 76 77 78 81 public void testCreateTable() { 82 System.out.println("Method End : testCreateTable"); 83 boolean result = false; 84 try{ 85 result = me.createTable(con); 86 System.out.println("Method End Create Table returned = "+ result); 87 }catch (Exception e){ 88 e.printStackTrace(); 89 } 90 assertTrue(result); 91 } 92 93 public void testInsert (){ 94 System.out.println(" testStoremethodEnd"); 95 try{ 96 String insertSQL = me.getInsertSQL(); 97 System.out.println (" Insert SQL :"+ insertSQL); 98 pstmt = con.prepareStatement(insertSQL); 99 100 for (int i = 0; i < methodEnd.length; i++) { 101 methodEnd[i] = new MethodEndTO(); 102 methodEnd[i].requestId = "RequestID_"+i; 103 methodEnd[i].timeStamp = System.nanoTime(); 104 methodEnd[i].exception = null; 105 } 106 } catch (Exception e) { 107 e.printStackTrace(); 108 } 109 boolean result = me.insert (pstmt, methodEnd); 110 System.out.println("testStoremethodEnd returned = "+result); 111 assertTrue (result); 112 } 113 116 public void testDropTable() { 117 System.out.println("MethodEnd testDropTable"); 118 boolean result = me.dropTable(con); 119 System.out.println("Method End Drop Table returned = "+result); 120 assertTrue (result); 121 } 122 123 public static void main(java.lang.String [] argList) { 124 125 126 } 127 128 } 129 | Popular Tags |