com.meterware.httpunit

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 » HttpUnit » com.meterware.httpunit 
com.meterware.httpunit
Classes for testing http server systems. Each test session should begin by creating a {@link com.meterware.httpunit.WebConversation WebConversation} to which it should submit an initial {@link com.meterware.httpunit.GetMethodWebRequest http request} using the {@link com.meterware.httpunit.WebConversation#getResponse getResponse} method. With each subsequent step, it will typically examine the response either textually or as a DOM, and create new requests based on either submitting a form or clicking on a link.

Installation

The package depends on a number of external jar files, provided in the jar directory:
nekohtml.jar
The NekoHTML parser, used to convert raw HTML into an XML DOM. This is required for handling HTML.
js.jar
The Rhino JavaScript interpreter, required for any JavaScript processing.
xmlParserAPIs.jar
The interfaces for a W3-compliant XML parser. Required for interpreting either HTML or XML pages.
xercesImpl.jar
The Xerces 2 implementation of an XML parser. NekoHTML requires this implementation.
servlet.jar
The APIs and common classes for the Java Servlet 1.3 standard. Required for use with ServletUnit.
junit.jar
JUnit, the unit test framework. Used to test HttpUnit and recommended for writing tests that use HttpUnit.
tidy.jar
JTidy, an alternate HTML parser/validator. JTidy is a lot pickier about HTML structure than NekoHTML, and uses its own implementation of the DOM classes, rather than using those found in the xerces jar. Some JavaScript features, such as document.write() will only work with NekoHTML.

Example

In the following code, a web conversation is started and an initial request sent. The program then prints out the response and extracts the first form (the login form) from it. After setting the name parameter to the desired value, it submits the form and prints the response.
import com.meterware.httpunit.*;

import java.io.IOException;
import java.net.MalformedURLException;

import org.xml.sax.*;

public class Example {


    public static void main( String[] params ) {
        try {
            WebConversation     conversation = new WebConversation();
            
            WebResponse response = conversation.getResponse( "http://www.meterware.com/servlet/TopSecret" );
            System.out.println( response );

            WebForm loginForm = response.getForms()[0];

            loginForm.setParameter( "name", "master" );
            response = loginForm.submit();
            System.out.println( response );

        } catch (Exception e) {
            System.err.println( "Exception: " + e );
        }
    }
}
Please direct any questions to Russell Gold.
Java Source File NameTypeComment
AppletContextImpl.javaClass
AppletStubImpl.javaClass
AuthorizationRequiredException.javaClass This exception is thrown when an unauthorized request is made for a page that requires authentication.
Base64.javaClass A utility class to convert to and from base 64 encoding.
BlockElement.javaClass Represents a block-level element such as a paragraph or table cell, which can contain other elements.
Button.javaClass A button in a form.
ClientProperties.javaClass A class which represents the properties of a web client.
ContentConcealer.javaInterface This is a marker interface implemented by HTMLElement classes which hide their content.
DialogAdapter.javaClass
DialogResponder.javaInterface Interface for an object to supply user responses to dialogs.
DNSListener.javaInterface A listener for DNS Requests.
FixedURLWebRequestSource.javaClass An implementation of web request source whose URL does not change under user action.
FormControl.javaClass Represents a control in an HTML form.
FormParameter.javaClass Represents the aggregate of all form controls with a particular name.
FrameHolder.javaClass
FrameSelector.javaClass An immutable class which describes the position of a frame in the window hierarchy.
GetMethodWebRequest.javaClass An HTTP request using the GET method.
HeaderOnlyWebRequest.javaClass A web request which has no information in its message body.
HeadMethodWebRequest.javaClass A web request using the HEAD method.
HTMLElement.javaInterface An interface which defines the common properties for an HTML element, which can correspond to any HTML tag.
HTMLElementBase.javaClass
HTMLElementPredicate.javaInterface An interface which can be used to define matching criteria for an HTML element.
HTMLElementScriptable.javaClass
HtmlErrorListener.javaInterface This interface represents a listener which can receive notification of errors and warnings during the parsing of an HTML page.
HTMLPage.javaClass This class represents an HTML page returned from a request.
HTMLSegment.javaInterface Represents the parse tree for a segment of HTML.
HttpException.javaClass This exception is thrown when an Http error (response code 4xx or 5xx) is detected.
HttpInternalErrorException.javaClass This exception is thrown when an internal error is found on the server.
HttpNotFoundException.javaClass This exception is thrown when the desired URL is not found.
HttpsProtocolSupport.javaClass Encapsulates support for the HTTPS protocol.
HttpUnitOptions.javaClass A collection of global options to control HttpUnit's behavior.
HttpUnitUtils.javaClass Utility code shared by httpunit and servletunit.
HttpWebResponse.javaClass A response from a web server to an Http request.
IllegalRequestParameterException.javaClass This exception is thrown on an attempt to set a form parameter in a way not possible from a browser.
MessageBody.javaClass An abstract class representing the body of a web request.
MessageBodyWebRequest.javaClass A web request which contains a non-empty message body.
MimeEncodedMessageBody.javaClass A POST-method message body which is MIME-encoded.
NodeUtils.javaClass Some common utilities for manipulating DOM nodes.
NoSuchFrameException.javaClass
NotHTMLException.javaClass $Id: NotHTMLException.java,v 1.1 2002/05/16 17:44:20 russgold Exp $ Copyright (c) 2002, Russell Gold Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
ParameterHolder.javaClass This abstract class is extended by classes which hold parameters for web requests.
ParameterProcessor.javaInterface
ParsedHTML.javaClass
PostMethodWebRequest.javaClass An HTTP request using the POST method.
PutMethodWebRequest.javaClass A web request using the PUT protocol.
RequestContext.javaClass The context for a request which could have subrequests.
ResetButton.javaClass Represents a form 'reset' button.
ScriptException.javaClass An exception thrown when there is a problem running a script.
SubmitButton.javaClass This class represents a submit button in an HTML form.
TableCell.javaClass A single cell in an HTML table.
TableRow.javaClass
TextBlock.javaClass A class which represents a block of text in a web page.
UncheckedParameterHolder.javaClass
UnsupportedActionException.javaClass An exception thrown when an action URL is not supported.
UploadFileSpec.javaClass A description of a file to be uploaded as part of a form submission.
WebApplet.javaClass This class represents the embedding of an applet in a web page.
WebClient.javaClass The context for a series of web requests.
WebClientListener.javaInterface A listener for messages sent and received by a web client.
WebConversation.javaClass The context for a series of HTTP requests.
WebForm.javaClass This class represents a form in an HTML page.
WebFrame.javaClass A frame in a web page.
WebImage.javaClass Represents an image in an HTML document.
WebLink.javaClass This class represents a link in an HTML page.
WebList.javaClass Represents an HTML list.
WebRequest.javaClass A request sent to a web server.
WebRequestSource.javaClass Base class for objects which can be clicked to generate new web requests.
WebResponse.javaClass A response to a web request from a web server.
WebTable.javaClass This class represents a table in an HTML page.
WebWindow.javaClass A window managed by a com.meterware.httpunit.WebClient WebClient .
WebWindowListener.javaInterface A listener for web window openings and closings.
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.