Package com.meterware.httpunit
Class HttpUnitOptions
java.lang.Object
com.meterware.httpunit.HttpUnitOptions
A collection of global options to control HttpUnit's behavior.
- Author:
- Russell Gold, Dave Glowacki, Benoit Xhenseval
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic void
addCustomAttribute
(String attributeName) Deprecated.for new Scripting enginestatic void
Deprecated.as of 1.5.2, use HTMLParserfactory#addHTMLParserListenerstatic void
Clears the accumulated script error messages.static boolean
Deprecated.as of 1.5.3, use ClientProperties#isAutoRedirect();static boolean
Deprecated.as of 1.5.3, use ClientProperties#isAutoRefresh();static String
Returns the character set to be used for pages which do not specify one.static String
Returns the content type to be used for pages which do not specify one.static boolean
Returns true if WebClient.getResponse throws exceptions when detected an error status.static boolean
Returns true if script errors cause exceptions to be thrown.static Vector
Deprecated.as of 1.5.2, removed with no replacementstatic boolean
Returns true if images are treated as text, using their alt attributes.static int
getter for Java Script optimization levelstatic boolean
If true, text matches in methods such asHTMLSegment.getLinkWith(java.lang.String)
are case insensitive.static boolean
Deprecated.as of 1.6, use WebForm#newUnvalidatedRequest() to obtain a request without parameter validation.static boolean
Deprecated.as of 1.5.2, use HTMLParserFactory#isParserWarningsEnabledstatic int
Returns the delay, in milliseconds, before a redirect request is issues.static String
static String[]
Returns the accumulated script error messages encountered.static ScriptingEngineFactory
static boolean
Deprecated.as of 1.5.3, use ClientProperties#isAcceptCookies();static boolean
Deprecated.as of 1.5.3, use ClientProperties#isAcceptGzip();static boolean
Returns true if HttpUnit will throw an exception when a message is only partially received.static boolean
Returns true if HTTP headers are to be dumped to system output.static boolean
Returns true if POST requests should include the character set in the content-type header.static boolean
static void
Deprecated.as of 1.5.2, use HTMLParserfactory#removeHTMLParserListenerstatic void
reset()
Resets all options to their default values.static void
Resets the default character set to the HTTP default encoding.static void
Resets the default content type to plain text.static void
setAcceptCookies
(boolean acceptCookies) Deprecated.as of 1.5.3, use ClientProperties#setAcceptCookies();static void
setAcceptGzip
(boolean acceptGzip) Deprecated.as of 1.5.3, use ClientProperties#setAcceptGzip();static void
setAutoRedirect
(boolean autoRedirect) Deprecated.as of 1.5.3, use ClientProperties#setAutoRedirect();static void
setAutoRefresh
(boolean autoRefresh) Deprecated.as of 1.5.3, use ClientProperties#setAutoRefresh();static void
setCheckContentLength
(boolean checkContentLength) Specifies whether HttpUnit should throw an exception when the content length of a message does not match its actual received length.static void
setDefaultCharacterSet
(String characterSet) Sets the default character set for pages which do not specify one and for requests created without HTML sources.static void
setDefaultContentType
(String contentType) Sets the default content type for pages which do not specify one.static void
setExceptionsThrownOnErrorStatus
(boolean enabled) If true, WebClient.getResponse throws an exception when it receives an error status.static void
setExceptionsThrownOnScriptError
(boolean throwExceptions) Determines whether script errors result in exceptions or warning messages.static void
setImagesTreatedAsAltText
(boolean asText) If true, tells HttpUnit to treat images with alt attributes as though they were the text value of that attribute in all searches and displays.static void
setJavaScriptOptimizationLevel
(int scriptOptimizationLevel) setter for Java Script optimization levelstatic void
setLoggingHttpHeaders
(boolean enabled) If true, tells HttpUnit to log HTTP headers to system output.static void
setMatchesIgnoreCase
(boolean ignoreCase) If true, text matches in methods such asHTMLSegment.getLinkWith(java.lang.String)
are case insensitive.static void
setParameterValuesValidated
(boolean validated) Deprecated.as of 1.6, use WebForm#newUnvalidatedRequest() to obtain a request without parameter validation.static void
setParserWarningsEnabled
(boolean enabled) Deprecated.as of 1.5.2, use HTMLParserFactory#setParserWarningsEnabledstatic void
setPostIncludesCharset
(boolean postIncludesCharset) Determines whether a normal POST request will include the character set in the content-type header.static void
setRedirectDelay
(int delayInMilliseconds) Sets the delay, in milliseconds, before a redirect request is issued.static void
setScriptEngineClassName
(String scriptEngineClassName) static void
setScriptingEnabled
(boolean scriptingEnabled) change the scriptingEnabled flag
-
Field Details
-
ORIGINAL_SCRIPTING_ENGINE_FACTORY
- See Also:
-
DEFAULT_SCRIPT_ENGINE_FACTORY
- See Also:
-
-
Constructor Details
-
HttpUnitOptions
public HttpUnitOptions()
-
-
Method Details
-
reset
public static void reset()Resets all options to their default values. -
isAcceptCookies
public static boolean isAcceptCookies()Deprecated.as of 1.5.3, use ClientProperties#isAcceptCookies();Returns true if HttpUnit is accepting and saving cookies. The default is to accept them. -
setAcceptCookies
public static void setAcceptCookies(boolean acceptCookies) Deprecated.as of 1.5.3, use ClientProperties#setAcceptCookies();Specifies whether HttpUnit should accept and send cookies. -
isAcceptGzip
public static boolean isAcceptGzip()Deprecated.as of 1.5.3, use ClientProperties#isAcceptGzip();Returns true if any WebClient created will accept GZIP encoding of responses. The default is to accept GZIP encoding. -
setAcceptGzip
public static void setAcceptGzip(boolean acceptGzip) Deprecated.as of 1.5.3, use ClientProperties#setAcceptGzip();Specifies whether a WebClient will be initialized to accept GZIP encoded responses. The default is true. -
resetDefaultCharacterSet
public static void resetDefaultCharacterSet()Resets the default character set to the HTTP default encoding. -
resetDefaultContentType
public static void resetDefaultContentType()Resets the default content type to plain text. -
setDefaultCharacterSet
Sets the default character set for pages which do not specify one and for requests created without HTML sources. By default, HttpUnit uses the HTTP default encoding, iso-8859-1. -
getDefaultCharacterSet
Returns the character set to be used for pages which do not specify one. -
isCheckContentLength
public static boolean isCheckContentLength()Returns true if HttpUnit will throw an exception when a message is only partially received. The default is to avoid such checks. -
setCheckContentLength
public static void setCheckContentLength(boolean checkContentLength) Specifies whether HttpUnit should throw an exception when the content length of a message does not match its actual received length. Defaults to false. -
setPostIncludesCharset
public static void setPostIncludesCharset(boolean postIncludesCharset) Determines whether a normal POST request will include the character set in the content-type header. The default is to include it; however, some older servlet engines (most notably Tomcat 3.1) get confused when they see it. -
isPostIncludesCharset
public static boolean isPostIncludesCharset()Returns true if POST requests should include the character set in the content-type header. -
setDefaultContentType
Sets the default content type for pages which do not specify one. -
getDefaultContentType
Returns the content type to be used for pages which do not specify one. -
getParserWarningsEnabled
public static boolean getParserWarningsEnabled()Deprecated.as of 1.5.2, use HTMLParserFactory#isParserWarningsEnabledReturns true if parser warnings are enabled. -
setParserWarningsEnabled
public static void setParserWarningsEnabled(boolean enabled) Deprecated.as of 1.5.2, use HTMLParserFactory#setParserWarningsEnabledIf true, tells the parser to display warning messages. The default is false (warnings are not shown). -
setExceptionsThrownOnErrorStatus
public static void setExceptionsThrownOnErrorStatus(boolean enabled) If true, WebClient.getResponse throws an exception when it receives an error status. Defaults to true. -
getExceptionsThrownOnErrorStatus
public static boolean getExceptionsThrownOnErrorStatus()Returns true if WebClient.getResponse throws exceptions when detected an error status. -
getParameterValuesValidated
public static boolean getParameterValuesValidated()Deprecated.as of 1.6, use WebForm#newUnvalidatedRequest() to obtain a request without parameter validation.Returns true if form parameter settings are checked. -
setParameterValuesValidated
public static void setParameterValuesValidated(boolean validated) Deprecated.as of 1.6, use WebForm#newUnvalidatedRequest() to obtain a request without parameter validation.If true, tells HttpUnit to throw an exception on any attempt to set a form parameter to a value which could not be set via the browser. The default is true (parameters are validated).
Note: this only applies to a WebRequest created after this setting is changed. A request created with this option disabled will not only not be checked for correctness, its parameter submission order will not be guaranteed, and changing parameters will not trigger Javascript onChange / onClick events. -
getImagesTreatedAsAltText
public static boolean getImagesTreatedAsAltText()Returns true if images are treated as text, using their alt attributes. -
setImagesTreatedAsAltText
public static void setImagesTreatedAsAltText(boolean asText) If true, tells HttpUnit to treat images with alt attributes as though they were the text value of that attribute in all searches and displays. The default is false (image text is generally ignored). -
getMatchesIgnoreCase
public static boolean getMatchesIgnoreCase()If true, text matches in methods such asHTMLSegment.getLinkWith(java.lang.String)
are case insensitive. The default is true (matches ignore case). -
setMatchesIgnoreCase
public static void setMatchesIgnoreCase(boolean ignoreCase) If true, text matches in methods such asHTMLSegment.getLinkWith(java.lang.String)
are case insensitive. The default is true (matches ignore case). -
isLoggingHttpHeaders
public static boolean isLoggingHttpHeaders()Returns true if HTTP headers are to be dumped to system output. -
setLoggingHttpHeaders
public static void setLoggingHttpHeaders(boolean enabled) If true, tells HttpUnit to log HTTP headers to system output. The default is false. -
getAutoRedirect
public static boolean getAutoRedirect()Deprecated.as of 1.5.3, use ClientProperties#isAutoRedirect();Returns true if HttpUnit should automatically follow page redirect requests (status 3xx). By default, this is true. -
setAutoRedirect
public static void setAutoRedirect(boolean autoRedirect) Deprecated.as of 1.5.3, use ClientProperties#setAutoRedirect();Determines whether HttpUnit should automatically follow page redirect requests (status 3xx). By default, this is true in order to simulate normal browser operation. -
getRedirectDelay
public static int getRedirectDelay()Returns the delay, in milliseconds, before a redirect request is issues. -
setRedirectDelay
public static void setRedirectDelay(int delayInMilliseconds) Sets the delay, in milliseconds, before a redirect request is issued. This may be necessary if the server under some cases where the server performs asynchronous processing which must be completed before the new request can be handled properly, and is taking advantage of slower processing by most user agents. It almost always indicates an error in the server design, and therefore the default delay is zero. -
getAutoRefresh
public static boolean getAutoRefresh()Deprecated.as of 1.5.3, use ClientProperties#isAutoRefresh();Returns true if HttpUnit should automatically follow page refresh requests. By default, this is false, so that programs can verify the redirect page presented to users before the browser switches to the new page. -
setAutoRefresh
public static void setAutoRefresh(boolean autoRefresh) Deprecated.as of 1.5.3, use ClientProperties#setAutoRefresh();Specifies whether HttpUnit should automatically follow page refresh requests. By default, this is false, so that programs can verify the redirect page presented to users before the browser switches to the new page. Setting this to true can cause an infinite loop on pages that refresh themselves. -
removeHtmlErrorListener
Deprecated.as of 1.5.2, use HTMLParserfactory#removeHTMLParserListenerRemove an Html error listener. -
addHtmlErrorListener
Deprecated.as of 1.5.2, use HTMLParserfactory#addHTMLParserListenerAdd an Html error listener. -
getHtmlErrorListeners
Deprecated.as of 1.5.2, removed with no replacementGet the list of Html Error Listeners -
getScriptEngineClassName
-
setScriptEngineClassName
-
getScriptingEngine
-
setScriptingEnabled
public static void setScriptingEnabled(boolean scriptingEnabled) change the scriptingEnabled flag- Parameters:
scriptingEnabled
-
-
isScriptingEnabled
public static boolean isScriptingEnabled() -
setExceptionsThrownOnScriptError
public static void setExceptionsThrownOnScriptError(boolean throwExceptions) Determines whether script errors result in exceptions or warning messages. -
getExceptionsThrownOnScriptError
public static boolean getExceptionsThrownOnScriptError()Returns true if script errors cause exceptions to be thrown. -
getScriptErrorMessages
Returns the accumulated script error messages encountered. Error messages are accumulated only if 'throwExceptionsOnError' is disabled. -
clearScriptErrorMessages
public static void clearScriptErrorMessages()Clears the accumulated script error messages. -
addCustomAttribute
Deprecated.for new Scripting engineAdd the name of a custom attribute that should be supported for form controls. -
getJavaScriptOptimizationLevel
public static int getJavaScriptOptimizationLevel()getter for Java Script optimization level- Returns:
- the javaScriptOptimizationLevel to be use for running scripts
-
setJavaScriptOptimizationLevel
public static void setJavaScriptOptimizationLevel(int scriptOptimizationLevel) setter for Java Script optimization level- Parameters:
scriptOptimizationLevel
- the _javaScriptOptimizationLevel to set see rhino documentation for valid values: -2: with continuation -1: interpret 0: compile to Java bytecode, don't optimize 1..9: compile to Java bytecode, optimize *
-