|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjunit.framework.Assert
junit.framework.TestCase
webapplicationtestcase.WebApplicationTestCase
public abstract class WebApplicationTestCase
This class provides the simplest web application integration testing available. The idea behind this test is that you send some request parameters to a web application, via post or get, and then analyze the response. It is taken directly from the Ruby on Rails test framework by David Heinemeier Hansson -- I have just implemented it in Java. More information on what I have done can be had from the article "A Guide to Testing the Rails.
Constructor Summary | |
---|---|
WebApplicationTestCase()
|
Method Summary | |
---|---|
void |
assertNoTag(java.lang.String tagName,
java.util.Map attributes,
java.lang.String text)
Evaluates the contents of the response to determine no tag meets the criteria specified. |
void |
assertRedirectedToAction(java.lang.String action)
Evaluates the response was a redirect to the specified action. |
void |
assertResponse_Error()
Evaluates the http status is an error (5xx). |
void |
assertResponse_Missing()
Evaluates the http status is missing (404). |
void |
assertResponse_Redirect()
Evaluates the http status is a redirect (3xx). |
void |
assertResponse_Success()
Evaluates the http response status is success (200). |
void |
assertResponse(int responseCode)
Evaluates the http status. |
void |
assertTag(java.lang.String tagName,
java.util.Map attributes,
java.lang.String text)
Evaluates the contents of the response to determine if a tag meets the criteria specified. |
void |
get(java.lang.String action,
java.util.Map requestParameters)
Sends a request to the specified action as a "get". |
protected HttpResponse |
getHttpResponse()
Accessor for the most recent HttpResponse for the current WebApplicatoinSession . |
protected abstract java.lang.String |
getWebApplicationBaseUrl()
This is the base url of the web application to test. |
void |
post(java.lang.String action,
java.util.Map requestParameters)
Sends a request to the specified action as a "post". |
protected void |
setUp()
|
Methods inherited from class junit.framework.TestCase |
---|
countTestCases, createResult, getName, run, run, runBare, runTest, setName, tearDown, toString |
Methods inherited from class junit.framework.Assert |
---|
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public WebApplicationTestCase()
Method Detail |
---|
protected void setUp() throws java.lang.Exception
setUp
in class junit.framework.TestCase
java.lang.Exception
protected abstract java.lang.String getWebApplicationBaseUrl()
get("index.html", null, null);
to request the "index.html" page.
protected HttpResponse getHttpResponse()
HttpResponse
for the current WebApplicatoinSession
.
HttpResponse
for the current WebApplicationSession
.public void post(java.lang.String action, java.util.Map requestParameters)
action
- a String
containing the name of the action the request should be sent to.requestParameters
- a java.util.Map
of the request parameters to be passed to the action.public void get(java.lang.String action, java.util.Map requestParameters)
action
- a String
containing the name of the action the request should be sent to.requestParameters
- a java.util.Map
of the request parameters to be passed to the action.public void assertResponse_Success()
public void assertResponse_Redirect()
public void assertResponse_Missing()
public void assertResponse_Error()
public void assertResponse(int responseCode)
responseCode
- the expected http response codepublic void assertTag(java.lang.String tagName, java.util.Map attributes, java.lang.String text)
tagName
- The name of the tag to find, e.g. div
, span
, a
attributes
- Attributes of the tag to find, e.g. id="errorMessage"
or href="login.html"
text
- The text to find in the content.WebApplicationAssertions.assertTag(HttpResponse, String, java.util.Map, String)
public void assertNoTag(java.lang.String tagName, java.util.Map attributes, java.lang.String text)
tagName
- The name of the tag to find, e.g. div
, span
, a
attributes
- Attributes of the tag to find, e.g. id="errorMessage"
or href="login.html"
text
- The text to find in the content.WebApplicationAssertions.assertNoTag(HttpResponse, String, java.util.Map, String)
public void assertRedirectedToAction(java.lang.String action)
action
- The name of the action you are expecting to be redirected toWebApplicationAssertions.assertRedirectedToAction(HttpResponse, String, String)
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |