KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > DDTest


1 /*
2  * JOnAS: Java(TM) Open Application Server
3  * Copyright (C) 1999 Bull S.A.
4  * Contact: jonas-team@objectweb.org
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or 1any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19  * USA
20  *
21  * Initial developer: Florent BENOIT
22  * --------------------------------------------------------------------------
23  * $Id: DDTest.java,v 1.9 2004/08/04 12:38:10 sauthieg Exp $
24  * --------------------------------------------------------------------------
25  */

26
27 import java.io.BufferedReader;
28 import java.io.InputStreamReader;
29
30 import org.objectweb.jonas_lib.deployment.xml.*;
31 import org.objectweb.jonas_lib.deployment.tests.*;
32
33 import org.objectweb.jonas_client.deployment.tests.*;
34 import org.objectweb.jonas_client.deployment.xml.*;
35
36 import org.objectweb.jonas_ejb.deployment.tests.*;
37 import org.objectweb.jonas_ejb.deployment.xml.*;
38
39 import org.objectweb.jonas_ear.deployment.tests.*;
40 import org.objectweb.jonas_ear.deployment.xml.*;
41
42 import org.objectweb.jonas_rar.deployment.tests.*;
43 import org.objectweb.jonas_rar.deployment.xml.*;
44
45 import org.objectweb.jonas_web.deployment.tests.*;
46 import org.objectweb.jonas_web.deployment.xml.*;
47
48 import org.objectweb.jonas_ws.deployment.tests.*;
49 import org.objectweb.jonas_ws.deployment.xml.*;
50
51
52 /**
53  * Defines a class for testing
54  * @author Florent Benoit
55  * @author Philippe Coq
56  * @author Helene Joanin
57  */

58
59 public class DDTest {
60
61     /**
62      * WebApp tests
63      */

64     private static WebDeploymentTest webDeploymentTest = null;
65     private static JonasWebDeploymentTest jonasWebDeploymentTest = null;
66
67     /**
68      * Connector tests
69      */

70     private static RarDeploymentTest rarDeploymentTest = null;
71     private static JonasRarDeploymentTest jonasRarDeploymentTest = null;
72     /**
73      * Application Client tests
74      */

75     private static ClientDeploymentTest clientDeploymentTest = null;
76     private static JonasClientDeploymentTest jonasClientDeploymentTest = null;
77     /**
78      * EJB tests
79      */

80     private static EJBDeploymentTest ejbDeploymentTest = null;
81     private static JonasEJBDeploymentTest jonasEjbDeploymentTest = null;
82     /**
83      * Application tests
84      */

85     private static EarDeploymentTest earDeploymentTest = null;
86
87     /**
88      * Web Services tests
89      */

90     private static WsDeploymentTest wsDeploymentTest = null;
91     private static JonasWsDeploymentTest jonasWsDeploymentTest = null;
92
93     private DDTest() {
94         webDeploymentTest = new WebDeploymentTest();
95         jonasWebDeploymentTest = new JonasWebDeploymentTest();
96         rarDeploymentTest = new RarDeploymentTest();
97         jonasRarDeploymentTest = new JonasRarDeploymentTest();
98         clientDeploymentTest = new ClientDeploymentTest();
99         jonasClientDeploymentTest = new JonasClientDeploymentTest();
100         ejbDeploymentTest = new EJBDeploymentTest();
101         jonasEjbDeploymentTest = new JonasEJBDeploymentTest();
102         earDeploymentTest = new EarDeploymentTest();
103         wsDeploymentTest = new WsDeploymentTest();
104         jonasWsDeploymentTest = new JonasWsDeploymentTest();
105
106     }
107
108     public static void main(String[] args) throws Exception {
109         DDTest ddTest = new DDTest();
110         try {
111             ddTest.interactUser();
112         }catch (Exception e) {
113             System.out.println("Error : '" + e.getMessage() + "'");
114             e.printStackTrace();
115             System.exit(2);
116         }
117     }
118
119     private void choice() {
120         System.out.println("d for Displaying an XML element");
121         System.out.println("t for Testing an XML element");
122         System.out.println("s for Stressing an XML element");
123         System.out.println("p for Parsing check");
124         System.out.println("f for Parsing from an XML file");
125         System.out.println("q for Quit");
126     }
127
128     private void help() {
129         System.out.println("+--------------------------------+");
130         System.out.println("| |");
131         System.out.println("+--------------------------------+");
132
133     }
134
135     private void interactUser() throws Exception {
136         // User interface
137
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
138         while (true) {
139             choice();
140             System.out.print("> ");
141             String readLine = in.readLine();
142             if (readLine.length() == 0) {
143                 continue;
144             }
145             char c = readLine.charAt(0);
146
147             switch (c) {
148             case 'd':
149                 System.out.println("1 - WebApp element");
150                 System.out.println("2 - JonasWebApp element");
151                 System.out.println("3 - Connector element");
152                 System.out.println("4 - JonasConnector element");
153                 System.out.println("5 - ClientApp element");
154                 System.out.println("6 - JonasClient element");
155                 System.out.println("7 - Application element");
156                 System.out.println("8 - EjbJar element");
157                 System.out.println("9 - JonasEjbJar element");
158                 System.out.println("a - WebServices element");
159                 System.out.println("b - JonasWebServices element");
160                 System.out.println("c - JavaWsdlMapping element");
161
162                 System.out.println("0 - Customize element");
163
164                 System.out.print("> ");
165                 readLine = in.readLine();
166                 if (readLine.length() == 0) {
167                     continue;
168                 }
169                 c = readLine.charAt(0);
170                 Element element = null;
171                 switch (c) {
172                 case '1' :
173                     element = new WebApp();
174                     break;
175                 case '2' :
176                     element = new JonasWebApp();
177                     break;
178                 case '3' :
179                     element = new Connector();
180                     break;
181                 case '4' :
182                     element = new JonasConnector();
183                     break;
184                 case '5' :
185                     element = new ApplicationClient();
186                     break;
187                 case '6' :
188                     element = new JonasClient();
189                     break;
190                 case '7' :
191                     element = new Application();
192                     break;
193                 case '8' :
194                     element = new EjbJar();
195                     break;
196                 case '9' :
197                     element = new JonasEjbJar();
198                     break;
199                 case 'a' :
200                     element = new Webservices();
201                     break;
202                 case 'b' :
203                     element = new JonasWebservices();
204                     break;
205                 case 'c' :
206                     element = new JavaWsdlMapping();
207                     break;
208
209                 case '0' :
210                     System.out.print("Enter the name of the Element > ");
211                     String className = in.readLine();
212                     try {
213                         Class cl = Class.forName(className);
214                         element = (Element) cl.newInstance();
215                     } catch (Exception e) {
216                         System.out.println("className is not a good element " + e);
217                         continue;
218                     }
219                     break;
220  
221                 default :
222                     continue;
223                 }
224
225                 wsDeploymentTest.fill(element, false);
226                 System.out.println("");
227                 System.out.println(element);
228                 break;
229
230             case 't':
231                 System.out.println("1 - WebApp element");
232                 System.out.println("2 - JonasWebApp element");
233                 System.out.println("3 - Connector element");
234                 System.out.println("4 - JonasConnector element");
235                 System.out.println("5 - ClientApp element");
236                 System.out.println("6 - JonasClient element");
237                 System.out.println("7 - Application element");
238                 System.out.println("8 - EjbJar element");
239                 System.out.println("9 - JonasEjbJar element");
240                 System.out.println("a - WebServices element");
241                 System.out.println("b - JonasWebServices element");
242                 System.out.println("c - JaxrcpMapping element");
243
244                 System.out.print("> ");
245                 readLine = in.readLine();
246                 if (readLine.length() == 0) {
247                     continue;
248                 }
249                 c = readLine.charAt(0);
250                 AbsDeploymentTest testElememt = null;
251                 switch (c) {
252                 case '1' :
253                     webDeploymentTest.startTest(true);
254                     break;
255                 case '2' :
256                     jonasWebDeploymentTest.startTest(true);
257                     break;
258                 case '3' :
259                     rarDeploymentTest.startTest(true);
260                     break;
261                 case '4' :
262                     jonasRarDeploymentTest.startTest(true);
263                     break;
264                 case '5' :
265                     clientDeploymentTest.startTest(true);
266                     break;
267                 case '6' :
268                     jonasClientDeploymentTest.startTest(true);
269                     break;
270                 case '7' :
271                     earDeploymentTest.startTest(true);
272                     break;
273                 case '8' :
274                     ejbDeploymentTest.startTest(true);
275                     break;
276                 case '9' :
277                     jonasEjbDeploymentTest.startTest(true);
278                     break;
279                 case 'a' :
280                     wsDeploymentTest.startTest(true);
281                     break;
282                 case 'b' :
283                     wsDeploymentTest.startTest(true);
284                     break;
285                 case 'c' :
286                     wsDeploymentTest.startJaxrpcMappingTest(true);
287                     break;
288
289                 default :
290                     continue;
291                 }
292                 break;
293
294             case 's':
295                 System.out.println("1 - WebApp element");
296                 System.out.println("2 - JonasWebApp element");
297                 System.out.println("3 - Connector element");
298                 System.out.println("4 - JonasConnector element");
299                 System.out.println("5 - ClientApp element");
300                 System.out.println("6 - JonasClient element");
301                 System.out.println("7 - Application element");
302                 System.out.println("8 - EjbJar element");
303                 System.out.println("9 - JonasEjbJar element");
304                 System.out.println("a - WebServices element");
305                 System.out.println("b - JonasWebServices element");
306                 System.out.println("c - JaxrcpMapping element");
307
308                 System.out.print("> ");
309                 readLine = in.readLine();
310                 if (readLine.length() == 0) {
311                     continue;
312                 }
313                 c = readLine.charAt(0);
314
315                 switch (c) {
316                 case '1' :
317                     webDeploymentTest.stress();
318                     break;
319                 case '2' :
320                     jonasWebDeploymentTest.stress();
321                     break;
322                 case '3' :
323                     rarDeploymentTest.stress();
324                     break;
325                 case '4' :
326                     jonasRarDeploymentTest.stress();
327                     break;
328                 case '5' :
329                     clientDeploymentTest.stress();
330                     break;
331                 case '6' :
332                     jonasClientDeploymentTest.stress();
333                     break;
334                 case '7' :
335                     earDeploymentTest.stress();
336                     break;
337                 case '8' :
338                     ejbDeploymentTest.stress();
339                     break;
340                 case '9' :
341                     jonasEjbDeploymentTest.stress();
342                     break;
343                 case 'a' :
344                     wsDeploymentTest.stress();
345                     break;
346                 case 'b' :
347                     jonasWsDeploymentTest.stress();
348                     break;
349                 case 'c' :
350                     wsDeploymentTest.startJaxrpcMappingTest(true);
351                     break;
352
353                 default :
354                     continue;
355                 }
356                 break;
357
358             case 'p':
359                 System.out.println("1 - WebApp element");
360                 System.out.println("2 - JonasWebApp element");
361                 System.out.println("3 - Connector element");
362                 System.out.println("4 - JonasConnector element");
363                 System.out.println("5 - ClientApp element");
364                 System.out.println("6 - JonasClient element");
365                 System.out.println("7 - Application element");
366                 System.out.println("8 - EjbJar element");
367                 System.out.println("9 - JonasEjbJar element");
368                 System.out.println("a - WebServices element");
369                 System.out.println("b - JonasWebServices element");
370                 System.out.println("c - JaxrcpMapping element");
371
372                 System.out.print("> ");
373                 readLine = in.readLine();
374                 if (readLine.length() == 0) {
375                     continue;
376                 }
377                 c = readLine.charAt(0);
378                 switch (c) {
379                 case '1' :
380                     webDeploymentTest.parseElement();
381                     break;
382                 case '2' :
383                     jonasWebDeploymentTest.parseElement();
384                     break;
385                 case '3' :
386                     rarDeploymentTest.parseElement();
387                     break;
388                 case '4' :
389                     jonasRarDeploymentTest.parseElement();
390                     break;
391                 case '5' :
392                     clientDeploymentTest.parseElement();
393                     break;
394                 case '6' :
395                     jonasClientDeploymentTest.parseElement();
396                     break;
397                 case '7' :
398                     earDeploymentTest.parseElement();
399                     break;
400                 case '8' :
401                     ejbDeploymentTest.parseElement();
402                     break;
403                 case '9' :
404                     jonasEjbDeploymentTest.parseElement();
405                     break;
406
407                 }
408
409                 break;
410             case 'f':
411                 System.out.println("1 - web.xml file");
412                 System.out.println("2 - jonas-web.xml file");
413                 System.out.println("3 - ra.xml file");
414                 System.out.println("4 - jonas-ra.xml file");
415                 System.out.println("5 - client.xml file");
416                 System.out.println("6 - jonas-client.xml file");
417                 System.out.println("7 - application.xml file");
418                 System.out.println("8 - ejb-jar.xml file");
419                 System.out.println("9 - jonas-ejbjar.xml file");
420
421                 System.out.print("> ");
422                 readLine = in.readLine();
423                 if (readLine.length() == 0) {
424                     continue;
425                 }
426                 c = readLine.charAt(0);
427                 System.out.print("Enter the name of the xml file > ");
428                 String fileName = in.readLine();
429  
430                 switch (c) {
431                 case '1' :
432                     webDeploymentTest.parseXmlfromFile(fileName);
433                     break;
434                 case '2' :
435                     jonasWebDeploymentTest.parseXmlfromFile(fileName);
436                     break;
437                 case '3' :
438                     rarDeploymentTest.parseXmlfromFile(fileName);
439                     break;
440                 case '4' :
441                     jonasRarDeploymentTest.parseXmlfromFile(fileName);
442                     break;
443                 case '5' :
444                     clientDeploymentTest.parseXmlfromFile(fileName);
445                     break;
446                 case '6' :
447                     jonasClientDeploymentTest.parseXmlfromFile(fileName);
448                     break;
449                 case '7' :
450                     earDeploymentTest.parseXmlfromFile(fileName);
451                     break;
452                 case '8' :
453                     ejbDeploymentTest.parseXmlfromFile(fileName);
454                     break;
455                 case '9' :
456                     jonasEjbDeploymentTest.parseXmlfromFile(fileName);
457                     break;
458                 case 'a' :
459                     wsDeploymentTest.parseXmlfromFile(fileName);
460                     break;
461                 case 'b' :
462                     jonasWsDeploymentTest.parseXmlfromFile(fileName);
463                     break;
464                 case 'c' :
465                     wsDeploymentTest.parseJaxrcpMappingElement();
466                     break;
467
468                 }
469                 break;
470
471             case 'q':
472                 System.exit(0);
473                 break;
474
475             default :
476                 break;
477             }
478         }
479     }
480
481
482 }
483
Popular Tags