1 23 24 29 30 package com.sun.enterprise.admin.monitor.callflow; 31 32 import java.sql.DriverManager ; 33 import java.sql.PreparedStatement ; 34 import junit.framework.*; 35 import java.sql.Connection ; 36 import com.sun.enterprise.admin.monitor.callflow.TableInfo; 37 import com.sun.enterprise.admin.monitor.callflow.AbstractTableAccessObject; 38 39 40 44 public class EndTimeAccessObjectImplTest extends TestCase { 45 Connection con = null; 46 TableAccessObject ce = null; 47 PreparedStatement pstmt = null; 48 EndTimeTO[] endTime = new EndTimeTO[10]; 49 50 public EndTimeAccessObjectImplTest(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 ce = EndTimeAccessObjectImpl.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 77 80 public void testCreateTable() { 81 System.out.println("End Time: testCreateTable"); 82 boolean result = false; 83 try{ 84 result = ce.createTable(con); 85 System.out.println("End Time Create Table returned = "+ result); 86 }catch (Exception e){ 87 e.printStackTrace(); 88 } 89 assertTrue(result); 90 } 91 92 public void testInsert (){ 93 System.out.println(" testStoreendTime"); 94 try{ 95 String insertSQL = ce.getInsertSQL(); 96 System.out.println (" Insert SQL :"+ insertSQL); 97 pstmt = con.prepareStatement(insertSQL); 98 99 for (int i = 0; i < endTime.length; i++) { 100 endTime[i] = new EndTimeTO(); 101 endTime[i].requestId = "RequestID_"+i; 102 endTime[i].timeStamp = System.nanoTime(); 103 endTime[i].containerTypeOrApplicationType = "ORB"; 104 } 105 } catch (Exception e) { 106 e.printStackTrace(); 107 } 108 boolean result = ce.insert (pstmt, endTime); 109 System.out.println("testStoreendTime returned = "+result); 110 assertTrue (result); 111 } 112 115 public void testDropTable() { 116 System.out.println("EndTime testDropTable"); 117 boolean result = ce.dropTable(con); 118 System.out.println("End Time Drop Table returned = "+result); 119 assertTrue (result); 120 } 121 122 public static void main(java.lang.String [] argList) { 123 124 125 } 126 127 } 128 | Popular Tags |