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


001:        // Copyright © 2002-2005 Canoo Engineering AG, Switzerland.
002:        package com.canoo.webtest.steps.verify;
003:
004:        import com.canoo.webtest.engine.StepFailedException;
005:        import com.canoo.webtest.extension.StoreElementAttribute;
006:        import com.canoo.webtest.steps.Step;
007:        import com.canoo.webtest.steps.form.AbstractSetFieldStep;
008:        import com.gargoylesoftware.htmlunit.html.HtmlElement;
009:        import com.gargoylesoftware.htmlunit.html.HtmlForm;
010:        import org.apache.log4j.Logger;
011:
012:        import java.io.IOException;
013:        import java.util.List;
014:
015:        /**
016:         * @author Marc Guillemot
017:         * @author Paul King
018:         * @author Denis N. Antonioli
019:         */
020:        public abstract class AbstractVerifyFormStep extends Step {
021:            private static final Logger LOG = Logger
022:                    .getLogger(AbstractVerifyFormStep.class);
023:
024:            private String fName;
025:            private String fValue;
026:            private String fFormName;
027:            private String fFieldIndex;
028:            private String fHtmlId;
029:            private String fXPath;
030:
031:            /**
032:             * @param name
033:             * @webtest.parameter
034:             * 	 required="yes"
035:             * description="The xpath of the input field of interest. One of <em>name</em>, <em>htmlId</em> or <em>xpath</em> is required."
036:             */
037:            public void setName(final String name) {
038:                fName = name;
039:            }
040:
041:            public String getName() {
042:                return fName;
043:            }
044:
045:            /**
046:             * @param value
047:             * @webtest.parameter
048:             * 	 required="no"
049:             *   description="The value of the input field of interest."
050:             */
051:            public void setValue(final String value) {
052:                fValue = value;
053:            }
054:
055:            public String getValue() {
056:                return fValue;
057:            }
058:
059:            /**
060:             * @param formName
061:             * @webtest.parameter
062:             *   required="no"
063:             *   description="The name of the form containing the field of interest."
064:             */
065:            public void setFormName(final String formName) {
066:                fFormName = formName;
067:            }
068:
069:            public String getFormName() {
070:                return fFormName;
071:            }
072:
073:            /**
074:             * @param index
075:             * @webtest.parameter
076:             *   required="no"
077:             *   description="The index (starting at 0) of the field of interest (if more than one)."
078:             */
079:            public void setFieldIndex(final String index) {
080:                fFieldIndex = index;
081:            }
082:
083:            public String getFieldIndex() {
084:                return fFieldIndex;
085:            }
086:
087:            /**
088:             * Set the xpath.
089:             *
090:             * @param xpath
091:             * @webtest.parameter required="yes/no"
092:             * description="The xpath of the input field of interest. One of <em>name</em>, <em>htmlId</em> or <em>xpath</em> is required."
093:             */
094:            public void setXpath(final String xpath) {
095:                fXPath = xpath;
096:            }
097:
098:            public String getXpath() {
099:                return fXPath;
100:            }
101:
102:            /**
103:             * Set the html id.
104:             *
105:             * @param htmlId
106:             * @webtest.parameter required="yes/no"
107:             * description="The id of the input field of interest. One of <em>name</em>, <em>htmlId</em> or <em>xpath</em> is required."
108:             */
109:            public void setHtmlId(final String htmlId) {
110:                fHtmlId = htmlId;
111:            }
112:
113:            public String getHtmlId() {
114:                return fHtmlId;
115:            }
116:
117:            public void doExecute() throws IOException {
118:                if (getName() != null) {
119:                    final HtmlForm form = findForm();
120:                    if (form == null) {
121:                        throw new StepFailedException(
122:                                "No suitable form found having field named \""
123:                                        + getName() + "\"", this );
124:                    }
125:                    verifyField(AbstractSetFieldStep.selectField(
126:                            findFields(form), getFieldIndex(), this ));
127:                } else {
128:                    verifyField(StoreElementAttribute.findElement(getContext()
129:                            .getCurrentResponse(), getHtmlId(), getXpath(),
130:                            LOG, this ));
131:                }
132:            }
133:
134:            /**
135:             * Finds the relevant form.
136:             *
137:             */
138:            protected abstract HtmlForm findForm();
139:
140:            /**
141:             * Finds then verifies the field of interest.
142:             * @param form
143:             */
144:            protected abstract List findFields(final HtmlForm form);
145:
146:            /**
147:             * Verifies a field according to the step.
148:             * It is up to the step's implementation to decide how to verify the step.
149:             *
150:             * @param field The field to verify.
151:             */
152:            protected abstract void verifyField(final HtmlElement field)
153:                    throws IOException;
154:
155:            protected void verifyParameters() {
156:                super .verifyParameters();
157:                nullResponseCheck();
158:
159:                int count = 0;
160:                if (getXpath() != null) {
161:                    count++;
162:                }
163:                if (getName() != null) {
164:                    count++;
165:                }
166:                if (getHtmlId() != null) {
167:                    count++;
168:                }
169:                paramCheck(count == 0,
170:                        AbstractSetFieldStep.MESSAGE_ARGUMENT_MISSING);
171:                paramCheck(count > 1,
172:                        AbstractSetFieldStep.MESSAGE_ARGUMENT_REDUNDANT);
173:                if (getName() == null) {
174:                    paramCheck(getFieldIndex() != null,
175:                            "The attribute 'fieldIndex' is only valid with the attribute 'name'.");
176:                } else {
177:                    optionalIntegerParamCheck(getFieldIndex(), "fieldIndex",
178:                            false);
179:                }
180:            }
181:
182:            protected boolean isValueNull() {
183:                return getValue() == null;
184:            }
185:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.