1 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 ; 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 50 public class F_JonasAdminJoramProperties extends JonasAdminTestCase { 51 52 55 private static final String URL_JONASADMIN_JORAM = "EditJoramPlatform.do"; 56 57 60 private static final String JONASADMINTEST_PROPERTY_NAME = "jonasAdminTests"; 61 62 65 private static final String JORAM_VERSION = "joram.version"; 66 67 70 private static final String JORAM_SERVER_ID = "joram.serverId"; 71 72 75 private static final String JORAM_SERVER_NAME = "joram.serverName"; 76 77 80 private static final String JORAM_COLLOCATED = "joram.collocated"; 81 82 85 private static final String JORAM_PERSISTENT = "joram.persistent"; 86 87 90 private static final String JORAM_CONNECTING_TIMER = "joram.connectingTimer"; 91 92 95 private static final String JORAM_CONNECTION_PENDING_TIMER = "joram.connectionPendingTimer"; 96 97 100 private static final String JORAM_TRANSACTED_SESSION_MAXIMUM_IDLENESS = "joram.transactedSessionMaximumIdleness"; 101 102 105 private static final String JORAM_TIMEOUT_TO_ABORT_REQUEST = "joram.timeoutToAbortRequest"; 106 107 110 private static final String JORAM_DEFAULT_THRESHOLD = "joram.defaultThresholdForDMQ"; 111 112 113 117 public F_JonasAdminJoramProperties(String s) { 118 super(s, URL_JONASADMIN); 119 } 120 121 126 public F_JonasAdminJoramProperties(WebConversation wc, String s) { 127 super(wc, s, URL_JONASADMIN); 128 } 129 130 134 public static void main(String [] args) { 135 136 String testtorun = null; 137 for (int argn = 0; argn < args.length; argn++) { 139 String 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 155 public static TestSuite suite() { 156 return new TestSuite(F_JonasAdminJoramProperties.class); 157 } 158 159 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 175 protected void setUp() throws Exception { 176 super.setUp(); 177 178 if (wc.getCurrentPage().getURL() == null) { 179 useWar("jonasAdmin"); 180 try { 182 JonasAdminAuth.doValidAuth(wc, url); 183 } catch (Exception e) { 184 fail("authentification failed : " + e); 185 } 186 } else { 187 try { 189 wc.getFrameContents(FRAME_TREE); 190 } catch (Exception e) { 191 wc.getResponse(urlLogOut); 192 try { 194 JonasAdminAuth.doValidAuth(wc, url); 195 } catch (Exception auth) { 196 fail("authentification failed : " + auth); 197 } 198 } 199 } 200 } 201 202 206 public void testJoramProperties() throws Exception { 207 208 JProperties jProp = new JProperties(); 209 JonasAdminUtils utils = new JonasAdminUtils(); 210 211 if (jProp.isJoram()) { 213 214 HttpUnitOptions.setExceptionsThrownOnScriptError(false); 216 HttpUnitOptions.setExceptionsThrownOnErrorStatus(false); 218 219 221 String version = configFile.getProperty(JORAM_VERSION); 222 String serverId = configFile.getProperty(JORAM_SERVER_ID); 223 String serverName = configFile.getProperty(JORAM_SERVER_NAME); 224 String collocatedServer = configFile.getProperty(JORAM_COLLOCATED); 225 String persistentServer = configFile.getProperty(JORAM_PERSISTENT); 226 String connectingTimer = configFile.getProperty(JORAM_CONNECTING_TIMER); 227 String connectionPendingTimer = configFile.getProperty(JORAM_CONNECTION_PENDING_TIMER); 228 String transactedSessionMaximumIdleness = configFile.getProperty(JORAM_TRANSACTED_SESSION_MAXIMUM_IDLENESS); 229 String timeoutToAbortRequest = configFile.getProperty(JORAM_TIMEOUT_TO_ABORT_REQUEST); 230 String defaultThreshold = configFile.getProperty(JORAM_DEFAULT_THRESHOLD); 231 232 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 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 String fileName = currentJoramTable.getTableCell(6, 2).getText(); 247 248 String serverPort = JonasAdminFiles.getJoramServerPort(fileName); 250 251 String hostName = JonasAdminFiles.getJoramHostName(fileName); 253 254 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 e) { 280 fail("Tables are not correct."); 281 } 282 } 283 284 } 285 } 286 | Popular Tags |