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


001:        // Copyright © 2002-2007 Canoo Engineering AG, Switzerland.
002:        package com.canoo.webtest.steps.request;
003:
004:        import java.io.File;
005:
006:        import com.canoo.webtest.engine.StepFailedException;
007:        import com.canoo.webtest.engine.WebTestException;
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:        import com.gargoylesoftware.htmlunit.MockWebConnection;
013:
014:        /**
015:         * Unit tests for {@link InvokePage}.
016:         * @author Unknown
017:         * @author Marc Guillemot
018:         */
019:        public class InvokePageTest extends BaseStepTestCase {
020:            protected Step createStep() {
021:                return new InvokePage();
022:            }
023:
024:            public void testExecuteFailsWithoutUrl() {
025:                assertErrorOnExecute(getStep(), "no Url", "");
026:            }
027:
028:            public void testExecuteFailsWithTooManyParams() {
029:                InvokePage step = (InvokePage) getStep();
030:                step.setMethod("POST");
031:                assertErrorOnExecute(step,
032:                        "post with no content or contentFile", "");
033:                step.setContent("dummy");
034:                step.setContentFile(new File("dummy"));
035:                assertErrorOnExecute(step, "both content and contentFile", "");
036:            }
037:
038:            /**
039:             * Tests that javascript errors are caught and correctly reported
040:             * @throws Exception if the test fails
041:             */
042:            public void testCatchRuntimeScriptError() throws Exception {
043:                final String url = "http://myhost.mydomain/myPage.html";
044:                final String html = "<html><head><script>notExisting()</script></head></html>";
045:                final String message = checkCodeWithScriptError(url, html)
046:                        .getMessage();
047:                assertTrue("message doesn't contain page url: " + message,
048:                        message.indexOf(url) != -1);
049:                assertTrue(
050:                        "message doesn't contain information about failing function: "
051:                                + message, message.indexOf("notExisting") != -1);
052:            }
053:
054:            /**
055:             * Tests that javascript parsing errors are caught and correctly reported
056:             * @throws Exception if the test fails
057:             */
058:            public void testCatchParseScriptError() throws Exception {
059:                final String url = "http://myhost.mydomain/myPage.html";
060:                final String html = "<html><head><script>var a = 1;\nnotExisting(;</script></head></html>";
061:                final WebTestException t = (WebTestException) checkCodeWithScriptError(
062:                        url, html);
063:                assertTrue("message doesn't contain page url: "
064:                        + t.getMessage(), t.getMessage().indexOf(url) != -1);
065:                assertTrue(
066:                        "message doesn't contain information about non parseable code: "
067:                                + t.getDetails(), t.getDetails().toString()
068:                                .indexOf("notExisting(;") != -1);
069:            }
070:
071:            /**
072:             * Loads the given html as answer from the url,
073:             * checks that a StepFailedException is thrown and return the error message
074:             * @return the error message
075:             */
076:            private Throwable checkCodeWithScriptError(final String url,
077:                    final String html) {
078:                final InvokePage step = (InvokePage) getStep();
079:                ((MockWebConnection) getContext().getWebClient()
080:                        .getWebConnection()).setDefaultResponse(html);
081:
082:                step.setUrl(url);
083:                final TestBlock block = new TestBlock() {
084:                    public void call() throws Throwable {
085:                        step.execute();
086:                    }
087:                };
088:                return ThrowAssert.assertThrows("", StepFailedException.class,
089:                        block);
090:            }
091:
092:            public void testNestedText() throws Exception {
093:                InvokePage invokeStep = (InvokePage) getStep();
094:                testNestedTextEquivalent(invokeStep, "url");
095:
096:                invokeStep = (InvokePage) createAndConfigureStep();
097:                invokeStep.setUrl("http://my.web.site/foo");
098:                testNestedTextEquivalent(invokeStep, "content");
099:
100:            }
101:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.