KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jonas > jonasadmin > test > joram > F_JonasAdminJoramProperties


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_JonasAdminJoramProperties.java,v 1.7 2005/07/25 12:29:58 kemlerp Exp $
23  * --------------------------------------------------------------------------
24  */

25
26 package org.objectweb.jonas.jonasadmin.test.joram;
27
28 import junit.framework.TestSuite;
29
30 import org.objectweb.jonas.jonasadmin.test.util.JProperties;
31 import org.objectweb.jonas.jonasadmin.test.util.JonasAdminAuth;
32 import org.objectweb.jonas.jonasadmin.test.util.JonasAdminFiles;
33 import org.objectweb.jonas.jonasadmin.test.util.JonasAdminTestCase;
34 import org.objectweb.jonas.jonasadmin.test.util.JonasAdminUtils;
35 import org.xml.sax.SAXException JavaDoc;
36
37 import com.meterware.httpunit.HttpUnitOptions;
38 import com.meterware.httpunit.WebConversation;
39 import com.meterware.httpunit.WebLink;
40 import com.meterware.httpunit.WebResponse;
41 import com.meterware.httpunit.WebTable;
42
43
44 /**
45  * Define a class to test the JOnAS Admin console
46  * Test properties of joram platform
47  * @author kemlerp
48  *
49  */

50 public class F_JonasAdminJoramProperties extends JonasAdminTestCase {
51
52     /**
53      * URL of the Joram Platform
54      */

55     private static final String JavaDoc URL_JONASADMIN_JORAM = "EditJoramPlatform.do";
56
57     /**
58      * Name of the file of jonasAdmin test properties
59      */

60     private static final String JavaDoc JONASADMINTEST_PROPERTY_NAME = "jonasAdminTests";
61
62     /**
63      * Name of the property joram.version
64      */

65     private static final String JavaDoc JORAM_VERSION = "joram.version";
66
67     /**
68      * Name of the property joram.serverId
69      */

70     private static final String JavaDoc JORAM_SERVER_ID = "joram.serverId";
71
72     /**
73      * Name of the property joram.serverName
74      */

75     private static final String JavaDoc JORAM_SERVER_NAME = "joram.serverName";
76
77     /**
78      * Name of the property joram.collocated
79      */

80     private static final String JavaDoc JORAM_COLLOCATED = "joram.collocated";
81
82     /**
83      * Name of the property joram.persistent
84      */

85     private static final String JavaDoc JORAM_PERSISTENT = "joram.persistent";
86
87     /**
88      * Name of the property joram.connectingTimer
89      */

90     private static final String JavaDoc JORAM_CONNECTING_TIMER = "joram.connectingTimer";
91
92     /**
93      * Name of the property joram.connectionPendingTimer
94      */

95     private static final String JavaDoc JORAM_CONNECTION_PENDING_TIMER = "joram.connectionPendingTimer";
96
97     /**
98      * Name of the property joram.transactedSessionMaximumIdleness
99      */

100     private static final String JavaDoc JORAM_TRANSACTED_SESSION_MAXIMUM_IDLENESS = "joram.transactedSessionMaximumIdleness";
101
102     /**
103      * Name of the property joram.timeoutToAbortRequest
104      */

105     private static final String JavaDoc JORAM_TIMEOUT_TO_ABORT_REQUEST = "joram.timeoutToAbortRequest";
106
107     /**
108      * Name of the property joram.defaultThresholdForDMQ
109      */

110     private static final String JavaDoc JORAM_DEFAULT_THRESHOLD = "joram.defaultThresholdForDMQ";
111
112
113     /**
114      * Constructor with a specified name
115      * @param s name
116      */

117     public F_JonasAdminJoramProperties(String JavaDoc s) {
118         super(s, URL_JONASADMIN);
119     }
120
121     /**
122      * Constructor with a specified name
123      * @param wc the WebConversation of the suite test
124      * @param s name
125      */

126     public F_JonasAdminJoramProperties(WebConversation wc, String JavaDoc s) {
127         super(wc, s, URL_JONASADMIN);
128     }
129
130     /**
131      * Main method
132      * @param args the arguments
133      */

134     public static void main(String JavaDoc[] args) {
135
136         String JavaDoc testtorun = null;
137         // Get args
138
for (int argn = 0; argn < args.length; argn++) {
139             String JavaDoc sArg = args[argn];
140             if (sArg.equals("-n")) {
141                 testtorun = args[++argn];
142             }
143         }
144         if (testtorun == null) {
145             junit.textui.TestRunner.run(suite());
146         } else {
147             junit.textui.TestRunner.run(new F_JonasAdminJoramProperties(testtorun));
148         }
149     }
150
151     /**
152      * Get a new TestSuite for this class
153      * @return a new TestSuite for this class
154      */

155     public static TestSuite suite() {
156         return new TestSuite(F_JonasAdminJoramProperties.class);
157     }
158
159     /**
160      * Get a new TestSuite for this class
161      * @param wc the WebConversation
162      * @return a new TestSuite for this class with the WebConversation instance
163      */

164     public static TestSuite suite(WebConversation wc) {
165         TestSuite suite = new TestSuite();
166         suite.addTest(new F_JonasAdminJoramProperties(wc, "testJoramProperties"));
167         return suite;
168     }
169
170     /**
171      * Setup need for these tests
172      * jonasAdmin is required
173      * @throws Exception if it fails
174      */

175     protected void setUp() throws Exception JavaDoc {
176         super.setUp();
177
178         if (wc.getCurrentPage().getURL() == null) {
179             useWar("jonasAdmin");
180             // login to jonas admin
181
try {
182                 JonasAdminAuth.doValidAuth(wc, url);
183             } catch (Exception JavaDoc e) {
184                 fail("authentification failed : " + e);
185             }
186         } else {
187             // if there was an error, the connection must be restablished
188
try {
189                 wc.getFrameContents(FRAME_TREE);
190             } catch (Exception JavaDoc e) {
191                 wc.getResponse(urlLogOut);
192                 // login to jonas admin
193
try {
194                     JonasAdminAuth.doValidAuth(wc, url);
195                 } catch (Exception JavaDoc auth) {
196                     fail("authentification failed : " + auth);
197                 }
198             }
199         }
200     }
201
202     /**
203      * Test properties of joram
204      * @throws Exception if error occurs
205      */

206     public void testJoramProperties() throws Exception JavaDoc {
207
208         JProperties jProp = new JProperties();
209         JonasAdminUtils utils = new JonasAdminUtils();
210
211             // Joram platform is in jonas
212
if (jProp.isJoram()) {
213
214             // Disable errors of javascript
215
HttpUnitOptions.setExceptionsThrownOnScriptError(false);
216             // Disable exception thrown on error status
217
HttpUnitOptions.setExceptionsThrownOnErrorStatus(false);
218
219             // READ joram properties from jonasAdminTests.properties
220

221             String JavaDoc version = configFile.getProperty(JORAM_VERSION);
222             String JavaDoc serverId = configFile.getProperty(JORAM_SERVER_ID);
223             String JavaDoc serverName = configFile.getProperty(JORAM_SERVER_NAME);
224             String JavaDoc collocatedServer = configFile.getProperty(JORAM_COLLOCATED);
225             String JavaDoc persistentServer = configFile.getProperty(JORAM_PERSISTENT);
226             String JavaDoc connectingTimer = configFile.getProperty(JORAM_CONNECTING_TIMER);
227             String JavaDoc connectionPendingTimer = configFile.getProperty(JORAM_CONNECTION_PENDING_TIMER);
228             String JavaDoc transactedSessionMaximumIdleness = configFile.getProperty(JORAM_TRANSACTED_SESSION_MAXIMUM_IDLENESS);
229             String JavaDoc timeoutToAbortRequest = configFile.getProperty(JORAM_TIMEOUT_TO_ABORT_REQUEST);
230             String JavaDoc defaultThreshold = configFile.getProperty(JORAM_DEFAULT_THRESHOLD);
231
232             // Go to Joram Platform
233
WebResponse wr = wc.getFrameContents(FRAME_TREE);
234             WebLink link = wr.getFirstMatchingLink(WebLink.MATCH_URL_STRING, URL_JONASADMIN_JORAM);
235             link.click();
236             wr = wc.getFrameContents(FRAME_CONTENT);
237
238             // Get table
239
try {
240                 WebTable versionTable = utils.getTable(wr, 0);
241                 WebTable currentJoramTable = utils.getTable(wr, 3);
242                 WebTable timerTable = utils.getTable(wr, 6);
243                 WebTable dmqTable = utils.getTable(wr, 9);
244
245                 // Get name of administration task file
246
String JavaDoc fileName = currentJoramTable.getTableCell(6, 2).getText();
247
248                 // Get server port from administration task file
249
String JavaDoc serverPort = JonasAdminFiles.getJoramServerPort(fileName);
250
251                 // Get host name from administration task file
252
String JavaDoc hostName = JonasAdminFiles.getJoramHostName(fileName);
253
254                 // Verify
255
assertEquals("It is not the expected joram version. ", version, versionTable.getTableCell(0, 2)
256                         .getText());
257                 assertEquals("It is not the expected joram local server id. ", serverId, currentJoramTable
258                         .getTableCell(0, 2).getText());
259                 assertEquals("It is not the expected joram local server name. ", serverName, currentJoramTable
260                         .getTableCell(1, 2).getText());
261                 assertEquals("It is not the expected joram local host name. ", hostName, currentJoramTable
262                         .getTableCell(2, 2).getText());
263                 assertEquals("It is not the expected joram local server port. ", serverPort, currentJoramTable
264                         .getTableCell(3, 2).getText());
265                 assertEquals("It is not the expected value of the collocated server attribut. ", collocatedServer,
266                         currentJoramTable.getTableCell(4, 2).getText());
267                 assertEquals("It is not the expected value of the persistent server attribut. ", persistentServer,
268                         currentJoramTable.getTableCell(5, 2).getText());
269                 assertEquals("It is not the expected connecting timer. ", connectingTimer, timerTable
270                         .getTableCell(0, 2).getText());
271                 assertEquals("It is not the expected connection pending timer. ", connectionPendingTimer, timerTable
272                         .getTableCell(1, 2).getText());
273                 assertEquals("It is not the expected transacted session maximum idleness. ",
274                         transactedSessionMaximumIdleness, timerTable.getTableCell(2, 2).getText());
275                 assertEquals("It is not the expected timeout to abort request. ", timeoutToAbortRequest, timerTable
276                         .getTableCell(3, 2).getText());
277                 assertEquals("It is not the expected default threshold for DMQ. ", defaultThreshold, dmqTable
278                         .getTableCell(1, 2).getText());
279             } catch (SAXException JavaDoc e) {
280                 fail("Tables are not correct.");
281             }
282         }
283
284     }
285 }
286
Popular Tags