vmassol 01/09/22 12:20:36
Modified: docs/framework/xdocs changes.xml contributors.xml
doc-book.xml site-book.xml todo.xml
Added: docs/framework/xdocs howto_ejb.xml howto_ejb_j2eeri.xml
Log:
new EJB tutorial + changed email address of author
Revision Changes Path
1.52 +30 -1 jakarta-cactus/docs/framework/xdocs/changes.xml
Index: changes.xml
===================================================================
RCS file: /home/cvs/jakarta-cactus/docs/framework/xdocs/changes.xml,v
retrieving revision 1.51
retrieving revision 1.52
diff -u -r1.51 -r1.52
--- changes.xml 2001/09/18 17:34:32 1.51
+++ changes.xml 2001/09/22 19:20:35 1.52
@@ -28,6 +28,15 @@
<table>
<tr>
<td>
+ 22/09/2001
+ </td>
+ <td>
+ The <link href="howto_ejb.html">EJB testing
+ tutorial</link> is now available ! Thanks Hudson !
+ </td>
+ </tr>
+ <tr>
+ <td>
18/09/2001
</td>
<td>
@@ -56,6 +65,15 @@
<code>org.apache.cactus.*</code>.
</td>
</tr>
+ <tr>
+ <td>
+ 10/09/2001
+ </td>
+ <td>
+ The <link href="howto_testcase_filter.html">Filter testing
+ tutorial</link> is now available !
+ </td>
+ </tr>
</table>
</s1>
@@ -85,10 +103,21 @@
<releases title="Release changes">
<devs>
- <person name="Vincent Massol" email="[EMAIL PROTECTED]" id="VMA"/>
+ <person name="Vincent Massol" email="[EMAIL PROTECTED]" id="VMA"/>
+ <person name="Nicholas Lesiecki" email="[EMAIL PROTECTED]" id="NDL"/>
</devs>
<release version="1.2 in CVS">
+ <action dev="VMA" type="add">
+ Tutorial for unit testing EJBs. Thanks to
+ <link href="mailto:[EMAIL PROTECTED]">Hudson Wong</link>.
+ </action>
+ <action dev="NDL" type="add">
+ Tutorial for unit testing Taglibs.
+ </action>
+ <action dev="VMA" type="add">
+ Tutorial for unit testing Servlet Filters.
+ </action>
<action dev="VMA" type="add">
<code>HttpServletRequestWrapper.getPathTranslated()</code> now takes
into account any path info set up in <code>WebRequest.setURL()</code>.
1.10 +7 -4 jakarta-cactus/docs/framework/xdocs/contributors.xml
Index: contributors.xml
===================================================================
RCS file: /home/cvs/jakarta-cactus/docs/framework/xdocs/contributors.xml,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- contributors.xml 2001/09/18 17:27:54 1.9
+++ contributors.xml 2001/09/22 19:20:35 1.10
@@ -6,7 +6,7 @@
<header>
<title>Contributors</title>
<authors>
- <person name="Vincent Massol" email="[EMAIL PROTECTED]"/>
+ <person name="Vincent Massol" email="[EMAIL PROTECTED]"/>
</authors>
</header>
@@ -35,7 +35,7 @@
<ul>
<li>
- <link href="mailto:[EMAIL PROTECTED]">Vincent
+ <link href="mailto:[EMAIL PROTECTED]">Vincent
Massol</link>
</li>
<li>
@@ -62,7 +62,7 @@
<ul>
<li>
- <link href="mailto:[EMAIL PROTECTED]">Vincent
+ <link href="mailto:[EMAIL PROTECTED]">Vincent
Massol</link>
</li>
<li>
@@ -81,6 +81,9 @@
<li>
<link href="mailto:[EMAIL PROTECTED]">Nicholas Lesiecki</link>
</li>
+ <li>
+ <link href="mailto:[EMAIL PROTECTED]">Hudson Wong</link>
+ </li>
</ul>
</s1>
@@ -90,7 +93,7 @@
<ul>
<li>
- <link href="mailto:[EMAIL PROTECTED]">Vincent
+ <link href="mailto:[EMAIL PROTECTED]">Vincent
Massol</link>
</li>
<li>
1.31 +4 -3 jakarta-cactus/docs/framework/xdocs/doc-book.xml
Index: doc-book.xml
===================================================================
RCS file: /home/cvs/jakarta-cactus/docs/framework/xdocs/doc-book.xml,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -r1.30 -r1.31
--- doc-book.xml 2001/09/18 20:04:49 1.30
+++ doc-book.xml 2001/09/22 19:20:35 1.31
@@ -27,8 +27,6 @@
<menu-item label="How it works ?" source="how_it_works.xml"/>
<menu-item label="Getting Started" source="getting_started.xml"/>
<menu-item label="Mock vs Container" source="mockobjects.xml"/>
- <!-- To be added : Testing Strategies (explains the different kind of
- tests and how Cactus is positioned -->
<menu-item type="external" label="API Reference" href="javadoc/index.html"/>
</menu>
@@ -49,7 +47,10 @@
<menu-item label="HttpUnit Howto" source="howto_httpunit.xml"/>
<menu-item label="Sample Howto" source="howto_sample.xml"/>
- <!--menu-item label="Reference Manual" source="reference_manual.xml"/-->
+
+ <!-- EJB tutorial -->
+ <menu-item label="EJB Howto" source="howto_ejb.xml"/>
+ <menu-item type="hidden" source="howto_ejb_j2eeri.xml"/>
<!-- IDE tutorials -->
<menu-item label="IDE Howto" source="howto_ide.xml"/>
1.27 +4 -3 jakarta-cactus/docs/framework/xdocs/site-book.xml
Index: site-book.xml
===================================================================
RCS file: /home/cvs/jakarta-cactus/docs/framework/xdocs/site-book.xml,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -r1.26 -r1.27
--- site-book.xml 2001/09/18 20:04:49 1.26
+++ site-book.xml 2001/09/22 19:20:35 1.27
@@ -27,8 +27,6 @@
<menu-item label="How it works ?" source="how_it_works.xml"/>
<menu-item label="Getting Started" source="getting_started.xml"/>
<menu-item label="Mock vs Container" source="mockobjects.xml"/>
- <!-- To be added : Testing Strategies (explains the different kind of
- tests and how Cactus is positioned -->
<menu-item label="API Reference" source="javadoc.xml"/>
</menu>
@@ -49,7 +47,10 @@
<menu-item label="HttpUnit Howto" source="howto_httpunit.xml"/>
<menu-item label="Sample Howto" source="howto_sample.xml"/>
- <!--menu-item label="Reference Manual" source="reference_manual.xml"/-->
+
+ <!-- EJB tutorial -->
+ <menu-item label="EJB Howto" source="howto_ejb.xml"/>
+ <menu-item type="hidden" source="howto_ejb_j2eeri.xml"/>
<!-- IDE tutorials -->
<menu-item label="IDE Howto" source="howto_ide.xml"/>
1.61 +0 -7 jakarta-cactus/docs/framework/xdocs/todo.xml
Index: todo.xml
===================================================================
RCS file: /home/cvs/jakarta-cactus/docs/framework/xdocs/todo.xml,v
retrieving revision 1.60
retrieving revision 1.61
diff -u -r1.60 -r1.61
--- todo.xml 2001/09/22 14:41:24 1.60
+++ todo.xml 2001/09/22 19:20:35 1.61
@@ -31,13 +31,6 @@
<version title="Version 1.2">
- <category title="Documentation">
- <action assigned-to="Hudson Wong">
- Add a tutorial that explains how to unit test EJBs in the current
- version of Cactus.
- </action>
- </category>
-
<category title="Design/Code">
<action assigned-to="Nicholas Lesiecki">
Provide some sample taglib tests.
1.1 jakarta-cactus/docs/framework/xdocs/howto_ejb.xml
Index: howto_ejb.xml
===================================================================
<?xml version="1.0"?>
<!DOCTYPE document SYSTEM "./dtd/document-v10.dtd">
<document>
<header>
<title>EJB Testing with Cactus Howto</title>
<authors>
<person name="Vincent Massol" email="[EMAIL PROTECTED]"/>
</authors>
</header>
<body>
<s1 title="Introduction">
<p>
This document explains how to unit test EJBs with Cactus. It is
divided in 2 parts :
</p>
<ul>
<li>
<jump anchor="ejb_general">General concepts</jump> : explains the
generic concepts behind EJB unit testing with Cactus,
</li>
<li>
<jump anchor="ejb_j2eeri">J2EE RI tutorial</jump> : provides a
detailed tutorial, on a sample, on how to explicitely perform EJB
unit testing with the
<link href="http://java.sun.com/j2ee/download.html#sdk">J2EE Reference
Implementation</link> server from Sun.
</li>
</ul>
<note>
EJB unit testing works with Cactus 1.0 or later.
</note>
</s1>
<anchor id="ejb_general"/>
<s1 title="General Concepts">
<s2 title="Why use Cactus for testing EJBs ?">
<p>
You might be wondering why you would use Cactus to unit test your
EJBs whereas you could use standard JUnit test cases. Indeed,
you could write a standard JUnit test case and view your code as
client side code for the EJB to test ... There are actually a few
reasons to choose Cactus instead :
</p>
<ul>
<li>
Very often the production code that will call the EJBs is server
side code (Servlets, JSPs, Tag libs or Filters). This means that if
you run the tests from a standard JUnit test case, your tests will
run in a different execution environment than the production one,
which can lead to different test results,
</li>
<li>
An application using EJBs very often includes a front end part which
is in almost all cases a web application (i.e. using Servlets,
JSP, Tag libs or Filters). It means that you would also need a
framework for unit testing these components. Cactus is providing
a comprehensive and consistent framework for testing all server
side components. This is a compelling enough reason to use it !
</li>
<li>
Cactus provides automated Ant tasks to automatically start your
EJB server, run the tests and stop it, thus automating your
entire test process and making it easy to implement continuous
build and continuous integration of your J2EE project.
</li>
</ul>
</s2>
<s2 title="The process">
<p>
You can unit test your EJBs from any of Cactus redirectors :
<code>ServletTestCase</code>, <code>JspTestCase</code> or
<code>FilterTestCase</code>.
</p>
<p>
This means that you would write a test case class that extends any
of Cactus redirectors, get a home reference to your EJB, create an
instance of it, call the method to test and perform asserts on the
result.
</p>
<p>
It is that simple ! What is slightly more complex is the deployment
of your EJBs to your EJB container but you should be familiar with
this, right ?
</p>
</s2>
</s1>
<anchor id="ejb_j2eeri"/>
<s1 title="J2EE RI Tutorial">
<p>
This <link href="howto_ejb_j2eeri.html">J2EE RI tutorial</link>
is a step by step guide for writing Cactus EJB unit test for the
Sun J2EE RI server.
</p>
</s1>
</body>
</document>
1.1 jakarta-cactus/docs/framework/xdocs/howto_ejb_j2eeri.xml
Index: howto_ejb_j2eeri.xml
===================================================================
<?xml version="1.0"?>
<!DOCTYPE document SYSTEM "./dtd/document-v10.dtd">
<document>
<header>
<title>EJB Testing with J2EE RI</title>
<authors>
<person name="Hudson Wong" email="[EMAIL PROTECTED]"/>
<person name="Vincent Massol" email="[EMAIL PROTECTED]"/>
</authors>
</header>
<body>
<s1 title="Forewords">
<p>
This tutorial shows how to write test cases for unit testing
EJB methods. The EJB used in this example is a simple Session Bean.
</p>
<p>
This tutorial assumes the reader has already understood how to use
Cactus to test Servlet. To test an EJB, you need to prepare a war to
contain the cactus setting and test cases, and then prepare a jar of
your ejb. You need to match the JNDI name in the ejb jar and the war.
</p>
<note>
This is an EJB 1.1 example but the same principles are valid for
EJB 2.0
</note>
</s1>
<s1 title="EJB Jar">
<s2 title="Step 1 : Prepare the Sample EJB">
<p>
The EJB used in this tutorial is a simple Session Bean with a method
for converting Yen to Dollar.
</p>
<s3 title="EJB Remote">
<source><![CDATA[
package org.apache.cactus.sample.ejb;
import java.rmi.*;
import javax.ejb.*;
public interface Converter extends EJBObject
{
public double convertYenToDollar(double theYenAmount) throws RemoteException;
}
]]></source>
</s3>
<s3 title="EJB Home">
<source><![CDATA[
package org.apache.cactus.sample.ejb;
import java.rmi.*;
import javax.ejb.*;
public interface ConverterHome extends EJBHome
{
public Converter create() throws RemoteException, CreateException;
}
]]></source>
</s3>
<s3 title="EJB Bean">
<source><![CDATA[
package org.apache.cactus.sample.ejb;
import javax.ejb.*;
public class ConverterEJB implements SessionBean
{
private SessionContext context;
public double convertYenToDollar(double theYenAmount)
{
return theYenAmount / 100.0;
}
public ConverterEJB()
{
}
public void ejbCreate() throws CreateException
{
}
public void setSessionContext(SessionContext theContext)
{
this.context = theContext;
}
public void ejbActivate()
{
}
public void ejbPassivate()
{
}
public void ejbRemove()
{
}
}
]]></source>
</s3>
</s2>
<s2 title="Step 2 : Prepare EJB Deployment Descriptor (ejb-jar.xml)">
<p>
Prepare the standard EJB Deployment Descriptor for the Session EJB :
</p>
<source><![CDATA[
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE ejb-jar PUBLIC
'-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 1.1//EN'
'http://java.sun.com/j2ee/dtds/ejb-jar_1_1.dtd'>
<ejb-jar>
<display-name>testejb</display-name>
<enterprise-beans>
<session>
<description>Converter Session Bean</description>
<display-name>Converter</display-name>
<ejb-name>Converter</ejb-name>
<home>org.apache.cactus.sample.ejb.ConverterHome</home>
<remote>org.apache.cactus.sample.ejb.Converter</remote>
<ejb-class>org.apache.cactus.sample.ejb.ConverterEJB</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
</session>
</enterprise-beans>
<assembly-descriptor>
<container-transaction>
<method>
<ejb-name>Converter</ejb-name>
<method-intf>Remote</method-intf>
<method-name>*</method-name>
</method>
<trans-attribute>NotSupported</trans-attribute>
</container-transaction>
</assembly-descriptor>
</ejb-jar>
]]></source>
</s2>
<s2 title="Step 3 : Prepare EJB Runtime (only valid for J2EE RI)">
<source><![CDATA[
<?xml version="1.0" encoding="ISO-8859-1"?>
<j2ee-ri-specific-information>
<server-name></server-name>
<rolemapping />
<enterprise-beans>
<ejb>
<ejb-name>Converter</ejb-name>
<jndi-name>ejb/Converter</jndi-name>
</ejb>
</enterprise-beans>
</j2ee-ri-specific-information>
]]></source>
</s2>
</s1>
<s1 title="Cactus Web Application">
<s2 title="Step 1 : Prepare test code">
<source><![CDATA[
package org.apache.cactus.sample.ejb;
import javax.naming.*;
import javax.rmi.*;
import junit.framework.*;
import org.apache.cactus.*;
public class ConverterTest extends ServletTestCase
{
private Converter converter;
public ConverterTest(String name)
{
super(name);
}
public static Test suite()
{
return new TestSuite(ConverterTest.class);
}
public void setUp()
{
Context ctx = new InitialContext();
ConverterHome home = (ConverterHome)
PortableRemoteObject.narrow(ctx.lookup("java:comp/ejb/Converter"),
ConverterHome.class);
this.converter = home.create();
}
public void testConvert() throws Exception
{
double dollar = this.converter.convertYenToDollar(100.0);
assertEquals("dollar", 1.0, dollar, 0.01);
}
}
]]></source>
</s2>
<s2 title="Step 2 : Prepare Web Application Deployment Descriptor (web.xml)">
<source><![CDATA[
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
"http://java.sun.com/j2ee/dtds/web-app_2.2.dtd">
<web-app>
<servlet>
<servlet-name>ServletRedirector</servlet-name>
<servlet-class>org.apache.cactus.server.ServletTestRedirector</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>ServletRedirector</servlet-name>
<url-pattern>/ServletRedirector/</url-pattern>
</servlet-mapping>
[...]
<ejb-ref>
<ejb-ref-name>ejb/Converter</ejb-ref-name>
<ejb-ref-type>Session</ejb-ref-type>
<home>org.apache.cactus.sample.ejb.ConverterHome</home>
<remote>org.apache.cactus.sample.ejb.Converter</remote>
</ejb-ref>
</web-app>
]]></source>
</s2>
<s2 title="Step 3 : Package Web Application">
<p>
Package the web application into a war and then deploy it. Please
note that the <code>ejb-ref-name</code> in the deployment descriptor
need to match with the JNDI name of the test EJB.
</p>
</s2>
<s2 title="Step 4 : (Only valid to J2EE RI 1.2.1): War Runtime">
<source><![CDATA[
<j2ee-ri-specific-information>
<server-name/>
<rolemapping/>
<web>
<display-name>test</display-name>
<context-root>test</context-root>
<ejb-ref>
<ejb-ref-name>ejb/Converter</ejb-ref-name>
<jndi-name>ejb/Converter</jndi-name>
</ejb-ref>
</web>
</j2ee-ri-specific-information>
]]></source>
</s2>
<s2 title="Step 5 : Deploy">
<p>
You need to deploy the war and the <code>ejb-jar.xml</code> based on
the deployment procedure of your servlet container and your ejb
container.
</p>
</s2>
</s1>
</body>
</document>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]