KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jonas > examples > clients > sampleCluster2 > F_SampleCluster2


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  */

22
23 package org.objectweb.jonas.examples.clients.sampleCluster2;
24
25 import junit.framework.TestSuite;
26
27 import org.objectweb.jonas.examples.util.JExampleTestCase;
28
29 import com.meterware.httpunit.WebResponse;
30
31 /**
32  * Define a class to test the sampleCluster2 example
33  * @author Georges Goebel
34  */

35 public class F_SampleCluster2 extends JExampleTestCase {
36
37     /**
38      * URL of the earsample page
39      */

40     private static final String JavaDoc URL_EARSAMPLE = "/sampleCluster2";
41
42     /**
43      * Constructor with a specified name
44      * @param s name
45      */

46     public F_SampleCluster2(String JavaDoc s) {
47         super(s, URL_EARSAMPLE);
48     }
49
50     /**
51      * Main method
52      * @param args the arguments
53      */

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

76     public static TestSuite suite() {
77         return new TestSuite(F_SampleCluster2.class);
78     }
79
80     /**
81      * Setup need for these tests sampleCluster2 is required
82      * @throws Exception if it fails
83      */

84     protected void setUp() throws Exception JavaDoc {
85         super.setUp();
86         useEar("sampleCluster2");
87     }
88
89     /**
90      * Check if the First Page is OK. Analyze response
91      * @throws Exception if an error occurs
92      */

93     public void testIsFirstPageOk() throws Exception JavaDoc {
94         WebResponse wr = wc.getResponse(url);
95         String JavaDoc txt = wr.getText();
96
97         if (txt.indexOf("<strong>Sample is OK.</strong>") == -1) {
98             fail("The example was not ok : " + txt);
99         }
100     }
101
102     /**
103      * Check if the sessionServlet is OK. Analyze response
104      * @throws Exception if an error occurs
105      */

106     public void testIsSessionOk() throws Exception JavaDoc {
107         WebResponse wr = wc.getResponse(url + "/servlet/session");
108         String JavaDoc txt = wr.getText();
109
110         if (txt.indexOf("<strong>Sample is OK.</strong>") == -1) {
111             fail("The example was not ok : " + txt);
112         }
113     }
114
115     /**
116      * Check if the checkServlet is OK. Analyze response
117      * @throws Exception if an error occurs
118      */

119     public void testIsCheckOk() throws Exception JavaDoc {
120         WebResponse wr = wc.getResponse(url + "/servlet/check");
121         String JavaDoc txt = wr.getText();
122
123         if (txt.indexOf("<strong>Sample is OK.</strong>") == -1) {
124             fail("The example was not ok : " + txt);
125         }
126     }
127
128     /**
129      * Check if the releaseServlet is OK. Analyze response
130      * @throws Exception if an error occurs
131      */

132     public void testIsReleaseOk() throws Exception JavaDoc {
133         WebResponse wr = wc.getResponse(url + "/servlet/release");
134         String JavaDoc txt = wr.getText();
135
136         if (txt.indexOf("<strong>Sample is OK.</strong>") == -1) {
137             fail("The example was not ok : " + txt);
138         }
139     }
140
141 }
142
Popular Tags