You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cactus-dev@jakarta.apache.org by vm...@apache.org on 2002/07/27 23:21:20 UTC
cvs commit: jakarta-cactus/documentation/docs/xdocs howto_testcase.xml howto_testcase_servlet.xml
vmassol 2002/07/27 14:21:20
Modified: documentation/docs/xdocs howto_testcase.xml
howto_testcase_servlet.xml
Log:
added more details on additional methods provided by Cactus when it wraps the Servlet objects
Revision Changes Path
1.3 +7 -5 jakarta-cactus/documentation/docs/xdocs/howto_testcase.xml
Index: howto_testcase.xml
===================================================================
RCS file: /home/cvs/jakarta-cactus/documentation/docs/xdocs/howto_testcase.xml,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- howto_testcase.xml 10 Apr 2002 00:29:47 -0000 1.2
+++ howto_testcase.xml 27 Jul 2002 21:21:20 -0000 1.3
@@ -123,12 +123,13 @@
A constructor with a single parameter (it is the test name),
</li>
<li>
- A <code>main()</code> method in which you start a JUnit test
- runner if you want your test to be executable,
+ (optional): A <code>main()</code> method in which you start a JUnit
+ test runner if you want your test to be executable,
</li>
<li>
- A <code>suite()</code> method to list the tests that should
- be executed by your test class
+ (optional): A <code>suite()</code> method to list the tests that
+ should be executed by your test class (default is to include all
+ method starting with "<code>test</code>").
</li>
</ul>
<p>
@@ -200,7 +201,8 @@
(of type <code>HttpServletRequest</code>),
<code>config</code> (of type <code>ServletConfig</code> for
<code>ServletTestCase</code> or of type <code>FilterConfig</code>
- for <code>FilterTestCase</code>), ... (see Step 8 below),
+ for <code>FilterTestCase</code>), ... (see the "Testcase Specific
+ Details" Step below),
</li>
<li>
call the method to test,
1.3 +81 -0 jakarta-cactus/documentation/docs/xdocs/howto_testcase_servlet.xml
Index: howto_testcase_servlet.xml
===================================================================
RCS file: /home/cvs/jakarta-cactus/documentation/docs/xdocs/howto_testcase_servlet.xml,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- howto_testcase_servlet.xml 19 Apr 2002 21:36:01 -0000 1.2
+++ howto_testcase_servlet.xml 27 Jul 2002 21:21:20 -0000 1.3
@@ -95,6 +95,28 @@
</code> classes for all details. You should also look at the
samples provided in the Cactus distribution.
</p>
+
+ <s3 title="Additional methods">
+
+ <p>
+ Cactus provides some additional methods to ease writing tests
+ (see the javadoc for full details). These methods are provided
+ because it is not easy (if not downright impossible in some
+ cases) to simulate them with real configuration data:
+ </p>
+ <ul>
+ <li>
+ <code>setRemoteIPAddress()</code>: sets the remote IP address
+ that will be returned by <code>getRemoteIPAddress()</code>,
+ </li>
+ <li>
+ <code>setRemoteHostName()</code>: sets the remote Host name
+ that will be returned by <code>getRemoteHostName()</code>,
+ </li>
+ </ul>
+
+ </s3>
+
</s2>
<anchor id="servlet_response"/>
@@ -178,6 +200,65 @@
class for all details. You should also look at the
samples provided in the Cactus distribution.
</p>
+
+ <s3 title="Additional methods">
+
+ <p>
+ Additional methods provided:
+ </p>
+ <ul>
+ <li>
+ <code>setInitParameter()</code>: sets an initialisation
+ parameter (as if it has been defined in the <code>web.xml</code>
+ file),
+ </li>
+ <li>
+ <code>setServletName()</code>: sets the Servlet name that will be
+ returned by <code>getServletName()</code> (if not set, the
+ Cactus Servlet redirector name will be returned).
+ </li>
+ </ul>
+
+ </s3>
+
+ </s2>
+
+ <anchor id="servlet_context"/>
+ <s2 title="ServletContextWrapper">
+
+ <p>
+ This is not an implicit object per see (as it is not accessible as
+ an instance variable). It is available by calling
+ <code>config.getServletContext()</code>.
+ </p>
+ <p>
+ However, Cactus wraps the <code>ServletContext</code> in a
+ <code>ServletContextWrapper</code> in order to take into account
+ simulated URLs and provide additional methods to help write tests.
+ </p>
+
+ <p>
+ See the javadoc for the
+ <code>org.apache.cactus.server.ServletContextWrapper</code>
+ class for all details. You should also look at the
+ samples provided in the Cactus distribution.
+ </p>
+
+ <s3 title="Additional methods">
+
+ <p>
+ Additional methods provided:
+ </p>
+ <ul>
+ <li>
+ <code>getLogs()</code>: returns the text that has been logged
+ by calls to <code>ServletContext.log()</code> methods. This is
+ a helper method that makes it easy to assert what is logged.
+ </li>
+ </ul>
+
+ </s3>
+
</s2>
<anchor id="servlet_session"/>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>