FileDocCategorySizeDatePackage
MethodStartAccessObjectImplTest.javaAPI DocGlassfish v2 API5784Fri May 04 22:24:28 BST 2007com.sun.enterprise.admin.monitor.callflow

MethodStartAccessObjectImplTest

public class MethodStartAccessObjectImplTest extends TestCase
author
Harpreet Singh

Fields Summary
Connection
con
TableAccessObject
ms
PreparedStatement
pstmt
MethodStartTO[]
methodStart
Constructors Summary
public MethodStartAccessObjectImplTest(String testName)

    
        
       
        super(testName);
    
Methods Summary
public static voidmain(java.lang.String[] argList)


//        junit.textui.TestRunner.run(suite());
    
protected voidsetUp()

    try{
            // TODO code application logic here
            String url="jdbc:derby://localhost:1527/sun-callflow;retrieveMessagesFromServerOnGetMessage=true;create=true;";            
            Class.forName("org.apache.derby.jdbc.ClientDriver").newInstance();
            con = DriverManager.getConnection(url, "APP", "APP");         
            // drop request start table
            ms = MethodStartAccessObjectImpl.getInstance();            
        } catch (Exception e){
            e.printStackTrace();
        }        
                
    
protected voidtearDown()

        try{
            con.close();
        } finally{
            con = null;
        }
    
public voidtestCreateTable()
Test of createTable method, of class com.sun.enterprise.admin.monitor.callflow.MethodStartAccessObjectImpl.

       System.out.println("Method Start : testCreateTable");
        boolean result = false;
        try{
            result = ms.createTable(con);
            System.out.println("Method Start Create Table returned = "+ result);
        }catch (Exception e){
            e.printStackTrace();
        }
        assertTrue(result);           
    
public voidtestDropTable()
Test of dropTable method, of class com.sun.enterprise.admin.monitor.callflow.MethodStartAccessObjectImpl.

        System.out.println("Method Start testDropTable");
        boolean result = ms.dropTable(con);
        System.out.println("Method Start Drop Table returned = "+result);
        assertTrue(result);
    
public voidtestInsert()

        System.out.println(" testStoreMethodStart");
        try{
            String insertSQL = ms.getInsertSQL();
            System.out.println (" Insert SQL :"+ insertSQL);            
            pstmt = con.prepareStatement(insertSQL);
            
            
            for (int i = 0; i < methodStart.length; i++) {
                methodStart[i] = new MethodStartTO();
                methodStart[i].requestId = "RequestID_"+i;
                methodStart[i].timeStamp = System.nanoTime();
                methodStart[i].componentType = ComponentType.SERVLET;
                methodStart[i].componentName = "Component_Name_"+i;
                methodStart[i].appName = "APP_NAME";
                methodStart[i].methodName = "Method_Name_" +i;
                methodStart[i].moduleName = "Module_Name_" +i;
                methodStart[i].transactionId = "Transaction_Id_"+i;
                methodStart[i].threadId = "Thread_Id_"+i;
                methodStart[i].securityId = "watchman_"+i;
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        boolean result = ms.insert (pstmt, methodStart);
        System.out.println("testStoreMethodStart returned = "+result);
        assertTrue (result);