001: /*
002: * JOnAS: Java(TM) Open Application Server
003: * Copyright (C) 1999 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:
023: package org.objectweb.jonas.examples.clients.sampleCluster2;
024:
025: import junit.framework.TestSuite;
026:
027: import org.objectweb.jonas.examples.util.JExampleTestCase;
028:
029: import com.meterware.httpunit.WebResponse;
030:
031: /**
032: * Define a class to test the sampleCluster2 example
033: * @author Georges Goebel
034: */
035: public class F_SampleCluster2 extends JExampleTestCase {
036:
037: /**
038: * URL of the earsample page
039: */
040: private static final String URL_EARSAMPLE = "/sampleCluster2";
041:
042: /**
043: * Constructor with a specified name
044: * @param s name
045: */
046: public F_SampleCluster2(String s) {
047: super (s, URL_EARSAMPLE);
048: }
049:
050: /**
051: * Main method
052: * @param args the arguments
053: */
054: public static void main(String[] args) {
055:
056: String testtorun = null;
057: // Get args
058: for (int argn = 0; argn < args.length; argn++) {
059: String sArg = args[argn];
060: if (sArg.equals("-n")) {
061: testtorun = args[++argn];
062: }
063: }
064:
065: if (testtorun == null) {
066: junit.textui.TestRunner.run(suite());
067: } else {
068: junit.textui.TestRunner
069: .run(new F_SampleCluster2(testtorun));
070: }
071: }
072:
073: /**
074: * Get a new TestSuite for this class
075: * @return a new TestSuite for this class
076: */
077: public static TestSuite suite() {
078: return new TestSuite(F_SampleCluster2.class);
079: }
080:
081: /**
082: * Setup need for these tests sampleCluster2 is required
083: * @throws Exception if it fails
084: */
085: protected void setUp() throws Exception {
086: super .setUp();
087: useEar("sampleCluster2");
088: }
089:
090: /**
091: * Check if the First Page is OK. Analyze response
092: * @throws Exception if an error occurs
093: */
094: public void testIsFirstPageOk() throws Exception {
095: WebResponse wr = wc.getResponse(url);
096: String txt = wr.getText();
097:
098: if (txt.indexOf("<strong>Sample is OK.</strong>") == -1) {
099: fail("The example was not ok : " + txt);
100: }
101: }
102:
103: /**
104: * Check if the sessionServlet is OK. Analyze response
105: * @throws Exception if an error occurs
106: */
107: public void testIsSessionOk() throws Exception {
108: WebResponse wr = wc.getResponse(url + "/servlet/session");
109: String txt = wr.getText();
110:
111: if (txt.indexOf("<strong>Sample is OK.</strong>") == -1) {
112: fail("The example was not ok : " + txt);
113: }
114: }
115:
116: /**
117: * Check if the checkServlet is OK. Analyze response
118: * @throws Exception if an error occurs
119: */
120: public void testIsCheckOk() throws Exception {
121: WebResponse wr = wc.getResponse(url + "/servlet/check");
122: String txt = wr.getText();
123:
124: if (txt.indexOf("<strong>Sample is OK.</strong>") == -1) {
125: fail("The example was not ok : " + txt);
126: }
127: }
128:
129: /**
130: * Check if the releaseServlet is OK. Analyze response
131: * @throws Exception if an error occurs
132: */
133: public void testIsReleaseOk() throws Exception {
134: WebResponse wr = wc.getResponse(url + "/servlet/release");
135: String txt = wr.getText();
136:
137: if (txt.indexOf("<strong>Sample is OK.</strong>") == -1) {
138: fail("The example was not ok : " + txt);
139: }
140: }
141:
142: }
|