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 39 43 public class RequestEndAccessObjectImplTest extends TestCase { 44 45 Connection con = null; 46 TableAccessObject re = null; 47 PreparedStatement pstmt = null; 48 RequestEndTO[] requestEnd = new RequestEndTO[10]; 49 50 51 public RequestEndAccessObjectImplTest(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 re = RequestEndAccessObjectImpl.getInstance(); 63 } catch (Exception e){ 64 e.printStackTrace(); 65 } 66 } 67 68 protected void tearDown() throws Exception { 69 try{ 70 con.close(); 71 } finally{ 72 con = null; 73 } 74 } 75 78 public void testCreateTable() { 79 System.out.println("Request End testCreateTable"); 80 boolean result = false; 81 try{ 82 result = re.createTable(con); 83 System.out.println("Request End Create Table returned = "+ result); 84 }catch (Exception e){ 85 e.printStackTrace(); 86 } 87 assertTrue(result); 88 } 89 90 public void testInsert (){ 91 System.out.println(" testStorerequestEnd"); 92 try{ 93 String insertSQL = re.getInsertSQL(); 94 System.out.println (" Insert SQL :"+ insertSQL); 95 pstmt = con.prepareStatement(insertSQL); 96 97 for (int i = 0; i < requestEnd.length; i++) { 98 requestEnd[i] = new RequestEndTO(); 99 requestEnd[i].requestId = "RequestID_"+i; 100 requestEnd[i].timeStamp = System.nanoTime(); 101 } 102 } catch (Exception e) { 103 e.printStackTrace(); 104 } 105 boolean result = re.insert (pstmt, requestEnd); 106 System.out.println("testStorerequestEnd returned = "+result); 107 assertTrue (result); 108 } 109 110 113 public void testDropTable() { 114 System.out.println("Request End testDropTable"); 115 boolean result = re.dropTable(con); 116 System.out.println("Request End Drop Table returned = "+result); 117 assertTrue (result); 118 } 119 120 public static void main(java.lang.String [] argList) { 121 } 122 123 } 124 | Popular Tags |