01: /*
02: * JOnAS: Java(TM) Open Application Server
03: * Copyright (C) 1999 Bull S.A.
04: * Contact: jonas-team@objectweb.org
05: *
06: * This library is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU Lesser General Public
08: * License as published by the Free Software Foundation; either
09: * 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: A_WebServices.java 7129 2005-07-27 14:42:00Z mwringe $
24: * --------------------------------------------------------------------------
25: */
26:
27: package org.objectweb.jonas.examples.clients.webservices;
28:
29: import org.objectweb.jonas.examples.util.JExampleTestCase;
30:
31: import com.meterware.httpunit.WebForm;
32: import com.meterware.httpunit.WebLink;
33: import com.meterware.httpunit.WebResponse;
34:
35: /**
36: * Define an abstract class to test the webServices examples
37: * @author Guillaume Sauthier
38: */
39: public abstract class A_WebServices extends JExampleTestCase {
40:
41: public A_WebServices(String s, String urlPrefix) {
42: super (s, urlPrefix);
43: }
44:
45: public A_WebServices(String s, String urlPrefix, String username,
46: String password) {
47: super (s, urlPrefix, username, password);
48: }
49:
50: /**
51: * Check if home page is accessible
52: * @throws Exception if an error occurs
53: */
54: public void checkDeploymentCompleted(int nbHomePageLinks)
55: throws Exception {
56: WebResponse wr = wc.getResponse(url + "index.html");
57: WebLink[] links = wr.getLinks();
58: assertEquals("deployment OK", nbHomePageLinks, links.length);
59: }
60:
61: public WebResponse executeGoogleWebService(String page, String query)
62: throws Exception {
63:
64: WebResponse wr = wc.getResponse(url + page);
65:
66: WebForm form = wr.getForms()[0];
67: // set Search Query
68: form.setParameter("search", query);
69: return form.submit();
70: }
71: }
|