Source Code Cross Referenced for VerifyPropertyTest.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 © 2004-2005 ASERT. Released under the Canoo Webtest license.
002:        package com.canoo.webtest.steps.verify;
003:
004:        import org.apache.tools.ant.Project;
005:
006:        import com.canoo.webtest.engine.StepExecutionException;
007:        import com.canoo.webtest.engine.StepFailedException;
008:        import com.canoo.webtest.self.TestBlock;
009:        import com.canoo.webtest.self.ThrowAssert;
010:        import com.canoo.webtest.steps.BaseStepTestCase;
011:        import com.canoo.webtest.steps.Step;
012:
013:        /**
014:         * Tests the verifyProperty step.
015:         *
016:         * @author   Paul King, ASERT
017:         */
018:        public class VerifyPropertyTest extends BaseStepTestCase {
019:            private VerifyProperty fStep;
020:
021:            protected void setUp() throws Exception {
022:                super .setUp();
023:                fStep = (VerifyProperty) getStep();
024:                fStep.setWebtestProperty("dynProp", "The DynProp Value");
025:                fStep.setProject(new Project());
026:                fStep.getProject().setNewProperty("antProp",
027:                        "The AntProp Value");
028:            }
029:
030:            protected Step createStep() {
031:                return new VerifyProperty();
032:            }
033:
034:            public void testAliases() throws Exception {
035:                fStep.setValue("foo");
036:                assertEquals("foo", fStep.getValue());
037:                assertEquals("foo", fStep.getText());
038:                fStep.setText("fii");
039:                assertEquals("fii", fStep.getValue());
040:                assertEquals("fii", fStep.getText());
041:
042:                fStep.setProperty("foo");
043:                assertEquals("foo", fStep.getProperty());
044:                assertEquals("foo", fStep.getName());
045:                fStep.setName("fii");
046:                assertEquals("fii", fStep.getProperty());
047:                assertEquals("fii", fStep.getName());
048:            }
049:
050:            /*
051:             * There is some overlap with the functional tests in these
052:             * unit tests but thought it was better to be safe than sorry
053:             */
054:
055:            // <verifyProperty />
056:            public void testNoPropertyNameAttributes() throws Exception {
057:                assertStepRejectsNullParam("name", new TestBlock() {
058:                    public void call() throws Exception {
059:                        executeStep(fStep);
060:                    }
061:                });
062:            }
063:
064:            // <verifyProperty name="dynProp" />
065:            public void testDynPropertyExists() throws Exception {
066:                fStep.setName("dynProp");
067:                executeStep(fStep);
068:            }
069:
070:            // <verifyProperty name="antProp" propertyType="ant" />
071:            public void testAntPropertyExists() throws Exception {
072:                fStep.setName("antProp");
073:                fStep.setPropertyType(Step.PROPERTY_TYPE_ANT);
074:                executeStep(fStep);
075:            }
076:
077:            // <verifyProperty name="dynProp" text="The DynProp Value"/>
078:            public void testDynPropertyHasCorrectValue() throws Exception {
079:                fStep.setName("dynProp");
080:                fStep.setText("The DynProp Value");
081:                executeStep(fStep);
082:            }
083:
084:            // <verifyProperty name="antProp" propertyType="ant" text="The AntProp Value"/>
085:            public void testAntPropertyHasCorrectValue() throws Exception {
086:                fStep.setName("antProp");
087:                fStep.setPropertyType(Step.PROPERTY_TYPE_ANT);
088:                fStep.setText("The AntProp Value");
089:                executeStep(fStep);
090:            }
091:
092:            // <verifyProperty name="dynProp" text="The DynProp Value"/>
093:            public void testDynPropertyValueWithRegex() throws Exception {
094:                fStep.setName("dynProp");
095:                fStep.setRegex("true");
096:                fStep.setText(".*Value");
097:                executeStep(fStep);
098:            }
099:
100:            // <verifyProperty name="antProp" propertyType="ant" text="The AntProp Value"/>
101:            public void testAntPropertyValueWithRegex() throws Exception {
102:                fStep.setName("antProp");
103:                fStep.setPropertyType(Step.PROPERTY_TYPE_ANT);
104:                fStep.setRegex("true");
105:                fStep.setText(".*Value");
106:                executeStep(fStep);
107:            }
108:
109:            // <verifyProperty name="dynProp" text="Something completely different" />
110:            public void testDynPropertyIncorrectValue() throws Exception {
111:                fStep.setName("dynProp");
112:                fStep.setText("Something completely different");
113:                String msg = ThrowAssert.assertThrows(
114:                        StepFailedException.class, new TestBlock() {
115:                            public void call() throws Exception {
116:                                executeStep(fStep);
117:                            }
118:                        });
119:                assertTrue(msg.indexOf("Incorrect property value found!") != -1);
120:            }
121:
122:            // <verifyProperty name="antProp" propertyType="ant" text="Something completely different" />
123:            public void testAntPropertyIncorrectValue() throws Exception {
124:                fStep.setName("antProp");
125:                fStep.setPropertyType(Step.PROPERTY_TYPE_ANT);
126:                fStep.setText("Something completely different");
127:                String msg = ThrowAssert.assertThrows(
128:                        StepFailedException.class, new TestBlock() {
129:                            public void call() throws Exception {
130:                                executeStep(fStep);
131:                            }
132:                        });
133:                assertTrue(msg.indexOf("Incorrect property value found!") != -1);
134:            }
135:
136:            // <verifyProperty name="someOtherProp" text="The DynProp Value" />
137:            public void testDynPropertyUnknownName() throws Exception {
138:                fStep.setName("someOtherProp");
139:                fStep.setText("The DynProp Value");
140:                String msg = ThrowAssert.assertThrows(
141:                        StepFailedException.class, new TestBlock() {
142:                            public void call() throws Exception {
143:                                executeStep(fStep);
144:                            }
145:                        });
146:                assertTrue(msg
147:                        .indexOf("Expected property \"someOtherProp\" to be defined!") != -1);
148:            }
149:
150:            // <verifyProperty name="antProp" text="The AntProp Value" propertyType="unknown"/>
151:            public void testUnknownPropertyType() {
152:                fStep.setName("antProp");
153:                fStep.setPropertyType("unknown");
154:                fStep.setText("The AntProp Value");
155:                String msg = ThrowAssert.assertThrows(
156:                        StepExecutionException.class, new TestBlock() {
157:                            public void call() throws Exception {
158:                                executeStep(fStep);
159:                            }
160:                        });
161:                assertTrue(msg.indexOf("Unknown propertyType") != -1);
162:            }
163:
164:            // <verifyProperty name="someOtherProp" propertyType="ant" text="The AntProp Value" />
165:            public void testAntPropertyUnknownName() throws Exception {
166:                fStep.setName("someOtherProp");
167:                fStep.setPropertyType(Step.PROPERTY_TYPE_ANT);
168:                fStep.setText("The AntProp Value");
169:                String msg = ThrowAssert.assertThrows(
170:                        StepFailedException.class, new TestBlock() {
171:                            public void call() throws Exception {
172:                                executeStep(fStep);
173:                            }
174:                        });
175:                assertTrue(msg
176:                        .indexOf("Expected property \"someOtherProp\" to be defined!") != -1);
177:            }
178:
179:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.