KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jonas > examples > clients > webservices > F_WsAccessTest


1 /**
2  * JOnAS: Java(TM) Open Application Server
3  * Copyright (C) 1999-2005 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  * --------------------------------------------------------------------------
22  * $Id: F_WsAccessTest.java,v 1.5 2005/03/09 10:26:42 sauthieg Exp $
23  * --------------------------------------------------------------------------
24  */

25
26 package org.objectweb.jonas.examples.clients.webservices;
27
28 import junit.framework.TestSuite;
29
30 import com.meterware.httpunit.WebResponse;
31
32
33 /**
34  * Define a class to test the webServices examples wsAccessTest
35  * Test WebServices deployment OK
36  * @author Guillaume Sauthier
37  */

38 public class F_WsAccessTest extends A_WebServices {
39
40     /**
41      * URL of the wsAccessTest page
42      */

43     private static final String JavaDoc URL_WSACCESSTEST = "/wsaccess/";
44
45     /**
46      * Main method
47      * @param args the arguments
48      */

49     public static void main(String JavaDoc[] args) {
50
51         String JavaDoc testtorun = null;
52         // Get args
53
for (int argn = 0; argn < args.length; argn++) {
54             String JavaDoc sArg = args[argn];
55             if (sArg.equals("-n")) {
56                 testtorun = args[++argn];
57             }
58         }
59
60         if (testtorun == null) {
61             junit.textui.TestRunner.run(suite());
62         } else {
63             junit.textui.TestRunner.run(new F_WsAccessTest(testtorun));
64         }
65     }
66
67     /**
68      * Get a new TestSuite for this class
69      * @return a new TestSuite for this class
70      */

71     public static TestSuite suite() {
72         return new TestSuite(F_WsAccessTest.class);
73     }
74
75     /**
76      * Setup need for these tests
77      * earsample is required
78      * @throws Exception if it fails
79      */

80     protected void setUp() throws Exception JavaDoc {
81         super.setUp();
82         useWar("wsaccess");
83     }
84
85     /**
86      * Constructor with a specified name
87      * @param s name
88      */

89     public F_WsAccessTest(String JavaDoc s) {
90         super(s, URL_WSACCESSTEST);
91     }
92
93     /**
94      * Check if home page is accessible
95      * @throws Exception if an error occurs
96      */

97     public void testDeploymentCompleted() throws Exception JavaDoc {
98         // 2 links + 3 logo links on homepage
99
checkDeploymentCompleted(2+3);
100     }
101
102     /**
103      * Check if JSP can access external google WebService
104      * @throws Exception if an error occurs
105      */

106     public void testWebServiceJspAccess() throws Exception JavaDoc {
107
108         WebResponse wr = executeGoogleWebService("googleByJSP.jsp",
109                                                  "ObjectWeb JOnAS");
110         assertTrue("a list is returned", wr.getLinks().length > 0);
111     }
112
113     /**
114      * Check if JSP can access external google WebService
115      * @throws Exception if an error occurs
116      */

117     public void testWebServiceServletAccess() throws Exception JavaDoc {
118
119         WebResponse wr = executeGoogleWebService("googleByServlet.html",
120                                                  "ObjectWeb JOnAS");
121         assertTrue("a list is returned", wr.getLinks().length > 0);
122
123     }
124 }
125
Popular Tags