Source Code Cross Referenced for F_JonasAdminDiscovery.java in  » J2EE » JOnAS-4.8.6 » org » objectweb » jonas » jonasadmin » test » service » discovery » 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.discovery 
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_JonasAdminDiscovery.java 7381 2005-09-14 16:00:02Z kemlerp $
023:         * --------------------------------------------------------------------------
024:         */package org.objectweb.jonas.jonasadmin.test.service.discovery;
025:
026:        import junit.framework.TestSuite;
027:
028:        import org.objectweb.jonas.jonasadmin.test.util.JonasAdminAuth;
029:        import org.objectweb.jonas.jonasadmin.test.util.JonasAdminTestCase;
030:        import org.objectweb.jonas.jonasadmin.test.util.JonasAdminUtils;
031:
032:        import com.meterware.httpunit.HTMLElement;
033:        import com.meterware.httpunit.HttpUnitOptions;
034:        import com.meterware.httpunit.WebLink;
035:        import com.meterware.httpunit.WebResponse;
036:        import com.meterware.httpunit.WebTable;
037:
038:        /**
039:         * Class for testing discovery service
040:         * @author Paul Kemler
041:         *
042:         */
043:        public class F_JonasAdminDiscovery extends JonasAdminTestCase {
044:
045:            /**
046:             * URL of discovery service
047:             */
048:            private static final String URL_JONASADMIN_DISCOVERY = "EditServiceDiscovery.do";
049:
050:            /**
051:             * number of tabs when you are in discovery
052:             */
053:            private static final int NUMBER_OF_TABS_FOR_DISCOVERY = 1;
054:
055:            /**
056:             * Constructor with a specified name
057:             * @param s name
058:             */
059:            public F_JonasAdminDiscovery(String s) {
060:                super (s, URL_JONASADMIN);
061:            }
062:
063:            /**
064:             * Main method
065:             * @param args the arguments
066:             */
067:            public static void main(String[] args) {
068:
069:                String testtorun = null;
070:                // Get args
071:                for (int argn = 0; argn < args.length; argn++) {
072:                    String sArg = args[argn];
073:                    if (sArg.equals("-n")) {
074:                        testtorun = args[++argn];
075:                    }
076:                }
077:                if (testtorun == null) {
078:                    junit.textui.TestRunner.run(suite());
079:                } else {
080:                    junit.textui.TestRunner.run(new F_JonasAdminDiscovery(
081:                            testtorun));
082:                }
083:            }
084:
085:            /**
086:             * Get a new TestSuite for this class
087:             * @return a new TestSuite for this class
088:             */
089:            public static TestSuite suite() {
090:                return new TestSuite(F_JonasAdminDiscovery.class);
091:            }
092:
093:            /**
094:             * Setup need for these tests
095:             * jonasAdmin is required
096:             * @throws Exception if it fails
097:             */
098:            protected void setUp() throws Exception {
099:                super .setUp();
100:
101:                if (wc.getCurrentPage().getURL() == null) {
102:                    useWar("jonasAdmin");
103:                    // login to jonas admin
104:                    try {
105:                        JonasAdminAuth.doValidAuth(wc, url);
106:                    } catch (Exception e) {
107:                        fail("authentification failed :  " + e);
108:                    }
109:                } else {
110:                    // if there was an error, the connection must be restablished
111:                    try {
112:                        wc.getFrameContents(FRAME_TREE);
113:                    } catch (Exception e) {
114:                        wc.getResponse(urlLogOut);
115:                        // login to jonas admin
116:                        try {
117:                            JonasAdminAuth.doValidAuth(wc, url);
118:                        } catch (Exception auth) {
119:                            fail("authentification failed :  " + auth);
120:                        }
121:                    }
122:                }
123:            }
124:
125:            /**
126:             * Test discovery table
127:             * @throws Exception if error occurs
128:             *
129:             */
130:            public void testDiscovery() throws Exception {
131:
132:                WebResponse wr;
133:                WebLink link;
134:                WebTable table;
135:                WebTable tabTable;
136:                int selectedTab;
137:                JonasAdminUtils utils = new JonasAdminUtils();
138:
139:                // Disable errors of javascript
140:                HttpUnitOptions.setExceptionsThrownOnScriptError(false);
141:                // Disable exception thrown on error status
142:                HttpUnitOptions.setExceptionsThrownOnErrorStatus(false);
143:
144:                // Test only if the discovery service is enabled
145:                if (jProp.isDiscovery()) {
146:
147:                    // Go to discovery service
148:                    wr = wc.getFrameContents(FRAME_TREE);
149:                    link = wr.getFirstMatchingLink(WebLink.MATCH_URL_STRING,
150:                            URL_JONASADMIN_DISCOVERY);
151:                    link.click();
152:                    wr = wc.getFrameContents(FRAME_CONTENT);
153:                    selectedTab = 1;
154:
155:                    // Verify multicast infos
156:                    table = utils.getTable(wr, 0);
157:                    // Multicast address
158:                    String address = jProp.getPropertiesEnv().getProperty(
159:                            "jonas.service.discovery.multicast.address");
160:                    assertEquals("It is not the expected multicast address. ",
161:                            address, table.getTableCell(0, 2).getText());
162:                    // Multicast port
163:                    String port = jProp.getPropertiesEnv().getProperty(
164:                            "jonas.service.discovery.multicast.port");
165:                    assertEquals("It is not the expected multicast port. ",
166:                            port, table.getTableCell(1, 2).getText());
167:
168:                    // Verify action
169:                    String master = table.getTableCell(2, 2).getText();
170:                    table = utils.getTable(wr, 3);
171:                    if (master.equals("true")) {
172:                        // class="btnDisabled"
173:                        HTMLElement[] btnDisabled = table.getTableCell(0, 0)
174:                                .getElementsWithAttribute("class",
175:                                        "btnDisabled");
176:                        assertEquals(
177:                                "The class of the Start button is not 'btnDisabled'. ",
178:                                1, btnDisabled.length);
179:
180:                        // No link
181:                        WebLink[] btnLink = table.getTableCell(0, 0).getLinks();
182:                        assertEquals("There is a link on the Start button. ",
183:                                0, btnLink.length);
184:                    } else {
185:                        // No class="btnDisabled"
186:                        HTMLElement[] btnDisabled = table.getTableCell(0, 0)
187:                                .getElementsWithAttribute("class",
188:                                        "btnDisabled");
189:                        assertEquals(
190:                                "The class of the Start button is not 'btnDisabled'. ",
191:                                0, btnDisabled.length);
192:
193:                        // link=/DiscoveryServiceStartMaster.do
194:                        WebLink[] btnLink = table.getTableCell(0, 0).getLinks();
195:                        assertEquals("There is no link on the Start button. ",
196:                                1, btnLink.length);
197:                        assertTrue(
198:                                "It is not the expected URL of the Start button. ",
199:                                btnLink[0].getURLString().endsWith(
200:                                        "/DiscoveryServiceStartMaster.do"));
201:
202:                        // Start Master
203:                        btnLink[0].click();
204:                        wr = wc.getFrameContents(FRAME_CONTENT);
205:
206:                        // Verify is master
207:                        table = utils.getTable(wr, 0);
208:                        master = table.getTableCell(2, 2).getText();
209:                        assertEquals("It is not master. ", "true", master);
210:                        table = utils.getTable(wr, 3);
211:                        // class="btnDisabled"
212:                        btnDisabled = table.getTableCell(0, 0)
213:                                .getElementsWithAttribute("class",
214:                                        "btnDisabled");
215:                        assertEquals(
216:                                "The class of the Start button is not 'btnDisabled'. ",
217:                                1, btnDisabled.length);
218:
219:                        // No link
220:                        btnLink = table.getTableCell(0, 0).getLinks();
221:                        assertEquals("There is a link on the Start button. ",
222:                                0, btnLink.length);
223:                    }
224:
225:                    // Verify there is 1 tab
226:                    tabTable = utils.getTabTable(wr);
227:                    testTabs(tabTable, NUMBER_OF_TABS_FOR_DISCOVERY,
228:                            selectedTab, "Problem in 'Discovery' tab.");
229:                }
230:            }
231:
232:            /**
233:             * Tear Down cleanUp action
234:             * @throws Exception if an error occurs
235:             */
236:            public void tearDown() throws Exception {
237:                super.tearDown();
238:            }
239:
240:        }
ww_w.___j___a__v__a2__s_.__c_o___m_ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.