|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.uwyn.rife.test.MockConversation
public class MockConversation
Simulates a conversation between a web browser and a servlet container.
Cookies will be remembered between requests and can be easily examined.
To check which new cookies have been set during a request, the MockResponse.getNewCookieNames() method can be used.
An instance of this class is tied to a regular Site structure
instance. Your tests can thus reference existing site XML declarations,
combine different sites into one, build a new site-structure on-the-fly in
Java, modify existing element declarations, override property injections,
...
Note that RIFE relies on EngineClassLoader
to provide continuations functionalities to pure Java elements. If you want
to test elements that use continuations, you have to make sure the first
class in your test setup is loaded by EngineClassLoader. The easiest way to do so is to run
your main class with RunWithEngineClassLoader.
| Constructor Summary | |
|---|---|
MockConversation(Site site)
Creates a new MockConversation instance for a particular
site. |
|
| Method Summary | |
|---|---|
void |
addCookie(Cookie cookie)
Add a cookie. |
void |
addCookie(String name,
String value)
Add a cookie with only a name and a value, the other fields will be empty. |
MockConversation |
contextPath(String contextPath)
Sets the context path that will be used by this conversation. |
MockConversation |
cookie(Cookie cookie)
Add a cookie. |
MockConversation |
cookie(String name,
String value)
Add a cookie with only a name and a value, the other fields will be empty. |
MockResponse |
doRequest(String url)
Perform a request for a particular URL. |
MockResponse |
doRequest(String url,
MockRequest request)
Perform a request for a particular URL and request configuration. |
String |
getContextPath()
Retrieves the context path that is used by this conversation. |
Cookie |
getCookie(String name)
Retrieves a cookie. |
Cookie[] |
getCookies()
Retrieves all cookies. |
String |
getCookieValue(String name)
Retrieves the value of a cookie. |
String |
getScheme()
Retrieves the scheme that is used by this conversation. |
String |
getServerName()
Retrieves the server name that is used by this conversation. |
int |
getServerPort()
Retrieves the server port that is used by this conversation. |
boolean |
hasCookie(String name)
Checks whether a cookie is present. |
MockConversation |
scheme(String scheme)
Sets the scheme that will be used by this conversation. |
MockConversation |
serverName(String serverName)
Sets the server name that will be used by this conversation. |
MockConversation |
serverPort(int serverPort)
Sets the server port that will be used by this conversation. |
void |
setContextPath(String contextPath)
Sets the context path that will be used by this conversation. |
void |
setScheme(String scheme)
Sets the scheme that will be used by this conversation. |
void |
setServerName(String serverName)
Sets the server name that will be used by this conversation. |
void |
setServerPort(int serverPort)
Sets the server port that will be used by this conversation. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public MockConversation(Site site)
throws EngineException
MockConversation instance for a particular
site.
site - the site structure that will be tested
EngineException| Method Detail |
|---|
public MockResponse doRequest(String url)
throws EngineException
url - the url that should be tested
MockResponse instance;
or
null if the scheme, hostname and port don't correspond
to the conversation setup
EngineExceptiondoRequest(String, MockRequest)
public MockResponse doRequest(String url,
MockRequest request)
throws EngineException
The request can either be complete with the scheme and hostname, or an absolute path. These two URLs are thus considered the same:
http://localhost/some/url?name1=value1&name2=value2
/some/url?name1=value1&name2=value2
Note that when the complete URL form is used, it should correspond to the scheme, hostname and port configuration of this conversation.
url - the url that should be testedrequest - the request that will be used
MockResponse instance;
or
null if the scheme, hostname and port don't correspond
to the conversation setup
EngineExceptiondoRequest(String)public String getScheme()
setScheme(java.lang.String),
scheme(java.lang.String)public void setScheme(String scheme)
scheme - the schemegetScheme(),
scheme(java.lang.String)public MockConversation scheme(String scheme)
scheme - the scheme
MockConversation instancegetScheme(),
setScheme(java.lang.String)public String getServerName()
setServerName(java.lang.String),
serverName(java.lang.String)public void setServerName(String serverName)
serverName - the server namegetServerName(),
serverName(java.lang.String)public MockConversation serverName(String serverName)
serverName - the server name
MockConversation instancegetServerName(),
setServerName(java.lang.String)public int getServerPort()
setServerPort(int),
serverPort(int)public void setServerPort(int serverPort)
serverPort - the server portgetServerPort(),
serverPort(int)public MockConversation serverPort(int serverPort)
serverPort - the server port
MockConversation instancegetServerPort(),
setServerPort(int)public String getContextPath()
setContextPath(java.lang.String),
contextPath(java.lang.String)public void setContextPath(String contextPath)
contextPath - the context pathgetContextPath(),
contextPath(java.lang.String)public MockConversation contextPath(String contextPath)
contextPath - the context path
MockConversation instancegetContextPath(),
setContextPath(java.lang.String)public boolean hasCookie(String name)
name - the name of the cookie.
true if the cookie was present; or
false otherwise
getCookie(String),
getCookieValue(String),
getCookies(),
addCookie(Cookie),
addCookie(String, String)public Cookie getCookie(String name)
name - the name of the cookie.
null if no such cookie is present
hasCookie(String),
getCookieValue(String),
getCookies(),
addCookie(Cookie),
addCookie(String, String)public String getCookieValue(String name)
name - the name of the cookie.
null if no such cookie is present
hasCookie(String),
getCookie(String),
getCookies(),
addCookie(Cookie),
addCookie(String, String)public Cookie[] getCookies()
null if no cookies are present
hasCookie(String),
getCookie(String),
getCookieValue(String),
addCookie(Cookie),
addCookie(String, String)public void addCookie(Cookie cookie)
cookie - the cookie instance that will be addedhasCookie(String),
getCookie(String),
getCookieValue(String),
getCookies(),
addCookie(String, String)
public void addCookie(String name,
String value)
name - the name of the cookievalue - the value of the cookiehasCookie(String),
getCookie(String),
getCookieValue(String),
getCookies(),
addCookie(Cookie)public MockConversation cookie(Cookie cookie)
cookie - the cookie instance that will be added
MockConversation instancehasCookie(String),
getCookie(String),
getCookieValue(String),
getCookies(),
addCookie(Cookie),
addCookie(String, String)
public MockConversation cookie(String name,
String value)
name - the name of the cookievalue - the value of the cookie
MockConversation instancehasCookie(String),
getCookie(String),
getCookieValue(String),
getCookies(),
addCookie(Cookie),
addCookie(String, String)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||