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 StartTimeAccessObjectImplTest extends TestCase { 45 Connection con = null; 46 TableAccessObject cs = null; 47 PreparedStatement pstmt = null; 48 StartTimeTO[] startTime = new StartTimeTO[10]; 49 50 public StartTimeAccessObjectImplTest(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 cs = StartTimeAccessObjectImpl.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("Start Time : testCreateTable"); 82 boolean result = false; 83 try{ 84 result = cs.createTable(con); 85 System.out.println("Start 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(" testStorestartTime"); 94 try{ 95 String insertSQL = cs.getInsertSQL(); 96 System.out.println (" Insert SQL :"+ insertSQL); 97 pstmt = con.prepareStatement(insertSQL); 98 99 for (int i = 0; i < startTime.length; i++) { 100 startTime[i] = new StartTimeTO(); 101 startTime[i].requestId = "RequestID_"+i; 102 startTime[i].timeStamp = System.nanoTime(); 103 startTime[i].containerTypeOrApplicationType = "ORB"; 104 } 105 } catch (Exception e) { 106 e.printStackTrace(); 107 } 108 boolean result = cs.insert (pstmt, startTime); 109 System.out.println("testStorestartTime returned = "+result); 110 assertTrue (result); 111 } 112 115 public void testDropTable() { 116 System.out.println("StartTime testDropTable"); 117 boolean result = cs.dropTable(con); 118 System.out.println("Start 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 |