KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > jaspersoft > jasperserver > war > repository > RepositoryBrowserFlowTest


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

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

36 public class RepositoryBrowserFlowTest
37     extends AbstractHttpRepositeryBaseFlow {
38
39     /**
40      * Constructor
41      *
42      * @param s
43      */

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

54     
55     /**
56      * This test case method is for testing Repository Browser flow with respect to DataSource,
57      * DataType & JRXML files
58      *
59      * @throws Exception if fails.
60      */

61     public void testRepositoryBrowser() throws Exception JavaDoc {
62         
63         TestAttribute attrib = new TestAttribute();
64         attrib.setDataSourceReportName(String.valueOf("TestJNDI"+String.valueOf((int)(Math.random()*1000))));
65         attrib.setDataTypeReportName("DataType"+String.valueOf((int)(Math.random()*1000)));
66         attrib.setInputControlReportName("InputControl"+String.valueOf((int)(Math.random()*1000)));
67         attrib.setJRXMLReportName("JRXMLFile"+String.valueOf((int)(Math.random()*1000)));
68         attrib.setLabel("Test report by http unit test");
69         attrib.setServiceName("jndi/jserver");
70         attrib.setJrxml("AllAccounts.jrxml");
71         attrib.setJrmlResources(resourceMap);
72         DataSourceAttrb dsattrb = attrib.new DataSourceAttrb();
73         dsattrb.setDataSourceType(TestAttribute.DSTYPE_JNDI);
74         dsattrb.setName("jndi");
75         dsattrb.setLabel("Using JNDI DS");
76         dsattrb.setDriver("com.mysql.jdbc.Driver");
77         dsattrb.setUrl("jndi:mysql://localhost:3306/jasperserver");
78         dsattrb.setUsername("root");
79         dsattrb.setPassword("root");
80         attrib.setDataSourceAttrb(dsattrb);
81         this.repositoryFlow(attrib);
82     }
83     
84     /**
85      * This test case method is for testing Repository Browser flow with respect to Image File
86      *
87      * @throws Exception if fails.
88      */

89     public void testImageFileAddition() throws Exception JavaDoc {
90         
91         TestAttribute attrib = new TestAttribute();
92         attrib.setDataSourceReportName("TestJNDI"+String.valueOf((int)(Math.random()*1000)));
93         attrib.setDataTypeReportName("DataType"+String.valueOf((int)(Math.random()*1000)));
94         attrib.setInputControlReportName("InputControl"+String.valueOf((int)(Math.random()*1000)));
95         attrib.setJRXMLReportName("JRXMLFile"+String.valueOf((int)(Math.random()*1000)));
96         attrib.setLabel("Test report by http unit test for Image File");
97         attrib.setServiceName("jndi/jserver");
98         attrib.setJrxml("logo.jpg");
99         attrib.setJrmlResources(resourceMap);
100         DataSourceAttrb dsattrb = attrib.new DataSourceAttrb();
101         dsattrb.setDataSourceType(TestAttribute.DSTYPE_JNDI);
102         dsattrb.setName("jndi");
103         dsattrb.setLabel("Using JNDI DS");
104         dsattrb.setDriver("com.mysql.jdbc.Driver");
105         dsattrb.setUrl("jndi:mysql://localhost:3306/jasperserver");
106         dsattrb.setUsername("root");
107         dsattrb.setPassword("root");
108         attrib.setDataSourceAttrb(dsattrb);
109         this.repositoryFlow(attrib);
110     }
111     
112     /**
113      * This test case method is for testing Repository Browser flow with respect to Jar File
114      *
115      * @throws Exception if fails.
116      */

117     public void testJarFileAddition() throws Exception JavaDoc {
118         
119         TestAttribute attrib = new TestAttribute();
120         attrib.setDataSourceReportName("TestJNDI"+String.valueOf((int)(Math.random()*1000)));
121         attrib.setDataTypeReportName("DataType"+String.valueOf((int)(Math.random()*1000)));
122         attrib.setInputControlReportName("InputControl"+String.valueOf((int)(Math.random()*1000)));
123         attrib.setJRXMLReportName("JRXMLFile"+String.valueOf((int)(Math.random()*1000)));
124         attrib.setLabel("Test report by http unit test for Jar file");
125         attrib.setServiceName("jndi/jserver");
126         attrib.setJrxml("httpunit.jar");
127         attrib.setJrmlResources(resourceMap);
128         DataSourceAttrb dsattrb = attrib.new DataSourceAttrb();
129         dsattrb.setDataSourceType(TestAttribute.DSTYPE_JNDI);
130         dsattrb.setName("jndi");
131         dsattrb.setLabel("Using JNDI DS");
132         dsattrb.setDriver("com.mysql.jdbc.Driver");
133         dsattrb.setUrl("jndi:mysql://localhost:3306/jasperserver");
134         dsattrb.setUsername("root");
135         dsattrb.setPassword("root");
136         attrib.setDataSourceAttrb(dsattrb);
137         this.repositoryFlow(attrib);
138     }
139     
140     
141     /**
142      * This test case method is for testing Repository Browser flow with respect to Resource Bundle
143      *
144      * @throws Exception if fails.
145      */

146     public void testResourceBundleAddition() throws Exception JavaDoc {
147         
148         TestAttribute attrib = new TestAttribute();
149         attrib.setDataSourceReportName("TestJNDI"+String.valueOf((int)(Math.random()*1000)));
150         attrib.setDataTypeReportName("DataType"+String.valueOf((int)(Math.random()*1000)));
151         attrib.setInputControlReportName("InputControl"+String.valueOf((int)(Math.random()*1000)));
152         attrib.setJRXMLReportName("JRXMLFile"+String.valueOf((int)(Math.random()*1000)));
153         attrib.setLabel("Test report by http unit test for Resource Bundle");
154         attrib.setServiceName("jndi/jserver");
155         attrib.setJrxml("jndi.properties");
156         attrib.setJrmlResources(resourceMap);
157         DataSourceAttrb dsattrb = attrib.new DataSourceAttrb();
158         dsattrb.setDataSourceType(TestAttribute.DSTYPE_JNDI);
159         dsattrb.setName("jndi");
160         dsattrb.setLabel("Using JNDI DS");
161         dsattrb.setDriver("com.mysql.jdbc.Driver");
162         dsattrb.setUrl("jndi:mysql://localhost:3306/jasperserver");
163         dsattrb.setUsername("root");
164         dsattrb.setPassword("root");
165         attrib.setDataSourceAttrb(dsattrb);
166         this.repositoryFlow(attrib);
167     }
168     
169     
170     
171     /**
172      * This test case method is for testing Repository Browser flow with respect to Font File
173      *
174      * @throws Exception if fails.
175      */

176     public void testFontFileAddition() throws Exception JavaDoc {
177         
178         TestAttribute attrib = new TestAttribute();
179         attrib.setDataSourceReportName("TestJNDI"+String.valueOf((int)(Math.random()*1000)));
180         attrib.setDataTypeReportName("DataType"+String.valueOf((int)(Math.random()*1000)));
181         attrib.setInputControlReportName("InputControl"+String.valueOf((int)(Math.random()*1000)));
182         attrib.setJRXMLReportName("JRXMLFile"+String.valueOf((int)(Math.random()*1000)));
183         attrib.setLabel("Test report by http unit test for Font file");
184         attrib.setServiceName("jndi/jserver");
185         attrib.setJrxml("arial.ttf");
186         attrib.setJrmlResources(resourceMap);
187         DataSourceAttrb dsattrb = attrib.new DataSourceAttrb();
188         dsattrb.setDataSourceType(TestAttribute.DSTYPE_JNDI);
189         dsattrb.setName("jndi");
190         dsattrb.setLabel("Using JNDI DS");
191         dsattrb.setDriver("com.mysql.jdbc.Driver");
192         dsattrb.setUrl("jndi:mysql://localhost:3306/jasperserver");
193         dsattrb.setUsername("root");
194         dsattrb.setPassword("root");
195         attrib.setDataSourceAttrb(dsattrb);
196         this.repositoryFlow(attrib);
197     }
198     
199     
200     /**
201      * This test case method is for testing Repository Browser flow with respect to Text File
202      *
203      * @throws Exception if fails.
204      */

205     public void testTextFileAddition() throws Exception JavaDoc {
206         
207         TestAttribute attrib = new TestAttribute();
208         attrib.setDataSourceReportName("TestJNDI"+String.valueOf((int)(Math.random()*1000)));
209         attrib.setDataTypeReportName("DataType"+String.valueOf((int)(Math.random()*1000)));
210         attrib.setInputControlReportName("InputControl"+String.valueOf((int)(Math.random()*1000)));
211         attrib.setJRXMLReportName("JRXMLFile"+String.valueOf((int)(Math.random()*1000)));
212         attrib.setLabel("Test report by http unit test for Text file");
213         attrib.setServiceName("jndi/jserver");
214         attrib.setJrxml("test.txt");
215         attrib.setJrmlResources(resourceMap);
216         DataSourceAttrb dsattrb = attrib.new DataSourceAttrb();
217         dsattrb.setDataSourceType(TestAttribute.DSTYPE_JNDI);
218         dsattrb.setName("jndi");
219         dsattrb.setLabel("Using JNDI DS");
220         dsattrb.setDriver("com.mysql.jdbc.Driver");
221         dsattrb.setUrl("jndi:mysql://localhost:3306/jasperserver");
222         dsattrb.setUsername("root");
223         dsattrb.setPassword("root");
224         attrib.setDataSourceAttrb(dsattrb);
225         this.repositoryFlow(attrib);
226     }
227
228     
229     //****--------------------------------------------------------------------------*****/
230
//* Base class method implementaion */
231
//****--------------------------------------------------------------------------*****/
232

233     
234     
235     /* (non-Javadoc)
236      * @see com.jaspersoft.jasperserver.war.HttpUnitBaseTestCase#getloginCredentials()
237      */

238     protected String JavaDoc[] getloginCredentials() {
239         return new String JavaDoc[] { USERNAME, PASSWORD };
240     }
241     
242     
243     //****--------------------------------------------------------------------------*****/
244
//* HttpUnit framework methods */
245
//****--------------------------------------------------------------------------*****/
246

247     
248     /**
249      * the main method for calling all the test cases whichever is being added into the suite.
250      *
251      * @param args
252      **/

253     public static void main(String JavaDoc[] args) {
254         try {
255             junit.textui.TestRunner.run(suite());
256         } catch (Exception JavaDoc _ex) {
257             _ex.printStackTrace();
258         }
259     }
260
261     /**
262      * this method is for adding which all test case/s method/s need to be
263      *
264      * @return Test
265      *
266      * @throws Exception if fails
267      **/

268     public static Test suite()
269       throws Exception JavaDoc {
270         TestSuite suite = new TestSuite();
271
272         TestCase test1 = new RepositoryBrowserFlowTest("testRepositoryBrowser");
273         TestCase test2 = new RepositoryBrowserFlowTest("testImageFileAddition");
274         TestCase test3 = new RepositoryBrowserFlowTest("testJarFileAddition");
275         TestCase test4 = new RepositoryBrowserFlowTest("testResourceBundleAddition");
276         TestCase test5 = new RepositoryBrowserFlowTest("testFontFileAddition");
277         TestCase test6 = new RepositoryBrowserFlowTest("testTextFileAddition");
278         
279         suite.addTest(test1);
280         suite.addTest(test2);
281         suite.addTest(test3);
282         suite.addTest(test4);
283         suite.addTest(test5);
284         suite.addTest(test6);
285         
286         return suite;
287     }
288 }
Popular Tags