Source Code Cross Referenced for IdentityValidation.java in  » IDE-Netbeans » identity.kit » org » netbeans » modules » identity » qaf » 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 » IDE Netbeans » identity.kit » org.netbeans.modules.identity.qaf 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003:         *
004:         * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005:         *
006:         * The contents of this file are subject to the terms of either the GNU
007:         * General Public License Version 2 only ("GPL") or the Common
008:         * Development and Distribution License("CDDL") (collectively, the
009:         * "License"). You may not use this file except in compliance with the
010:         * License. You can obtain a copy of the License at
011:         * http://www.netbeans.org/cddl-gplv2.html
012:         * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013:         * specific language governing permissions and limitations under the
014:         * License.  When distributing the software, include this License Header
015:         * Notice in each file and include the License file at
016:         * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
017:         * particular file as subject to the "Classpath" exception as provided
018:         * by Sun in the GPL Version 2 section of the License file that
019:         * accompanied this code. If applicable, add the following below the
020:         * License Header, with the fields enclosed by brackets [] replaced by
021:         * your own identifying information:
022:         * "Portions Copyrighted [year] [name of copyright owner]"
023:         *
024:         * Contributor(s):
025:         *
026:         * The Original Software is NetBeans. The Initial Developer of the Original
027:         * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
028:         * Microsystems, Inc. All Rights Reserved.
029:         *
030:         * If you wish your version of this file to be governed by only the CDDL
031:         * or only the GPL Version 2, indicate your decision by adding
032:         * "[Contributor] elects to include this software in this distribution
033:         * under the [CDDL or GPL Version 2] license." If you do not indicate a
034:         * single choice of license, a recipient has the option to distribute
035:         * your version of this file under either the CDDL, the GPL Version 2 or
036:         * to extend the choice of license to its licensees as provided above.
037:         * However, if you add GPL Version 2 code and therefore, elected the GPL
038:         * Version 2 license, then the option applies only if the new code is
039:         * made subject to such option by the copyright holder.
040:         */
041:        /*
042:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
043:         *
044:         * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
045:         *
046:         * The contents of this file are subject to the terms of either the GNU
047:         * General Public License Version 2 only ("GPL") or the Common
048:         * Development and Distribution License("CDDL") (collectively, the
049:         * "License"). You may not use this file except in compliance with the
050:         * License. You can obtain a copy of the License at
051:         * http://www.netbeans.org/cddl-gplv2.html
052:         * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
053:         * specific language governing permissions and limitations under the
054:         * License.  When distributing the software, include this License Header
055:         * Notice in each file and include the License file at
056:         * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
057:         * particular file as subject to the "Classpath" exception as provided
058:         * by Sun in the GPL Version 2 section of the License file that
059:         * accompanied this code. If applicable, add the following below the
060:         * License Header, with the fields enclosed by brackets [] replaced by
061:         * your own identifying information:
062:         * "Portions Copyrighted [year] [name of copyright owner]"
063:         *
064:         * Contributor(s):
065:         *
066:         * The Original Software is NetBeans. The Initial Developer of the Original
067:         * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
068:         * Microsystems, Inc. All Rights Reserved.
069:         *
070:         * If you wish your version of this file to be governed by only the CDDL
071:         * or only the GPL Version 2, indicate your decision by adding
072:         * "[Contributor] elects to include this software in this distribution
073:         * under the [CDDL or GPL Version 2] license." If you do not indicate a
074:         * single choice of license, a recipient has the option to distribute
075:         * your version of this file under either the CDDL, the GPL Version 2 or
076:         * to extend the choice of license to its licensees as provided above.
077:         * However, if you add GPL Version 2 code and therefore, elected the GPL
078:         * Version 2 license, then the option applies only if the new code is
079:         * made subject to such option by the copyright holder.
080:         */
081:        package org.netbeans.modules.identity.qaf;
082:
083:        import java.io.File;
084:        import java.io.IOException;
085:        import junit.framework.TestSuite;
086:        import junit.textui.TestRunner;
087:        import org.netbeans.jellytools.Bundle;
088:        import org.netbeans.jellytools.NbDialogOperator;
089:        import org.netbeans.jellytools.ProjectsTabOperator;
090:        import org.netbeans.jellytools.nodes.Node;
091:        import org.netbeans.junit.NbTestSuite;
092:        import org.netbeans.jemmy.EventTool;
093:        import org.netbeans.jellytools.modules.j2ee.nodes.J2eeServerNode;
094:        import org.netbeans.jellytools.nodes.ProjectRootNode;
095:        import org.netbeans.jellytools.OutputTabOperator;
096:        import org.netbeans.jemmy.JemmyProperties;
097:        import org.netbeans.jemmy.operators.JCheckBoxOperator;
098:        import org.netbeans.jemmy.operators.JComboBoxOperator;
099:        import org.netbeans.jemmy.operators.JTreeOperator;
100:        import org.netbeans.modules.ws.qaf.WsValidation;
101:
102:        /**
103:         *
104:         * @author jp154641
105:         * 
106:         * This test suite was created to automate most basic Identity test cases
107:         * such as editing of AM Profiles, securing WS and WSC in Web and EJB Module
108:         * Basic functionality for web services area is implemented in WSValidation class
109:         */
110:        public class IdentityValidation extends WsValidation {
111:
112:            /**
113:             * Initialization of suite properties
114:             */
115:            public static String SERVER_PATH;
116:            private static final String SERVERS = Bundle.getString(
117:                    "org.netbeans.modules.j2ee.deployment.impl.ui.Bundle",
118:                    "SERVER_REGISTRY_NODE"); //NOI18N
119:            private static final String TARGET_SERVER_NAME = "Glassfish V2"; //NOI18N
120:            public static File PROJECTS_FOLDER_FILE;
121:            public static File WSP_PROJECT_FILE;
122:            public static File WSC_PROJECT_FILE;
123:
124:            @Override
125:            protected String getWsProjectName() {
126:                return "TestIdentityWSWebApp"; //NOI18N
127:            }
128:
129:            @Override
130:            protected String getWsClientProjectName() {
131:                return "TestIdentityWSCWebApp"; //NOI18N
132:            }
133:
134:            @Override
135:            protected String getWsName() {
136:                return "TestWS"; //NOI18N
137:            }
138:
139:            @Override
140:            protected String getWsPackage() {
141:                return "org.identity.ws.test"; //NOI18N
142:            }
143:
144:            @Override
145:            protected String getWsClientPackage() {
146:                return "org.identity.wsc.test"; //NOI18N
147:            }
148:
149:            /** Creates a new instance of IdentityValidation */
150:            public IdentityValidation(String name) {
151:                super (name);
152:            }
153:
154:            public static TestSuite suite() {
155:                TestSuite suite = new NbTestSuite();
156:                suite.addTest(new IdentityValidation("prepareWSProject")); //NOI18N
157:                suite.addTest(new IdentityValidation("prepareWSClientProject")); //NOI18N
158:                suite.addTest(new IdentityValidationInEJB("prepareWSProject")); //NOI18N
159:                suite.addTest(new IdentityValidationInEJB(
160:                        "prepareWSClientProject")); //NOI18N
161:                suite.addTest(new IdentityValidation("checkAMProfiles")); //NOI18N
162:                suite.addTest(new IdentityValidation("testAMSecurityInWeb")); //NOI18N
163:                suite
164:                        .addTest(new IdentityValidationInEJB(
165:                                "testAMSecurityInEJB")); //NOI18N
166:                suite.addTest(new IdentityValidation("stopSDKGlassfish")); //NOI18N
167:                return suite;
168:            }
169:
170:            /** 
171:             * Use for execution inside IDE 
172:             */
173:            public static void main(java.lang.String[] args) {
174:                // run whole suite
175:                TestRunner.run(suite());
176:            }
177:
178:            /**
179:             * This method creates test web project with web service and two
180:             * operations, then deploys it.
181:             * @throws java.io.IOException
182:             */
183:            public void prepareWSProject() throws IOException {
184:                testCreateNewWs();
185:                //        testChangeServer(false);
186:                testAddOperation();
187:                testDeployWsProject();
188:            }
189:
190:            /**
191:             * This method creates web module and web service client to previously
192:             * deployed web service. The word Client in name ot the suite method
193:             * is essential for correct working of this method!
194:             * @throws java.io.IOException
195:             */
196:            public void prepareWSClientProject() throws IOException {
197:                testCreateWsClient();
198:                //        testChangeServer(true);
199:                testCallWsOperationInServlet();
200:                testDeployWsClientProject();
201:            }
202:
203:            /** 
204:             * Add SDK Glassfish - key component to use AM security 
205:             * - adds SDK Glassfish with Access manager component
206:             */
207:            //    public void addSDKGlassfish() {
208:            //        SERVER_PATH = "/space/SDK"; //NOI18N
209:            //        String osType = System.getProperty("os.name"); //NOI18N
210:            //        if (osType.contains("Windows")) { //NOI18N
211:            //            SERVER_PATH = "E:\\Space\\Sun\\SDK";
212:            ////            SERVER_PATH = "C:\\Sun\\SDK";      //NOI18N For testing purpose only
213:            //        }
214:            //        String actionName = Bundle.getStringTrimmed("org.netbeans.modules.j2ee.deployment.impl.ui.actions.Bundle", "LBL_Add_Server_Instance"); //NOI18N
215:            //        RuntimeTabOperator runtime = new RuntimeTabOperator();
216:            //        runtime.getTimeouts().setTimeout("JTreeOperator.WaitNextNodeTimeout", 90000); //NOI18N
217:            //        Node servers = new Node(runtime.getRootNode(), SERVERS);
218:            //        servers.expand();
219:            //        servers.callPopup().pushMenuNoBlock(actionName);
220:            //        WizardOperator dialog = new WizardOperator(org.netbeans.jellytools.Bundle.getStringTrimmed("org.netbeans.modules.j2ee.deployment.impl.ui.wizard.Bundle", "LBL_ASIW_Title")); //NOI18N
221:            //        new JTextFieldOperator(dialog, 0).setText(TARGET_SERVER_NAME);
222:            //        dialog.next();
223:            //        new JTextFieldOperator(dialog, 0).setText(SERVER_PATH);
224:            //        new org.netbeans.jemmy.EventTool().waitNoEvent(10000);
225:            //        dialog.next();
226:            //        new JTextFieldOperator(dialog, 1).setText("adminadmin"); //NOI18N
227:            //        new JButtonOperator(dialog, "Finish").push(); //NOI18N
228:            //    }
229:            /** 
230:             * Start SDK Glassfish  - to test AM functionality 
231:             * - this feature is neccessary,when we want to test AM profiles,since these are
232:             * available in Runtime tab only if server is running
233:             */
234:            //    public void startSDKGlassfish() {
235:            //        System.out.println("########  TestCase: " + getName() + "  #######"); //NOI18N
236:            //        J2eeServerNode serverNode = J2eeServerNode.invoke(TARGET_SERVER_NAME);
237:            //        JemmyProperties.setCurrentTimeout("Waiter.WaitingTime", 120000); //NOI18N
238:            //        serverNode.start();
239:            //    }
240:            /** 
241:             * Test AM Profiles 
242:             * - this test kills many birds with one stone, when it tests if AM node is present,
243:             * if AM Profiles are editable/configuration test and edit each of them
244:             */
245:            public void checkAMProfiles() {
246:                System.out.println("########  TestCase: " + getName()
247:                        + "  #######"); //NOI18N
248:                J2eeServerNode serverNode = J2eeServerNode
249:                        .invoke(TARGET_SERVER_NAME);
250:                Node profiles = new Node(serverNode, "Access Manager|Profiles"); //NOI18N
251:                editProfile(profiles, "Anonymous"); //NOI18N
252:                editProfile(profiles, "SAML-SenderVouches"); //NOI18N
253:                editProfile(profiles, "SAML-HolderOfKey"); //NOI18N
254:                editProfile(profiles, "X509Token"); //NOI18N
255:                editProfile(profiles, "UserNameToken"); //NOI18N
256:                editProfile(profiles, "UserNameToken-Plain"); //NOI18N
257:                editProfile(profiles, "LibertyX509Token"); //NOI18N
258:                editProfile(profiles, "LibertyBearerToken"); //NOI18N
259:                editProfile(profiles, "LibertySAMLToken"); //NOI18N
260:            }
261:
262:            /** 
263:             * Method for editing of selected profile 
264:             * - we check if Verify Response checkbox is editable
265:             */
266:            public void editProfile(Node profiles, String nodeName) {
267:                Node myNode = new Node(profiles, nodeName);
268:                myNode.callPopup().pushMenuNoBlock("Edit"); //NOI18N
269:                if (nodeName.equals("Anonymous")) { //NOI18N
270:                    new EventTool().waitNoEvent(10000);
271:                }
272:
273:                NbDialogOperator dialog = new NbDialogOperator("Edit "
274:                        + nodeName + " Profile"); //NOI18N
275:                if (!nodeName.startsWith("Liberty")) { //NOI18N
276:                    JCheckBoxOperator checkB = new JCheckBoxOperator(dialog,
277:                            "Sign Response"); //NOI18N
278:                    checkB.push();
279:                }
280:
281:                dialog.ok();
282:                new EventTool().waitNoEvent(2000);
283:            }
284:
285:            /** 
286:             * Stop SDK Glassfish 
287:             * - just stops the server,after testing's done 
288:             */
289:            public void stopSDKGlassfish() {
290:                System.out.println("########  TestCase: " + getName()
291:                        + "  #######"); //NOI18N
292:                J2eeServerNode serverNode = J2eeServerNode
293:                        .invoke(TARGET_SERVER_NAME);
294:                JemmyProperties.setCurrentTimeout("Waiter.WaitingTime", 60000); //NOI18N
295:                serverNode.stop();
296:                new EventTool().waitNoEvent(2000);
297:            }
298:
299:            /** 
300:             * Test of AM security in web project 
301:             * - both ws provider and client 
302:             * - sets AM security in WS provider, deploys WS and then sets AM security in WSC and deploys it
303:             */
304:            public void testAMSecurityInWeb() {
305:                System.out.println("########  TestCase: " + getName()
306:                        + "  #######"); //NOI18N
307:                secureWSinWebModule();
308:                secureWSCinWebModule();
309:            }
310:
311:            /** 
312:             * Test of AM security in ejb project 
313:             * - both ws provider and client 
314:             * - sets AM security in WS provider, deploys WS and then sets AM security in WSC and deploys it
315:             */
316:
317:            /** 
318:             * Setting AM security for WS provider in web module 
319:             */
320:            public void secureWSinWebModule() {
321:                ProjectsTabOperator prj = new ProjectsTabOperator();
322:                JTreeOperator prjtree = new JTreeOperator(prj);
323:                ProjectRootNode prjnd = new ProjectRootNode(prjtree,
324:                        getWsProjectName());
325:                Node websvc = new Node(prjnd, "Web Services|TestWS"); //NOI18N
326:                websvc
327:                        .performPopupActionNoBlock(org.netbeans.jellytools.Bundle
328:                                .getStringTrimmed(
329:                                        "org.netbeans.modules.websvc.customization.core.ui.Bundle",
330:                                        "CTL_EditAttributesAction")); //NOI18N
331:                NbDialogOperator dialog = new NbDialogOperator("TestWS"); //NOI18N
332:                JCheckBoxOperator activate = new JCheckBoxOperator(dialog, 0);
333:                activate.push();
334:                JComboBoxOperator profiles = new JComboBoxOperator(dialog, 0);
335:                profiles.selectItem("SAML-HolderOfKey"); //NOI18N
336:                new EventTool().waitNoEvent(1000);
337:                dialog.ok();
338:                prjnd.performPopupActionNoBlock("Undeploy and Deploy"); //NOI18N
339:                OutputTabOperator oto = new OutputTabOperator(
340:                        getWsProjectName());
341:                JemmyProperties.setCurrentTimeout(
342:                        "ComponentOperator.WaitStateTimeout", 120000); //NOI18N
343:                oto.waitText("(total time: "); //NOI18N
344:                assertTrue(oto.getText().indexOf("BUILD SUCCESSFUL") > -1); //NOI18N  
345:            }
346:
347:            /** 
348:             * Setting AM security for WS client in web module 
349:             */
350:            public void secureWSCinWebModule() {
351:                ProjectsTabOperator prj = new ProjectsTabOperator();
352:                JTreeOperator prjtree = new JTreeOperator(prj);
353:                ProjectRootNode prjnd = new ProjectRootNode(prjtree,
354:                        getWsClientProjectName());
355:                Node websvc = new Node(prjnd,
356:                        "Web Service References|TestWSService"); //NOI18N
357:                new EventTool().waitNoEvent(10000);
358:                websvc
359:                        .performPopupActionNoBlock(org.netbeans.jellytools.Bundle
360:                                .getStringTrimmed(
361:                                        "org.netbeans.modules.websvc.core.jaxws.actions.Bundle",
362:                                        "LBL_RefreshClientAction")); //NOI18N
363:                NbDialogOperator ccr = new NbDialogOperator(
364:                        "Confirm Client Refresh"); //NOI18N
365:                ccr.yes();
366:                new EventTool().waitNoEvent(10000);
367:                websvc
368:                        .performPopupActionNoBlock(org.netbeans.jellytools.Bundle
369:                                .getStringTrimmed(
370:                                        "org.netbeans.modules.websvc.customization.core.ui.Bundle",
371:                                        "CTL_EditAttributesAction")); //NOI18N
372:                NbDialogOperator dialog = new NbDialogOperator("TestWSService"); //NOI18N
373:                JCheckBoxOperator activate = new JCheckBoxOperator(
374:                        dialog,
375:                        org.netbeans.jellytools.Bundle
376:                                .getStringTrimmed(
377:                                        "org.netbeans.modules.identity.profile.ui.Bundle",
378:                                        "LBL_EnableSecurity")); //NOI18N
379:                activate.push();
380:                JComboBoxOperator profiles = new JComboBoxOperator(dialog, 0);
381:                profiles.selectItem("SAML-HolderOfKey"); //NOI18N
382:                new EventTool().waitNoEvent(1000);
383:                dialog.ok();
384:                prjnd.performPopupActionNoBlock("Undeploy and Deploy"); //NOI18N
385:                OutputTabOperator oto = new OutputTabOperator(
386:                        getWsClientProjectName());
387:                JemmyProperties.setCurrentTimeout(
388:                        "ComponentOperator.WaitStateTimeout", 120000); //NOI18N
389:                oto.waitText("(total time: "); //NOI18N
390:                assertTrue(oto.getText().indexOf("BUILD SUCCESSFUL") > -1); //NOI18N  
391:            }
392:
393:            /**
394:             * Changes server for test projects,created on default server to SDK Glassfish.
395:             * @param client is for determination of project name.
396:             */
397:            //    private void testChangeServer(boolean client) {
398:            //        String actual = getWsProjectName();
399:            //        if(client){
400:            //            actual = getWsClientProjectName();
401:            //        }
402:            //        ProjectRootNode prj = ProjectsTabOperator.invoke().getProjectRootNode(actual);
403:            //        prj.performPopupActionNoBlock(org.netbeans.jellytools.Bundle.getStringTrimmed("org.openide.nodes.Bundle", "Properties")); //NOI18N
404:            //        // "Project Properties"
405:            //        String projectPropertiesTitle = Bundle.getStringTrimmed("org.netbeans.modules.web.project.ui.customizer.Bundle", "LBL_Customizer_Title"); //NOI18N
406:            //        NbDialogOperator propertiesDialogOper = new NbDialogOperator(projectPropertiesTitle);
407:            //        // "Run"
408:            //        String runLabel = Bundle.getString("org.netbeans.modules.web.project.ui.customizer.Bundle", "LBL_Config_Run"); //NOI18N
409:            //        // select "Run" category
410:            //        new Node(new JTreeOperator(propertiesDialogOper), runLabel).select();
411:            //        JComboBoxOperator server = new JComboBoxOperator(propertiesDialogOper,0);
412:            //        server.selectItem(TARGET_SERVER_NAME);
413:            //        propertiesDialogOper.ok();
414:            //    }  
415:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.