Overview | Package | Class | Tree | Deprecated | Index | Help
PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES

## Package com.meterware.httpunit

Classes for testing http server systems.

See:
Description

Interface Summary
HtmlErrorListener | This interface represents a listener which can receive notification of errors and warnings during the parsing of an HTML page.
HTMLSegment | Represents the parse tree for a segment of HTML.
ScriptableObject | An interface for objects which will be accessible via scripting.
WebClientListener | A listener for messages sent and received by a web client.

Class Summary
Base64 | $Id: Base64.java,v 1.3 2002/03/21 15:44:03 russgold Exp $ Copyright (c) 2000, 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.
GetMethodWebRequest | An HTTP request using the GET method.
HttpUnitOptions | A collection of global options to control HttpUnit's behavior.
HttpUnitUtils | Utility code shared by httpunit and servletunit.
MessageBodyWebRequest | A web request which contains a non-empty message body.
MessageBodyWebRequest.InputStreamMessageBody | A method request message body read directly from an input stream.
PostMethodWebRequest | An HTTP request using the POST method.
PutMethodWebRequest | A web request using the PUT protocol.
SubmitButton | This class represents a submit button in an HTML form.
TableCell | A single cell in an HTML table.
UploadFileSpec | A description of a file to be uploaded as part of a form submission.
WebClient | The context for a series of web requests.
WebClient.HeaderDictionary |
WebConversation | The context for a series of HTTP requests.
WebForm | This class represents a form in an HTML page.
WebLink | This class represents a link in an HTML page.
WebRequest | A request sent to a web server.
WebRequestSource |
WebResponse | A response to a web request from a web server.
WebTable | This class represents a table in an HTML page.

Exception Summary
AuthorizationRequiredException | This exception is thrown when an unauthorized request is made for a page that requires authentication.
HttpException | This exception is thrown when an Http error (response code 4xx or 5xx) is detected.
HttpInternalErrorException | This exception is thrown when an internal error is found on the server.
HttpNotFoundException | This exception is thrown when the desired URL is not found.
IllegalRequestParameterException | This exception is thrown on an attempt to set a form parameter in a way not possible from a browser.

## Package com.meterware.httpunit Description

Classes for testing http server systems. Each test session should begin by creating a `WebConversation` to which it should submit an initial `http request` using the `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 JTidy, an HTML parser/validator. The jtidy.jar must be in the class path ahead of any other implementation of the DOM classes. In addition, unit tests will require JUnit as well.

## 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 {
                WebRequest          request;
                WebResponse         response;
                WebConversation     conversation = new WebConversation();

                request = new GetMethodWebRequest( "http://www.meterware.com/servlet/TopSecret" );
                response = conversation.getResponse( request );
                System.out.println( response );

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

                request = loginForm.getRequest();
                request.setParameter( "name", "master" );
                response = conversation.getResponse( request );
                System.out.println( response );

            } catch (Exception e) {
                System.err.println( "Exception: " + e );
            }
        }
    }

Please direct any questions to Russell Gold.

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES