Class WTestEnvironment
public class WTestEnvironment extends WEnvironment
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:
WEnvironment
,WApplication(WEnvironment env)
-
Nested Class Summary
Nested classes/interfaces inherited from class eu.webtoolkit.jwt.WEnvironment
WEnvironment.ContentType, WEnvironment.UserAgent
-
Field Summary
Fields inherited from class eu.webtoolkit.jwt.WEnvironment
timeZoneName_
-
Constructor Summary
Constructors Constructor Description WTestEnvironment(Configuration configuration)
Default constructor.WTestEnvironment(Configuration configuration, EntryPointType type)
Default constructor. -
Method Summary
Modifier and Type Method Description void
close()
Closes the test environment.void
endRequest()
Simulates the end of a request by the main event loop.boolean
isTest()
Returns whether this is a mocked test environment.void
setAccept(java.lang.String accept)
Sets the accept header.void
setAjax(boolean enabled)
Sets whether AJAX is supported.void
setClientAddress(java.lang.String clientAddress)
Sets the client address.void
setContentType(WEnvironment.ContentType contentType)
Sets the content type (deprecated.void
setCookies(java.util.Map<java.lang.String,java.lang.String> cookies)
Sets HTTP cookies.void
setDpiScale(double dpiScale)
Sets the display's DPI scale.void
setHeaderValue(java.lang.String value)
Sets a HTTP header value.void
setHostName(java.lang.String hostName)
Sets the host name.void
setInternalPath(java.lang.String internalPath)
Sets the initial internal path.void
setLocale(java.util.Locale locale)
Sets the locale.void
setParameterMap(java.util.Map<java.lang.String,java.lang.String[]> parameters)
Sets parameters to the application.void
setReferer(java.lang.String referer)
Sets the referer.void
setServerAdmin(java.lang.String serverAdmin)
Sets the server admin.void
setServerSignature(java.lang.String signature)
Sets the server signature.void
setServerSoftware(java.lang.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(java.lang.String scheme)
Sets the URL scheme.void
startRequest()
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, getCookieValue, getDeploymentPath, getDpiScale, getHeaderValue, getHostName, getInternalPath, getJavaScriptWtScope, getLibraryVersion, getLocale, getParameter, getParameterMap, getParameterValues, getReferer, getScreenHeight, getScreenWidth, getServer, getServerAdmin, getServerSignature, getServerSoftware, getSessionId, getTimeZoneName, getTimeZoneOffset, getUrlScheme, getUserAgent, hasAjax, hasJavaScript, hasWebGL, isInternalPathUsingFragments, supportsCookies, supportsCss3Animations
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
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
public void setParameterMap(java.util.Map<java.lang.String,java.lang.String[]> parameters)Sets parameters to the application.The default value is an empty map.
- See Also:
WEnvironment.getParameterMap()
-
setCookies
public void setCookies(java.util.Map<java.lang.String,java.lang.String> cookies)Sets HTTP cookies.The default value is an empty map.
- See Also:
WEnvironment.getCookies()
-
setHeaderValue
public void setHeaderValue(java.lang.String value)Sets a HTTP header value.The default value is no headers.
- See Also:
WEnvironment.getHeaderValue(String name)
-
setSupportsCookies
public void setSupportsCookies(boolean enabled)Sets whether cookies are supported.The default value is true.
- See Also:
WEnvironment.supportsCookies()
-
setAjax
public void setAjax(boolean enabled)Sets whether AJAX is supported.The default value is true.
- See Also:
WEnvironment.hasAjax()
-
setDpiScale
public void setDpiScale(double dpiScale)Sets the display's DPI scale.The default value is 1.
- See Also:
WEnvironment.getDpiScale()
-
setLocale
public void setLocale(java.util.Locale locale)Sets the locale.The default value is the English locale ("en").
- See Also:
WEnvironment.getLocale()
-
setHostName
public void setHostName(java.lang.String hostName)Sets the host name.The default value is "localhost".
- See Also:
WEnvironment.getHostName()
-
setUrlScheme
public void setUrlScheme(java.lang.String scheme)Sets the URL scheme.The default value is "http".
- See Also:
WEnvironment.getUrlScheme()
-
setReferer
public void setReferer(java.lang.String referer)Sets the referer.The default value is "".
- See Also:
WEnvironment.getReferer()
-
setAccept
public void setAccept(java.lang.String accept)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:
WEnvironment.getAccept()
-
setServerSignature
public void setServerSignature(java.lang.String signature)Sets the server signature.The default value is "None (WTestEnvironment)".
- See Also:
WEnvironment.getServerSignature()
-
setServerSoftware
public void setServerSoftware(java.lang.String software)Sets the server software.The default value is "None (WTestEnvironment)".
- See Also:
WEnvironment.getServerSoftware()
-
setServerAdmin
public void setServerAdmin(java.lang.String serverAdmin)Sets the server admin.The default value is "your@onyourown.here".
- See Also:
WEnvironment.getServerAdmin()
-
setClientAddress
public void setClientAddress(java.lang.String clientAddress)Sets the client address.The default value is "127.0.0.1".
- See Also:
WEnvironment.getClientAddress()
-
setInternalPath
public void setInternalPath(java.lang.String internalPath)Sets the initial internal path.The default value is "".
- See Also:
WEnvironment.getInternalPath()
-
setContentType
Sets the content type (deprecated.Since contentType is now always HTML5, this setting is ignored.
-
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()
-
startRequest
public void startRequest()Simulates the start of a new request by the main event loop.- See Also:
endRequest()
-
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
-