KickJava   Java API By Example, From Geeks To Geeks.

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


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  * RequestEndAccessObjectImplTest.java
26  * JUnit based test
27  *
28  * Created on July 14, 2005, 10:47 AM
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
39 /**
40  *
41  * @author Harpreet Singh
42  */

43 public class RequestEndAccessObjectImplTest extends TestCase {
44
45     Connection JavaDoc con = null;
46     TableAccessObject re = null;
47     PreparedStatement JavaDoc pstmt = null;
48     RequestEndTO[] requestEnd = new RequestEndTO[10];
49     
50
51     public RequestEndAccessObjectImplTest(String JavaDoc testName) {
52         super(testName);
53     }
54
55     protected void setUp() throws Exception JavaDoc {
56       try{
57             // TODO code application logic here
58
String JavaDoc url="jdbc:derby://localhost:1527/sun-callflow;retrieveMessagesFromServerOnGetMessage=true;create=true;";
59             Class.forName("org.apache.derby.jdbc.ClientDriver").newInstance();
60             con = DriverManager.getConnection(url, "APP", "APP");
61             // drop request start table
62
re = RequestEndAccessObjectImpl.getInstance();
63         } catch (Exception JavaDoc e){
64             e.printStackTrace();
65         }
66     }
67
68     protected void tearDown() throws Exception JavaDoc {
69         try{
70             con.close();
71         } finally{
72             con = null;
73         }
74     }
75     /**
76      * Test of createTable method, of class com.sun.enterprise.admin.monitor.callflow.RequestEndAccessObjectImpl.
77      */

78     public void testCreateTable() {
79         System.out.println("Request End testCreateTable");
80         boolean result = false;
81         try{
82             result = re.createTable(con);
83             System.out.println("Request End Create Table returned = "+ result);
84         }catch (Exception JavaDoc e){
85             e.printStackTrace();
86         }
87         assertTrue(result);
88     }
89
90    public void testInsert (){
91         System.out.println(" testStorerequestEnd");
92         try{
93             String JavaDoc insertSQL = re.getInsertSQL();
94             System.out.println (" Insert SQL :"+ insertSQL);
95             pstmt = con.prepareStatement(insertSQL);
96             
97             for (int i = 0; i < requestEnd.length; i++) {
98                 requestEnd[i] = new RequestEndTO();
99                 requestEnd[i].requestId = "RequestID_"+i;
100                 requestEnd[i].timeStamp = System.nanoTime();
101             }
102         } catch (Exception JavaDoc e) {
103             e.printStackTrace();
104         }
105         boolean result = re.insert (pstmt, requestEnd);
106         System.out.println("testStorerequestEnd returned = "+result);
107         assertTrue (result);
108     }
109
110    /**
111      * Test of dropTable method, of class com.sun.enterprise.admin.monitor.callflow.RequestEndAccessObjectImpl.
112      */

113     public void testDropTable() {
114         System.out.println("Request End testDropTable");
115         boolean result = re.dropTable(con);
116         System.out.println("Request End Drop Table returned = "+result);
117         assertTrue (result);
118     }
119
120     public static void main(java.lang.String JavaDoc[] argList) {
121     }
122     
123 }
124
Popular Tags