001: /**
002: * JOnAS: Java(TM) Open Application Server
003: * Copyright (C) 1999-2005 Bull S.A.
004: * Contact: jonas-team@objectweb.org
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation; either
009: * version 2.1 of the License, or 1any later version.
010: *
011: * This library is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Lesser General Public License for more details.
015: *
016: * You should have received a copy of the GNU Lesser General Public
017: * License along with this library; if not, write to the Free Software
018: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
019: * USA
020: *
021: * --------------------------------------------------------------------------
022: * $Id: F_WsAccessTest.java 6392 2005-03-09 10:26:42Z sauthieg $
023: * --------------------------------------------------------------------------
024: */package org.objectweb.jonas.examples.clients.webservices;
025:
026: import junit.framework.TestSuite;
027:
028: import com.meterware.httpunit.WebResponse;
029:
030: /**
031: * Define a class to test the webServices examples wsAccessTest
032: * Test WebServices deployment OK
033: * @author Guillaume Sauthier
034: */
035: public class F_WsAccessTest extends A_WebServices {
036:
037: /**
038: * URL of the wsAccessTest page
039: */
040: private static final String URL_WSACCESSTEST = "/wsaccess/";
041:
042: /**
043: * Main method
044: * @param args the arguments
045: */
046: public static void main(String[] args) {
047:
048: String testtorun = null;
049: // Get args
050: for (int argn = 0; argn < args.length; argn++) {
051: String sArg = args[argn];
052: if (sArg.equals("-n")) {
053: testtorun = args[++argn];
054: }
055: }
056:
057: if (testtorun == null) {
058: junit.textui.TestRunner.run(suite());
059: } else {
060: junit.textui.TestRunner.run(new F_WsAccessTest(testtorun));
061: }
062: }
063:
064: /**
065: * Get a new TestSuite for this class
066: * @return a new TestSuite for this class
067: */
068: public static TestSuite suite() {
069: return new TestSuite(F_WsAccessTest.class);
070: }
071:
072: /**
073: * Setup need for these tests
074: * earsample is required
075: * @throws Exception if it fails
076: */
077: protected void setUp() throws Exception {
078: super .setUp();
079: useWar("wsaccess");
080: }
081:
082: /**
083: * Constructor with a specified name
084: * @param s name
085: */
086: public F_WsAccessTest(String s) {
087: super (s, URL_WSACCESSTEST);
088: }
089:
090: /**
091: * Check if home page is accessible
092: * @throws Exception if an error occurs
093: */
094: public void testDeploymentCompleted() throws Exception {
095: // 2 links + 3 logo links on homepage
096: checkDeploymentCompleted(2 + 3);
097: }
098:
099: /**
100: * Check if JSP can access external google WebService
101: * @throws Exception if an error occurs
102: */
103: public void testWebServiceJspAccess() throws Exception {
104:
105: WebResponse wr = executeGoogleWebService("googleByJSP.jsp",
106: "ObjectWeb JOnAS");
107: assertTrue("a list is returned", wr.getLinks().length > 0);
108: }
109:
110: /**
111: * Check if JSP can access external google WebService
112: * @throws Exception if an error occurs
113: */
114: public void testWebServiceServletAccess() throws Exception {
115:
116: WebResponse wr = executeGoogleWebService(
117: "googleByServlet.html", "ObjectWeb JOnAS");
118: assertTrue("a list is returned", wr.getLinks().length > 0);
119:
120: }
121: }
|