Source Code Cross Referenced for F_JonasAdminServiceSecurity.java in  » J2EE » JOnAS-4.8.6 » org » objectweb » jonas » jonasadmin » test » service » security » 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.security 
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_JonasAdminServiceSecurity.java 7381 2005-09-14 16:00:02Z kemlerp $
023:         * --------------------------------------------------------------------------
024:         */package org.objectweb.jonas.jonasadmin.test.service.security;
025:
026:        import java.io.File;
027:
028:        import junit.framework.TestSuite;
029:
030:        import org.objectweb.jonas.jonasadmin.test.util.JonasAdminAuth;
031:        import org.objectweb.jonas.jonasadmin.test.util.JonasAdminTestCase;
032:        import org.objectweb.jonas.jonasadmin.test.util.JonasAdminUtils;
033:
034:        import com.meterware.httpunit.HttpUnitOptions;
035:        import com.meterware.httpunit.WebLink;
036:        import com.meterware.httpunit.WebResponse;
037:        import com.meterware.httpunit.WebTable;
038:
039:        /**
040:         * Class for testing security service
041:         * @author Paul Kemler
042:         *
043:         */
044:        public class F_JonasAdminServiceSecurity extends JonasAdminTestCase {
045:
046:            /**
047:             * URL of security service
048:             */
049:            private static final String URL_JONASADMIN_SECURITY = "EditServiceSecurity.do";
050:
051:            /**
052:             * number of tabs when you are in security
053:             */
054:            private static final int NUMBER_OF_TABS_FOR_SECURITY = 1;
055:
056:            /**
057:             * Constructor with a specified name
058:             * @param s name
059:             */
060:            public F_JonasAdminServiceSecurity(String s) {
061:                super (s, URL_JONASADMIN);
062:            }
063:
064:            /**
065:             * Main method
066:             * @param args the arguments
067:             */
068:            public static void main(String[] args) {
069:
070:                String testtorun = null;
071:                // Get args
072:                for (int argn = 0; argn < args.length; argn++) {
073:                    String sArg = args[argn];
074:                    if (sArg.equals("-n")) {
075:                        testtorun = args[++argn];
076:                    }
077:                }
078:                if (testtorun == null) {
079:                    junit.textui.TestRunner.run(suite());
080:                } else {
081:                    junit.textui.TestRunner
082:                            .run(new F_JonasAdminServiceSecurity(testtorun));
083:                }
084:            }
085:
086:            /**
087:             * Get a new TestSuite for this class
088:             * @return a new TestSuite for this class
089:             */
090:            public static TestSuite suite() {
091:                return new TestSuite(F_JonasAdminServiceSecurity.class);
092:            }
093:
094:            /**
095:             * Setup need for these tests
096:             * jonasAdmin is required
097:             * @throws Exception if it fails
098:             */
099:            protected void setUp() throws Exception {
100:                super .setUp();
101:
102:                if (wc.getCurrentPage().getURL() == null) {
103:                    useWar("jonasAdmin");
104:                    // login to jonas admin
105:                    try {
106:                        JonasAdminAuth.doValidAuth(wc, url);
107:                    } catch (Exception e) {
108:                        fail("authentification failed :  " + e);
109:                    }
110:                } else {
111:                    // if there was an error, the connection must be restablished
112:                    try {
113:                        wc.getFrameContents(FRAME_TREE);
114:                    } catch (Exception e) {
115:                        wc.getResponse(urlLogOut);
116:                        // login to jonas admin
117:                        try {
118:                            JonasAdminAuth.doValidAuth(wc, url);
119:                        } catch (Exception auth) {
120:                            fail("authentification failed :  " + auth);
121:                        }
122:                    }
123:                }
124:            }
125:
126:            /**
127:             * Test realms table
128:             * @throws Exception if error occurs
129:             *
130:             */
131:            public void testRealms() throws Exception {
132:
133:                WebResponse wr;
134:                WebLink link;
135:                WebTable table;
136:                WebTable tabTable;
137:                int selectedTab;
138:                String name;
139:                String type;
140:                String path;
141:                boolean used;
142:                JonasAdminUtils utils = new JonasAdminUtils();
143:
144:                // Disable errors of javascript
145:                HttpUnitOptions.setExceptionsThrownOnScriptError(false);
146:                // Disable exception thrown on error status
147:                HttpUnitOptions.setExceptionsThrownOnErrorStatus(false);
148:
149:                // Test only if the security service is enabled
150:                if (jProp.isSecurity()) {
151:
152:                    // Go to security service
153:                    wr = wc.getFrameContents(FRAME_TREE);
154:                    link = wr.getFirstMatchingLink(WebLink.MATCH_URL_STRING,
155:                            URL_JONASADMIN_SECURITY);
156:                    link.click();
157:                    wr = wc.getFrameContents(FRAME_CONTENT);
158:                    selectedTab = 1;
159:
160:                    // Verify 'Realms'
161:                    path = File.separator + "jonasAdmin";
162:                    name = "memrlm_1";
163:                    type = "memory";
164:                    used = true;
165:                    try {
166:                        table = utils.getTable(wr, 0);
167:                        int rowJonasAdmin = utils.getFirstRow(path, table, 2)
168:                                .intValue();
169:                        if (rowJonasAdmin != -1) {
170:                            testRealmRow(table, rowJonasAdmin, name, type,
171:                                    path, used);
172:                        }
173:                    } catch (Exception e) {
174:                        if (jProp.isCatalina()) {
175:                            fail("The realm security table is not found. ");
176:                        } else {
177:                            throw new IllegalStateException(
178:                                    "Not implemented: JETTY. ");
179:                        }
180:                    }
181:
182:                    // "Olstore": type=datasource and not used
183:                    if (jProp.isEar()) {
184:                        useEar("olstore");
185:
186:                        path = File.separator + "olstore";
187:                        name = "olstorerlm_1";
188:                        type = "datasource";
189:                        used = false;
190:                        wr = wc.getFrameContents(FRAME_TREE);
191:                        link = wr.getFirstMatchingLink(
192:                                WebLink.MATCH_URL_STRING,
193:                                URL_JONASADMIN_SECURITY);
194:                        link.click();
195:                        wr = wc.getFrameContents(FRAME_CONTENT);
196:                        table = utils.getTable(wr, 0);
197:                        int rowDatasourceType = utils.getFirstRow(path, table,
198:                                2).intValue();
199:                        if (rowDatasourceType != -1) {
200:                            testRealmRow(table, rowDatasourceType, name, type,
201:                                    path, used);
202:                        } else {
203:                            if (jProp.isCatalina()) {
204:                                fail("The realm security for the context path '"
205:                                        + path + "' is not found. ");
206:                            } else {
207:                                throw new IllegalStateException(
208:                                        "Not implemented: JETTY. ");
209:                            }
210:                        }
211:                    }
212:
213:                    // Verify there is 1 tab
214:                    tabTable = utils.getTabTable(wr);
215:                    testTabs(tabTable, NUMBER_OF_TABS_FOR_SECURITY,
216:                            selectedTab, "Problem in 'Realms' tab.");
217:                }
218:            }
219:
220:            /**
221:             * Test infos of a realm row
222:             * @param table the table of realms
223:             * @param row the row to test
224:             * @param name the value of the name
225:             * @param type the value of the type
226:             * @param path the value of the path
227:             * @param used the value of 'used'
228:             */
229:            private void testRealmRow(WebTable table, int row, String name,
230:                    String type, String path, boolean used) {
231:                // Verify Name
232:                assertEquals("It is not the name for the context path '" + path
233:                        + "' . ", name, table.getTableCell(row, 0).getText());
234:                // Verify Type
235:                assertEquals("It is not the type for the context path '" + path
236:                        + "' . ", type, table.getTableCell(row, 1).getText());
237:                // Verify Used
238:                if (used) {
239:                    assertEquals(
240:                            "It is not the value of 'used' for the context path '"
241:                                    + path + "' . ", used, table.getTableCell(
242:                                    row, 3).getImages()[0].getSource()
243:                                    .endsWith("images/icon/tag_blue.gif"));
244:                } else {
245:                    assertEquals(
246:                            "It is not the value of 'used' for the context path '"
247:                                    + path + "' . ", 0, table.getTableCell(row,
248:                                    3).getImages().length);
249:                }
250:            }
251:
252:            /**
253:             * Tear Down cleanUp action
254:             * @throws Exception if an error occurs
255:             */
256:            public void tearDown() throws Exception {
257:                super.tearDown();
258:            }
259:
260:        }
w_w__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.