KickJava   Java API By Example, From Geeks To Geeks.

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


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  * EndTimeAccessObjectImpl.java
26  *
27  * Created on August 3, 2005, 3:04 PM
28  */

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

44 public class EndTimeAccessObjectImplTest extends TestCase {
45     Connection JavaDoc con = null;
46     TableAccessObject ce = null;
47     PreparedStatement JavaDoc pstmt = null;
48     EndTimeTO[] endTime = new EndTimeTO[10];
49     
50     public EndTimeAccessObjectImplTest(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
ce = EndTimeAccessObjectImpl.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     /**
78      * Test of createTable method, of class com.sun.enterprise.admin.monitor.callflow.EndTimeAccessObjectImpl.
79      */

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 JavaDoc e){
87             e.printStackTrace();
88         }
89         assertTrue(result);
90     }
91    
92     public void testInsert (){
93         System.out.println(" testStoreendTime");
94         try{
95             String JavaDoc 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 JavaDoc e) {
106             e.printStackTrace();
107         }
108         boolean result = ce.insert (pstmt, endTime);
109         System.out.println("testStoreendTime returned = "+result);
110         assertTrue (result);
111     }
112     /**
113      * Test of dropTable method, of class com.sun.enterprise.admin.monitor.callflow.EndTimeAccessObjectImpl.
114      */

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 JavaDoc[] argList) {
123
124         
125     }
126     
127 }
128
Popular Tags