KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > jaspersoft > jasperserver > war > wizard > WizardFlowTest


1
2 /*
3  * Copyright (C) 2006 JasperSoft http://www.jaspersoft.com
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed WITHOUT ANY WARRANTY; and without the
11  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12  * See the GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, see http://www.gnu.org/licenses/gpl.txt
16  * or write to:
17  *
18  * Free Software Foundation, Inc.,
19  * 59 Temple Place - Suite 330,
20  * Boston, MA USA 02111-1307
21  */

22
23 package com.jaspersoft.jasperserver.war.wizard;
24
25 import com.jaspersoft.jasperserver.war.wizard.TestAttribute.DataSourceAttrb;
26
27 import junit.framework.Test;
28 import junit.framework.TestCase;
29 import junit.framework.TestSuite;
30
31
32 /**
33  * The test cases are for: -
34  * testing the wizard flow for the AllAccounts Jrxml file
35  *
36  **/

37 public class WizardFlowTest
38     extends AbstractHttpWizardBaseFlow {
39     
40     /**
41      * Creates a new JDBCWizardFlowTest object.
42      *
43      * @param s
44      **/

45     public WizardFlowTest(String JavaDoc s) {
46         super(s);
47     }
48     
49     
50     
51     //****--------------------------------------------------------------------------*****/
52
//* HttpUnit test cases */
53
//****--------------------------------------------------------------------------*****/
54

55     
56
57     /**
58      * This test case method is for testing Wizard flow with respect to JDBC, for JS application
59      * This Page checks for the cancel and back buttons on different pages within the folw,
60      * also checks for the next button functionality with and without proer response.
61      * And finally publish the report on Report Browser page.
62      *
63      * @throws Exception if fails
64      **/

65     public void testWizardFlowWithJDBC()
66       throws Exception JavaDoc {
67         TestAttribute attrbs = new TestAttribute();
68         attrbs.setReportName("TestJDBC"+String.valueOf((int)(Math.random()*1000)));
69         attrbs.setLabel("Test report by http unit test for JDBC");
70         attrbs.setJrxml("AllAccounts.jrxml");
71         attrbs.setJrmlResources(resourceMap);
72         DataSourceAttrb dsattrbs = attrbs.new DataSourceAttrb();
73         dsattrbs.setDataSourceType(TestAttribute.DSTYPE_JDBC);
74         dsattrbs.setName("jdbc");
75         dsattrbs.setLabel("Using JDBC DS");
76         dsattrbs.setDriver("com.mysql.jdbc.Driver");
77         dsattrbs.setUrl("jdbc:mysql://localhost:3306/jasperserver");
78         dsattrbs.setUsername("root");
79         dsattrbs.setPassword("root");
80         attrbs.setDataSourceAttrb(dsattrbs);
81         this.runWizardFlow(attrbs);
82     }
83     
84     
85     /**
86      * This test case method is for testing Wizard flow with respect to JNDI, for JS application
87      * This Page checks for the cancel and back buttons on different pages within the folw,
88      * also checks for the next button functionality with and without proer response.
89      * And finally publish the report on Report Browser page.
90      *
91      * @throws Exception if fails
92      **/

93     public void testWizardFlowWithJNDI()
94       throws Exception JavaDoc {
95         TestAttribute attrbs = new TestAttribute();
96         attrbs.setReportName("TestJNDI"+String.valueOf((int)(Math.random()*1000)));
97         attrbs.setLabel("Test report by http unit test for JNDI");
98         attrbs.setJrxml("AllAccounts.jrxml");
99         attrbs.setJrmlResources(resourceMap);
100         DataSourceAttrb dsattrbs = attrbs.new DataSourceAttrb();
101         dsattrbs.setDataSourceType(TestAttribute.DSTYPE_JNDI);
102         dsattrbs.setName("jndi");
103         dsattrbs.setLabel("Using jndi ds");
104         dsattrbs.setServiceName("jdbc/jserver");
105         attrbs.setDataSourceAttrb(dsattrbs);
106         this.runWizardFlow(attrbs);
107     }
108     
109     
110
111     //****--------------------------------------------------------------------------*****/
112
//* Base class method implementaion */
113
//****--------------------------------------------------------------------------*****/
114

115     
116
117     
118     /* (non-Javadoc)
119      * @see com.jaspersoft.jasperserver.war.HttpUnitBaseTestCase#getloginCredentials()
120      */

121     protected String JavaDoc[] getloginCredentials() {
122         return new String JavaDoc[] { USERNAME, PASSWORD };
123     }
124     
125     
126
127     //****--------------------------------------------------------------------------*****/
128
//* main method to run the test */
129
//****--------------------------------------------------------------------------*****/
130

131     
132     
133     /**
134      * the main method for calling all the test cases whichever is being added into the suite.
135      *
136      * @param args
137      **/

138     public static void main(String JavaDoc[] args) {
139         try {
140             junit.textui.TestRunner.run(suite());
141         } catch (Exception JavaDoc _ex) {
142             _ex.printStackTrace();
143         }
144     }
145
146     /**
147      * this method is for adding which all test case/s method/s need to be
148      *
149      * @return Test
150      *
151      * @throws Exception if fails
152      **/

153     public static Test suite()
154       throws Exception JavaDoc {
155         TestSuite suite = new TestSuite();
156
157         TestCase test1 = new WizardFlowTest("testWizardFlowWithJDBC");
158         TestCase test2 = new WizardFlowTest("testWizardFlowWithJNDI");
159         suite.addTest(test1);
160         suite.addTest(test2);
161         return suite;
162     }
163 }
164
Popular Tags