com.canoo.webtest.engine
Class Configuration

java.lang.Object
  extended by org.apache.tools.ant.ProjectComponent
      extended by org.apache.tools.ant.Task
          extended by com.canoo.webtest.engine.Configuration
All Implemented Interfaces:
Cloneable

public class Configuration
extends Task

Captures configuration information.

Author:
unknown, Marc Guillemot, Paul King

Field Summary
static String DEFAULT_HOST
           
static int DEFAULT_PORT
           
protected static int DEFAULT_TIMEOUT
          The number of seconds before http connections timeout: (default=300)
static int PORT_HTTP
           
static int PORT_HTTPS
           
static String PROTOCOL_FILE
           
static String PROTOCOL_HTTP
           
static String PROTOCOL_HTTPS
           
 
Fields inherited from class org.apache.tools.ant.Task
target, taskName, taskType, wrapper
 
Fields inherited from class org.apache.tools.ant.ProjectComponent
description, location, project
 
Constructor Summary
Configuration()
          Configuration constructor used by instance creation as nested element in ant.
Configuration(WebtestTask testSpec)
          Configuration constructor used to generate a default configuration when the user omit it.
 
Method Summary
 void addHeader(Header header)
           
 void addOption(Option option)
           
protected  File computeSubFolder(File _resultDir)
          Compute the name of the subfolder for this test
protected  void configurePageCreator(com.gargoylesoftware.htmlunit.WebClient webClient)
          Configures WebTest's custom page creator able to create PDFPage (as long as this is not integrated directly into HtmlUnit)
 com.gargoylesoftware.htmlunit.WebClient createWebClient()
          Configures the webclient used for the test
 void execute()
           
 String getAutoRefresh()
          Returns true if the client should automatically follow page refresh requests.
 String getBasePath()
           
 String getBrowser()
          Gets the configured browser
 Context getContext()
          Gets the context for the current webtest
 String getDefaultPropertyType()
           
 int getEasyAjaxDelay()
          Experimental.
 String getErrorProperty()
           
 String getExternalProperty(String name)
           
 String getFailureProperty()
           
 List getHeaderList()
           
 String getHost()
           
 List getOptionList()
           
 Map getParameterDictionary()
           
 int getPort()
           
 String getProtocol()
           
 String getResultFile()
           
protected  int getResultFolderIndex(File _resultDir)
          Get the index to use as prefix for the dedicated result folder of this test
 File getResultpath()
          This is the configured general result dir.
 String getSavePrefix()
           
 File getSummaryFile()
          Gets the file where the summary should be written.
 int getTimeout()
          Gets the timeout in seconds
 String getUrlForPage(String page)
          Completes a URL based on configuration values by expanding where needed from a base URL (protocol and optionally host:port).
 boolean getUseInsecureSSL()
          Indicate if insecure SSL should be used, ie that certificates should not be validated and therefore outdated or self-signed certificates accepted.
 String getUserAgent()
          Gets the User-Agent header to be sent.
 File getWebTestResultDir()
          Gets the directory where all artifacts of this specific test should be saved.
 void init()
          Get's called from Ant once the project and target references have been set but before the properties are configured
 boolean isEasyAjax()
           
 boolean isHaltOnError()
           
 boolean isHaltOnFailure()
           
 boolean isRespectVisibility()
          Experimental: indicates if WebTest tries to work only on displayed elements.
 boolean isSaveResponse()
           
 boolean isShowHtmlParserOutput()
           
 void setAutoRefresh(String str)
          Determines if the client should automatically follow page refresh requests.
 void setBasepath(String newBasePath)
          Defines the constant base path used to construct request URLs, e.g.
 void setBrowser(String browser)
          Configures the browser that should be simulated in the test
 void setContext(Context context)
          Defines the context.
 void setDefaultPropertyType(String type)
           
 void setEasyAjax(boolean b)
          Experimental.
 void setEasyAjaxDelay(int delay)
          Experimental.
 void setErrorProperty(String errorProperty)
           
 void setFailureProperty(String failureProperty)
           
 void setHaltonerror(boolean haltOnError)
           
 void setHaltonfailure(boolean haltOnFailure)
           
 void setHost(String newHost)
           
 void setPort(int newPort)
           
 void setPropertyHandler(IPropertyHandler propertyHandler)
           
 void setProtocol(String newProtocol)
           
 void setRespectVisibility(boolean b)
          Experimental: indicates if WebTest should try to work only on displayed elements.
 void setResultfile(String resultFile)
           
 void setResultFolderIndex(int index)
          Sets the index of the result folder.
 void setResultpath(File newResultPath)
           
 void setSavePrefix(String savePrefix)
           
 void setSaveresponse(boolean newSaveResponse)
           
 void setShowhtmlparseroutput(boolean showParserOutput)
           
 void setSummary(boolean newSummary)
           
 void setTimeout(int timeout)
          Sets the timeout
protected  void setupWebClient()
           
 void setUseInsecureSSL(boolean insecureSSL)
          Defines if insecure SSL should be used, ie that certificates should not be validated and therefore outdated or self-signed certificates accepted.
 
Methods inherited from class org.apache.tools.ant.Task
bindToOwner, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, isInvalid, log, log, log, log, maybeConfigure, perform, reconfigure, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskType
 
Methods inherited from class org.apache.tools.ant.ProjectComponent
clone, getDescription, getLocation, getProject, setDescription, setLocation, setProject
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PORT_HTTP

public static final int PORT_HTTP
See Also:
Constant Field Values

PORT_HTTPS

public static final int PORT_HTTPS
See Also:
Constant Field Values

DEFAULT_PORT

public static final int DEFAULT_PORT
See Also:
Constant Field Values

DEFAULT_HOST

public static final String DEFAULT_HOST
See Also:
Constant Field Values

PROTOCOL_HTTP

public static final String PROTOCOL_HTTP
See Also:
Constant Field Values

PROTOCOL_HTTPS

public static final String PROTOCOL_HTTPS
See Also:
Constant Field Values

PROTOCOL_FILE

public static final String PROTOCOL_FILE
See Also:
Constant Field Values

DEFAULT_TIMEOUT

protected static final int DEFAULT_TIMEOUT
The number of seconds before http connections timeout: (default=300)

See Also:
Constant Field Values
Constructor Detail

Configuration

public Configuration()
Configuration constructor used by instance creation as nested element in ant.


Configuration

public Configuration(WebtestTask testSpec)
Configuration constructor used to generate a default configuration when the user omit it.

Method Detail

init

public void init()
Get's called from Ant once the project and target references have been set but before the properties are configured

Overrides:
init in class Task

execute

public void execute()
             throws BuildException
Overrides:
execute in class Task
Throws:
BuildException

setupWebClient

protected void setupWebClient()
                       throws IOException
Throws:
IOException

computeSubFolder

protected File computeSubFolder(File _resultDir)
Compute the name of the subfolder for this test

Parameters:
_resultDir - the "main" result dir
Returns:
the name of the subfolder

setResultFolderIndex

public void setResultFolderIndex(int index)
Sets the index of the result folder. Normally this shouldn't be set from outside but the new experimental feature "WebTest parallel" currently needs it.

Parameters:
index - the index

getResultFolderIndex

protected int getResultFolderIndex(File _resultDir)
Get the index to use as prefix for the dedicated result folder of this test

Parameters:
_resultDir - the base result directory
Returns:
the index

getSummaryFile

public File getSummaryFile()
Gets the file where the summary should be written.

Returns:
null if no resultfile was specified

addHeader

public void addHeader(Header header)
Parameters:
header -

getHeaderList

public List getHeaderList()

addOption

public void addOption(Option option)
Parameters:
option -

getOptionList

public List getOptionList()

getBasePath

public String getBasePath()

getUserAgent

public String getUserAgent()
Gets the User-Agent header to be sent.

Returns:
null if none has been configured

getHost

public String getHost()

getPort

public int getPort()

getProtocol

public String getProtocol()

getResultpath

public File getResultpath()
This is the configured general result dir. This value should not be used directly as results will be placed in a sub folder of it in the future

Returns:
the configured result path

getWebTestResultDir

public File getWebTestResultDir()
Gets the directory where all artifacts of this specific test should be saved. This is currently the same than getResultpath() but this may change in the future.

Returns:
the folder

getSavePrefix

public String getSavePrefix()

getUrlForPage

public String getUrlForPage(String page)
Completes a URL based on configuration values by expanding where needed from a base URL (protocol and optionally host:port). If the provided page is complete (already with protocol), it is returned as is.

Parameters:
page - the maybe relative target URL
Returns:
the assembled URL

isSaveResponse

public boolean isSaveResponse()

setSavePrefix

public void setSavePrefix(String savePrefix)

setBasepath

public void setBasepath(String newBasePath)
Defines the constant base path used to construct request URLs, e.g. "shop" can be considered a basepath in "http://www.myhost.com/shop/productlist" and "http://www.myhost.com/shop/checkout".

Parameters:
newBasePath - the new value

setHost

public void setHost(String newHost)

setPort

public void setPort(int newPort)

setProtocol

public void setProtocol(String newProtocol)

setResultpath

public void setResultpath(File newResultPath)

setSaveresponse

public void setSaveresponse(boolean newSaveResponse)

setSummary

public void setSummary(boolean newSummary)

setHaltonerror

public void setHaltonerror(boolean haltOnError)

setHaltonfailure

public void setHaltonfailure(boolean haltOnFailure)

setErrorProperty

public void setErrorProperty(String errorProperty)

setFailureProperty

public void setFailureProperty(String failureProperty)

getFailureProperty

public String getFailureProperty()

getErrorProperty

public String getErrorProperty()

getDefaultPropertyType

public String getDefaultPropertyType()

setDefaultPropertyType

public void setDefaultPropertyType(String type)

setShowhtmlparseroutput

public void setShowhtmlparseroutput(boolean showParserOutput)

isShowHtmlParserOutput

public boolean isShowHtmlParserOutput()

isHaltOnFailure

public boolean isHaltOnFailure()

isHaltOnError

public boolean isHaltOnError()

getParameterDictionary

public Map getParameterDictionary()

getResultFile

public String getResultFile()

setResultfile

public void setResultfile(String resultFile)

setPropertyHandler

public void setPropertyHandler(IPropertyHandler propertyHandler)

getExternalProperty

public String getExternalProperty(String name)

getAutoRefresh

public String getAutoRefresh()
Returns true if the client should automatically follow page refresh requests.


setAutoRefresh

public void setAutoRefresh(String str)
Determines if the client should automatically follow page refresh requests.

Parameters:
str - the new refresh value

setContext

public void setContext(Context context)
Defines the context. This is called to set the context on the task before execute() is called

Parameters:
context - the context

getContext

public Context getContext()
Gets the context for the current webtest


createWebClient

public com.gargoylesoftware.htmlunit.WebClient createWebClient()
Configures the webclient used for the test


configurePageCreator

protected void configurePageCreator(com.gargoylesoftware.htmlunit.WebClient webClient)
Configures WebTest's custom page creator able to create PDFPage (as long as this is not integrated directly into HtmlUnit)


getTimeout

public int getTimeout()
Gets the timeout in seconds

Returns:
the timeout (default value is DEFAULT_TIMEOUT).

setTimeout

public void setTimeout(int timeout)
Sets the timeout

Parameters:
timeout - the new value (in seconds), set 0 for no timeout

setEasyAjax

public void setEasyAjax(boolean b)
Experimental. Indicates if WebTest should wait for completion of background js tasks after each step. This should become true per default once HtmlUnit has the necessary functionality to control this which is not yet the case with HtmlUnit 1.14. This feature is intentionally undocumented.

Parameters:
b - the new value

isEasyAjax

public boolean isEasyAjax()

setEasyAjaxDelay

public void setEasyAjaxDelay(int delay)
Experimental. See setEasyAjax(boolean)

Parameters:
delay - the new value

getEasyAjaxDelay

public int getEasyAjaxDelay()
Experimental. Default value is 2000


setUseInsecureSSL

public void setUseInsecureSSL(boolean insecureSSL)
Defines if insecure SSL should be used, ie that certificates should not be validated and therefore outdated or self-signed certificates accepted.

Parameters:
insecureSSL - the new value

getUseInsecureSSL

public boolean getUseInsecureSSL()
Indicate if insecure SSL should be used, ie that certificates should not be validated and therefore outdated or self-signed certificates accepted.

Returns:
the value (default is false)

setRespectVisibility

public void setRespectVisibility(boolean b)
Experimental: indicates if WebTest should try to work only on displayed elements. Currently not all WebTest steps respect this configuration option. No documentation is generated as long as it is experimental.

Since:
Build 1783

isRespectVisibility

public boolean isRespectVisibility()
Experimental: indicates if WebTest tries to work only on displayed elements. Currently not all WebTest steps respect this configuration option.

Returns:
default is false
Since:
Build 1783

setBrowser

public void setBrowser(String browser)
Configures the browser that should be simulated in the test

Parameters:
browser - the browser name like "Firefox3" or "FF3"

getBrowser

public String getBrowser()
Gets the configured browser

Returns:
null if nothing has been configured

Copyright © 2001-2007 Canoo Engineering AG, Basel. All rights reserved.