KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > admin > monitor > callflow > MethodStartAccessObjectImplTest


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23
24 /*
25  * MethodStartAccessObjectImplTest.java
26  * JUnit based test
27  *
28  * Created on July 14, 2005, 1:59 PM
29  */

30
31 package com.sun.enterprise.admin.monitor.callflow;
32
33 import java.sql.DriverManager JavaDoc;
34 import java.sql.PreparedStatement JavaDoc;
35 import junit.framework.*;
36 import java.sql.Connection JavaDoc;
37 import com.sun.enterprise.admin.monitor.callflow.TableInfo;
38 import com.sun.enterprise.admin.monitor.callflow.AbstractTableAccessObject;
39
40 /**
41  *
42  * @author Harpreet Singh
43  */

44 public class MethodStartAccessObjectImplTest extends TestCase {
45     Connection JavaDoc con = null;
46     TableAccessObject ms = null;
47     PreparedStatement JavaDoc pstmt = null;
48     MethodStartTO[] methodStart = new MethodStartTO[10];
49         
50     public MethodStartAccessObjectImplTest(String JavaDoc testName) {
51         super(testName);
52     }
53
54     protected void setUp() throws Exception JavaDoc {
55     try{
56             // TODO code application logic here
57
String JavaDoc 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             // drop request start table
61
ms = MethodStartAccessObjectImpl.getInstance();
62         } catch (Exception JavaDoc e){
63             e.printStackTrace();
64         }
65                 
66     }
67
68     protected void tearDown() throws Exception JavaDoc {
69         try{
70             con.close();
71         } finally{
72             con = null;
73         }
74     }
75     
76     /**
77      * Test of createTable method, of class com.sun.enterprise.admin.monitor.callflow.MethodStartAccessObjectImpl.
78      */

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 JavaDoc e){
86             e.printStackTrace();
87         }
88         assertTrue(result);
89     }
90    public void testInsert (){
91         System.out.println(" testStoreMethodStart");
92         try{
93             String JavaDoc 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 JavaDoc e) {
112             e.printStackTrace();
113         }
114         boolean result = ms.insert (pstmt, methodStart);
115         System.out.println("testStoreMethodStart returned = "+result);
116         assertTrue (result);
117     }
118     /**
119      * Test of dropTable method, of class com.sun.enterprise.admin.monitor.callflow.MethodStartAccessObjectImpl.
120      */

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 JavaDoc[] argList) {
129
130 // junit.textui.TestRunner.run(suite());
131
}
132     
133 }
134
Popular Tags