Source Code Cross Referenced for F_JonasAdminEjbContainer.java in  » J2EE » JOnAS-4.8.6 » org » objectweb » jonas » jonasadmin » test » service » container » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » J2EE » JOnAS 4.8.6 » org.objectweb.jonas.jonasadmin.test.service.container 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


0001:        /**
0002:         * JOnAS: Java(TM) Open Application Server
0003:         * Copyright (C) 2005 Bull S.A.
0004:         * Contact: jonas-team@objectweb.org
0005:         *
0006:         * This library is free software; you can redistribute it and/or
0007:         * modify it under the terms of the GNU Lesser General Public
0008:         * License as published by the Free Software Foundation; either
0009:         * version 2.1 of the License, or 1any later version.
0010:         *
0011:         * This library is distributed in the hope that it will be useful,
0012:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
0013:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0014:         * Lesser General Public License for more details.
0015:         *
0016:         * You should have received a copy of the GNU Lesser General Public
0017:         * License along with this library; if not, write to the Free Software
0018:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
0019:         * USA
0020:         *
0021:         * --------------------------------------------------------------------------
0022:         * $Id: F_JonasAdminEjbContainer.java 8124 2006-03-14 09:57:57Z danesa $
0023:         * --------------------------------------------------------------------------
0024:         */package org.objectweb.jonas.jonasadmin.test.service.container;
0025:
0026:        import java.io.File;
0027:        import java.util.Iterator;
0028:
0029:        import javax.management.MBeanServerConnection;
0030:        import javax.management.ObjectName;
0031:
0032:        import junit.framework.TestSuite;
0033:
0034:        import org.objectweb.jonas.jonasadmin.test.util.JonasAdminAuth;
0035:        import org.objectweb.jonas.jonasadmin.test.util.JonasAdminTestCase;
0036:        import org.objectweb.jonas.jonasadmin.test.util.JonasAdminUtils;
0037:
0038:        import com.meterware.httpunit.HttpUnitOptions;
0039:        import com.meterware.httpunit.TableCell;
0040:        import com.meterware.httpunit.WebConversation;
0041:        import com.meterware.httpunit.WebForm;
0042:        import com.meterware.httpunit.WebLink;
0043:        import com.meterware.httpunit.WebResponse;
0044:        import com.meterware.httpunit.WebTable;
0045:
0046:        /**
0047:         * Class for testing ejb container in jonasAdmin
0048:         * @author Paul Kemler
0049:         *
0050:         */
0051:        public class F_JonasAdminEjbContainer extends JonasAdminTestCase {
0052:
0053:            /**
0054:             * URL of Ejb container
0055:             */
0056:            private static final String URL_JONASADMIN_EJB_CONTAINER = "ListContainers.do";
0057:
0058:            /**
0059:             * URL of the container tab
0060:             */
0061:            private static final String URL_JONASADMIN_CONTAINER = "/ViewContainer.do";
0062:
0063:            /**
0064:             * URL of the container jsp
0065:             */
0066:            private static final String URL_JONASADMIN_CONTAINER_JSP = "/jonasAdmin/service/container.jsp";
0067:
0068:            /**
0069:             * URL of the statistic tab
0070:             */
0071:            private static final String URL_JONASADMIN_STATISTICS = "/EditContainerStatistic.do";
0072:
0073:            /**
0074:             * URL of the ejb container's' statistics tab
0075:             */
0076:            private static final String URL_JONASADMIN_CONTAINERS_STATISTICS = "EditEjbContainersStatistic.do";
0077:
0078:            /**
0079:             * URL of the view ejb container tab
0080:             */
0081:            private static final String URL_JONASADMIN_VIEW_EJB = "/ViewContainerEjbs.do";
0082:
0083:            /**
0084:             * URL of the mdb tab
0085:             */
0086:            private static final String URL_JONASADMIN_MDB = "/jonasAdmin/service/ejbMessage.jsp";
0087:
0088:            /**
0089:             * URL of the entity bean tab
0090:             */
0091:            private static final String URL_JONASADMIN_EB = "/jonasAdmin/service/ejbEntity.jsp";
0092:
0093:            /**
0094:             * URL of the view ejb container jsp
0095:             */
0096:            private static final String URL_JONASADMIN_VIEW_EJB_JSP = "/jonasAdmin/service/containerEjbs.jsp";
0097:
0098:            /**
0099:             * URL of the ejb dependency jsp
0100:             */
0101:            private static final String URL_JONASADMIN_DEPENDENCIES = "/jonasAdmin/service/ejbDependency.jsp";
0102:
0103:            /**
0104:             * URL of the synchronize button
0105:             */
0106:            private static final String URL_JONASADMIN_SYNCHRONIZE = "ExecuteEjb.do?action=synchronize";
0107:
0108:            /**
0109:             * URL of the reduce button
0110:             */
0111:            private static final String URL_JONASADMIN_REDUCE = "ExecuteEjb.do?action=reduceCache";
0112:
0113:            /**
0114:             * number of tabs when you are in the jar page
0115:             */
0116:            private static final int NUMBER_OF_TABS_FOR_JAR = 4;
0117:
0118:            /**
0119:             * number of tabs when you are in the MDB page
0120:             */
0121:            private static final int NUMBER_OF_TABS_FOR_MDB = 6;
0122:
0123:            /**
0124:             * number of tabs when you are in the EntityBean page when using dbm
0125:             */
0126:            private static final int NUMBER_OF_TABS_FOR_ENTITY_DBM = 6;
0127:            /**
0128:             * number of tabs when you are in the EntityBean page when using the RAR
0129:             * (there is no Dependency tab in this case)
0130:             */
0131:            private static final int NUMBER_OF_TABS_FOR_ENTITY_RAR = 5;
0132:
0133:            /**
0134:             * index of the Mdb tab
0135:             */
0136:            private static final int MDB_TAB_INDEX = 5;
0137:
0138:            /**
0139:             * Name of Mdb tab
0140:             */
0141:            private static final String TDB_TAB_TEXT = "Mdb";
0142:
0143:            /**
0144:             * Constructor with a specified name
0145:             * @param s name
0146:             */
0147:            public F_JonasAdminEjbContainer(String s) {
0148:                super (s, URL_JONASADMIN);
0149:            }
0150:
0151:            /**
0152:             * Main method
0153:             * @param args the arguments
0154:             */
0155:            public static void main(String[] args) {
0156:
0157:                String testtorun = null;
0158:                // Get args
0159:                for (int argn = 0; argn < args.length; argn++) {
0160:                    String sArg = args[argn];
0161:                    if (sArg.equals("-n")) {
0162:                        testtorun = args[++argn];
0163:                    }
0164:                }
0165:                if (testtorun == null) {
0166:                    junit.textui.TestRunner.run(suite());
0167:                } else {
0168:                    junit.textui.TestRunner.run(new F_JonasAdminEjbContainer(
0169:                            testtorun));
0170:                }
0171:            }
0172:
0173:            /**
0174:             * Get a new TestSuite for this class
0175:             * @return a new TestSuite for this class
0176:             */
0177:            public static TestSuite suite() {
0178:                return new TestSuite(F_JonasAdminEjbContainer.class);
0179:            }
0180:
0181:            /**
0182:             * Setup need for these tests
0183:             * jonasAdmin is required
0184:             * @throws Exception if it fails
0185:             */
0186:            protected void setUp() throws Exception {
0187:                super .setUp();
0188:
0189:                if (wc.getCurrentPage().getURL() == null) {
0190:                    useWar("jonasAdmin");
0191:                    // login to jonas admin
0192:                    try {
0193:                        JonasAdminAuth.doValidAuth(wc, url);
0194:                    } catch (Exception e) {
0195:                        fail("authentification failed :  " + e);
0196:                    }
0197:                } else {
0198:                    // if there was an error, the connection must be restablished
0199:                    try {
0200:                        wc.getFrameContents(FRAME_TREE);
0201:                    } catch (Exception e) {
0202:                        wc.getResponse(urlLogOut);
0203:                        // login to jonas admin
0204:                        try {
0205:                            JonasAdminAuth.doValidAuth(wc, url);
0206:                        } catch (Exception auth) {
0207:                            fail("authentification failed :  " + auth);
0208:                        }
0209:                    }
0210:                }
0211:            }
0212:
0213:            /**
0214:             * Test ejb container with alarm.ear
0215:             * @throws Exception if error occurs
0216:             *
0217:             */
0218:            public void testEjbContainer() throws Exception {
0219:
0220:                WebResponse wr;
0221:                WebLink link;
0222:                WebTable table;
0223:                WebTable tabTable;
0224:                TableCell selectedCell;
0225:                TableCell cell;
0226:                String ear = "alarm";
0227:                int selectedTab;
0228:                JonasAdminUtils utils = new JonasAdminUtils();
0229:
0230:                // Disable errors of javascript
0231:                HttpUnitOptions.setExceptionsThrownOnScriptError(false);
0232:                // Disable exception thrown on error status
0233:                HttpUnitOptions.setExceptionsThrownOnErrorStatus(false);
0234:
0235:                if (jProp.isEar() && jProp.isEjb()) {
0236:                    // Add alarm.ear
0237:                    useEar(ear);
0238:
0239:                    // Go to ejb container
0240:                    wr = wc.getFrameContents(FRAME_TREE);
0241:                    link = wr.getFirstMatchingLink(WebLink.MATCH_URL_STRING,
0242:                            URL_JONASADMIN_EJB_CONTAINER);
0243:                    link.click();
0244:                    wr = wc.getFrameContents(FRAME_CONTENT);
0245:
0246:                    // Go to alarm.jar page
0247:                    link = wr.getFirstMatchingLink(WebLink.MATCH_URL_STRING,
0248:                            ear);
0249:                    link.click();
0250:                    wr = wc.getFrameContents(FRAME_CONTENT);
0251:                    selectedTab = 2;
0252:
0253:                    // Verify infos
0254:                    table = utils.getTable(wr, 0);
0255:                    cell = table.getTableCell(0, 2);
0256:                    // Name
0257:                    assertEquals("It is not the name of the jar. ", ear, cell
0258:                            .getText());
0259:                    // Path
0260:                    cell = table.getTableCell(1, 2);
0261:                    assertTrue("It is not the path of the jar file. ", cell
0262:                            .getText().endsWith(File.separator + "alarm.jar"));
0263:
0264:                    // Verify tabs
0265:                    tabTable = utils.getTabTable(wr);
0266:                    testTabs(tabTable, NUMBER_OF_TABS_FOR_JAR, selectedTab,
0267:                            "Problem in 'alarm.jar' tab.");
0268:                    // - links
0269:                    assertTrue("The link " + URL_JONASADMIN_EJB_CONTAINER
0270:                            + " is not found in the first tab. ", tabTable
0271:                            .getTableCell(0, 0).getLinks()[0].getURLString()
0272:                            .endsWith(URL_JONASADMIN_EJB_CONTAINER));
0273:                    assertTrue("The link " + URL_JONASADMIN_STATISTICS
0274:                            + " is not found in the third tab. ", tabTable
0275:                            .getTableCell(0, 4).getLinks()[0].getURLString()
0276:                            .endsWith(URL_JONASADMIN_STATISTICS));
0277:                    assertTrue("The link " + URL_JONASADMIN_VIEW_EJB
0278:                            + " is not found in the fourth tab. ", tabTable
0279:                            .getTableCell(0, 6).getLinks()[0].getURLString()
0280:                            .endsWith(URL_JONASADMIN_VIEW_EJB));
0281:
0282:                    // Go to the statistic tab
0283:                    link = wr.getFirstMatchingLink(WebLink.MATCH_URL_STRING,
0284:                            URL_JONASADMIN_STATISTICS);
0285:                    link.click();
0286:                    wr = wc.getFrameContents(FRAME_CONTENT);
0287:                    selectedTab = 3;
0288:
0289:                    // Verify stats
0290:                    table = utils.getTable(wr, 1);
0291:
0292:                    int alarmBMP = Integer.parseInt(table.getTableCell(1, 2)
0293:                            .getText());
0294:                    int alarmCMP = Integer.parseInt(table.getTableCell(2, 2)
0295:                            .getText());
0296:                    int alarmStateful = Integer.parseInt(table.getTableCell(3,
0297:                            2).getText());
0298:                    int alarmStateless = Integer.parseInt(table.getTableCell(4,
0299:                            2).getText());
0300:                    int alarmMDB = Integer.parseInt(table.getTableCell(5, 2)
0301:                            .getText());
0302:                    int alarmTotal = Integer.parseInt(table.getTableCell(0, 2)
0303:                            .getText());
0304:
0305:                    assertEquals(
0306:                            "It is not the number of Entity with Bean-Managed Persistence in alarm.jar. ",
0307:                            0, alarmBMP);
0308:                    assertEquals(
0309:                            "It is not the number of Entity with Container-Managed Persistence in alarm.jar. ",
0310:                            1, alarmCMP);
0311:                    assertEquals(
0312:                            "It is not the number of Stateful Session Bean in alarm.jar. ",
0313:                            1, alarmStateful);
0314:                    assertEquals(
0315:                            "It is not the number of Stateless Session Bean in alarm.jar. ",
0316:                            0, alarmStateless);
0317:                    assertEquals(
0318:                            "It is not the number of Message Driven Bean in alarm.jar. ",
0319:                            1, alarmMDB);
0320:                    assertEquals("It is not the number of EJBs in alarm.jar. ",
0321:                            3, alarmTotal);
0322:
0323:                    // Verify tabs
0324:                    tabTable = utils.getTabTable(wr);
0325:                    testTabs(tabTable, NUMBER_OF_TABS_FOR_JAR, selectedTab,
0326:                            "Problem in 'statistic' tab.");
0327:                    // - links
0328:                    assertTrue("The link " + URL_JONASADMIN_EJB_CONTAINER
0329:                            + " is not found in the first tab. ", tabTable
0330:                            .getTableCell(0, 0).getLinks()[0].getURLString()
0331:                            .endsWith(URL_JONASADMIN_EJB_CONTAINER));
0332:                    assertTrue("The link " + URL_JONASADMIN_CONTAINER_JSP
0333:                            + " is not found in the second tab. ", tabTable
0334:                            .getTableCell(0, 2).getLinks()[0].getURLString()
0335:                            .endsWith(URL_JONASADMIN_CONTAINER_JSP));
0336:                    assertTrue("The link " + URL_JONASADMIN_VIEW_EJB_JSP
0337:                            + " is not found in the fourth tab. ", tabTable
0338:                            .getTableCell(0, 6).getLinks()[0].getURLString()
0339:                            .endsWith(URL_JONASADMIN_VIEW_EJB_JSP));
0340:
0341:                    // Go to the Ejb tab
0342:                    link = wr.getFirstMatchingLink(WebLink.MATCH_URL_STRING,
0343:                            URL_JONASADMIN_VIEW_EJB_JSP);
0344:                    link.click();
0345:                    wr = wc.getFrameContents(FRAME_CONTENT);
0346:                    selectedTab = 4;
0347:
0348:                    // Verify infos
0349:                    table = utils.getTable(wr, 0);
0350:                    // Name
0351:                    cell = table.getTableCell(1, 0);
0352:                    assertEquals("It is not the name of the EJB. ",
0353:                            "AlarmListener", cell.getText());
0354:                    cell = table.getTableCell(2, 0);
0355:                    assertEquals("It is not the name of the EJB. ",
0356:                            "AlarmRecord", cell.getText());
0357:                    cell = table.getTableCell(3, 0);
0358:                    assertEquals("It is not the name of the EJB. ", "View",
0359:                            cell.getText());
0360:                    // Type
0361:                    cell = table.getTableCell(1, 2);
0362:                    assertEquals(
0363:                            "It is not the type of the AlarmListener EJB. ",
0364:                            "MessageDrivenBean", cell.getText());
0365:                    cell = table.getTableCell(2, 2);
0366:                    assertEquals("It is not the type of the AlarmRecord EJB. ",
0367:                            "EntityBean", cell.getText());
0368:                    cell = table.getTableCell(3, 2);
0369:                    assertEquals("It is not the type of the View EJB. ",
0370:                            "StatefulSessionBean", cell.getText());
0371:
0372:                    // Verify tabs
0373:                    tabTable = utils.getTabTable(wr);
0374:                    testTabs(tabTable, NUMBER_OF_TABS_FOR_JAR, selectedTab,
0375:                            "Problem in 'EJBs' tab.");
0376:                    // - links
0377:                    assertTrue("The link " + URL_JONASADMIN_EJB_CONTAINER
0378:                            + " is not found in the first tab. ", tabTable
0379:                            .getTableCell(0, 0).getLinks()[0].getURLString()
0380:                            .endsWith(URL_JONASADMIN_EJB_CONTAINER));
0381:                    assertTrue("The link " + URL_JONASADMIN_CONTAINER
0382:                            + " is not found in the second tab. ", tabTable
0383:                            .getTableCell(0, 2).getLinks()[0].getURLString()
0384:                            .endsWith(URL_JONASADMIN_CONTAINER));
0385:                    assertTrue("The link " + URL_JONASADMIN_STATISTICS
0386:                            + " is not found in the third tab. ", tabTable
0387:                            .getTableCell(0, 4).getLinks()[0].getURLString()
0388:                            .endsWith(URL_JONASADMIN_STATISTICS));
0389:                }
0390:
0391:            }
0392:
0393:            /**
0394:             * Test the message driven bean management
0395:             * @throws Exception if error occurs
0396:             */
0397:            public void testMessageDrivenBean() throws Exception {
0398:
0399:                WebResponse wr;
0400:                WebLink link;
0401:                WebTable table;
0402:                WebTable tabTable;
0403:                TableCell selectedCell;
0404:                TableCell cell;
0405:                String ear = "alarm";
0406:                int selectedTab;
0407:                JonasAdminUtils utils = new JonasAdminUtils();
0408:
0409:                // Disable errors of javascript
0410:                HttpUnitOptions.setExceptionsThrownOnScriptError(false);
0411:                // Disable exception thrown on error status
0412:                HttpUnitOptions.setExceptionsThrownOnErrorStatus(false);
0413:
0414:                if (jProp.isEar() && jProp.isEjb()) {
0415:                    // Add alarm.ear
0416:                    useEar(ear);
0417:
0418:                    // Go to ejb container
0419:                    wr = wc.getFrameContents(FRAME_TREE);
0420:                    link = wr.getFirstMatchingLink(WebLink.MATCH_URL_STRING,
0421:                            URL_JONASADMIN_EJB_CONTAINER);
0422:                    link.click();
0423:                    wr = wc.getFrameContents(FRAME_CONTENT);
0424:
0425:                    // Go to alarm.jar page
0426:                    link = wr.getFirstMatchingLink(WebLink.MATCH_URL_STRING,
0427:                            ear);
0428:                    link.click();
0429:                    wr = wc.getFrameContents(FRAME_CONTENT);
0430:                    selectedTab = 2;
0431:
0432:                    // Go to the Ejb tab
0433:                    link = wr.getFirstMatchingLink(WebLink.MATCH_URL_STRING,
0434:                            URL_JONASADMIN_VIEW_EJB);
0435:                    link.click();
0436:                    wr = wc.getFrameContents(FRAME_CONTENT);
0437:                    selectedTab = 4;
0438:
0439:                    table = utils.getTable(wr, 0);
0440:
0441:                    // Get links
0442:                    int nbLink = table.getRowCount() - 1;
0443:                    WebLink[] links = new WebLink[nbLink];
0444:                    WebResponse[] responses = new WebResponse[nbLink];
0445:                    for (int i = 0; i < nbLink; i++) {
0446:                        links[i] = table.getTableCell(i + 1, 0).getLinks()[0];
0447:                    }
0448:
0449:                    /*
0450:                     * Verify the MessageDrivenBean: AlarmListener
0451:                     */
0452:                    links[0].click();
0453:                    responses[0] = wc.getFrameContents(FRAME_CONTENT);
0454:                    selectedTab = 5;
0455:                    table = utils.getTable(responses[0], 1);
0456:                    // Name AlarmListener
0457:                    assertEquals(
0458:                            "It is not the name of the MessageDrivenBean. ",
0459:                            "AlarmListener", table.getTableCell(0, 2).getText());
0460:                    // File .../alarm.jar
0461:                    assertTrue("It is not the file of the MessageDrivenBean. ",
0462:                            table.getTableCell(1, 2).getText().endsWith(
0463:                                    "alarm.jar"));
0464:
0465:                    // Naming and Classes
0466:                    table = utils.getTable(responses[0], 4);
0467:                    // EJB class org.objectweb.alarm.beans.AlarmListenerBean
0468:                    assertEquals(
0469:                            "It is not the EJB class of the MessageDrivenBean. ",
0470:                            "org.objectweb.alarm.beans.AlarmListenerBean",
0471:                            table.getTableCell(0, 2).getText());
0472:                    // EJB JNDI Name AlarmListenerHome
0473:                    assertEquals(
0474:                            "It is not the EJB JNDI Name of the MessageDrivenBean. ",
0475:                            "AlarmListenerHome", table.getTableCell(1, 2)
0476:                                    .getText());
0477:                    // EJB HomeClass
0478:                    assertEquals(
0479:                            "It is not the EJB HomeClass of the MessageDrivenBean. ",
0480:                            "", table.getTableCell(2, 2).getText());
0481:                    // EJB RemoteClass
0482:                    assertEquals(
0483:                            "It is not the EJB RemoteClass of the MessageDrivenBean. ",
0484:                            "", table.getTableCell(3, 2).getText());
0485:                    // EJB LocalHomeClass
0486:                    assertEquals(
0487:                            "It is not the EJB LocalHomeClass of the MessageDrivenBean. ",
0488:                            "", table.getTableCell(4, 2).getText());
0489:                    // EJB LocalClass
0490:                    assertEquals(
0491:                            "It is not the EJB LocalClass of the MessageDrivenBean. ",
0492:                            "", table.getTableCell(5, 2).getText());
0493:
0494:                    // Mdb Configuration
0495:                    table = utils.getTable(responses[0], 7);
0496:                    // JMS Destination name AlarmTopic
0497:                    assertEquals(
0498:                            "It is not the JMS Destination name of the MessageDrivenBean. ",
0499:                            "AlarmTopic", table.getTableCell(0, 2).getText());
0500:
0501:                    // Verify tabs
0502:                    tabTable = utils.getTabTable(responses[0]);
0503:                    testTabs(tabTable, NUMBER_OF_TABS_FOR_MDB, selectedTab,
0504:                            "Problem in 'AlarmListener' tab.");
0505:                    // - links
0506:                    assertTrue("The link " + URL_JONASADMIN_EJB_CONTAINER
0507:                            + " is not found in the first tab. ", tabTable
0508:                            .getTableCell(0, 0).getLinks()[0].getURLString()
0509:                            .endsWith(URL_JONASADMIN_EJB_CONTAINER));
0510:                    assertTrue("The link " + URL_JONASADMIN_CONTAINER
0511:                            + " is not found in the second tab. ", tabTable
0512:                            .getTableCell(0, 2).getLinks()[0].getURLString()
0513:                            .endsWith(URL_JONASADMIN_CONTAINER));
0514:                    assertTrue("The link " + URL_JONASADMIN_STATISTICS
0515:                            + " is not found in the third tab. ", tabTable
0516:                            .getTableCell(0, 4).getLinks()[0].getURLString()
0517:                            .endsWith(URL_JONASADMIN_STATISTICS));
0518:                    assertTrue("The link " + URL_JONASADMIN_VIEW_EJB
0519:                            + " is not found in the fourth tab. ", tabTable
0520:                            .getTableCell(0, 6).getLinks()[0].getURLString()
0521:                            .endsWith(URL_JONASADMIN_VIEW_EJB));
0522:                    assertTrue("The link " + URL_JONASADMIN_DEPENDENCIES
0523:                            + " is not found in the sixth tab. ", tabTable
0524:                            .getTableCell(0, 10).getLinks()[0].getURLString()
0525:                            .endsWith(URL_JONASADMIN_DEPENDENCIES));
0526:
0527:                    // Go to Dependency
0528:                    link = responses[0].getFirstMatchingLink(
0529:                            WebLink.MATCH_URL_STRING,
0530:                            URL_JONASADMIN_DEPENDENCIES);
0531:                    link.click();
0532:                    responses[0] = wc.getFrameContents(FRAME_CONTENT);
0533:                    selectedTab = 6;
0534:
0535:                    // JMS Destination
0536:                    table = utils.getTable(responses[0], 0);
0537:                    assertEquals(
0538:                            "The title of table is not 'JMS Destinastion'. ",
0539:                            "JMS Destination", table.getTableCell(0, 0)
0540:                                    .getText());
0541:                    // Topic AlarmTopic
0542:                    table = utils.getTable(responses[0], 1);
0543:                    assertEquals("The JMS destination is not 'AlarmTopic'. ",
0544:                            "AlarmTopic", table.getTableCell(0, 0).getText());
0545:
0546:                    // Verify tabs
0547:                    tabTable = utils.getTabTable(responses[0]);
0548:                    testTabs(tabTable, NUMBER_OF_TABS_FOR_MDB, selectedTab,
0549:                            "Problem in 'Dependency' tab.");
0550:                    // - links
0551:                    assertTrue("The link " + URL_JONASADMIN_EJB_CONTAINER
0552:                            + " is not found in the first tab. ", tabTable
0553:                            .getTableCell(0, 0).getLinks()[0].getURLString()
0554:                            .endsWith(URL_JONASADMIN_EJB_CONTAINER));
0555:                    assertTrue("The link " + URL_JONASADMIN_CONTAINER
0556:                            + " is not found in the second tab. ", tabTable
0557:                            .getTableCell(0, 2).getLinks()[0].getURLString()
0558:                            .endsWith(URL_JONASADMIN_CONTAINER));
0559:                    assertTrue("The link " + URL_JONASADMIN_STATISTICS
0560:                            + " is not found in the third tab. ", tabTable
0561:                            .getTableCell(0, 4).getLinks()[0].getURLString()
0562:                            .endsWith(URL_JONASADMIN_STATISTICS));
0563:                    assertTrue("The link " + URL_JONASADMIN_VIEW_EJB
0564:                            + " is not found in the fourth tab. ", tabTable
0565:                            .getTableCell(0, 6).getLinks()[0].getURLString()
0566:                            .endsWith(URL_JONASADMIN_VIEW_EJB));
0567:                    assertTrue("The link " + URL_JONASADMIN_MDB
0568:                            + " is not found in the sixth tab. ", tabTable
0569:                            .getTableCell(0, 8).getLinks()[0].getURLString()
0570:                            .endsWith(URL_JONASADMIN_MDB));
0571:                }
0572:            }
0573:
0574:            /**
0575:             * Test the entity bean management
0576:             * @throws Exception if error occurs
0577:             */
0578:            public void testEntityBean() throws Exception {
0579:
0580:                WebResponse wr;
0581:                WebLink link;
0582:                WebTable table;
0583:                WebTable tabTable;
0584:                TableCell selectedCell;
0585:                TableCell cell;
0586:                String ear = "alarm";
0587:                int selectedTab;
0588:                JonasAdminUtils utils = new JonasAdminUtils();
0589:
0590:                // Disable errors of javascript
0591:                HttpUnitOptions.setExceptionsThrownOnScriptError(false);
0592:                // Disable exception thrown on error status
0593:                HttpUnitOptions.setExceptionsThrownOnErrorStatus(false);
0594:
0595:                if (jProp.isEar() && jProp.isEjb()) {
0596:                    // Add alarm.ear
0597:                    useEar(ear);
0598:
0599:                    // Go to ejb container
0600:                    wr = wc.getFrameContents(FRAME_TREE);
0601:                    link = wr.getFirstMatchingLink(WebLink.MATCH_URL_STRING,
0602:                            URL_JONASADMIN_EJB_CONTAINER);
0603:                    link.click();
0604:                    wr = wc.getFrameContents(FRAME_CONTENT);
0605:
0606:                    // Go to alarm.jar page
0607:                    link = wr.getFirstMatchingLink(WebLink.MATCH_URL_STRING,
0608:                            ear);
0609:                    link.click();
0610:                    wr = wc.getFrameContents(FRAME_CONTENT);
0611:                    selectedTab = 2;
0612:
0613:                    // Go to the Ejb tab
0614:                    link = wr.getFirstMatchingLink(WebLink.MATCH_URL_STRING,
0615:                            URL_JONASADMIN_VIEW_EJB);
0616:                    link.click();
0617:                    wr = wc.getFrameContents(FRAME_CONTENT);
0618:                    selectedTab = 4;
0619:
0620:                    table = utils.getTable(wr, 0);
0621:
0622:                    // Get links
0623:                    int nbLink = table.getRowCount() - 1;
0624:                    WebLink[] links = new WebLink[nbLink];
0625:                    WebResponse[] responses = new WebResponse[nbLink];
0626:                    for (int i = 0; i < nbLink; i++) {
0627:                        links[i] = table.getTableCell(i + 1, 0).getLinks()[0];
0628:                    }
0629:
0630:                    /*
0631:                     * Verify the EntityBean: AlarmRecord
0632:                     */
0633:                    links[1].click();
0634:                    responses[1] = wc.getFrameContents(FRAME_CONTENT);
0635:                    selectedTab = 5;
0636:                    // EntityBean
0637:                    table = utils.getTable(responses[1], 3);
0638:                    assertEquals("The title of table is not 'EntityBean'. ",
0639:                            "EntityBean", table.getTableCell(0, 0).getText());
0640:
0641:                    table = utils.getTable(responses[1], 4);
0642:                    // Name                 AlarmRecord
0643:                    assertEquals("It is not the name of the EntityBean. ",
0644:                            "AlarmRecord", table.getTableCell(0, 2).getText());
0645:                    // File                 .../alarm.jar
0646:                    assertTrue("It is not the file of the EntityBean. ", table
0647:                            .getTableCell(1, 2).getText().endsWith("alarm.jar"));
0648:
0649:                    // Naming and Classes
0650:                    table = utils.getTable(responses[1], 7);
0651:                    // EJB class            org.objectweb.alarm.beans.AlarmRecordBean
0652:                    assertEquals("It is not the EJB class of the EntityBean. ",
0653:                            "org.objectweb.alarm.beans.AlarmRecordBean", table
0654:                                    .getTableCell(0, 2).getText());
0655:                    // EJB JNDI Name        alarmrecord
0656:                    assertEquals(
0657:                            "It is not the EJB JNDI Name of the EntityBean. ",
0658:                            "alarmrecord", table.getTableCell(1, 2).getText());
0659:                    // EJB HomeClass        org.objectweb.alarm.beans.AlarmRecordHome
0660:                    assertEquals(
0661:                            "It is not the EJB HomeClass of the EntityBean. ",
0662:                            "org.objectweb.alarm.beans.AlarmRecordHome", table
0663:                                    .getTableCell(2, 2).getText());
0664:                    // EJB RemoteClass      org.objectweb.alarm.beans.AlarmRecord
0665:                    assertEquals(
0666:                            "It is not the EJB RemoteClass of the EntityBean. ",
0667:                            "org.objectweb.alarm.beans.AlarmRecord", table
0668:                                    .getTableCell(3, 2).getText());
0669:                    // EJB LocalHomeClass
0670:                    assertEquals(
0671:                            "It is not the EJB LocalHomeClass of the EntityBean. ",
0672:                            "", table.getTableCell(4, 2).getText());
0673:                    // EJB LocalClass
0674:                    assertEquals(
0675:                            "It is not the EJB LocalClass of the EntityBean. ",
0676:                            "", table.getTableCell(5, 2).getText());
0677:
0678:                    // Entity Configuration
0679:                    table = utils.getTable(responses[1], 10);
0680:                    // Persistency              Container-Managed   Type of Persistency (CMP/BMP)
0681:                    assertEquals(
0682:                            "It is not the persistency of the EntityBean. ",
0683:                            "Container-Managed", table.getTableCell(0, 2)
0684:                                    .getText());
0685:                    // Passivation Timeout      0   Value in seconds
0686:                    assertEquals(
0687:                            "It is not the passivation timeout of the EntityBean. ",
0688:                            "0", table.getTableCell(1, 2).getText());
0689:                    // Inactivity Timeout       0   Maximum time of inactivity (in sec.) before freeing objects
0690:                    assertEquals(
0691:                            "It is not the inactivity timeout of the EntityBean. ",
0692:                            "0", table.getTableCell(2, 2).getText());
0693:                    // Lock Policy              container-serialized    one among CS/CRC/CRU/DB
0694:                    assertEquals(
0695:                            "It is not the lock policy of the EntityBean. ",
0696:                            "container-serialized", table.getTableCell(3, 2)
0697:                                    .getText());
0698:                    // Shared                   false   True if bean accessed outside this ejb server.
0699:                    assertEquals(
0700:                            "It is not the shared value of the EntityBean. ",
0701:                            "false", table.getTableCell(4, 2).getText());
0702:                    // Prefetch                 false   True if prefetch optimization wanted.
0703:                    assertEquals(
0704:                            "It is not the prefetch value of the EntityBean. ",
0705:                            "false", table.getTableCell(5, 2).getText());
0706:                    // HardLimit                false   True if hard limit optimization wanted.
0707:                    assertEquals(
0708:                            "It is not the hard limit value of the EntityBean. ",
0709:                            "false", table.getTableCell(6, 2).getText());
0710:                    // Initial Pool size        0   Nb of instances preallocated
0711:                    assertEquals(
0712:                            "It is not the initial pool size of the EntityBean. ",
0713:                            "0", table.getTableCell(7, 2).getText());
0714:                    // Max number of instances  20  Max nb of instances in memory
0715:                    assertEquals(
0716:                            "It is not the max number of instances of the EntityBean. ",
0717:                            "20", table.getTableCell(8, 2).getText());
0718:
0719:                    // Memory Management
0720:                    int currentPoolSize;
0721:                    int usedInTX;
0722:                    int usedOutsideTX;
0723:                    int unusedButReady;
0724:                    int markedRemoved;
0725:                    int currentNbInstances;
0726:                    int pkNumber;
0727:                    int passivated;
0728:                    int total;
0729:                    // Create instances
0730:                    createInstances();
0731:                    // Synchronize
0732:                    link = responses[1].getFirstMatchingLink(
0733:                            WebLink.MATCH_URL_STRING,
0734:                            URL_JONASADMIN_SYNCHRONIZE);
0735:                    link.click();
0736:                    responses[1] = wc.getFrameContents(FRAME_CONTENT);
0737:                    table = utils.getTable(responses[1], 13);
0738:                    currentPoolSize = Integer.parseInt(table.getTableCell(0, 2)
0739:                            .getText());
0740:                    usedInTX = Integer.parseInt(table.getTableCell(1, 2)
0741:                            .getText());
0742:                    usedOutsideTX = Integer.parseInt(table.getTableCell(2, 2)
0743:                            .getText());
0744:                    unusedButReady = Integer.parseInt(table.getTableCell(3, 2)
0745:                            .getText());
0746:                    markedRemoved = Integer.parseInt(table.getTableCell(4, 2)
0747:                            .getText());
0748:                    currentNbInstances = Integer.parseInt(table.getTableCell(5,
0749:                            2).getText());
0750:                    pkNumber = Integer.parseInt(table.getTableCell(6, 2)
0751:                            .getText());
0752:                    passivated = Integer.parseInt(table.getTableCell(7, 2)
0753:                            .getText());
0754:                    total = currentPoolSize + usedInTX + usedOutsideTX
0755:                            + unusedButReady + markedRemoved;
0756:                    // Current number of instances
0757:                    assertEquals(
0758:                            "The current number of instances doesn't correspond to the sum of instances. ",
0759:                            total, currentNbInstances);
0760:                    assertEquals("It is not the current number of instances. ",
0761:                            getAlarmRecordCurrentNbInstances(),
0762:                            currentNbInstances);
0763:                    assertEquals("The number of passivated instances is not '"
0764:                            + getAlarmRecordPassivatedInstances() + "' . ",
0765:                            getAlarmRecordPassivatedInstances(), passivated);
0766:                    assertEquals("The number of PK is not '"
0767:                            + getAlarmRecordPkNumber() + "' . ",
0768:                            getAlarmRecordPkNumber(), pkNumber);
0769:                    // Reduce
0770:                    link = responses[1].getFirstMatchingLink(
0771:                            WebLink.MATCH_URL_STRING, URL_JONASADMIN_REDUCE);
0772:                    link.click();
0773:                    // Here we should verify that Reduce instances worked.
0774:                    // This test is done currently in testEntityBeanReduceInstances method.
0775:
0776:                    // Verify tabs
0777:                    tabTable = utils.getTabTable(responses[1]);
0778:                    if (isDatabaseService()) {
0779:                        testTabs(tabTable, NUMBER_OF_TABS_FOR_ENTITY_DBM,
0780:                                selectedTab, "Problem in 'AlarmRecord' tab.");
0781:                        assertTrue("The link " + URL_JONASADMIN_DEPENDENCIES
0782:                                + " is not found in the sixth tab. ", tabTable
0783:                                .getTableCell(0, 10).getLinks()[0]
0784:                                .getURLString().endsWith(
0785:                                        URL_JONASADMIN_DEPENDENCIES));
0786:                    } else {
0787:                        testTabs(tabTable, NUMBER_OF_TABS_FOR_ENTITY_RAR,
0788:                                selectedTab, "Problem in 'AlarmRecord' tab.");
0789:                    }
0790:                    // - links
0791:                    assertTrue("The link " + URL_JONASADMIN_EJB_CONTAINER
0792:                            + " is not found in the first tab. ", tabTable
0793:                            .getTableCell(0, 0).getLinks()[0].getURLString()
0794:                            .endsWith(URL_JONASADMIN_EJB_CONTAINER));
0795:                    assertTrue("The link " + URL_JONASADMIN_CONTAINER
0796:                            + " is not found in the second tab. ", tabTable
0797:                            .getTableCell(0, 2).getLinks()[0].getURLString()
0798:                            .endsWith(URL_JONASADMIN_CONTAINER));
0799:                    assertTrue("The link " + URL_JONASADMIN_STATISTICS
0800:                            + " is not found in the third tab. ", tabTable
0801:                            .getTableCell(0, 4).getLinks()[0].getURLString()
0802:                            .endsWith(URL_JONASADMIN_STATISTICS));
0803:                    assertTrue("The link " + URL_JONASADMIN_VIEW_EJB
0804:                            + " is not found in the fourth tab. ", tabTable
0805:                            .getTableCell(0, 6).getLinks()[0].getURLString()
0806:                            .endsWith(URL_JONASADMIN_VIEW_EJB));
0807:
0808:                    if (isDatabaseService()) {
0809:                        // dbm started, check for dependency
0810:                        link = responses[1].getFirstMatchingLink(
0811:                                WebLink.MATCH_URL_STRING,
0812:                                URL_JONASADMIN_DEPENDENCIES);
0813:                        link.click();
0814:                        responses[1] = wc.getFrameContents(FRAME_CONTENT);
0815:                        selectedTab = 6;
0816:
0817:                        // Datasource
0818:                        table = utils.getTable(responses[1], 0);
0819:                        assertEquals(
0820:                                "The title of table is not 'Datasource'. ",
0821:                                "Datasource", table.getTableCell(0, 0)
0822:                                        .getText());
0823:                        // jdbc_1       postgres
0824:                        table = utils.getTable(responses[1], 1);
0825:                        assertEquals("It is not 'jdbc_1'. ", "jdbc_1", table
0826:                                .getTableCell(0, 0).getText());
0827:                        // Here check getDataSourceName() maybe no datasource deployed ...
0828:                        String datasourceName = getDataSourceName();
0829:                        if (datasourceName != null) {
0830:                            assertEquals("The datasource is not '"
0831:                                    + getDataSourceName() + "'. ",
0832:                                    getDataSourceName(), table.getTableCell(0,
0833:                                            2).getText());
0834:                            link = table.getTableCell(0, 2).getLinks()[0];
0835:                            assertTrue("It is not the correct URL. ", link
0836:                                    .getURLString().endsWith(
0837:                                            "EditDatasource.do?name="
0838:                                                    + datasourceName));
0839:                            assertEquals("The link is not correct. ", 200, wc
0840:                                    .sendRequest(link.getRequest())
0841:                                    .getResponseCode());
0842:                            // Verify tabs
0843:                            tabTable = utils.getTabTable(responses[1]);
0844:                            testTabs(tabTable, NUMBER_OF_TABS_FOR_MDB,
0845:                                    selectedTab, "Problem in 'Dependency' tab.");
0846:                            // - links
0847:                            assertTrue(
0848:                                    "The link "
0849:                                            + URL_JONASADMIN_EJB_CONTAINER
0850:                                            + " is not found in the first tab. ",
0851:                                    tabTable.getTableCell(0, 0).getLinks()[0]
0852:                                            .getURLString()
0853:                                            .endsWith(
0854:                                                    URL_JONASADMIN_EJB_CONTAINER));
0855:                            assertTrue("The link " + URL_JONASADMIN_CONTAINER
0856:                                    + " is not found in the second tab. ",
0857:                                    tabTable.getTableCell(0, 2).getLinks()[0]
0858:                                            .getURLString().endsWith(
0859:                                                    URL_JONASADMIN_CONTAINER));
0860:                            assertTrue("The link " + URL_JONASADMIN_STATISTICS
0861:                                    + " is not found in the third tab. ",
0862:                                    tabTable.getTableCell(0, 4).getLinks()[0]
0863:                                            .getURLString().endsWith(
0864:                                                    URL_JONASADMIN_STATISTICS));
0865:                            assertTrue("The link " + URL_JONASADMIN_VIEW_EJB
0866:                                    + " is not found in the fourth tab. ",
0867:                                    tabTable.getTableCell(0, 6).getLinks()[0]
0868:                                            .getURLString().endsWith(
0869:                                                    URL_JONASADMIN_VIEW_EJB));
0870:                            assertTrue("The link " + URL_JONASADMIN_EB
0871:                                    + " is not found in the fifth tab. ",
0872:                                    tabTable.getTableCell(0, 8).getLinks()[0]
0873:                                            .getURLString().endsWith(
0874:                                                    URL_JONASADMIN_EB));
0875:                        }
0876:                    }
0877:                }
0878:            }
0879:
0880:            /**
0881:             * Test the entity bean management - reduce instances function
0882:             * @throws Exception if error occurs
0883:             */
0884:            public void testEntityBeanReduceInstances() throws Exception {
0885:
0886:                WebResponse wr;
0887:                WebLink link;
0888:                WebTable table;
0889:                WebTable tabTable;
0890:                TableCell selectedCell;
0891:                TableCell cell;
0892:                String ear = "alarm";
0893:                int selectedTab;
0894:                JonasAdminUtils utils = new JonasAdminUtils();
0895:
0896:                // Disable errors of javascript
0897:                HttpUnitOptions.setExceptionsThrownOnScriptError(false);
0898:                // Disable exception thrown on error status
0899:                HttpUnitOptions.setExceptionsThrownOnErrorStatus(false);
0900:
0901:                if (jProp.isEar() && jProp.isEjb()) {
0902:                    // Add alarm.ear
0903:                    useEar(ear);
0904:
0905:                    // Go to ejb container
0906:                    wr = wc.getFrameContents(FRAME_TREE);
0907:                    link = wr.getFirstMatchingLink(WebLink.MATCH_URL_STRING,
0908:                            URL_JONASADMIN_EJB_CONTAINER);
0909:                    link.click();
0910:                    wr = wc.getFrameContents(FRAME_CONTENT);
0911:
0912:                    // Go to alarm.jar page
0913:                    link = wr.getFirstMatchingLink(WebLink.MATCH_URL_STRING,
0914:                            ear);
0915:                    link.click();
0916:                    wr = wc.getFrameContents(FRAME_CONTENT);
0917:                    selectedTab = 2;
0918:
0919:                    // Go to the Ejb tab
0920:                    link = wr.getFirstMatchingLink(WebLink.MATCH_URL_STRING,
0921:                            URL_JONASADMIN_VIEW_EJB);
0922:                    link.click();
0923:                    wr = wc.getFrameContents(FRAME_CONTENT);
0924:                    selectedTab = 4;
0925:
0926:                    table = utils.getTable(wr, 0);
0927:
0928:                    // Get links
0929:                    int nbLink = table.getRowCount() - 1;
0930:                    WebLink[] links = new WebLink[nbLink];
0931:                    WebResponse[] responses = new WebResponse[nbLink];
0932:                    for (int i = 0; i < nbLink; i++) {
0933:                        links[i] = table.getTableCell(i + 1, 0).getLinks()[0];
0934:                    }
0935:
0936:                    // Verify the EntityBean: AlarmRecord
0937:                    links[1].click();
0938:                    responses[1] = wc.getFrameContents(FRAME_CONTENT);
0939:
0940:                    selectedTab = 5;
0941:                    // EntityBean
0942:                    table = utils.getTable(responses[1], 3);
0943:                    assertEquals("The title of table is not 'EntityBean'. ",
0944:                            "EntityBean", table.getTableCell(0, 0).getText());
0945:
0946:                    table = utils.getTable(responses[1], 4);
0947:                    // Name                 AlarmRecord
0948:                    assertEquals("It is not the name of the EntityBean. ",
0949:                            "AlarmRecord", table.getTableCell(0, 2).getText());
0950:                    // File                 .../alarm.jar
0951:                    assertTrue("It is not the file of the EntityBean. ", table
0952:                            .getTableCell(1, 2).getText().endsWith("alarm.jar"));
0953:
0954:                    // Memory Management
0955:                    int unusedButReady;
0956:                    int currentNbInstances;
0957:                    int passivated;
0958:                    // Create instances
0959:                    createInstances();
0960:                    // Synchronize
0961:                    link = responses[1].getFirstMatchingLink(
0962:                            WebLink.MATCH_URL_STRING,
0963:                            URL_JONASADMIN_SYNCHRONIZE);
0964:                    link.click();
0965:                    responses[1] = wc.getFrameContents(FRAME_CONTENT);
0966:                    table = utils.getTable(responses[1], 13);
0967:                    unusedButReady = Integer.parseInt(table.getTableCell(3, 2)
0968:                            .getText());
0969:                    currentNbInstances = Integer.parseInt(table.getTableCell(5,
0970:                            2).getText());
0971:                    passivated = Integer.parseInt(table.getTableCell(7, 2)
0972:                            .getText());
0973:                    if (unusedButReady == 0) {
0974:                        // there is nothing to reduce
0975:                        return;
0976:                    }
0977:                    // Reduce
0978:                    link = responses[1].getFirstMatchingLink(
0979:                            WebLink.MATCH_URL_STRING, URL_JONASADMIN_REDUCE);
0980:                    link.click();
0981:                    responses[1] = wc.getFrameContents(FRAME_CONTENT);
0982:                    table = utils.getTable(responses[1], 13);
0983:                    // Current number of instances is less big than previous number of instances
0984:                    int previousNbInstances = currentNbInstances;
0985:                    assertTrue(
0986:                            "The number of instances doesn't decrease when reduce button is clicked. ",
0987:                            previousNbInstances > currentNbInstances);
0988:                    currentNbInstances = Integer.parseInt(table.getTableCell(5,
0989:                            2).getText());
0990:                    passivated = Integer.parseInt(table.getTableCell(7, 2)
0991:                            .getText());
0992:                    assertTrue(
0993:                            "The number of passivated instances is not positif. ",
0994:                            passivated > 0);
0995:                }
0996:            }
0997:
0998:            /**
0999:             * Test the stateful session bean management
1000:             * @throws Exception if error occurs
1001:             */
1002:            public void testStatefulSessionBean() throws Exception {
1003:
1004:                WebResponse wr;
1005:                WebLink link;
1006:                WebTable table;
1007:                WebTable tabTable;
1008:                TableCell selectedCell;
1009:                TableCell cell;
1010:                String ear = "alarm";
1011:                int selectedTab;
1012:                JonasAdminUtils utils = new JonasAdminUtils();
1013:
1014:                // Disable errors of javascript
1015:                HttpUnitOptions.setExceptionsThrownOnScriptError(false);
1016:                // Disable exception thrown on error status
1017:                HttpUnitOptions.setExceptionsThrownOnErrorStatus(false);
1018:
1019:                if (jProp.isEar() && jProp.isEjb()) {
1020:                    // Add alarm.ear
1021:                    useEar(ear);
1022:
1023:                    // Go to ejb container
1024:                    wr = wc.getFrameContents(FRAME_TREE);
1025:                    link = wr.getFirstMatchingLink(WebLink.MATCH_URL_STRING,
1026:                            URL_JONASADMIN_EJB_CONTAINER);
1027:                    link.click();
1028:                    wr = wc.getFrameContents(FRAME_CONTENT);
1029:
1030:                    // Go to alarm.jar page
1031:                    link = wr.getFirstMatchingLink(WebLink.MATCH_URL_STRING,
1032:                            ear);
1033:                    link.click();
1034:                    wr = wc.getFrameContents(FRAME_CONTENT);
1035:                    selectedTab = 2;
1036:
1037:                    // Go to the Ejb tab
1038:                    link = wr.getFirstMatchingLink(WebLink.MATCH_URL_STRING,
1039:                            URL_JONASADMIN_VIEW_EJB);
1040:                    link.click();
1041:                    wr = wc.getFrameContents(FRAME_CONTENT);
1042:                    selectedTab = 4;
1043:
1044:                    table = utils.getTable(wr, 0);
1045:
1046:                    // Get links
1047:                    int nbLink = table.getRowCount() - 1;
1048:                    WebLink[] links = new WebLink[nbLink];
1049:                    WebResponse[] responses = new WebResponse[nbLink];
1050:                    for (int i = 0; i < nbLink; i++) {
1051:                        links[i] = table.getTableCell(i + 1, 0).getLinks()[0];
1052:                    }
1053:
1054:                    /*
1055:                     * Verify the StatefulSessionBean: View
1056:                     */
1057:                    links[2].click();
1058:                    responses[2] = wc.getFrameContents(FRAME_CONTENT);
1059:                    selectedTab = 5;
1060:                    // StatefulSessionBean
1061:                    table = utils.getTable(responses[2], 0);
1062:                    assertEquals(
1063:                            "The title of table is not 'StatefulSessionBean'. ",
1064:                            "StatefulSessionBean", table.getTableCell(0, 0)
1065:                                    .getText());
1066:
1067:                    table = utils.getTable(responses[2], 1);
1068:                    // Name                 AlarmListener
1069:                    assertEquals(
1070:                            "It is not the name of the StatefulSessionBean. ",
1071:                            "View", table.getTableCell(0, 2).getText());
1072:                    // File                 .../alarm.jar
1073:                    assertTrue(
1074:                            "It is not the file of the StatefulSessionBean. ",
1075:                            table.getTableCell(1, 2).getText().endsWith(
1076:                                    "alarm.jar"));
1077:
1078:                    // Naming and Classes
1079:                    table = utils.getTable(responses[2], 4);
1080:                    // EJB class            org.objectweb.alarm.beans.ViewBean
1081:                    assertEquals(
1082:                            "It is not the EJB class of the StatefulSessionBean. ",
1083:                            "org.objectweb.alarm.beans.ViewBean", table
1084:                                    .getTableCell(0, 2).getText());
1085:                    // EJB JNDI Name        viewhome
1086:                    assertEquals(
1087:                            "It is not the EJB JNDI Name of the StatefulSessionBean. ",
1088:                            "viewhome", table.getTableCell(1, 2).getText());
1089:                    // EJB HomeClass        org.objectweb.alarm.beans.ViewHome
1090:                    assertEquals(
1091:                            "It is not the EJB HomeClass of the StatefulSessionBean. ",
1092:                            "org.objectweb.alarm.beans.ViewHome", table
1093:                                    .getTableCell(2, 2).getText());
1094:                    // EJB RemoteClass      org.objectweb.alarm.beans.View
1095:                    assertEquals(
1096:                            "It is not the EJB RemoteClass of the StatefulSessionBean. ",
1097:                            "org.objectweb.alarm.beans.View", table
1098:                                    .getTableCell(3, 2).getText());
1099:                    // EJB LocalHomeClass
1100:                    assertEquals(
1101:                            "It is not the EJB LocalHomeClass of the StatefulSessionBean. ",
1102:                            "", table.getTableCell(4, 2).getText());
1103:                    // EJB LocalClass
1104:                    assertEquals(
1105:                            "It is not the EJB LocalClass of the StatefulSessionBean. ",
1106:                            "", table.getTableCell(5, 2).getText());
1107:
1108:                    // Session Configuration
1109:                    WebForm form = responses[2].getForms()[0];
1110:                    // sessionTimeOut = 0
1111:                    form.setParameter("sessionTimeOut", "0");
1112:                    responses[2] = form.submit();
1113:                    form = responses[2].getForms()[0];
1114:                    assertTrue(
1115:                            "The value of sessionTimeOut is not 'no limit'/'pas de limite'. ",
1116:                            form.getParameterValue("sessionTimeOut").indexOf(
1117:                                    "limit") != -1);
1118:                    // sessionTimeOut = 10
1119:                    form.setParameter("sessionTimeOut", "10");
1120:                    responses[2] = form.submit();
1121:                    form = responses[2].getForms()[0];
1122:                    assertEquals("The value of sessionTimeOut is not '10'. ",
1123:                            "10", form.getParameterValue("sessionTimeOut"));
1124:                    // empty
1125:                    form.setParameter("sessionTimeOut", "");
1126:                    responses[2] = form.submit();
1127:                    form = responses[2].getForms()[0];
1128:                    table = utils.getTable(responses[2], 0);
1129:                    cell = table.getTableCell(0, 0);
1130:                    assertEquals("There is not an error. ", "errors", cell
1131:                            .getAttribute("class"));
1132:                    assertEquals(
1133:                            "The message is not 'Session timeout cannot be empty'. ",
1134:                            "Session timeout cannot be empty", cell.getText());
1135:                    // not a valid integer
1136:                    form.setParameter("sessionTimeOut", "10.5");
1137:                    responses[2] = form.submit();
1138:                    form = responses[2].getForms()[0];
1139:                    table = utils.getTable(responses[2], 0);
1140:                    cell = table.getTableCell(0, 0);
1141:                    assertEquals("There is not an error. ", "errors", cell
1142:                            .getAttribute("class"));
1143:                    assertEquals(
1144:                            "The message is not 'Session timeout not a valid integer !'. ",
1145:                            "Session timeout not a valid integer !", cell
1146:                                    .getText());
1147:                    // negative value
1148:                    form.setParameter("sessionTimeOut", "-1");
1149:                    responses[2] = form.submit();
1150:                    table = utils.getTable(responses[2], 0);
1151:                    cell = table.getTableCell(0, 0);
1152:                    assertEquals("There is not an error. ", "errors", cell
1153:                            .getAttribute("class"));
1154:                    assertFalse(
1155:                            "An error was found but there is no text for a negative value for 'Current session TimeOut'. ",
1156:                            cell.getText().equals(""));
1157:                }
1158:            }
1159:
1160:            /**
1161:             * Test the stateless session bean management
1162:             * @throws Exception if error occurs
1163:             */
1164:            public void testStatelessSessionBean() throws Exception {
1165:
1166:                WebResponse wr;
1167:                WebLink link;
1168:                WebTable table;
1169:                WebTable tabTable;
1170:                TableCell selectedCell;
1171:                TableCell cell;
1172:                String ear = "olstore";
1173:                int selectedTab;
1174:                JonasAdminUtils utils = new JonasAdminUtils();
1175:
1176:                // Disable errors of javascript
1177:                HttpUnitOptions.setExceptionsThrownOnScriptError(false);
1178:                // Disable exception thrown on error status
1179:                HttpUnitOptions.setExceptionsThrownOnErrorStatus(false);
1180:
1181:                if (jProp.isEar() && jProp.isEjb()) {
1182:                    // Add olstore.ear
1183:                    useEar(ear);
1184:
1185:                    // Go to ejb container
1186:                    wr = wc.getFrameContents(FRAME_TREE);
1187:                    link = wr.getFirstMatchingLink(WebLink.MATCH_URL_STRING,
1188:                            URL_JONASADMIN_EJB_CONTAINER);
1189:                    link.click();
1190:                    wr = wc.getFrameContents(FRAME_CONTENT);
1191:
1192:                    // Go to olstoreejb.jar page
1193:                    link = wr.getFirstMatchingLink(WebLink.MATCH_URL_STRING,
1194:                            ear);
1195:                    link.click();
1196:                    wr = wc.getFrameContents(FRAME_CONTENT);
1197:                    selectedTab = 2;
1198:
1199:                    // Go to the Ejb tab
1200:                    link = wr.getFirstMatchingLink(WebLink.MATCH_URL_STRING,
1201:                            URL_JONASADMIN_VIEW_EJB);
1202:                    link.click();
1203:                    wr = wc.getFrameContents(FRAME_CONTENT);
1204:                    selectedTab = 4;
1205:
1206:                    table = utils.getTable(wr, 0);
1207:
1208:                    // Get a link to a StatelessSessionBean
1209:                    int rowLastStatelessSB = utils.getRow(
1210:                            "StatelessSessionBean", table, 2).intValue();
1211:                    if (rowLastStatelessSB == -1) {
1212:                        fail("No Stateless Session Bean found for the ear '"
1213:                                + ear + "'. ");
1214:                    }
1215:                    String sbName = table.getTableCell(rowLastStatelessSB, 0)
1216:                            .getText();
1217:                    link = table.getTableCell(rowLastStatelessSB, 0).getLinks()[0];
1218:                    if (link == null) {
1219:                        fail("No link found for the StatelessSessionBean '"
1220:                                + sbName + "'. ");
1221:                    }
1222:
1223:                    /*
1224:                     * verify the StatelessSessionBean
1225:                     */
1226:                    link.click();
1227:                    wr = wc.getFrameContents(FRAME_CONTENT);
1228:                    selectedTab = 5;
1229:                    // StatelessSessionBean
1230:                    table = utils.getTable(wr, 0);
1231:                    assertEquals(
1232:                            "The title of table is not 'StatelessSessionBean'. ",
1233:                            "StatelessSessionBean", table.getTableCell(0, 0)
1234:                                    .getText());
1235:
1236:                    table = utils.getTable(wr, 1);
1237:                    // Name                 UserHelper
1238:                    assertEquals(
1239:                            "It is not the name of the StatelessSessionBean. ",
1240:                            sbName, table.getTableCell(0, 2).getText());
1241:                    // File                 .../olstoreejb.jar
1242:                    assertTrue(
1243:                            "It is not the file of the StatelessSessionBean. ",
1244:                            table.getTableCell(1, 2).getText().endsWith(
1245:                                    "olstoreejb.jar"));
1246:
1247:                    // Naming and Classes
1248:                    String ejbClass = getStatelessSBClassName(sbName,
1249:                            "ejbClass");
1250:                    if (ejbClass == null) {
1251:                        ejbClass = "";
1252:                    }
1253:                    String jndiName = getStatelessSBClassName(sbName,
1254:                            "jndiName");
1255:                    if (jndiName == null) {
1256:                        jndiName = "";
1257:                    }
1258:                    String homeClass = getStatelessSBClassName(sbName,
1259:                            "homeClass");
1260:                    if (homeClass == null) {
1261:                        homeClass = "";
1262:                    }
1263:                    String remoteClass = getStatelessSBClassName(sbName,
1264:                            "remoteClass");
1265:                    if (remoteClass == null) {
1266:                        remoteClass = "";
1267:                    }
1268:                    String localHomeClass = getStatelessSBClassName(sbName,
1269:                            "localHomeClass");
1270:                    if (localHomeClass == null) {
1271:                        localHomeClass = "";
1272:                    }
1273:                    String localClass = getStatelessSBClassName(sbName,
1274:                            "localClass");
1275:                    if (localClass == null) {
1276:                        localClass = "";
1277:                    }
1278:                    table = utils.getTable(wr, 4);
1279:                    // EJB class            olstore.session.helper.UserHelperSession
1280:                    assertEquals(
1281:                            "It is not the EJB class of the StatelessSessionBean. ",
1282:                            ejbClass, table.getTableCell(0, 2).getText());
1283:                    // EJB JNDI Name        UserHelperLocal
1284:                    assertEquals(
1285:                            "It is not the EJB JNDI Name of the StatelessSessionBean. ",
1286:                            jndiName, table.getTableCell(1, 2).getText());
1287:                    // EJB HomeClass
1288:                    assertEquals(
1289:                            "It is not the EJB HomeClass of the StatelessSessionBean. ",
1290:                            homeClass, table.getTableCell(2, 2).getText());
1291:                    // EJB RemoteClass
1292:                    assertEquals(
1293:                            "It is not the EJB RemoteClass of the StatelessSessionBean. ",
1294:                            remoteClass, table.getTableCell(3, 2).getText());
1295:                    // EJB LocalHomeClass   olstore.session.helper.UserHelperLocalHome
1296:                    assertEquals(
1297:                            "It is not the EJB LocalHomeClass of the StatelessSessionBean. ",
1298:                            localHomeClass, table.getTableCell(4, 2).getText());
1299:                    // EJB LocalClass       olstore.session.helper.UserHelperLocal
1300:                    assertEquals(
1301:                            "It is not the EJB LocalClass of the StatelessSessionBean. ",
1302:                            localClass, table.getTableCell(5, 2).getText());
1303:
1304:                    // Instances
1305:                    int poolSize = getStatelessSBInstance(sbName, "poolSize");
1306:                    int cacheSize = getStatelessSBInstance(sbName, "cacheSize");
1307:                    table = utils.getTable(wr, 7);
1308:                    //
1309:                    assertEquals(
1310:                            "It is not the correct Pool size of the StatelessSessionBean. ",
1311:                            "" + poolSize, table.getTableCell(0, 2).getText());
1312:                    assertEquals(
1313:                            "It is not the correct Cache size of the StatelessSessionBean. ",
1314:                            "" + cacheSize, table.getTableCell(1, 2).getText());
1315:
1316:                    // Session Configuration
1317:                    int minPoolSize = getStatelessSBInstance(sbName,
1318:                            "minPoolSize");
1319:                    int maxCacheSize = getStatelessSBInstance(sbName,
1320:                            "maxCacheSize");
1321:                    table = utils.getTable(wr, 10);
1322:                    assertEquals(
1323:                            "It is not the correct Min Pool size of the StatelessSessionBean. ",
1324:                            "" + minPoolSize, table.getTableCell(0, 2)
1325:                                    .getText());
1326:                    assertEquals(
1327:                            "It is not the correct Max Cache size of the StatelessSessionBean. ",
1328:                            "" + maxCacheSize, table.getTableCell(1, 2)
1329:                                    .getText());
1330:
1331:                    WebForm form = wr.getForms()[0];
1332:                    // sessionTimeOut = 0
1333:                    form.setParameter("sessionTimeOut", "0");
1334:                    wr = form.submit();
1335:                    form = wr.getForms()[0];
1336:                    assertTrue(
1337:                            "The value of sessionTimeOut is not 'no limit'/'pas de limite'. ",
1338:                            form.getParameterValue("sessionTimeOut").indexOf(
1339:                                    "limit") != -1);
1340:                    // sessionTimeOut = 10
1341:                    form.setParameter("sessionTimeOut", "10");
1342:                    wr = form.submit();
1343:                    form = wr.getForms()[0];
1344:                    assertEquals("The value of sessionTimeOut is not '10'. ",
1345:                            "10", form.getParameterValue("sessionTimeOut"));
1346:                    // empty
1347:                    form.setParameter("sessionTimeOut", "");
1348:                    wr = form.submit();
1349:                    form = wr.getForms()[0];
1350:                    table = utils.getTable(wr, 0);
1351:                    cell = table.getTableCell(0, 0);
1352:                    assertEquals("There is not an error. ", "errors", cell
1353:                            .getAttribute("class"));
1354:                    assertEquals(
1355:                            "The message is not 'Session timeout cannot be empty'. ",
1356:                            "Session timeout cannot be empty", cell.getText());
1357:                    // not a valid integer
1358:                    form.setParameter("sessionTimeOut", "10.5");
1359:                    wr = form.submit();
1360:                    form = wr.getForms()[0];
1361:                    table = utils.getTable(wr, 0);
1362:                    cell = table.getTableCell(0, 0);
1363:                    assertEquals("There is not an error. ", "errors", cell
1364:                            .getAttribute("class"));
1365:                    assertEquals(
1366:                            "The message is not 'Session timeout not a valid integer !'. ",
1367:                            "Session timeout not a valid integer !", cell
1368:                                    .getText());
1369:                    // negative value
1370:                    form.setParameter("sessionTimeOut", "-1");
1371:                    wr = form.submit();
1372:                    table = utils.getTable(wr, 0);
1373:                    cell = table.getTableCell(0, 0);
1374:                    assertEquals("There is not an error. ", "errors", cell
1375:                            .getAttribute("class"));
1376:                    assertFalse(
1377:                            "An error was found but there is no text for a negative value for 'Current session TimeOut'. ",
1378:                            cell.getText().equals(""));
1379:                }
1380:
1381:            }
1382:
1383:            /**
1384:             * Test statistic
1385:             * @throws Exception if error occurs
1386:             *
1387:             */
1388:            public void testStatistics() throws Exception {
1389:
1390:                WebResponse wr;
1391:                WebLink link;
1392:                WebTable table;
1393:                WebTable tabTable;
1394:                TableCell selectedCell;
1395:                TableCell cell;
1396:                String ear = "alarm";
1397:                JonasAdminUtils utils = new JonasAdminUtils();
1398:
1399:                // Disable errors of javascript
1400:                HttpUnitOptions.setExceptionsThrownOnScriptError(false);
1401:                // Disable exception thrown on error status
1402:                HttpUnitOptions.setExceptionsThrownOnErrorStatus(false);
1403:
1404:                if (jProp.isEar() && jProp.isEjb()) {
1405:                    // Add alarm.ear
1406:                    useEar(ear);
1407:
1408:                    // Go to ejb container
1409:                    wr = wc.getFrameContents(FRAME_TREE);
1410:                    link = wr.getFirstMatchingLink(WebLink.MATCH_URL_STRING,
1411:                            URL_JONASADMIN_EJB_CONTAINER);
1412:                    link.click();
1413:                    wr = wc.getFrameContents(FRAME_CONTENT);
1414:
1415:                    // Get jar Links
1416:                    table = utils.getTable(wr, 0);
1417:                    int nbLink = table.getRowCount() - 1;
1418:                    WebLink[] links = new WebLink[nbLink];
1419:                    WebResponse[] responses = new WebResponse[nbLink];
1420:                    WebTable tableStat;
1421:                    int[] jarBMP = new int[nbLink];
1422:                    int[] jarCMP = new int[nbLink];
1423:                    int[] jarStateful = new int[nbLink];
1424:                    int[] jarStateless = new int[nbLink];
1425:                    int[] jarMDB = new int[nbLink];
1426:                    int[] jarTotal = new int[nbLink];
1427:
1428:                    int totalBMP = 0;
1429:                    int totalCMP = 0;
1430:                    int totalStateful = 0;
1431:                    int totalStateless = 0;
1432:                    int totalMDB = 0;
1433:                    int totalTotal = 0;
1434:
1435:                    int allBMP;
1436:                    int allCMP;
1437:                    int allStateful;
1438:                    int allStateless;
1439:                    int allMDB;
1440:                    int allTotal;
1441:
1442:                    // Go to statistics
1443:                    link = wr.getFirstMatchingLink(WebLink.MATCH_URL_STRING,
1444:                            URL_JONASADMIN_CONTAINERS_STATISTICS);
1445:                    link.click();
1446:                    wr = wc.getFrameContents(FRAME_CONTENT);
1447:                    tableStat = utils.getTable(wr, 1);
1448:                    allBMP = Integer.parseInt(tableStat.getTableCell(1, 2)
1449:                            .getText());
1450:                    allCMP = Integer.parseInt(tableStat.getTableCell(2, 2)
1451:                            .getText());
1452:                    allStateful = Integer.parseInt(tableStat.getTableCell(3, 2)
1453:                            .getText());
1454:                    allStateless = Integer.parseInt(tableStat
1455:                            .getTableCell(4, 2).getText());
1456:                    allMDB = Integer.parseInt(tableStat.getTableCell(5, 2)
1457:                            .getText());
1458:                    allTotal = Integer.parseInt(tableStat.getTableCell(0, 2)
1459:                            .getText());
1460:                    int total = allBMP + allCMP + allStateful + allStateless
1461:                            + allMDB;
1462:                    assertEquals(
1463:                            "It is not the number of EJBs in all EJB containers. ",
1464:                            total, allTotal);
1465:
1466:                    for (int i = 0; i < nbLink; i++) {
1467:                        links[i] = table.getTableCell(i + 1, 0).getLinks()[0];
1468:                        links[i].click();
1469:                        responses[i] = wc.getFrameContents(FRAME_CONTENT);
1470:
1471:                        // Go to the statistic tab
1472:                        link = responses[i].getFirstMatchingLink(
1473:                                WebLink.MATCH_URL_STRING,
1474:                                URL_JONASADMIN_STATISTICS);
1475:                        link.click();
1476:                        wr = wc.getFrameContents(FRAME_CONTENT);
1477:                        // Verify stats
1478:                        tableStat = utils.getTable(wr, 1);
1479:
1480:                        jarBMP[i] = Integer.parseInt(tableStat.getTableCell(1,
1481:                                2).getText());
1482:                        jarCMP[i] = Integer.parseInt(tableStat.getTableCell(2,
1483:                                2).getText());
1484:                        jarStateful[i] = Integer.parseInt(tableStat
1485:                                .getTableCell(3, 2).getText());
1486:                        jarStateless[i] = Integer.parseInt(tableStat
1487:                                .getTableCell(4, 2).getText());
1488:                        jarMDB[i] = Integer.parseInt(tableStat.getTableCell(5,
1489:                                2).getText());
1490:                        jarTotal[i] = Integer.parseInt(tableStat.getTableCell(
1491:                                0, 2).getText());
1492:                        total = jarBMP[i] + jarCMP[i] + jarStateful[i]
1493:                                + jarStateless[i] + jarMDB[i];
1494:                        assertEquals("It is not the number of EJBs in "
1495:                                + links[i].getText(), total, jarTotal[i]);
1496:
1497:                        tableStat = utils.getTable(wr, 4);
1498:                        int allTmpBMP = Integer.parseInt(tableStat
1499:                                .getTableCell(1, 2).getText());
1500:                        int allTmpCMP = Integer.parseInt(tableStat
1501:                                .getTableCell(2, 2).getText());
1502:                        int allTmpStateful = Integer.parseInt(tableStat
1503:                                .getTableCell(3, 2).getText());
1504:                        int allTmpStateless = Integer.parseInt(tableStat
1505:                                .getTableCell(4, 2).getText());
1506:                        int allTmpMDB = Integer.parseInt(tableStat
1507:                                .getTableCell(5, 2).getText());
1508:                        int allTmpTotal = Integer.parseInt(tableStat
1509:                                .getTableCell(0, 2).getText());
1510:
1511:                        assertEquals(
1512:                                "It is not the number of BMP in all EJB containers for the jar "
1513:                                        + links[i].getText() + ". ", allBMP,
1514:                                allTmpBMP);
1515:                        assertEquals(
1516:                                "It is not the number of CMP in all EJB containers for the jar "
1517:                                        + links[i].getText() + ". ", allCMP,
1518:                                allTmpCMP);
1519:                        assertEquals(
1520:                                "It is not the number of Stateful SB in all EJB containers for the jar "
1521:                                        + links[i].getText() + ". ",
1522:                                allStateful, allTmpStateful);
1523:                        assertEquals(
1524:                                "It is not the number of Stateless SB in all EJB containers for the jar "
1525:                                        + links[i].getText() + ". ",
1526:                                allStateless, allTmpStateless);
1527:                        assertEquals(
1528:                                "It is not the number of MDB in all EJB containers for the jar "
1529:                                        + links[i].getText() + ". ", allMDB,
1530:                                allTmpMDB);
1531:                        assertEquals(
1532:                                "It is not the number of all EJBs in all EJB containers for the jar "
1533:                                        + links[i].getText() + ". ", allTotal,
1534:                                allTmpTotal);
1535:
1536:                        totalBMP += jarBMP[i];
1537:                        totalCMP += jarCMP[i];
1538:                        totalStateful += jarStateful[i];
1539:                        totalStateless += jarStateless[i];
1540:                        totalMDB += jarMDB[i];
1541:                        totalTotal += jarTotal[i];
1542:                    }
1543:
1544:                    assertEquals("It is not the number of all BMPs. ",
1545:                            totalBMP, allBMP);
1546:                    assertEquals("It is not the number of all CMPs. ",
1547:                            totalCMP, allCMP);
1548:                    assertEquals("It is not the number of all stateful SBs. ",
1549:                            totalStateful, allStateful);
1550:                    assertEquals("It is not the number of all stateless SBs. ",
1551:                            totalStateless, allStateless);
1552:                    assertEquals("It is not the number of all MDBs. ",
1553:                            totalMDB, allMDB);
1554:                    assertEquals("It is not the number of all EJBs. ",
1555:                            totalTotal, allTotal);
1556:                }
1557:            }
1558:
1559:            /**
1560:             * Use Alarm Demo for creating instances
1561:             * @throws Exception if an error occurs
1562:             */
1563:            private void createInstances() throws Exception {
1564:                WebConversation wc2 = new WebConversation();
1565:                String urlAlarm = prefixUrl + "/alarm/secured/list.jsp";
1566:                // Start the alarm demo
1567:                wc2.setAuthorization("jonas", "jonas");
1568:                WebResponse wr = wc2.getResponse(urlAlarm);
1569:            }
1570:
1571:            /**
1572:             * Get the current number of instances of Alarm Record
1573:             * @return the current number of instances
1574:             * @throws Exception if an error occurs
1575:             */
1576:            private int getAlarmRecordCurrentNbInstances() throws Exception {
1577:                MBeanServerConnection server = getMBeanServer();
1578:                ObjectName on = ObjectName
1579:                        .getInstance("jonas:j2eeType=EntityBean,name=AlarmRecord,EJBModule=alarm,J2EEApplication=alarm,J2EEServer=jonas");
1580:
1581:                return ((Integer) server.getAttribute(on, "cacheSize"))
1582:                        .intValue();
1583:            }
1584:
1585:            /**
1586:             * Get the current number of instances of Alarm Record
1587:             * @return the current number of instances
1588:             * @throws Exception if an error occurs
1589:             */
1590:            private int getAlarmRecordPassivatedInstances() throws Exception {
1591:                MBeanServerConnection server = getMBeanServer();
1592:                ObjectName on = ObjectName
1593:                        .getInstance("jonas:j2eeType=EntityBean,name=AlarmRecord,EJBModule=alarm,J2EEApplication=alarm,J2EEServer=jonas");
1594:
1595:                Integer[] nbInstanceList = (Integer[]) server.getAttribute(on,
1596:                        "entityCounters");
1597:                return ((Integer) nbInstanceList[3]).intValue();
1598:            }
1599:
1600:            /**
1601:             * Get the pk number for Alarm Record
1602:             * @return the nmber of pk in memory
1603:             * @throws Exception if an error occurs
1604:             */
1605:            private int getAlarmRecordPkNumber() throws Exception {
1606:                MBeanServerConnection server = getMBeanServer();
1607:                ObjectName on = ObjectName
1608:                        .getInstance("jonas:j2eeType=EntityBean,name=AlarmRecord,EJBModule=alarm,J2EEApplication=alarm,J2EEServer=jonas");
1609:
1610:                Integer[] nbInstanceList = (Integer[]) server.getAttribute(on,
1611:                        "entityCounters");
1612:                return ((Integer) nbInstanceList[5]).intValue();
1613:            }
1614:
1615:            /**
1616:             * Get the name of the datasource
1617:             * @return name of the datasource
1618:             * @throws Exception if an error occurs
1619:             */
1620:            private String getDataSourceName() throws Exception {
1621:                String name = null;
1622:                MBeanServerConnection server = getMBeanServer();
1623:                ObjectName on = ObjectName
1624:                        .getInstance("jonas:j2eeType=JDBCDataSource,*");
1625:                Iterator it = server.queryNames(on, null).iterator();
1626:                if (it.hasNext()) {
1627:                    ObjectName jdbcDataSourceON = (ObjectName) it.next();
1628:                    name = (String) server.getAttribute(jdbcDataSourceON,
1629:                            "name");
1630:                }
1631:                return name;
1632:            }
1633:
1634:            /**
1635:             * Get the class name of a StatelessSessionBean
1636:             * @param sbName name of the StatelessSessionBean
1637:             * @param attributName {"ejbClass", "jndiName", "homeClass", "remoteClass", "localHomeClass", "localClass"}
1638:             * @return name of the class
1639:             * @throws Exception if an error occurs
1640:             */
1641:            private String getStatelessSBClassName(String sbName,
1642:                    String attributName) throws Exception {
1643:                MBeanServerConnection server = getMBeanServer();
1644:                ObjectName on = ObjectName
1645:                        .getInstance("jonas:j2eeType=StatelessSessionBean,name="
1646:                                + sbName
1647:                                + ",EJBModule=olstoreejb,J2EEApplication=olstore,J2EEServer=jonas");
1648:                String name = (String) server.getAttribute(on, attributName);
1649:                return name;
1650:            }
1651:
1652:            /**
1653:             * Get number of instances of a StatelessSessionBean
1654:             * @param sbName name of the StatelessSessionBean
1655:             * @param attributName {"nbInstances", "minPoolSize", "maxPoolSize"}
1656:             * @return name of the class
1657:             * @throws Exception if an error occurs
1658:             */
1659:            private int getStatelessSBInstance(String sbName,
1660:                    String attributName) throws Exception {
1661:                MBeanServerConnection server = getMBeanServer();
1662:                ObjectName on = ObjectName
1663:                        .getInstance("jonas:j2eeType=StatelessSessionBean,name="
1664:                                + sbName
1665:                                + ",EJBModule=olstoreejb,J2EEApplication=olstore,J2EEServer=jonas");
1666:                Integer nb = (Integer) server.getAttribute(on, attributName);
1667:                return nb.intValue();
1668:            }
1669:
1670:            /**
1671:             * Tear Down cleanUp action
1672:             * @throws Exception if an error occurs
1673:             */
1674:            public void tearDown() throws Exception {
1675:                super .tearDown();
1676:            }
1677:
1678:            public static int getNumberOfTabsForMdb() {
1679:                return NUMBER_OF_TABS_FOR_MDB;
1680:            }
1681:
1682:            public static int getMdbTabIndex() {
1683:                return MDB_TAB_INDEX;
1684:            }
1685:
1686:            public static String getMdbTabText() {
1687:                return TDB_TAB_TEXT;
1688:            }
1689:        }
w__w___w___.___j__a___v___a_2__s.c__om___ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.