org.apache.anteater.test
Class Listener

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.Listener
All Implemented Interfaces:
Groupable

public class Listener
extends ActionTask

Starts listening for an incoming HTTP request.

If no port is specified, the default port is the first port declared using the servletContainer element. The local path to which the listening occurs is specified using the path attribute.

The execution of the Ant script will stop until a request is received at the given local path. When the request is received, the listener element start the matching process using the matcher set described by the enclosed match elements.

You can specify a timeout for which a request is expected. If there's no request received, or if the request is received, but no matchers succeed, the listener element fails. See here for a description of how this interacts with other classes.

Since:
September 26, 2001
Version:
$Revision: 1.22 $ $Date: 2002/10/04 14:26:49 $
Author:
Ovidiu Predescu

Field Summary
 
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
Listener()
           
Listener(int port, String path)
           
 
Method Summary
 Object createMatchObject()
          This lifecycle method is called during execute(), and should be used to create the object on which Matchers should match on.
 boolean equals(Object another)
           
 void execute()
          Main lifecycle method.
 String getId()
          Return a String identification of this HTTP action suitable for reporting.
 String getPath()
           
 int getPort()
           
 String getURL()
          Return the URL associated with this task (that it implements or tests).
 int hashCode()
           
 void setHttpMessageRequest(HttpMessage request)
          Called by ListenerProxyServlet.
 void setHttpServletResponse(javax.servlet.http.HttpServletResponse servletResponse)
          Called by ListenerProxyServlet.
 void setPath(String path)
           
 void setPort(int port)
           
 void setResponseWriter(PipedWriter writer)
          Called by ListenerProxyServlet.
 void setTimeout(int timeout)
           
 void setUseTidy(Boolean yn)
           
 String toString()
           
 
Methods inherited from class org.apache.anteater.test.ActionTask
addConfiguredLogger, addConfiguredSession, addConfiguredUses, addMatch, addNamespace, 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, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Listener

public Listener()

Listener

public Listener(int port,
                String path)
Method Detail

equals

public boolean equals(Object another)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

toString

public String toString()
Overrides:
toString in class Object

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

setPort

public void setPort(int port)

setPath

public void setPath(String path)

setTimeout

public void setTimeout(int timeout)

setUseTidy

public void setUseTidy(Boolean yn)

getPort

public int getPort()

getPath

public String getPath()

setHttpMessageRequest

public void setHttpMessageRequest(HttpMessage request)
Called by ListenerProxyServlet.


setHttpServletResponse

public void setHttpServletResponse(javax.servlet.http.HttpServletResponse servletResponse)
Called by ListenerProxyServlet.


setResponseWriter

public void setResponseWriter(PipedWriter writer)
Called by ListenerProxyServlet.


createMatchObject

public Object createMatchObject()
                         throws Exception
Description copied from class: ActionTask
This lifecycle method is called during ActionTask.execute(), and should be used to create the object on which Matchers should match on. Typically, this will be a HttpMessage of some sort.

As this method is called from execute(), it can rely on the setXxx methods having been called.

Specified by:
createMatchObject in class ActionTask
Exception

execute

public void execute()
Description copied from class: ActionTask
Main lifecycle method. Sets up the object model, creates the object to match on (usually a HTTP response), sets up the matchers via a MatcherSet, and runs the matchers.

Usually, subclasses can get away with not touching this method, but instead overriding the ActionTask.createMatchObject() method, which is called from this method.

Overrides:
execute in class ActionTask


Ant Functional Tester -- see Project home page for details