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 40 44 public class MethodStartAccessObjectImplTest extends TestCase { 45 Connection con = null; 46 TableAccessObject ms = null; 47 PreparedStatement pstmt = null; 48 MethodStartTO[] methodStart = new MethodStartTO[10]; 49 50 public MethodStartAccessObjectImplTest(String testName) { 51 super(testName); 52 } 53 54 protected void setUp() throws Exception { 55 try{ 56 String url="jdbc:derby://localhost:1527/sun-callflow;retrieveMessagesFromServerOnGetMessage=true;create=true;"; 58 Class.forName("org.apache.derby.jdbc.ClientDriver").newInstance(); 59 con = DriverManager.getConnection(url, "APP", "APP"); 60 ms = MethodStartAccessObjectImpl.getInstance(); 62 } catch (Exception e){ 63 e.printStackTrace(); 64 } 65 66 } 67 68 protected void tearDown() throws Exception { 69 try{ 70 con.close(); 71 } finally{ 72 con = null; 73 } 74 } 75 76 79 public void testCreateTable() { 80 System.out.println("Method Start : testCreateTable"); 81 boolean result = false; 82 try{ 83 result = ms.createTable(con); 84 System.out.println("Method Start Create Table returned = "+ result); 85 }catch (Exception e){ 86 e.printStackTrace(); 87 } 88 assertTrue(result); 89 } 90 public void testInsert (){ 91 System.out.println(" testStoreMethodStart"); 92 try{ 93 String insertSQL = ms.getInsertSQL(); 94 System.out.println (" Insert SQL :"+ insertSQL); 95 pstmt = con.prepareStatement(insertSQL); 96 97 98 for (int i = 0; i < methodStart.length; i++) { 99 methodStart[i] = new MethodStartTO(); 100 methodStart[i].requestId = "RequestID_"+i; 101 methodStart[i].timeStamp = System.nanoTime(); 102 methodStart[i].componentType = ComponentType.SERVLET; 103 methodStart[i].componentName = "Component_Name_"+i; 104 methodStart[i].appName = "APP_NAME"; 105 methodStart[i].methodName = "Method_Name_" +i; 106 methodStart[i].moduleName = "Module_Name_" +i; 107 methodStart[i].transactionId = "Transaction_Id_"+i; 108 methodStart[i].threadId = "Thread_Id_"+i; 109 methodStart[i].securityId = "watchman_"+i; 110 } 111 } catch (Exception e) { 112 e.printStackTrace(); 113 } 114 boolean result = ms.insert (pstmt, methodStart); 115 System.out.println("testStoreMethodStart returned = "+result); 116 assertTrue (result); 117 } 118 121 public void testDropTable() { 122 System.out.println("Method Start testDropTable"); 123 boolean result = ms.dropTable(con); 124 System.out.println("Method Start Drop Table returned = "+result); 125 assertTrue(result); 126 } 127 128 public static void main(java.lang.String [] argList) { 129 130 } 132 133 } 134 | Popular Tags |