KickJava   Java API By Example, From Geeks To Geeks.

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


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  * StartTimeAccessObjectImplTest.java
26  *
27  * Created on August 3, 2005, 3:01 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 StartTimeAccessObjectImplTest extends TestCase {
45     Connection JavaDoc con = null;
46     TableAccessObject cs = null;
47     PreparedStatement JavaDoc pstmt = null;
48     StartTimeTO[] startTime = new StartTimeTO[10];
49     
50     public StartTimeAccessObjectImplTest(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
cs = StartTimeAccessObjectImpl.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.StartTimeAccessObjectImpl.
79      */

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

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