001: /**
002: * JOnAS: Java(TM) Open Application Server
003: * Copyright (C) 2005 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: * $Id: F_JonasAdminServiceTransaction.java 8107 2006-03-10 10:03:20Z danesa $
023: * --------------------------------------------------------------------------
024: */package org.objectweb.jonas.jonasadmin.test.service.jtm;
025:
026: import javax.management.MBeanServerConnection;
027: import javax.management.ObjectName;
028:
029: import junit.framework.TestSuite;
030:
031: import org.objectweb.jonas.jonasadmin.test.util.JonasAdminAuth;
032: import org.objectweb.jonas.jonasadmin.test.util.JonasAdminTestCase;
033: import org.objectweb.jonas.jonasadmin.test.util.JonasAdminUtils;
034:
035: import com.meterware.httpunit.Button;
036: import com.meterware.httpunit.HttpUnitOptions;
037: import com.meterware.httpunit.WebConversation;
038: import com.meterware.httpunit.WebForm;
039: import com.meterware.httpunit.WebLink;
040: import com.meterware.httpunit.WebResponse;
041: import com.meterware.httpunit.WebTable;
042:
043: /**
044: * Class for testing transaction service
045: * @author Paul Kemler
046: *
047: */
048: public class F_JonasAdminServiceTransaction extends JonasAdminTestCase {
049:
050: /**
051: * URL of transaction
052: */
053: private static final String URL_JONASADMIN_TRANSACTION = "EditJtmService.do";
054:
055: /**
056: * URL of transaction Statistics
057: */
058: private static final String URL_JONASADMIN_TRANSACTION_STATISTICS = "EditTransactionStatistic.do";
059:
060: /**
061: * URL of transaction Monitor
062: */
063: private static final String URL_JONASADMIN_TRANSACTION_MONITOR = "EditTransactionMonitor.do";
064:
065: /**
066: * URL of transaction Recovery
067: */
068: private static final String URL_JONASADMIN_TRANSACTION_RECOVERY = "EditTransactionRecovery.do";
069:
070: /**
071: * URL of reset button
072: */
073: private static final String URL_JONASADMIN_TRANSACTION_RESET = "ResetCounters.do";
074:
075: /**
076: * number of tabs when you are in the transaction tabs
077: */
078: private static final int NUMBER_OF_TABS_FOR_TRANSACTION = 4;
079:
080: /**
081: * Constructor with a specified name
082: * @param s name
083: */
084: public F_JonasAdminServiceTransaction(String s) {
085: super (s, URL_JONASADMIN);
086: }
087:
088: /**
089: * Main method
090: * @param args the arguments
091: */
092: public static void main(String[] args) {
093:
094: String testtorun = null;
095: // Get args
096: for (int argn = 0; argn < args.length; argn++) {
097: String sArg = args[argn];
098: if (sArg.equals("-n")) {
099: testtorun = args[++argn];
100: }
101: }
102: if (testtorun == null) {
103: junit.textui.TestRunner.run(suite());
104: } else {
105: junit.textui.TestRunner
106: .run(new F_JonasAdminServiceTransaction(testtorun));
107: }
108: }
109:
110: /**
111: * Get a new TestSuite for this class
112: * @return a new TestSuite for this class
113: */
114: public static TestSuite suite() {
115: return new TestSuite(F_JonasAdminServiceTransaction.class);
116: }
117:
118: /**
119: * Setup need for these tests
120: * jonasAdmin is required
121: * @throws Exception if it fails
122: */
123: protected void setUp() throws Exception {
124: super .setUp();
125:
126: if (wc.getCurrentPage().getURL() == null) {
127: useWar("jonasAdmin");
128: // login to jonas admin
129: try {
130: JonasAdminAuth.doValidAuth(wc, url);
131: } catch (Exception e) {
132: fail("authentification failed : " + e);
133: }
134: } else {
135: // if there was an error, the connection must be restablished
136: try {
137: wc.getFrameContents(FRAME_TREE);
138: } catch (Exception e) {
139: wc.getResponse(urlLogOut);
140: // login to jonas admin
141: try {
142: JonasAdminAuth.doValidAuth(wc, url);
143: } catch (Exception auth) {
144: fail("authentification failed : " + auth);
145: }
146: }
147: }
148: }
149:
150: /**
151: * Test Transaction Manager infos
152: * @throws Exception if error occurs
153: *
154: */
155: public void testTransactionManagerInfos() throws Exception {
156:
157: WebResponse wr;
158: WebLink link;
159: WebTable table;
160: WebTable tabTable;
161: int selectedTab;
162: String location;
163: String hostName;
164: String port;
165: JonasAdminUtils utils = new JonasAdminUtils();
166:
167: // Disable errors of javascript
168: HttpUnitOptions.setExceptionsThrownOnScriptError(false);
169: // Disable exception thrown on error status
170: HttpUnitOptions.setExceptionsThrownOnErrorStatus(false);
171:
172: // Test only if the transaction service is enabled
173: if (jProp.isJtm()) {
174:
175: // Go to transaction
176: wr = wc.getFrameContents(FRAME_TREE);
177: link = wr.getFirstMatchingLink(WebLink.MATCH_URL_STRING,
178: URL_JONASADMIN_TRANSACTION);
179: link.click();
180: wr = wc.getFrameContents(FRAME_CONTENT);
181: selectedTab = 1;
182:
183: // Verify transaction manager infos
184: table = utils.getTable(wr, 0);
185: location = getLocation();
186: hostName = getHostName();
187: port = getPortNumber();
188: if (port.equals("0")) {
189: port = "undefined";
190: }
191: // Location collocated
192: assertEquals("It is not the expected location value. ",
193: location, table.getTableCell(0, 2).getText());
194: // Host name mururoa.frec.bull.fr
195: assertEquals("It is not the expected host name value. ",
196: hostName, table.getTableCell(1, 2).getText());
197: // Port number undefined
198: assertEquals("It is not the expected port number. ", port,
199: table.getTableCell(2, 2).getText());
200:
201: // Verify tabs
202: tabTable = utils.getTabTable(wr);
203: testTabs(tabTable, NUMBER_OF_TABS_FOR_TRANSACTION,
204: selectedTab, "Problem in 'alarm.jar' tab.");
205: // - links
206: assertTrue("The link "
207: + URL_JONASADMIN_TRANSACTION_STATISTICS
208: + " is not found in the second tab. ", tabTable
209: .getTableCell(0, 2).getLinks()[0].getURLString()
210: .endsWith(URL_JONASADMIN_TRANSACTION_STATISTICS));
211: assertTrue("The link " + URL_JONASADMIN_TRANSACTION_MONITOR
212: + " is not found in the third tab. ", tabTable
213: .getTableCell(0, 4).getLinks()[0].getURLString()
214: .endsWith(URL_JONASADMIN_TRANSACTION_MONITOR));
215: assertTrue("The link "
216: + URL_JONASADMIN_TRANSACTION_RECOVERY
217: + " is not found in the fourth tab. ", tabTable
218: .getTableCell(0, 6).getLinks()[0].getURLString()
219: .endsWith(URL_JONASADMIN_TRANSACTION_RECOVERY));
220:
221: }
222: }
223:
224: /**
225: * Test to modify time-out
226: * @throws Exception if an error occurs.
227: */
228: public void testTransactionTimeOut() throws Exception {
229:
230: WebResponse wr;
231: WebLink link;
232: WebTable table;
233: JonasAdminUtils utils = new JonasAdminUtils();
234:
235: // Disable errors of javascript
236: HttpUnitOptions.setExceptionsThrownOnScriptError(false);
237: // Disable exception thrown on error status
238: HttpUnitOptions.setExceptionsThrownOnErrorStatus(false);
239:
240: // Test only if the transaction service is enabled
241: if (jProp.isJtm()) {
242:
243: // Go to transaction
244: wr = wc.getFrameContents(FRAME_TREE);
245: link = wr.getFirstMatchingLink(WebLink.MATCH_URL_STRING,
246: URL_JONASADMIN_TRANSACTION);
247: link.click();
248: wr = wc.getFrameContents(FRAME_CONTENT);
249:
250: // Modify time-out
251: WebForm form = wr.getForms()[0];
252: form.setParameter("timeOutText", "0");
253:
254: // Apply
255: Button button = form.getButtons()[0];
256: button.click();
257:
258: // Verify "timeOutText" value
259: wr = wc.getFrameContents(FRAME_CONTENT);
260: form = wr.getForms()[0];
261: assertEquals("The Transaction time-out is not '0'. ", "0",
262: form.getParameterValue("timeOutText"));
263: }
264: }
265:
266: /**
267: * Test transaction statistics with transactions of the cmp2.ear example.
268: * @throws Exception if an error occurs.
269: */
270: public void testTransactionStatistics() throws Exception {
271:
272: WebResponse wr;
273: WebLink link;
274: WebTable table;
275: WebTable tabTable;
276: int selectedTab;
277: JonasAdminUtils utils = new JonasAdminUtils();
278:
279: // Disable errors of javascript
280: HttpUnitOptions.setExceptionsThrownOnScriptError(false);
281: // Disable exception thrown on error status
282: HttpUnitOptions.setExceptionsThrownOnErrorStatus(false);
283:
284: // Test only if the transaction service is enabled
285: if (jProp.isJtm() && jProp.isEar()) {
286:
287: // Add cmp2.ear
288: useEar("cmp2");
289:
290: // Go to transaction
291: wr = wc.getFrameContents(FRAME_TREE);
292: link = wr.getFirstMatchingLink(WebLink.MATCH_URL_STRING,
293: URL_JONASADMIN_TRANSACTION);
294: link.click();
295: wr = wc.getFrameContents(FRAME_CONTENT);
296: selectedTab = 1;
297:
298: // Go to Statistics
299: link = wr.getFirstMatchingLink(WebLink.MATCH_URL_STRING,
300: URL_JONASADMIN_TRANSACTION_STATISTICS);
301: link.click();
302: wr = wc.getFrameContents(FRAME_CONTENT);
303: selectedTab = 2;
304:
305: // Verify tabs
306: tabTable = utils.getTabTable(wr);
307: testTabs(tabTable, NUMBER_OF_TABS_FOR_TRANSACTION,
308: selectedTab, "Problem in 'statistics' tab.");
309: // - links
310: assertTrue("The link " + URL_JONASADMIN_TRANSACTION
311: + " is not found in the first tab. ", tabTable
312: .getTableCell(0, 0).getLinks()[0].getURLString()
313: .endsWith(URL_JONASADMIN_TRANSACTION));
314: assertTrue("The link " + URL_JONASADMIN_TRANSACTION_MONITOR
315: + " is not found in the third tab. ", tabTable
316: .getTableCell(0, 4).getLinks()[0].getURLString()
317: .endsWith(URL_JONASADMIN_TRANSACTION_MONITOR));
318: assertTrue("The link "
319: + URL_JONASADMIN_TRANSACTION_RECOVERY
320: + " is not found in the fourth tab. ", tabTable
321: .getTableCell(0, 6).getLinks()[0].getURLString()
322: .endsWith(URL_JONASADMIN_TRANSACTION_RECOVERY));
323:
324: // Create transactions
325: executeCMP2Example2();
326:
327: // Refresh
328: wc.sendRequest(wr.getRefreshRequest());
329: wr = wc.getFrameContents(FRAME_CONTENT);
330:
331: // Verify statistics
332: table = utils.getTable(wr, 3);
333: // Current number of transactions
334: int currentNbTransaction = Integer.parseInt(table
335: .getTableCell(0, 2).getText());
336: // Number of begun transactions
337: int nbBegunTransaction = Integer.parseInt(table
338: .getTableCell(1, 2).getText());
339: // Number of commited transactions
340: int nbCommitedTransaction = Integer.parseInt(table
341: .getTableCell(2, 2).getText());
342: // Number of rolledback transactions
343: int nbRolledbackTransaction = Integer.parseInt(table
344: .getTableCell(3, 2).getText());
345: // Number of transactions with expired time-out
346: int nbTransactionExpiredTimeOut = Integer.parseInt(table
347: .getTableCell(4, 2).getText());
348:
349: // nbBegunTransaction > 0
350: assertTrue(
351: "'Number of begun transactions' is not positif. ",
352: nbBegunTransaction > 0);
353: // currentNbTransaction + nbCommitedTransaction + nbRolledbackTransaction > 0
354: assertTrue(
355: "The sum of 'Number of begun transactions', 'Number of commited transactions' and 'Number of rolledback transactions' is not positif. ",
356: currentNbTransaction + nbCommitedTransaction
357: + nbRolledbackTransaction > 0);
358:
359: // 0 <= nbTransactionExpiredTimeOut
360: assertTrue(
361: "'Number of transactions with expired time-out' is not positif. ",
362: nbTransactionExpiredTimeOut >= 0);
363: }
364: }
365:
366: /**
367: * Test the 'Reset Counters' button in statistics.
368: * @throws Exception if an error occurs
369: */
370: public void testResetCounters() throws Exception {
371:
372: WebResponse wr;
373: WebLink link;
374: WebTable table;
375: JonasAdminUtils utils = new JonasAdminUtils();
376:
377: // Disable errors of javascript
378: HttpUnitOptions.setExceptionsThrownOnScriptError(false);
379: // Disable exception thrown on error status
380: HttpUnitOptions.setExceptionsThrownOnErrorStatus(false);
381:
382: // Test only if the transaction service is enabled
383: if (jProp.isJtm() && jProp.isEar()) {
384:
385: // Add cmp2.ear
386: useEar("cmp2");
387:
388: // Go to transaction
389: wr = wc.getFrameContents(FRAME_TREE);
390: link = wr.getFirstMatchingLink(WebLink.MATCH_URL_STRING,
391: URL_JONASADMIN_TRANSACTION);
392: link.click();
393: wr = wc.getFrameContents(FRAME_CONTENT);
394:
395: // Go to Statistics
396: link = wr.getFirstMatchingLink(WebLink.MATCH_URL_STRING,
397: URL_JONASADMIN_TRANSACTION_STATISTICS);
398: link.click();
399: wr = wc.getFrameContents(FRAME_CONTENT);
400:
401: // Create transactions
402: executeCMP2Example1();
403:
404: // Refresh
405: wc.sendRequest(wr.getRefreshRequest());
406: wr = wc.getFrameContents(FRAME_CONTENT);
407:
408: // Verify statistics
409: table = utils.getTable(wr, 3);
410: // Current number of transactions
411: int currentNbTransaction = Integer.parseInt(table
412: .getTableCell(0, 2).getText());
413: // Number of begun transactions
414: int nbBegunTransaction = Integer.parseInt(table
415: .getTableCell(1, 2).getText());
416: // Number of commited transactions
417: int nbCommitedTransaction = Integer.parseInt(table
418: .getTableCell(2, 2).getText());
419: // Number of rolledback transactions
420: int nbRolledbackTransaction = Integer.parseInt(table
421: .getTableCell(3, 2).getText());
422: // Number of transactions with expired time-out
423: int nbTransactionExpiredTimeOut = Integer.parseInt(table
424: .getTableCell(4, 2).getText());
425: int total = currentNbTransaction + nbBegunTransaction
426: + nbCommitedTransaction + nbRolledbackTransaction
427: + nbTransactionExpiredTimeOut;
428: // total > 0
429: assertTrue(
430: "Counters are all at '0' after executing cmp2 example.",
431: total > 0);
432:
433: // Reset counters
434: link = wr.getFirstMatchingLink(WebLink.MATCH_URL_STRING,
435: URL_JONASADMIN_TRANSACTION_RESET);
436: link.click();
437: wr = wc.getFrameContents(FRAME_CONTENT);
438:
439: // Verify statistics
440: table = utils.getTable(wr, 3);
441: // Current number of transactions
442: currentNbTransaction = Integer.parseInt(table.getTableCell(
443: 0, 2).getText());
444: // Number of begun transactions
445: nbBegunTransaction = Integer.parseInt(table.getTableCell(1,
446: 2).getText());
447: // Number of commited transactions
448: nbCommitedTransaction = Integer.parseInt(table
449: .getTableCell(2, 2).getText());
450: // Number of rolledback transactions
451: nbRolledbackTransaction = Integer.parseInt(table
452: .getTableCell(3, 2).getText());
453: // Number of transactions with expired time-out
454: nbTransactionExpiredTimeOut = Integer.parseInt(table
455: .getTableCell(4, 2).getText());
456:
457: // currentNbTransaction = 0
458: assertEquals("'Current number of transactions' is not '0'",
459: 0, currentNbTransaction);
460: // nbBegunTransaction = 0
461: assertEquals("'Number of begun transactions' is not '0'",
462: 0, nbBegunTransaction);
463: // nbCommitedTransaction = 0
464: assertEquals(
465: "'Number of commited transactions' is not '0'", 0,
466: nbCommitedTransaction);
467: // nbRolledbackTransaction = 0
468: assertEquals(
469: "'Number of rolledback transactions' is not '0'",
470: 0, nbRolledbackTransaction);
471: // nbTransactionExpiredTimeOut = 0
472: assertEquals(
473: "'Number of transactions with expired time-out' is not '0'",
474: 0, nbTransactionExpiredTimeOut);
475:
476: // Create transactions
477: executeCMP2Example1();
478:
479: // Refresh
480: wc.sendRequest(wr.getRefreshRequest());
481: wr = wc.getFrameContents(FRAME_CONTENT);
482:
483: // Verify statistics
484: table = utils.getTable(wr, 3);
485: // Current number of transactions
486: currentNbTransaction = Integer.parseInt(table.getTableCell(
487: 0, 2).getText());
488: // Number of begun transactions
489: nbBegunTransaction = Integer.parseInt(table.getTableCell(1,
490: 2).getText());
491: // Number of commited transactions
492: nbCommitedTransaction = Integer.parseInt(table
493: .getTableCell(2, 2).getText());
494: // Number of rolledback transactions
495: nbRolledbackTransaction = Integer.parseInt(table
496: .getTableCell(3, 2).getText());
497: // Number of transactions with expired time-out
498: nbTransactionExpiredTimeOut = Integer.parseInt(table
499: .getTableCell(4, 2).getText());
500: total = currentNbTransaction + nbBegunTransaction
501: + nbCommitedTransaction + nbRolledbackTransaction
502: + nbTransactionExpiredTimeOut;
503: // total > 0
504: assertTrue(
505: "Counters are all at '0' after re-executing cmp2 example.",
506: total > 0);
507: }
508: }
509:
510: /**
511: * Test transaction Monitor
512: * @throws Exception if an error occurs
513: */
514: public void testTransactionMonitor() throws Exception {
515:
516: WebResponse wr;
517: WebLink link;
518: WebTable table;
519: WebTable tabTable;
520: int selectedTab;
521: String location;
522: String hostName;
523: String port;
524: JonasAdminUtils utils = new JonasAdminUtils();
525:
526: // Disable errors of javascript
527: HttpUnitOptions.setExceptionsThrownOnScriptError(false);
528: // Disable exception thrown on error status
529: HttpUnitOptions.setExceptionsThrownOnErrorStatus(false);
530:
531: // Test only if the transaction service is enabled
532: if (jProp.isJtm()) {
533:
534: // Go to transaction
535: wr = wc.getFrameContents(FRAME_TREE);
536: link = wr.getFirstMatchingLink(WebLink.MATCH_URL_STRING,
537: URL_JONASADMIN_TRANSACTION);
538: link.click();
539: wr = wc.getFrameContents(FRAME_CONTENT);
540:
541: // Go to 'Monitor'
542: link = wr.getFirstMatchingLink(WebLink.MATCH_URL_STRING,
543: URL_JONASADMIN_TRANSACTION_MONITOR);
544: link.click();
545: wr = wc.getFrameContents(FRAME_CONTENT);
546: selectedTab = 3;
547:
548: // Verify 'Monitor' table
549: table = utils.getTable(wr, 0);
550: if (!table.getTableCell(0, 0).getText().equals("Date")) {
551: // No Transactions in Execution !
552: assertEquals(
553: "There is not the message: 'No Transactions in Execution !'. ",
554: "No Transactions in Execution !", table
555: .getTableCell(0, 0).getText());
556: } else {
557: // There is one transaction (or more)
558: assertTrue("There is no text for the date. ", table
559: .getTableCell(1, 0).getText().length() > 0);
560: assertTrue("There is no text for the transaction. ",
561: table.getTableCell(1, 1).getText().length() > 0);
562: assertTrue("There is no text for the resource. ", table
563: .getTableCell(1, 2).getText().length() > 0);
564: assertTrue("There is no text for the state. ", table
565: .getTableCell(1, 3).getText().length() > 0);
566: }
567:
568: // Verify tabs
569: tabTable = utils.getTabTable(wr);
570: testTabs(tabTable, NUMBER_OF_TABS_FOR_TRANSACTION,
571: selectedTab, "Problem in 'Monitor' tab.");
572: // - links
573: assertTrue("The link " + URL_JONASADMIN_TRANSACTION
574: + " is not found in the first tab. ", tabTable
575: .getTableCell(0, 0).getLinks()[0].getURLString()
576: .endsWith(URL_JONASADMIN_TRANSACTION));
577: assertTrue("The link "
578: + URL_JONASADMIN_TRANSACTION_STATISTICS
579: + " is not found in the second tab. ", tabTable
580: .getTableCell(0, 2).getLinks()[0].getURLString()
581: .endsWith(URL_JONASADMIN_TRANSACTION_STATISTICS));
582: assertTrue("The link "
583: + URL_JONASADMIN_TRANSACTION_RECOVERY
584: + " is not found in the fourth tab. ", tabTable
585: .getTableCell(0, 6).getLinks()[0].getURLString()
586: .endsWith(URL_JONASADMIN_TRANSACTION_RECOVERY));
587: }
588: }
589:
590: /**
591: * Test transaction Recovery
592: * @throws Exception if an error occurs
593: */
594: public void testTransactionRecovery() throws Exception {
595:
596: WebResponse wr;
597: WebLink link;
598: WebTable table;
599: WebTable tabTable;
600: int selectedTab;
601: String location;
602: String hostName;
603: String port;
604: JonasAdminUtils utils = new JonasAdminUtils();
605:
606: // Disable errors of javascript
607: HttpUnitOptions.setExceptionsThrownOnScriptError(false);
608: // Disable exception thrown on error status
609: HttpUnitOptions.setExceptionsThrownOnErrorStatus(false);
610:
611: // Test only if the transaction service is enabled
612: if (jProp.isJtm()) {
613:
614: // Go to transaction
615: wr = wc.getFrameContents(FRAME_TREE);
616: link = wr.getFirstMatchingLink(WebLink.MATCH_URL_STRING,
617: URL_JONASADMIN_TRANSACTION);
618: link.click();
619: wr = wc.getFrameContents(FRAME_CONTENT);
620:
621: // Go to 'Recovery'
622: link = wr.getFirstMatchingLink(WebLink.MATCH_URL_STRING,
623: URL_JONASADMIN_TRANSACTION_RECOVERY);
624: link.click();
625: wr = wc.getFrameContents(FRAME_CONTENT);
626: selectedTab = 4;
627:
628: // Verify 'Recovery' table
629: table = utils.getTable(wr, 0);
630: // No Transactions in Execution !
631: assertEquals(
632: "There is not the message: 'No Transactions to Recover !'. ",
633: "No Transactions to Recover !", table.getTableCell(
634: 0, 0).getText());
635:
636: // Verify tabs
637: tabTable = utils.getTabTable(wr);
638: testTabs(tabTable, NUMBER_OF_TABS_FOR_TRANSACTION,
639: selectedTab, "Problem in 'Monitor' tab.");
640: // - links
641: assertTrue("The link " + URL_JONASADMIN_TRANSACTION
642: + " is not found in the first tab. ", tabTable
643: .getTableCell(0, 0).getLinks()[0].getURLString()
644: .endsWith(URL_JONASADMIN_TRANSACTION));
645: assertTrue("The link "
646: + URL_JONASADMIN_TRANSACTION_STATISTICS
647: + " is not found in the second tab. ", tabTable
648: .getTableCell(0, 2).getLinks()[0].getURLString()
649: .endsWith(URL_JONASADMIN_TRANSACTION_STATISTICS));
650: assertTrue("The link " + URL_JONASADMIN_TRANSACTION_MONITOR
651: + " is not found in the third tab. ", tabTable
652: .getTableCell(0, 4).getLinks()[0].getURLString()
653: .endsWith(URL_JONASADMIN_TRANSACTION_MONITOR));
654: }
655: }
656:
657: /**
658: * Get jtm location
659: * @return "collocated" or "Remote"
660: * @throws Exception if an error occurs
661: */
662: private String getLocation() throws Exception {
663: MBeanServerConnection server;
664: String location = "";
665: boolean localJtm;
666: server = getMBeanServer();
667: ObjectName on = new ObjectName(
668: "jonas:j2eeType=JTAResource,name=JTAResource,J2EEServer=jonas");
669: localJtm = ((Boolean) server.getAttribute(on, "localJtm"))
670: .booleanValue();
671: if (localJtm) {
672: location = "collocated";
673: } else {
674: location = "Remote";
675: }
676: return location;
677: }
678:
679: /**
680: * Get jtm Host Name
681: * @return jtm host name
682: * @throws Exception if an error occurs
683: */
684: private String getHostName() throws Exception {
685: MBeanServerConnection server = getMBeanServer();
686: String hostName = "";
687: ObjectName on = new ObjectName(
688: "jonas:j2eeType=JTAResource,name=JTAResource,J2EEServer=jonas");
689: hostName = (String) server.getAttribute(on, "hostName");
690: return hostName;
691: }
692:
693: /**
694: * Get jtm port number
695: * @return jtm port number
696: * @throws Exception if an error occurs
697: */
698: private String getPortNumber() throws Exception {
699: MBeanServerConnection server = getMBeanServer();
700: String port = "0";
701: ObjectName on = new ObjectName(
702: "jonas:j2eeType=JTAResource,name=JTAResource,J2EEServer=jonas");
703: port = ((Integer) server.getAttribute(on, "portNumber"))
704: .toString();
705: return port;
706: }
707:
708: /**
709: * Execute the test1 of cmp2
710: * @throws Exception if an error occurs
711: */
712: private void executeCMP2Example1() throws Exception {
713: WebConversation wc2 = new WebConversation();
714: String urlExample1 = prefixUrl + "/cmp2/test1?";
715: WebResponse wr = wc2.getResponse(urlExample1);
716: }
717:
718: /**
719: * Execute the test2 of cmp2
720: * @throws Exception if an error occurs
721: */
722: private void executeCMP2Example2() throws Exception {
723: WebConversation wc2 = new WebConversation();
724: String urlExample2 = prefixUrl + "/cmp2/test2?";
725: WebResponse wr = wc2.getResponse(urlExample2);
726: }
727:
728: /**
729: * Execute the test3 of cmp2
730: * @throws Exception if an error occurs
731: */
732: private void executeCMP2Example3() throws Exception {
733: WebConversation wc2 = new WebConversation();
734: String urlExample3 = prefixUrl + "/cmp2/test3?";
735: WebResponse wr = wc2.getResponse(urlExample3);
736: }
737:
738: /**
739: * Tear Down cleanUp action
740: * @throws Exception if an error occurs
741: */
742: public void tearDown() throws Exception {
743: super.tearDown();
744: }
745:
746: }
|