Source Code Cross Referenced for SelectForm.java in  » Testing » webtest » com » canoo » webtest » steps » form » 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 » Testing » webtest » com.canoo.webtest.steps.form 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        // Copyright © 2002-2005 Canoo Engineering AG, Switzerland.
002:        package com.canoo.webtest.steps.form;
003:
004:        import com.canoo.webtest.engine.Context;
005:        import com.canoo.webtest.engine.StepFailedException;
006:        import com.canoo.webtest.steps.Step;
007:        import com.canoo.webtest.util.FormUtil;
008:        import com.gargoylesoftware.htmlunit.html.HtmlForm;
009:        import com.gargoylesoftware.htmlunit.html.HtmlPage;
010:        import org.apache.log4j.Logger;
011:        import org.apache.commons.lang.StringUtils;
012:
013:        /**
014:         * Provides the ability to select a form as the current form for setting fields in this form
015:         * in subsequent steps.
016:         *
017:         * @author Marc Guillemot
018:         * @webtest.step
019:         *   category="Core"
020:         *   name="selectForm"
021:         *   alias="new_selectform,selectform"
022:         *   description="This step can be used to specify a form in the document as the <em>current form</em>. The <em>current form</em> is given precedence when locating the form to use in form-related steps."
023:         */
024:        public final class SelectForm extends Step {
025:            private static final Logger LOG = Logger
026:                    .getLogger(SelectForm.class);
027:            private String fIndex;
028:            private String fName;
029:
030:            /**
031:             * Select a form as the current one.
032:             *
033:             * @throws com.canoo.webtest.engine.StepExecutionException if no form is found
034:             */
035:            public void doExecute() throws Exception {
036:                nullResponseCheck();
037:                final Context context = getContext();
038:                final HtmlPage currentResp = (HtmlPage) context
039:                        .getCurrentResponse();
040:                LOG.debug("Selecting current form in response from "
041:                        + currentResp.getWebResponse().getUrl());
042:                HtmlForm form;
043:                if (fName != null) {
044:                    form = FormUtil.findFormByName(currentResp, fName);
045:                } else {
046:                    form = FormUtil.findFormByIndex(currentResp, fIndex);
047:                }
048:                if (form == null) {
049:                    throw new StepFailedException("Form not found in doc", this );
050:                }
051:                context.setCurrentForm(form);
052:            }
053:
054:            /**
055:             * Set the index.
056:             *
057:             * @param index
058:             * @webtest.parameter
059:             *   required="yes/no"
060:             *   description="The <em>index</em> of the form to select (starting at 0). Either <em>name</em> or <em>index</em> is required."
061:             */
062:            public void setIndex(final String index) {
063:                fIndex = index;
064:            }
065:
066:            public String getIndex() {
067:                return fIndex;
068:            }
069:
070:            /**
071:             * Set the name.
072:             *
073:             * @param name
074:             * @webtest.parameter
075:             *   required="yes/no"
076:             *   description="The <em>name</em> of the form to select (i.e. the value of the NAME attribute in <form name='foo' ... >). Either <em>name</em> or <em>index</em> is required."
077:             */
078:            public void setName(final String name) {
079:                fName = name;
080:            }
081:
082:            public String getName() {
083:                return fName;
084:            }
085:
086:            protected void verifyParameters() {
087:                super .verifyParameters();
088:                paramCheck(StringUtils.isEmpty(fName)
089:                        && StringUtils.isEmpty(fIndex),
090:                        "Either \"name\" or \"index\"  must be set");
091:                paramCheck(!StringUtils.isEmpty(fName)
092:                        && !StringUtils.isEmpty(fIndex),
093:                        "Only one of \"name\" and \"index\"  must be set");
094:                optionalIntegerParamCheck(fIndex, "index", false); // if exists, must be integer
095:            }
096:
097:            /**
098:             * Called by Ant to set the text nested between opening and closing tags.
099:             * @param text the text to set
100:             * @webtest.nested.parameter
101:             *    required="no"
102:             *    description="Alternative way to set the 'name' attribute."
103:             */
104:            public void addText(final String text) {
105:                setName(text);
106:            }
107:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.