KickJava   Java API By Example, From Geeks To Geeks.

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


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  * MethodEndAccessObjectImplTest.java
26  * JUnit based test
27  *
28  * Created on July 14, 2005, 11:53 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 import com.sun.enterprise.admin.monitor.callflow.AbstractTableAccessObject;
39 import org.omg.CORBA.MARSHAL JavaDoc;
40
41 /**
42  *
43  * @author Harpreet Singh
44  */

45 public class MethodEndAccessObjectImplTest extends TestCase {
46     Connection JavaDoc con = null;
47     TableAccessObject me = null;
48     PreparedStatement JavaDoc pstmt = null;
49     MethodEndTO[] methodEnd = new MethodEndTO[10];
50     
51     public MethodEndAccessObjectImplTest(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
me = MethodEndAccessObjectImpl.getInstance();
63         } catch (Exception JavaDoc e){
64             e.printStackTrace();
65         }
66         
67     }
68
69     protected void tearDown() throws Exception JavaDoc {
70         try{
71             con.close();
72         } finally{
73             con = null;
74         }
75     }
76
77
78     /**
79      * Test of createTable method, of class com.sun.enterprise.admin.monitor.callflow.MethodEndAccessObjectImpl.
80      */

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

116     public void testDropTable() {
117         System.out.println("MethodEnd testDropTable");
118         boolean result = me.dropTable(con);
119         System.out.println("Method End Drop Table returned = "+result);
120         assertTrue (result);
121     }
122
123     public static void main(java.lang.String JavaDoc[] argList) {
124
125         
126     }
127     
128 }
129
Popular Tags