KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jonas > jonasadmin > test > template > F_JonasAdminTemplate


1 /**
2  * JOnAS: Java(TM) Open Application Server
3  * Copyright (C) 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_JonasAdminTemplate.java,v 1.2 2005/07/12 13:20:02 kemlerp Exp $
23  * --------------------------------------------------------------------------
24  */

25
26 package org.objectweb.jonas.jonasadmin.test.template;
27
28 import junit.framework.TestSuite;
29
30 import org.objectweb.jonas.jonasadmin.test.util.JonasAdminAuth;
31 import org.objectweb.jonas.jonasadmin.test.util.JonasAdminTestCase;
32
33 import com.meterware.httpunit.HttpUnitOptions;
34 import com.meterware.httpunit.WebConversation;
35 import com.meterware.httpunit.WebLink;
36 import com.meterware.httpunit.WebResponse;
37 import com.meterware.httpunit.WebTable;
38
39 /**
40  * Class for testing ...
41  * @author Paul Kemler
42  *
43  */

44 public class F_JonasAdminTemplate extends JonasAdminTestCase {
45
46     /**
47      * Constructor with a specified name
48      * @param s name
49      */

50     public F_JonasAdminTemplate(String JavaDoc s) {
51         super(s, URL_JONASADMIN);
52     }
53
54     /**
55      * Constructor with a specified name and a WebConversation reference
56      * @param wc the WebConversation of the suite test
57      * @param s name
58      */

59     public F_JonasAdminTemplate(WebConversation wc, String JavaDoc s) {
60         super(wc, s, URL_JONASADMIN);
61     }
62
63     /**
64      * Main method
65      * @param args the arguments
66      */

67     public static void main(String JavaDoc[] args) {
68
69         String JavaDoc testtorun = null;
70         // Get args
71
for (int argn = 0; argn < args.length; argn++) {
72             String JavaDoc sArg = args[argn];
73             if (sArg.equals("-n")) {
74                 testtorun = args[++argn];
75             }
76         }
77         if (testtorun == null) {
78             junit.textui.TestRunner.run(suite());
79         } else {
80             /*
81              * TODO : replace F_JonasAdminTemplate
82              */

83             junit.textui.TestRunner.run(new F_JonasAdminTemplate(testtorun));
84         }
85     }
86
87     /**
88      * Get a new TestSuite for this class
89      * @return a new TestSuite for this class
90      */

91     public static TestSuite suite() {
92         /*
93          * TODO : replace F_JonasAdminTemplate
94          */

95         return new TestSuite(F_JonasAdminTemplate.class);
96     }
97
98     /**
99      * Get a new TestSuite for this class
100      * @param wc the WebConversation
101      * @return a new TestSuite for this class with the WebConversation instance
102      */

103     public static TestSuite suite(WebConversation wc) {
104         TestSuite suite = new TestSuite();
105         /*
106          * TODO : replace F_JonasAdminTemplate and "testTemplate"
107          */

108         suite.addTest(new F_JonasAdminTemplate(wc, "testTemplate"));
109         return suite;
110     }
111
112     /**
113      * Setup need for these tests
114      * jonasAdmin is required
115      * @throws Exception if it fails
116      */

117     protected void setUp() throws Exception JavaDoc {
118         super.setUp();
119
120         if (wc.getCurrentPage().getURL() == null) {
121             useWar("jonasAdmin");
122             // login to jonas admin
123
try {
124                 JonasAdminAuth.doValidAuth(wc, url);
125             } catch (Exception JavaDoc e) {
126                 fail("authentification failed : " + e);
127             }
128         } else {
129             // if there was an error, the connection must be restablished
130
try {
131                 wc.getFrameContents(FRAME_TREE);
132             } catch (Exception JavaDoc e) {
133                 wc.getResponse(urlLogOut);
134                 // login to jonas admin
135
try {
136                     JonasAdminAuth.doValidAuth(wc, url);
137                 } catch (Exception JavaDoc auth) {
138                     fail("authentification failed : " + auth);
139                 }
140             }
141         }
142     }
143
144     /**
145      * Test ...
146      * @throws Exception if error occurs
147      *
148      */

149     public void testTemplate() throws Exception JavaDoc {
150
151         WebResponse wr;
152         WebLink link;
153         WebTable table;
154         /*
155          * To get some utils for WebTable
156          */

157         // JonasAdminUtils utils = new JonasAdminUtils();
158

159         // Disable errors of javascript
160
HttpUnitOptions.setExceptionsThrownOnScriptError(false);
161         // Disable exception thrown on error status
162
HttpUnitOptions.setExceptionsThrownOnErrorStatus(false);
163
164         /*
165          * TODO : ADD YOUR CODE HERE
166          */

167
168     }
169
170     /**
171      * Tear Down
172      * cleanUp action
173      */

174     public void tearDown() throws Exception JavaDoc {
175
176     }
177
178 }
179
Popular Tags