Source Code Cross Referenced for F_JonasAdminDatabase.java in  » J2EE » JOnAS-4.8.6 » org » objectweb » jonas » jonasadmin » test » service » database » 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.database 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * JOnAS: Java(TM) Open Application Server
003:         * Copyright (C) 2005 Bull S.A.
004:         * Contact: jonas-team@objectweb.org
005:         *
006:         * This library is free software; you can redistribute it and/or
007:         * modify it under the terms of the GNU Lesser General Public
008:         * License as published by the Free Software Foundation; either
009:         * version 2.1 of the License, or 1any later version.
010:         *
011:         * This library is distributed in the hope that it will be useful,
012:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
013:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
014:         * Lesser General Public License for more details.
015:         *
016:         * You should have received a copy of the GNU Lesser General Public
017:         * License along with this library; if not, write to the Free Software
018:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
019:         * USA
020:         *
021:         * --------------------------------------------------------------------------
022:         * $Id: F_JonasAdminDatabase.java 7381 2005-09-14 16:00:02Z kemlerp $
023:         * --------------------------------------------------------------------------
024:         */package org.objectweb.jonas.jonasadmin.test.service.database;
025:
026:        import java.util.Properties;
027:
028:        import javax.management.MBeanServerConnection;
029:        import javax.management.ObjectName;
030:        import javax.management.Query;
031:        import javax.management.QueryExp;
032:
033:        import junit.framework.TestSuite;
034:
035:        import org.objectweb.jonas.jonasadmin.test.util.JonasAdminAuth;
036:        import org.objectweb.jonas.jonasadmin.test.util.JonasAdminFiles;
037:        import org.objectweb.jonas.jonasadmin.test.util.JonasAdminTestCase;
038:        import org.objectweb.jonas.jonasadmin.test.util.JonasAdminUtils;
039:
040:        import com.meterware.httpunit.HttpUnitOptions;
041:        import com.meterware.httpunit.WebForm;
042:        import com.meterware.httpunit.WebLink;
043:        import com.meterware.httpunit.WebResponse;
044:        import com.meterware.httpunit.WebTable;
045:
046:        /**
047:         * Class for testing database service
048:         * @author Paul Kemler
049:         *
050:         */
051:        public class F_JonasAdminDatabase extends JonasAdminTestCase {
052:
053:            /**
054:             * URL of database service
055:             */
056:            private static final String URL_JONASADMIN_SERVICE_DATABASE = "ListDatabases.do";
057:
058:            /**
059:             * URL of datasource statistics
060:             */
061:            private static final String URL_JONASADMIN_EDIT = "EditDatasource.do";
062:
063:            /**
064:             * URL of datasource statistics
065:             */
066:            private static final String URL_JONASADMIN_STATISTICS = "EditDatasourceStat.do";
067:
068:            /**
069:             * URL of database service
070:             */
071:            private static final String URL_JONASADMIN_USED_BY = "datasourceUsedBy.jsp";
072:
073:            /**
074:             * number of tabs when you are in the datasource tab
075:             */
076:            private static final int NUMBER_OF_TABS_FOR_DATASOURCE = 1;
077:
078:            /**
079:             * number of tabs when the datasource is not used
080:             */
081:            private static final int NUMBER_OF_TABS_FOR_DATASOURCE_NOT_USED = 3;
082:
083:            /**
084:             * number of tabs when the datasource is used
085:             */
086:            private static final int NUMBER_OF_TABS_FOR_DATASOURCE_USED = 4;
087:
088:            /**
089:             * name of the datasource
090:             */
091:            private String name = "";
092:
093:            /**
094:             * Constructor with a specified name
095:             * @param s name
096:             */
097:            public F_JonasAdminDatabase(String s) {
098:                super (s, URL_JONASADMIN);
099:            }
100:
101:            /**
102:             * Main method
103:             * @param args the arguments
104:             */
105:            public static void main(String[] args) {
106:
107:                String testtorun = null;
108:                // Get args
109:                for (int argn = 0; argn < args.length; argn++) {
110:                    String sArg = args[argn];
111:                    if (sArg.equals("-n")) {
112:                        testtorun = args[++argn];
113:                    }
114:                }
115:                if (testtorun == null) {
116:                    junit.textui.TestRunner.run(suite());
117:                } else {
118:                    junit.textui.TestRunner.run(new F_JonasAdminDatabase(
119:                            testtorun));
120:                }
121:            }
122:
123:            /**
124:             * Get a new TestSuite for this class
125:             * @return a new TestSuite for this class
126:             */
127:            public static TestSuite suite() {
128:                return new TestSuite(F_JonasAdminDatabase.class);
129:            }
130:
131:            /**
132:             * Setup need for these tests
133:             * jonasAdmin is required
134:             * @throws Exception if it fails
135:             */
136:            protected void setUp() throws Exception {
137:                super .setUp();
138:
139:                if (wc.getCurrentPage().getURL() == null) {
140:                    useWar("jonasAdmin");
141:                    // login to jonas admin
142:                    try {
143:                        JonasAdminAuth.doValidAuth(wc, url);
144:                    } catch (Exception e) {
145:                        fail("authentification failed :  " + e);
146:                    }
147:                } else {
148:                    // if there was an error, the connection must be restablished
149:                    try {
150:                        wc.getFrameContents(FRAME_TREE);
151:                    } catch (Exception e) {
152:                        wc.getResponse(urlLogOut);
153:                        // login to jonas admin
154:                        try {
155:                            JonasAdminAuth.doValidAuth(wc, url);
156:                        } catch (Exception auth) {
157:                            fail("authentification failed :  " + auth);
158:                        }
159:                    }
160:                }
161:            }
162:
163:            /**
164:             * Test information of a JDBC
165:             * @throws Exception if error occurs
166:             *
167:             */
168:            public void testJDBCInfo() throws Exception {
169:
170:                WebResponse wr;
171:                WebLink link;
172:                WebTable table;
173:                WebTable tabTable;
174:                int selectedTab;
175:                JonasAdminUtils utils = new JonasAdminUtils();
176:
177:                // Disable errors of javascript
178:                HttpUnitOptions.setExceptionsThrownOnScriptError(false);
179:                // Disable exception thrown on error status
180:                HttpUnitOptions.setExceptionsThrownOnErrorStatus(false);
181:                if (jProp.isDbm()) {
182:                    // Add datasource
183:                    name = "new_datasource_info";
184:                    String datasourceName = name;
185:                    String datasourceUrl = "jdbc:hsqldb:hsql://localhost:9001/db_jonas";
186:                    String datasourceClassname = "org.hsqldb.jdbcDriver";
187:                    String datasourceUsername = "jonas";
188:                    String datasourcePassword = "jonas";
189:                    String datasourceMapper = "rdb.hsql";
190:                    String jdbcConnchecklevel = "0";
191:                    String jdbcConnmaxage = "1440";
192:                    String jdbcMaxopentime = "60";
193:                    String jdbcConnteststmt = "select 1";
194:                    String jdbcMinconpool = "10";
195:                    String jdbcMaxconpool = "30";
196:                    String jdbcSamplingperiod = "30";
197:                    String jdbcMaxwaittime = "5";
198:                    String jdbcMaxwaiters = "100";
199:
200:                    Properties properties = new Properties();
201:                    properties.put("datasource.name", datasourceName);
202:                    properties.put("datasource.url", datasourceUrl);
203:                    properties.put("datasource.classname", datasourceClassname);
204:                    properties.put("datasource.username", datasourceUsername);
205:                    properties.put("datasource.password", datasourcePassword);
206:                    properties.put("datasource.mapper", datasourceMapper);
207:                    properties.put("jdbc.connchecklevel", jdbcConnchecklevel);
208:                    properties.put("jdbc.connmaxage", jdbcConnmaxage);
209:                    properties.put("jdbc.maxopentime", jdbcMaxopentime);
210:                    properties.put("jdbc.connteststmt", jdbcConnteststmt);
211:                    properties.put("jdbc.minconpool", jdbcMinconpool);
212:                    properties.put("jdbc.maxconpool", jdbcMaxconpool);
213:                    properties.put("jdbc.samplingperiod", jdbcSamplingperiod);
214:                    properties.put("jdbc.maxwaittime", jdbcMaxwaittime);
215:                    properties.put("jdbc.maxwaiters", jdbcMaxwaiters);
216:
217:                    useDatasource(name, properties);
218:
219:                    // Use alarm.ear for adding opened connections
220:                    useEar("alarm");
221:
222:                    // Go to service database
223:                    wr = wc.getFrameContents(FRAME_TREE);
224:                    link = wr.getFirstMatchingLink(WebLink.MATCH_URL_STRING,
225:                            URL_JONASADMIN_SERVICE_DATABASE);
226:                    link.click();
227:                    wr = wc.getFrameContents(FRAME_CONTENT);
228:                    selectedTab = 1;
229:
230:                    // Verify tabs
231:                    tabTable = utils.getTabTable(wr);
232:                    testTabs(tabTable, NUMBER_OF_TABS_FOR_DATASOURCE,
233:                            selectedTab, "Problem in 'Datasources' tab.");
234:
235:                    // Verify JNDI Name
236:                    table = utils.getTable(wr, 0);
237:                    int rowNewDatasource = utils.getRow(name, table).intValue();
238:                    if (rowNewDatasource == -1) {
239:                        fail("'" + name + "' was not found in the table. ");
240:                    }
241:                    int columnJNDI = 1;
242:                    assertEquals("It is not the JNDI name of '" + name + "'. ",
243:                            datasourceName, table.getTableCell(
244:                                    rowNewDatasource, columnJNDI).getText());
245:
246:                    // Verify JDBC Connection
247:                    int columnJDBCConnection = 2;
248:                    int currentOpenedConnection = getCurrentOpenedConnection(datasourceName);
249:                    assertEquals(
250:                            "It is not the number of opened connection for '"
251:                                    + name + "'. ", currentOpenedConnection,
252:                            Integer.parseInt(table.getTableCell(
253:                                    rowNewDatasource, columnJDBCConnection)
254:                                    .getText()));
255:
256:                    // Go to "new_datasource_info" database
257:                    link = wr.getLinkWith(name);
258:                    if (link == null) {
259:                        fail("No link was found for '" + name
260:                                + "'in the page. ");
261:                    }
262:                    link.click();
263:                    wr = wc.getFrameContents(FRAME_CONTENT);
264:                    selectedTab = 2;
265:
266:                    // Verify tabs
267:                    tabTable = utils.getTabTable(wr);
268:                    testTabs(tabTable, NUMBER_OF_TABS_FOR_DATASOURCE_NOT_USED,
269:                            selectedTab, "Problem in the datasource tab.");
270:                    // - links
271:                    assertTrue("The link " + URL_JONASADMIN_SERVICE_DATABASE
272:                            + " is not found in the first tab. ", tabTable
273:                            .getTableCell(0, 0).getLinks()[0].getURLString()
274:                            .endsWith(URL_JONASADMIN_SERVICE_DATABASE));
275:                    assertTrue("The link " + URL_JONASADMIN_STATISTICS
276:                            + " is not found in the third tab. ", tabTable
277:                            .getTableCell(0, 4).getLinks()[0].getURLString()
278:                            .endsWith(URL_JONASADMIN_STATISTICS));
279:
280:                    // Verify information
281:                    // JDBC Datasource configuration
282:                    table = utils.getTable(wr, 1);
283:                    // JNDI name        <name>
284:                    assertEquals("It is not the JNDI name of '" + name + "'. ",
285:                            datasourceName, table.getTableCell(0, 2).getText());
286:                    // Description      no desc
287:                    assertEquals("It is not the description of '" + name
288:                            + "'. ", "no desc", table.getTableCell(1, 2)
289:                            .getText());
290:                    // URL              jdbc:hsqldb:hsql://localhost:9001/db_jonas
291:                    assertEquals("It is not the URL of '" + name + "'. ",
292:                            datasourceUrl, table.getTableCell(2, 2).getText());
293:                    // User name        jonas
294:                    assertEquals("It is not the user name of '" + name + "'. ",
295:                            datasourceUsername, table.getTableCell(3, 2)
296:                                    .getText());
297:                    // User password    jonas
298:                    assertEquals("It is not the user password of '" + name
299:                            + "'. ", datasourcePassword, table.getTableCell(4,
300:                            2).getText());
301:                    // Mapper           rdb.hsql
302:                    assertEquals("It is not the mapper of '" + name + "'. ",
303:                            datasourceMapper, table.getTableCell(5, 2)
304:                                    .getText());
305:
306:                    // JDBC Driver configuration
307:                    table = utils.getTable(wr, 4);
308:                    // Driver class name       org.hsqldb.jdbcDriver
309:                    assertEquals("It is not the driver class name of '" + name
310:                            + "'. ", datasourceClassname, table.getTableCell(0,
311:                            2).getText());
312:
313:                    // JDBC connection configuration
314:                    WebForm form = wr.getForms()[0];
315:                    // Maximum age
316:                    assertEquals("It is not the maximum age of '" + name
317:                            + "'. ", jdbcConnmaxage, form
318:                            .getParameterValue("jdbcConnMaxAge"));
319:                    // Maximum open time
320:                    assertEquals("It is not the maximum open time of '" + name
321:                            + "'. ", jdbcMaxopentime, form
322:                            .getParameterValue("jdbcMaxOpenTime"));
323:                    // Checking level
324:                    assertEquals("It is not the checking level of '" + name
325:                            + "'. ", jdbcConnchecklevel, form
326:                            .getParameterValue("jdbcConnCheckLevel"));
327:                    // Test
328:                    assertEquals("It is not the test of '" + name + "'. ",
329:                            jdbcConnteststmt, form
330:                                    .getParameterValue("jdbcTestStatement"));
331:                    // Pool minimum
332:                    assertEquals("It is not the pool minimum of '" + name
333:                            + "'. ", jdbcMinconpool, form
334:                            .getParameterValue("jdbcMinConnPool"));
335:                    // Pool maximum
336:                    assertEquals("It is not the pool maximum time of '" + name
337:                            + "'. ", jdbcMaxconpool, form
338:                            .getParameterValue("jdbcMaxConnPool"));
339:                    // Max Wait Time
340:                    assertEquals("It is not the maximum wait time of '" + name
341:                            + "'. ", jdbcMaxwaittime, form
342:                            .getParameterValue("jdbcMaxWaitTime"));
343:                    // Max Waiters
344:                    assertEquals("It is not the maximum waiters of '" + name
345:                            + "'. ", jdbcMaxwaiters, form
346:                            .getParameterValue("jdbcMaxWaiters"));
347:                    // Sampling Period
348:                    assertEquals("It is not the sampling Period of '" + name
349:                            + "'. ", jdbcSamplingperiod, form
350:                            .getParameterValue("jdbcSamplingPeriod"));
351:
352:                }
353:            }
354:
355:            /**
356:             * Test Used By Tab of database service
357:             * @throws Exception if error occurs
358:             *
359:             */
360:            public void testJDBCUsedBy() throws Exception {
361:
362:                WebResponse wr;
363:                WebLink link;
364:                WebTable table;
365:                WebTable tabTable;
366:                int selectedTab;
367:                String jdbc1Datasource = "";
368:                JonasAdminUtils utils = new JonasAdminUtils();
369:
370:                // Disable errors of javascript
371:                HttpUnitOptions.setExceptionsThrownOnScriptError(false);
372:                // Disable exception thrown on error status
373:                HttpUnitOptions.setExceptionsThrownOnErrorStatus(false);
374:                if (jProp.isDbm()) {
375:
376:                    // Go to service database
377:                    wr = wc.getFrameContents(FRAME_TREE);
378:                    link = wr.getFirstMatchingLink(WebLink.MATCH_URL_STRING,
379:                            URL_JONASADMIN_SERVICE_DATABASE);
380:                    link.click();
381:                    wr = wc.getFrameContents(FRAME_CONTENT);
382:                    selectedTab = 1;
383:
384:                    // Search if there is a datasource with 'jdbc_1' as JNDI name
385:                    table = utils.getTable(wr, 0);
386:                    int columnJNDI = 1;
387:                    int rowJDBC1 = utils.getRow("jdbc_1", table, columnJNDI)
388:                            .intValue();
389:                    if (rowJDBC1 == -1) {
390:                        // Add datasource
391:                        name = "new_datasource_used_by";
392:                        String datasourceName = "jdbc_1";
393:                        String datasourceUrl = "jdbc:hsqldb:hsql://localhost:9001/db_jonas";
394:                        String datasourceClassname = "org.hsqldb.jdbcDriver";
395:                        String datasourceUsername = "jonas";
396:                        String datasourcePassword = "jonas";
397:                        String datasourceMapper = "rdb.hsql";
398:                        String jdbcConnchecklevel = "0";
399:                        String jdbcConnmaxage = "1440";
400:                        String jdbcMaxopentime = "60";
401:                        String jdbcConnteststmt = "select 1";
402:                        String jdbcMinconpool = "10";
403:                        String jdbcMaxconpool = "30";
404:                        String jdbcSamplingperiod = "30";
405:                        String jdbcMaxwaittime = "5";
406:                        String jdbcMaxwaiters = "100";
407:
408:                        Properties properties = new Properties();
409:                        properties.put("datasource.name", datasourceName);
410:                        properties.put("datasource.url", datasourceUrl);
411:                        properties.put("datasource.classname",
412:                                datasourceClassname);
413:                        properties.put("datasource.username",
414:                                datasourceUsername);
415:                        properties.put("datasource.password",
416:                                datasourcePassword);
417:                        properties.put("datasource.mapper", datasourceMapper);
418:                        properties.put("jdbc.connchecklevel",
419:                                jdbcConnchecklevel);
420:                        properties.put("jdbc.connmaxage", jdbcConnmaxage);
421:                        properties.put("jdbc.maxopentime", jdbcMaxopentime);
422:                        properties.put("jdbc.connteststmt", jdbcConnteststmt);
423:                        properties.put("jdbc.minconpool", jdbcMinconpool);
424:                        properties.put("jdbc.maxconpool", jdbcMaxconpool);
425:                        properties.put("jdbc.samplingperiod",
426:                                jdbcSamplingperiod);
427:                        properties.put("jdbc.maxwaittime", jdbcMaxwaittime);
428:                        properties.put("jdbc.maxwaiters", jdbcMaxwaiters);
429:
430:                        useDatasource(name, properties);
431:
432:                        jdbc1Datasource = name;
433:                    } else {
434:                        jdbc1Datasource = table.getTableCell(rowJDBC1, 0)
435:                                .getText();
436:                    }
437:
438:                    // Use alarm.ear
439:                    useEar("alarm");
440:
441:                    // Reload service database page
442:                    wr = wc.getFrameContents(FRAME_TREE);
443:                    link = wr.getFirstMatchingLink(WebLink.MATCH_URL_STRING,
444:                            URL_JONASADMIN_SERVICE_DATABASE);
445:                    link.click();
446:                    wr = wc.getFrameContents(FRAME_CONTENT);
447:                    selectedTab = 1;
448:
449:                    // Verify JDBC Connection is positif
450:                    rowJDBC1 = utils.getRow("jdbc_1", table, columnJNDI)
451:                            .intValue();
452:                    int columnJDBCConnection = 2;
453:                    int currentOpenedConnection = getCurrentOpenedConnection("jdbc_1");
454:                    assertEquals(
455:                            "It is not the number of opened connection for 'jdbc_1'. ",
456:                            currentOpenedConnection, Integer.parseInt(table
457:                                    .getTableCell(rowJDBC1,
458:                                            columnJDBCConnection).getText()));
459:                    assertTrue(
460:                            "There is no opened connection for 'jdbc_1' JNDI name. ",
461:                            currentOpenedConnection > 0);
462:
463:                    // Go to database
464:                    link = wr.getLinkWith(jdbc1Datasource);
465:                    if (link == null) {
466:                        fail("No link was found for '" + name
467:                                + "'in the page. ");
468:                    }
469:                    link.click();
470:                    wr = wc.getFrameContents(FRAME_CONTENT);
471:                    selectedTab = 2;
472:
473:                    // Verify tabs
474:                    tabTable = utils.getTabTable(wr);
475:                    testTabs(tabTable, NUMBER_OF_TABS_FOR_DATASOURCE_USED,
476:                            selectedTab, "Problem in the datasource tab.");
477:                    // - links
478:                    assertTrue("The link " + URL_JONASADMIN_SERVICE_DATABASE
479:                            + " is not found in the first tab. ", tabTable
480:                            .getTableCell(0, 0).getLinks()[0].getURLString()
481:                            .endsWith(URL_JONASADMIN_SERVICE_DATABASE));
482:                    assertTrue("The link " + URL_JONASADMIN_STATISTICS
483:                            + " is not found in the third tab. ", tabTable
484:                            .getTableCell(0, 4).getLinks()[0].getURLString()
485:                            .endsWith(URL_JONASADMIN_STATISTICS));
486:                    assertTrue("The link " + URL_JONASADMIN_USED_BY
487:                            + " is not found in the third tab. ", tabTable
488:                            .getTableCell(0, 6).getLinks()[0].getURLString()
489:                            .endsWith(URL_JONASADMIN_USED_BY));
490:
491:                    // Go to "Used by" tab
492:                    link = wr.getFirstMatchingLink(WebLink.MATCH_URL_STRING,
493:                            URL_JONASADMIN_USED_BY);
494:                    if (link == null) {
495:                        fail("No link was found for '" + name
496:                                + "'in the page. ");
497:                    }
498:                    link.click();
499:                    wr = wc.getFrameContents(FRAME_CONTENT);
500:                    selectedTab = 4;
501:
502:                    // Verify tabs
503:                    tabTable = utils.getTabTable(wr);
504:                    testTabs(tabTable, NUMBER_OF_TABS_FOR_DATASOURCE_USED,
505:                            selectedTab, "Problem in the datasource tab.");
506:                    // - links
507:                    assertTrue("The link " + URL_JONASADMIN_SERVICE_DATABASE
508:                            + " is not found in the first tab. ", tabTable
509:                            .getTableCell(0, 0).getLinks()[0].getURLString()
510:                            .endsWith(URL_JONASADMIN_SERVICE_DATABASE));
511:                    assertTrue("The link " + URL_JONASADMIN_EDIT
512:                            + " is not found in the third tab. ", tabTable
513:                            .getTableCell(0, 2).getLinks()[0].getURLString()
514:                            .endsWith(URL_JONASADMIN_EDIT));
515:                    assertTrue("The link " + URL_JONASADMIN_STATISTICS
516:                            + " is not found in the third tab. ", tabTable
517:                            .getTableCell(0, 4).getLinks()[0].getURLString()
518:                            .endsWith(URL_JONASADMIN_STATISTICS));
519:
520:                    // Verify there is Alarm Record EJB
521:                    table = utils.getTable(wr, 0);
522:                    int rowEJB = utils.getRow("AlarmRecord", table).intValue();
523:                    if (rowEJB == -1) {
524:                        fail("There is not 'Alarm Record' in the 'Used By' table. "
525:                                + table.getText());
526:                    }
527:
528:                    // Verify type
529:                    assertEquals("The EJB type is not EntityBean. ",
530:                            "EntityBean", table.getTableCell(rowEJB, 1)
531:                                    .getText());
532:
533:                    // Verify link
534:                    link = table.getTableCell(rowEJB, 0).getLinks()[0];
535:                    if (link == null) {
536:                        fail("No link was found for '" + name
537:                                + "'in the page. ");
538:                    }
539:                    int code = wc.sendRequest(link.getRequest())
540:                            .getResponseCode();
541:                    assertEquals("Fail to go to '" + link.getURLString()
542:                            + "'. ", 200, code);
543:
544:                }
545:            }
546:
547:            /**
548:             * Tear Down
549:             * cleanUp action
550:             */
551:            public void tearDown() throws Exception {
552:
553:                if (jProp.isDbm()) {
554:                    // remove created datasource file
555:                    if (!name.equals("")) {
556:                        // Undeploy datasource
557:                        unUseDatasource(name);
558:                        // Delete file
559:                        JonasAdminFiles.deleteConfigFile(name + ".properties");
560:                        name = "";
561:                    }
562:                }
563:                super .tearDown();
564:            }
565:
566:            /**
567:             * Get current opened connection
568:             * @return number of current opened connection
569:             * @throws Exception if an error occurs
570:             */
571:            private int getCurrentOpenedConnection(String jndiName)
572:                    throws Exception {
573:                MBeanServerConnection server = getMBeanServer();
574:                ObjectName on = ObjectName
575:                        .getInstance("*:j2eeType=JDBCDataSource,*");
576:
577:                QueryExp exp = Query.match(Query.attr("jndiName"), Query
578:                        .value(jndiName));
579:
580:                ObjectName dataSourceON = (ObjectName) server.queryNames(on,
581:                        exp).iterator().next();
582:                Integer currentOpenedConnection = (Integer) server
583:                        .getAttribute(dataSourceON, "currentOpened");
584:
585:                return currentOpenedConnection.intValue();
586:            }
587:
588:        }
w___w___w___.j___ava_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.