ptahchiev
Fri, 30 May 2008 08:48:08 -0700
Author: ptahchiev Date: Fri May 30 08:47:46 2008 New Revision: 661767 URL: http://svn.apache.org/viewvc?rev=661767&view=rev Log: Changes in the documentation. Added the HTMLUnit integration page and also improved the index.xml of the maven2 integration. Added: jakarta/cactus/trunk/cactus-site/src/site/xdoc/writing/howto_htmlunit.xml (with props) Modified: jakarta/cactus/trunk/cactus-site/src/site/site.xml jakarta/cactus/trunk/cactus-site/src/site/xdoc/integration/maven2/index.xml Modified: jakarta/cactus/trunk/cactus-site/src/site/site.xml URL: http://svn.apache.org/viewvc/jakarta/cactus/trunk/cactus-site/src/site/site.xml?rev=661767&r1=661766&r2=661767&view=diff ============================================================================== --- jakarta/cactus/trunk/cactus-site/src/site/site.xml (original) +++ jakarta/cactus/trunk/cactus-site/src/site/site.xml Fri May 30 08:47:46 2008 @@ -60,6 +60,7 @@ <item name="Writing tests" href="/writing/howto_ejb.html" collapse="true"> <item name="Howto EJB" href="/writing/howto_ejb_j2eeri.html"/> <item name="Howto HTTPUnit" href="/writing/howto_httpunit.html"/> + <item name="Howto HTMLUnit" href="/writing/howto_htmlunit.html"/> <item name="Howto JSP" href="/writing/howto_jsp.html"/> <item name="Howto Security" href="/writing/howto_security.html"/> <item name="Howto TestCase" href="/writing/howto_testcase.html"/> Modified: jakarta/cactus/trunk/cactus-site/src/site/xdoc/integration/maven2/index.xml URL: http://svn.apache.org/viewvc/jakarta/cactus/trunk/cactus-site/src/site/xdoc/integration/maven2/index.xml?rev=661767&r1=661766&r2=661767&view=diff ============================================================================== --- jakarta/cactus/trunk/cactus-site/src/site/xdoc/integration/maven2/index.xml (original) +++ jakarta/cactus/trunk/cactus-site/src/site/xdoc/integration/maven2/index.xml Fri May 30 08:47:46 2008 @@ -159,15 +159,13 @@ </zipUrlInstaller> </container> <configuration> - <deployables> + <deployables> <deployable> - <groupId>org.apache.cactus</groupId> - <artifactId>cactus.samples.servlet</artifactId> - <type>war</type> - <properties> - <context>/test</context> - </properties> - <pingURL>http://localhost:8080/</pingURL> + <location>cactifiedByMaven2.war</location> + <pingURL>http://localhost:8080/test/</pingURL> + <properties> + <context>/test</context> + </properties> </deployable> </deployables> </configuration> Added: jakarta/cactus/trunk/cactus-site/src/site/xdoc/writing/howto_htmlunit.xml URL: http://svn.apache.org/viewvc/jakarta/cactus/trunk/cactus-site/src/site/xdoc/writing/howto_htmlunit.xml?rev=661767&view=auto ============================================================================== --- jakarta/cactus/trunk/cactus-site/src/site/xdoc/writing/howto_htmlunit.xml (added) +++ jakarta/cactus/trunk/cactus-site/src/site/xdoc/writing/howto_htmlunit.xml Fri May 30 08:47:46 2008 @@ -0,0 +1,158 @@ +<?xml version="1.0"?> + +<!-- + * ======================================================================== + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ======================================================================== +--> + +<document id="howto_htmlunit"> + + <properties> + <title>HtmlUnit Howto</title> + </properties> + + <body> + + <section name="HtmlUnit integration"> + <p> + Cactus provides the exact same integration with HtmlUnit as with HttpUnit. This page discusses this integration. + </p> + + <note> + <strong>The HtmlUnit integration is only available for Cactus v1.8 and + later. It won't work with version 1.7 and earlier.</strong> + </note> + + <p> + Cactus test cases allow to assert the results of the returned server + output stream in an <code>endXXX()</code> method (where <code>XXX</code> + is the name of your test case). + </p> + <p> + Cactus proposes 2 ways of writing your <code>endXXX()</code> methods, + </p> + <ul> + <li> + <strong>Method 1</strong>: it allows you to do simple check on the + returned stream like checking for returned cookies, HTTP headers and + to do assertions on the returned content as a String, + </li> + <li> + <strong>Method 2</strong>: it allows you to do complex and + powerful assertions on the returned content. For example, you can + get an HTML DOM view of your returned HTML page and check that a given + named table has the correct number of columns, .... + </li> + </ul> + <p> + Method 2 is supported through the integration with + <a href="http://htmlunit.sourceforge.net">HtmlUnit</a>, meaning + you'll benefit from the full assertion power of HtmlUnit in your + <code>endXXX()</code> method. Method 1 is a class provided by Cactus. + </p> + <p> + Depending on your need you can choose, on a per test case basis, the + method you want to use. + </p> + + </section> + + <section name="Usage"> + + <p> + The signature of an <code>endXXX()</code> method is always: + </p> +<source><![CDATA[ +public void endXXX(WebResponse theResponse) +{ +[...] +} +]]></source> + + <p> + The <code>WebResponse</code> object is passed by the Cactus framework + to your <code>endXXX()</code> method. What changes between the 2 + methods described above is the class of the <code>WebResponse</code> + object that is passed: + </p> + <ul> + <li> + <code>org.apache.cactus.WebResponse</code> for Method 1, + </li> + <li> + <code>com.gargoylesoftware.htmlunit.WebResponse</code> for Method 2 + (HtmlUnit) + </li> + </ul> + + <section name="Method 1: Cactus provided WebResponse object"> + + <p> + An example: + </p> + +<source><![CDATA[ +public void endXXX(org.apache.cactus.WebResponse theResponse) +{ + // Get the returned cookies + Hashtable cookies = theResponse.getCookies(); + + // Get the returned content as a string + String content = theResponse.getText(); + + // Do some asserts + assertEquals(content, "<html><body><h1>Hello world!</h1></body></html>"); +[...] +} +]]></source> + + <note> + For the complete list of all methods available on the + <code>WebResponse</code> object, see the associated Javadoc. + </note> + + </section> + + <section name="Method 2: HtmlUnit provided WebResponse object"> + + <p> + An example: + </p> + +<source><![CDATA[ +public void endXXX(com.meterware.httpunit.WebResponse theResponse) +{ + WebTable table = theResponse.getTables()[0]; + assertEquals("<html><head/><body>A GET request</body></html>", theResponse.getContentAsString()); +[...] +} +]]></source> + + <note> + For the complete list of all methods available on the + HtmlUnit <code>WebResponse</code> object, see the HtmlUnit + documentation. + </note> + + </section> + + </section> + + </body> +</document> Propchange: jakarta/cactus/trunk/cactus-site/src/site/xdoc/writing/howto_htmlunit.xml ------------------------------------------------------------------------------ svn:eol-style = native --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]