Source Code Cross Referenced for VerifyText.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 java.io.IOException;
005:
006:        import org.xml.sax.SAXException;
007:
008:        import com.canoo.webtest.engine.Context;
009:        import com.canoo.webtest.engine.StepFailedException;
010:        import com.canoo.webtest.interfaces.IStepWithTableLocator;
011:        import com.canoo.webtest.interfaces.ITableLocator;
012:        import com.canoo.webtest.steps.locator.TableLocator;
013:        import com.canoo.webtest.steps.locator.TableNotFoundException;
014:
015:        /**
016:         * @author Carsten Seibert
017:         * @author Marc Guillemot
018:         * @webtest.step
019:         *   category="Core"
020:         *   name="verifyText"
021:         *   alias="verifytext"
022:         *   description="This step verifies the existence of the specified string somewhere in the response received from server
023:         *   (ie the changes that may have occured since the page has been loaded are not seen by this step). 
024:         *   The text could represent an <key>HTML</key> fragment like \"<BODY>\" or a arbitrary static text in the page (\"An application error has occurred!\")."
025:         */
026:        public class VerifyText extends AbstractVerifyTextStep implements 
027:                IStepWithTableLocator {
028:            private ITableLocator fTableLocator;
029:
030:            /**
031:             * Called by Ant to set the text nested between opening and closing tags.
032:             * @param text the text to set
033:             * @webtest.nested.parameter
034:             *    required="no"
035:             *    description="Alternative way to set the 'text' attribute."
036:             */
037:            public void addText(final String text) {
038:                if (getText() == null)
039:                    setText(getProject().replaceProperties(text));
040:            }
041:
042:            /**
043:             * @param tableLocator
044:             * @webtest.nested.parameter
045:             *    required="no"
046:             *    description="To locate a specific cell in a specific table on the page."
047:             */
048:            public void addTable(final TableLocator tableLocator) {
049:                addTableInternal(tableLocator);
050:            }
051:
052:            public void addTableInternal(final ITableLocator tableLocator) {
053:                fTableLocator = tableLocator;
054:            }
055:
056:            public void doExecute() throws Exception {
057:                if (!isExpectedStringPresent()) {
058:                    throw new StepFailedException(getStepLabel() + ": "
059:                            + getFailedMessage(), this );
060:                }
061:            }
062:
063:            protected String getFailedMessage() {
064:                return "Text not found in page. Expected <" + getText() + ">";
065:            }
066:
067:            /**
068:             * @deprecated Use {@link #isExpectedStringPresent()}
069:             */
070:            protected boolean isExpectedStringPresent(final Context context)
071:                    throws SAXException, IOException {
072:                return isExpectedStringPresent();
073:            }
074:
075:            protected boolean isExpectedStringPresent() throws SAXException,
076:                    IOException {
077:                Context context = getContext();
078:                try {
079:                    String text;
080:
081:                    if (getTableLocator() == null) {
082:                        text = context.getCurrentResponse().getWebResponse()
083:                                .getContentAsString();
084:                    } else {
085:                        text = getTableLocator().locateText(context, this );
086:                    }
087:                    if (isRegex()) {
088:                        return verifyText(text);
089:                    }
090:                    return text.indexOf(getText()) > -1;
091:                } catch (TableNotFoundException tnf) {
092:                    throw new StepFailedException("Cannot find table: "
093:                            + tnf.toString(), this );
094:                } catch (IndexOutOfBoundsException ioobe) {
095:                    throw new StepFailedException(
096:                            "Cannot find cell with supplied index in table",
097:                            this );
098:                }
099:            }
100:
101:            public ITableLocator getTableLocator() {
102:                return fTableLocator;
103:            }
104:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.