Source Code Cross Referenced for CheckTableCellCommand.java in  » Testing » slimdog » org » jzonic » webtester » commands » 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 » slimdog » org.jzonic.webtester.commands 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.jzonic.webtester.commands;
002:
003:        import org.jzonic.webtester.WebTestContext;
004:
005:        import com.meterware.httpunit.WebTable;
006:
007:        /**
008:         * This command will check if cell of a table contains
009:         * the required text. The x and y position are zero based.
010:         * If the x or y position is out of bounds for the table
011:         * then the test will fail. <br/>
012:         * The test will fail if no table was selected before.
013:         * <br/>
014:         * The required text can also contain variables
015:         * <br/>
016:         * parameter: (xpos,ypos) = text
017:         * <br/>
018:         * example:
019:         * <br/>
020:         * check_tablecell | (1,1) = Hello world
021:         * <br/>
022:         * check_tablecell | (2,5) = ${username}
023:         * 
024:         * @author Mecky
025:         */
026:        public class CheckTableCellCommand implements  WebTestNode {
027:
028:            public static final String COMMAND_NAME = "check_tablecell";
029:            private String searchText;
030:            private int x = -1;
031:            private int y = -1;
032:
033:            public WebTestNodeResult execute(WebTestContext context) {
034:                WebTestNodeResult result = new WebTestNodeResult(COMMAND_NAME,
035:                        "(" + x + "," + y + ") " + searchText);
036:                WebTable table = context.getTable();
037:                if (x == -1 || y == -1) {
038:                    result.setSuccess(false);
039:                    result
040:                            .setErrorMessage("check_tablecell: no valid cell position defined: x="
041:                                    + x + " y=" + y);
042:                } else {
043:                    if (table != null) {
044:                        try {
045:                            String cellText = table.getCellAsText(x, y);
046:                            String sText = context.replaceVar(searchText);
047:                            if (cellText.equals(sText)) {
048:                                result.setSuccess(true);
049:                            } else {
050:                                result.setSuccess(false);
051:                                result
052:                                        .setErrorMessage("check_tablecell: required:"
053:                                                + searchText
054:                                                + " but found:"
055:                                                + cellText);
056:                            }
057:                        } catch (Exception e) {
058:                            result.setSuccess(false);
059:                            result
060:                                    .setErrorMessage("check_tablecell: the position x="
061:                                            + x
062:                                            + " y="
063:                                            + y
064:                                            + " is out of bounds");
065:                        }
066:                    } else {
067:                        result.setSuccess(false);
068:                        result
069:                                .setErrorMessage("check_tablecell: no table selected");
070:                    }
071:                }
072:                return result;
073:            }
074:
075:            public void setParameter(String value) {
076:                String tmp = value.substring(0, value.indexOf("="));
077:                tmp = tmp.trim();
078:                if (tmp.startsWith("(")) {
079:                    tmp = tmp.substring(1);
080:                }
081:                if (tmp.endsWith(")")) {
082:                    tmp = tmp.substring(0, tmp.length() - 1);
083:                }
084:                if (tmp.indexOf(",") != -1) {
085:                    String xp = tmp.substring(0, tmp.indexOf(","));
086:                    String yp = tmp.substring(tmp.indexOf(",") + 1);
087:                    try {
088:                        x = Integer.parseInt(xp.trim());
089:                        y = Integer.parseInt(yp.trim());
090:                    } catch (Exception e) {
091:
092:                    }
093:                }
094:                searchText = value.substring(value.indexOf("=") + 1);
095:                searchText = searchText.trim();
096:            }
097:
098:            public String getName() {
099:                return COMMAND_NAME;
100:            }
101:
102:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.