org.apache.anteater.test
Class HttpRequest

java.lang.Object
  |
  +--org.apache.tools.ant.ProjectComponent
        |
        +--org.apache.tools.ant.Task
              |
              +--org.apache.anteater.test.BaseTask
                    |
                    +--org.apache.anteater.test.ActionTask
                          |
                          +--org.apache.anteater.test.HttpRequest
All Implemented Interfaces:
Groupable
Direct Known Subclasses:
SOAPRequest

public class HttpRequest
extends ActionTask

Defines an HTTP request.

Version:
$Revision: 1.49 $ $Date: 2003/01/04 07:24:17 $
Author:
Costin Manolache, Ovidiu Predescu, Jeff Turner

Field Summary
protected  String contentURL
          The URL from which we retrieve contents to send with the request, eg a SOAP body.
 
Fields inherited from class org.apache.anteater.test.ActionTask
haltonerror, logger, matcherSet, reqFeatures, result, session, successProp, successVal
 
Fields inherited from class org.apache.anteater.test.BaseTask
debug, debugWasSet
 
Fields inherited from class org.apache.tools.ant.Task
description, location, target, taskName, taskType, wrapper
 
Fields inherited from class org.apache.tools.ant.ProjectComponent
project
 
Constructor Summary
HttpRequest()
           
 
Method Summary
 void addConfiguredContentEquals(ContentEquals ce)
          Specify the HTTP body to post.
 void addConfiguredHeader(Header rh)
          Add a header to the request
 void addConfiguredMethod(Method m)
          Add a parameter to the request
 void addConfiguredParameter(Parameter rp)
          Add a parameter to the request
protected  Object createMatchObject()
          Create and return a HttpMessage containing the server's response, which the caller will then let the tester tasks loose on.
 String getId()
          Return a String identification of this HTTP action suitable for reporting.
 String getURL()
          Return the URL associated with this task (that it implements or tests).
 void setContent(String href)
          Assumes the value of the content attribute is an href whose content is to be POSTed.
 void setFollowRedirects(Boolean yn)
          Whether to follow HTTP 302 redirects or not.
 void setHeaders(String s)
          Add headers - string representation, will be parsed The value is a "|" separated list of headers to expect.
 void setHost(String h)
          Server that will receive the request
 void setHref(String href)
          Set the full URL to test.
 void setMethod(String method)
          Set HTTP method, eg GET or POST.
 void setPassword(String password)
           
 void setPath(String path)
          Set the 'path' in the HTTP request (part after the host and port).
 void setPort(int port)
           
 void setProtocol(String protocol)
          Set HTTP protocol, typically HTTP/1.0 or HTTP/1.1.
 void setTimeout(String time)
          Set the HTTP request's socket timeout.
 void setUser(String user)
           
 void setUseTidy(Boolean yn)
          Set whether to clean up the HTTP response body before applying tests.
 
Methods inherited from class org.apache.anteater.test.ActionTask
addConfiguredLogger, addConfiguredSession, addConfiguredUses, addMatch, addNamespace, execute, getObjectModel, getProperties, getProperty, getPropertyAsInt, getResult, setAssign, setDebug, setHaltonerror, setValue
 
Methods inherited from class org.apache.anteater.test.BaseTask
debug, getDebug, getGroup, print, println, resolveContentURL, setGroup, setGroup
 
Methods inherited from class org.apache.tools.ant.Task
getDescription, getLocation, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, handleErrorOutput, handleOutput, init, isInvalid, log, log, maybeConfigure, perform, setDescription, setLocation, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName
 
Methods inherited from class org.apache.tools.ant.ProjectComponent
getProject, setProject
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

contentURL

protected String contentURL
The URL from which we retrieve contents to send with the request, eg a SOAP body. URL is resolved in createMatchObject(), not in setContent(java.lang.String), in order to catch and report errors.

Constructor Detail

HttpRequest

public HttpRequest()
Method Detail

setHost

public void setHost(String h)
Server that will receive the request


setMethod

public void setMethod(String method)
Set HTTP method, eg GET or POST.


setProtocol

public void setProtocol(String protocol)
Set HTTP protocol, typically HTTP/1.0 or HTTP/1.1.


setPath

public void setPath(String path)
Set the 'path' in the HTTP request (part after the host and port). Typically '/'.


setPort

public void setPort(int port)

setUser

public void setUser(String user)

setPassword

public void setPassword(String password)

setTimeout

public void setTimeout(String time)
Set the HTTP request's socket timeout. Eg, 1000ms, 10s, 1.5m. If a prefix (ms=milliseconds, s=seconds, m=minutes) is not specified, milliseconds will be assumed.


setHref

public void setHref(String href)
Set the full URL to test.

Parameters:
href - URL to test, eg http://whatever/blah?foo=bar. The query string (foo=bar) part provides an alternative to nested <parameter> elements.

setUseTidy

public void setUseTidy(Boolean yn)
Set whether to clean up the HTTP response body before applying tests.


setFollowRedirects

public void setFollowRedirects(Boolean yn)
Whether to follow HTTP 302 redirects or not. "Following" a redirect means that the HTTP response will be that of the redirected-to page, not the redirect.


setHeaders

public void setHeaders(String s)
Add headers - string representation, will be parsed The value is a "|" separated list of headers to expect. It's preferable to use the other 2 methods.


setContent

public void setContent(String href)
Assumes the value of the content attribute is an href whose content is to be POSTed.


addConfiguredHeader

public void addConfiguredHeader(Header rh)
Add a header to the request


addConfiguredParameter

public void addConfiguredParameter(Parameter rp)
Add a parameter to the request


addConfiguredMethod

public void addConfiguredMethod(Method m)
Add a parameter to the request


addConfiguredContentEquals

public void addConfiguredContentEquals(ContentEquals ce)
Specify the HTTP body to post.


getId

public String getId()
Description copied from class: ActionTask
Return a String identification of this HTTP action suitable for reporting. The string should identify this object within a list of others. It is used to identify this ActionTask in test reports.

Specified by:
getId in class ActionTask

getURL

public String getURL()
Description copied from class: ActionTask
Return the URL associated with this task (that it implements or tests).

Specified by:
getURL in class ActionTask

createMatchObject

protected Object createMatchObject()
                            throws Exception
Create and return a HttpMessage containing the server's response, which the caller will then let the tester tasks loose on.

Specified by:
createMatchObject in class ActionTask
Throws:
org.apache.tools.ant.BuildException - some failure related to the Ant interface (eg a required property not set)
Exception - if the HTTP operation fails.


Ant Functional Tester -- see Project home page for details