Class WTestEnvironment
This environment is useful for use in automated (integration/unit) tests: you may configure its properties and pass it to the constructor of an application.
This is useful for automated test-cases:
void testX() {
WTestEnvironment environment(new Configuration());
MyApplication app(environment);
...
}
- See Also:
-
Field Summary
Fields inherited from class eu.webtoolkit.jwt.WEnvironment
redirectSecret_, timeZoneName_
-
Constructor Summary
ConstructorDescriptionWTestEnvironment
(Configuration configuration) Default constructor.WTestEnvironment
(Configuration configuration, EntryPointType type) Default constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Closes the test environment.void
Simulates the end of a request by the main event loop.boolean
isTest()
Returns whether this is a mocked test environment.void
Sets the accept header.void
setAjax
(boolean enabled) Sets whether AJAX is supported.void
setClientAddress
(String clientAddress) Sets the client address.void
setCookies
(Map<String, String> cookies) Sets HTTP cookies.void
setDeploymentPath
(String deployPath) Sets the deployment path.void
setDpiScale
(double dpiScale) Sets the display's DPI scale.void
setHeaderValue
(String value) Sets a HTTP header value.void
setHostName
(String hostName) Sets the host name.void
setInternalPath
(String internalPath) Sets the initial internal path.void
Sets the locale.void
setParameterMap
(Map<String, String[]> parameters) Sets parameters to the application.void
setReferer
(String referer) Sets the referer.void
setServerAdmin
(String serverAdmin) Sets the server admin.void
setServerSignature
(String signature) Sets the server signature.void
setServerSoftware
(String software) Sets the server software.void
setSessionIdInUrl
(boolean sessionIdInUrl) Simulates the presence of the session ID in the URL.void
setSupportsCookies
(boolean enabled) Sets whether cookies are supported.void
setUrlScheme
(String scheme) Sets the URL scheme.void
Simulates the start of a new request by the main event loop.Methods inherited from class eu.webtoolkit.jwt.WEnvironment
agentIsChrome, agentIsGecko, agentIsIE, agentIsIElt, agentIsIEMobile, agentIsMobileWebKit, agentIsOpera, agentIsSafari, agentIsSpiderBot, agentIsWebKit, getAccept, getAgent, getCgiValue, getClientAddress, getContentType, getCookie, getCookies, getDeploymentPath, getDpiScale, getHeaderValue, getHostName, getInternalPath, getJavaScriptWtScope, getLibraryVersion, getLocale, getParameter, getParameterMap, getParameterValues, getReferer, getScreenHeight, getScreenWidth, getServer, getServerAdmin, getServerSignature, getServerSoftware, getTimeZoneName, getTimeZoneOffset, getUrlScheme, getUserAgent, hasAjax, hasJavaScript, hasWebGL, isInternalPathUsingFragments, supportsCookies, supportsCss3Animations
-
Constructor Details
-
WTestEnvironment
Default constructor.Constructs a test environment that resembles FireFox 3.0 with default settings.
After construction, but before passing it to the constructor of a
WApplication
, you can change any of the environment properties using the setter methods. -
WTestEnvironment
Default constructor.
-
-
Method Details
-
close
public void close()Closes the test environment.Destroys the test environment. This will allow the environment and the application under test to be garbage collected.
-
setParameterMap
Sets parameters to the application.The default value is an empty map.
- See Also:
-
setCookies
Sets HTTP cookies.The default value is an empty map.
- See Also:
-
setHeaderValue
Sets a HTTP header value.The default value is no headers.
- See Also:
-
setSupportsCookies
public void setSupportsCookies(boolean enabled) Sets whether cookies are supported.The default value is true.
- See Also:
-
setAjax
public void setAjax(boolean enabled) Sets whether AJAX is supported.The default value is true.
- See Also:
-
setDpiScale
public void setDpiScale(double dpiScale) Sets the display's DPI scale.The default value is 1.
- See Also:
-
setLocale
Sets the locale.The default value is the English locale ("en").
- See Also:
-
setHostName
Sets the host name.The default value is "localhost".
- See Also:
-
setUrlScheme
Sets the URL scheme.The default value is "http".
- See Also:
-
setReferer
Sets the referer.The default value is "".
- See Also:
-
setAccept
Sets the accept header.The default value is "text/html,application/xhtml+xml,application/xml;q=0.9,*<span>/</span>*;q=0.8".
- See Also:
-
setServerSignature
Sets the server signature.The default value is "None (WTestEnvironment)".
- See Also:
-
setServerSoftware
Sets the server software.The default value is "None (WTestEnvironment)".
- See Also:
-
setServerAdmin
Sets the server admin.The default value is "your@onyourown.here".
- See Also:
-
setClientAddress
Sets the client address.The default value is "127.0.0.1".
- See Also:
-
setInternalPath
Sets the initial internal path.The default value is "".
- See Also:
-
setDeploymentPath
Sets the deployment path.The default value is "".
- See Also:
-
endRequest
public void endRequest()Simulates the end of a request by the main event loop.The environemnt (and application is) started from within the main event loop. To simulate the delivery of events posted to the application-under-test, by WServer::post(), you need to simulate the release of the session lock.
- See Also:
-
startRequest
public void startRequest()Simulates the start of a new request by the main event loop.- See Also:
-
setSessionIdInUrl
public void setSessionIdInUrl(boolean sessionIdInUrl) Simulates the presence of the session ID in the URL.A session ID in the URL should cause a trampoline to be used for references to external servers.
The default value is
false
. -
isTest
public boolean isTest()Description copied from class:WEnvironment
Returns whether this is a mocked test environment.- Overrides:
isTest
in classWEnvironment
-