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 pt...@apache.org on 2008/06/30 16:40:16 UTC
svn commit: r672783 - in /jakarta/cactus/trunk/cactus-site: pom.xml
src/site/site.xml src/site/xdoc/writing/howto_ejb.xml
src/site/xdoc/writing/howto_ejb_3.xml
src/site/xdoc/writing/howto_ejb_j2eeri.xml
Author: ptahchiev
Date: Mon Jun 30 07:40:15 2008
New Revision: 672783
URL: http://svn.apache.org/viewvc?rev=672783&view=rev
Log:
Added the EJB3 documentation and also some minor changes on the
Added:
jakarta/cactus/trunk/cactus-site/src/site/xdoc/writing/howto_ejb_3.xml (with props)
Modified:
jakarta/cactus/trunk/cactus-site/pom.xml
jakarta/cactus/trunk/cactus-site/src/site/site.xml
jakarta/cactus/trunk/cactus-site/src/site/xdoc/writing/howto_ejb.xml
jakarta/cactus/trunk/cactus-site/src/site/xdoc/writing/howto_ejb_j2eeri.xml
Modified: jakarta/cactus/trunk/cactus-site/pom.xml
URL: http://svn.apache.org/viewvc/jakarta/cactus/trunk/cactus-site/pom.xml?rev=672783&r1=672782&r2=672783&view=diff
==============================================================================
--- jakarta/cactus/trunk/cactus-site/pom.xml (original)
+++ jakarta/cactus/trunk/cactus-site/pom.xml Mon Jun 30 07:40:15 2008
@@ -115,7 +115,7 @@
<email>cactus@felipeal.net</email>
<organization>Falcon Informatica</organization>
<roles>
- <role>Developer</role>
+ <role>Emeritus Developer</role>
</roles>
</developer>
<developer>
@@ -128,9 +128,12 @@
<name>Petar Tahchiev</name>
<id>ptahchiev</id>
<email>ptahchiev@apache.org</email>
- <organization>Sofia University</organization>
+ <url>http://phamola.com/</url>
+ <organization>Phamola Inc.</organization>
<roles>
- <role>Developer</role>
+ <role>Lead Developer</role>
+ <role>Release Manager</role>
+ <role>Moderator</role>
</roles>
<timezone>+3</timezone>
</developer>
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=672783&r1=672782&r2=672783&view=diff
==============================================================================
--- jakarta/cactus/trunk/cactus-site/src/site/site.xml (original)
+++ jakarta/cactus/trunk/cactus-site/src/site/site.xml Mon Jun 30 07:40:15 2008
@@ -59,6 +59,7 @@
<item name="How it works" href="how_it_works.html"/>
<item name="Writing tests" href="/writing/howto_ejb.html" collapse="true">
<item name="Howto EJB" href="/writing/howto_ejb_j2eeri.html"/>
+ <item name="Howto EJB3" href="/writing/howto_ejb_3.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"/>
Modified: jakarta/cactus/trunk/cactus-site/src/site/xdoc/writing/howto_ejb.xml
URL: http://svn.apache.org/viewvc/jakarta/cactus/trunk/cactus-site/src/site/xdoc/writing/howto_ejb.xml?rev=672783&r1=672782&r2=672783&view=diff
==============================================================================
--- jakarta/cactus/trunk/cactus-site/src/site/xdoc/writing/howto_ejb.xml (original)
+++ jakarta/cactus/trunk/cactus-site/src/site/xdoc/writing/howto_ejb.xml Mon Jun 30 07:40:15 2008
@@ -30,7 +30,6 @@
<body>
<section name="Introduction">
-
<p>
This document explains how to unit test EJBs with Cactus. It is
divided in 2 parts:
@@ -52,7 +51,10 @@
<note>
EJB unit testing works with Cactus 1.0 or later.
</note>
-
+
+ <note>
+ EJB3 unit testing works with Cactus 1.8.1 or later.
+ </note>
</section>
<anchor id="ejb_general"/>
Added: jakarta/cactus/trunk/cactus-site/src/site/xdoc/writing/howto_ejb_3.xml
URL: http://svn.apache.org/viewvc/jakarta/cactus/trunk/cactus-site/src/site/xdoc/writing/howto_ejb_3.xml?rev=672783&view=auto
==============================================================================
--- jakarta/cactus/trunk/cactus-site/src/site/xdoc/writing/howto_ejb_3.xml (added)
+++ jakarta/cactus/trunk/cactus-site/src/site/xdoc/writing/howto_ejb_3.xml Mon Jun 30 07:40:15 2008
@@ -0,0 +1,232 @@
+<?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_ejb_j2eeri">
+
+ <properties>
+ <title>EJB Testing with J2EE RI</title>
+ </properties>
+
+ <body>
+
+ <section name="Forewords">
+ <p>
+ This document explains how to unit test EJBs version 3.0 with Cactus. It is a good idea
+ to have a look at the
+ sample applications that come with Cactus's distribution in <code>samples/ejb3</code>
+ </p>
+ <p>
+ This tutorial shows how to write test cases for unit testing
+ EJB methods. The EJB used in this example is a simple Stateless 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>
+
+ </section>
+
+ <section name="EJB Jar">
+
+ <subsection name="Step 1: Prepare the Sample EJB">
+
+ <p>
+ The EJB used in this tutorial is a simple Stateless Bean with a method
+ for converting Yen to Dollar.
+ </p>
+ </subsection>
+ <subsection name="EJB Bean">
+
+ <source>
+ <![CDATA[
+package org.apache.cactus.sample.ejb3;
+
+import javax.ejb.Stateless;
+
+import org.apache.cactus.sample.ejb3.IConvertLocal;
+
+/**
+* Sample EJB3 bean.
+*
+* @version $Id: ConverterBean.java 238816 2008-06-31 16:36:46Z ptahchiev $
+*/
+@Stateless
+public class ConverterBean implements IConvertLocal {
+
+ /* (non-Javadoc)
+ * @see org.apache.cactus.sample.ejb3.IConvertLocal#convert(double)
+ */
+ public double convert(double theYenAmount) {
+ return theYenAmount / 100.0;
+ }
+}
+ ]]>
+ </source>
+ </subsection>
+ <subsection name="EJB Local Interface">
+
+ <source>
+ <![CDATA[
+package org.apache.cactus.sample.ejb3;
+
+import java.io.Serializable;
+
+import javax.ejb.Local;
+
+/**
+ * Sample EJB local interface
+ *
+ * @version $Id: IConverterLocal.java 238816 2008-06-31 16:36:46Z ptahchiev $
+ */
+@Local
+public interface IConvertLocal extends Serializable
+{
+ /**
+ * A method declaration to convert yen to dollars.
+ *
+ * @param theYenAmount
+ * @return
+ */
+ public double convert(double theYenAmount);
+}]]>
+ </source>
+ </subsection>
+ </section>
+ <section name="Prepare deployment descriptors">
+ <subsection name="application.xml">
+ <source>
+<![CDATA[
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE application
+ PUBLIC '-//Sun Microsystems, Inc.//DTD J2EE Application 1.3//EN'
+ 'http://java.sun.com/j2ee/dtds/application_1_3.dtd'>
+<application>
+ <display-name>cactus-sample-ejb</display-name>
+ <description>Cactus EJB3 Sample</description>
+ <module>
+ <ejb>samples-ejb3-1.8.1-SNAPSHOT.ejb3</ejb>
+ </module>
+</application>
+]]>
+ </source>
+ </subsection>
+ </section>
+ <section name="Cactus Web Application">
+ <subsection name="Step 1: Prepare test code">
+ <source>
+ <![CDATA[
+package org.apache.cactus.sample.ejb3;
+
+import java.util.Properties;
+
+import javax.naming.InitialContext;
+
+import junit.framework.TestCase;
+
+import org.apache.cactus.ServletTestCase;
+
+/**
+ * Sample Cactus test for a session bean.
+ *
+ * @version $Id: TestConverterEJB.java 238816 2004-02-29 16:36:46Z vmassol $
+ */
+public class TestConverterEJB extends ServletTestCase
+{
+ /**
+ * Class under test
+ */
+ private IConvertLocal converter;
+ /**
+ * @see TestCase#setUp()
+ */
+ public void setUp() throws Exception
+ {
+ Properties properties = new Properties();
+ properties.put("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
+ properties.put("java.naming.factory.url.pkgs", "org.jboss.naming rg.jnp.interfaces");
+ properties.put("java.naming.provider.url", "jnp://localhost:1099");
+ InitialContext ctx = new InitialContext(properties);
+ converter = (IConvertLocal) ctx.lookup("samples-ejb-1.8.1-SNAPSHOT-cactified/"+ConverterBean.class.getSimpleName()+"/local");
+ }
+ /**
+ * Verify yen to dollars conversion works.
+ * @throws Exception on error
+ */
+ public void testConvert() throws Exception
+ {
+ double dollar = this.converter.convert(100.0);
+ assertEquals("dollar", 1.0, dollar, 0.01);
+ }
+}
+ ]]>
+ </source>
+ </subsection>
+ <subsection name="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>
+ </subsection>
+ <subsection name="Step 3: Package Web Application">
+
+ <p>
+ Package the web application into a war file.
+ </p>
+
+ </subsection>
+ </section>
+ <section name="Deploy">
+ <p>
+ You need to package the war file with all the additional jar files in an ear file
+ and then deploy the ear file based on
+ the deployment procedure of your servlet container and your ejb
+ container.
+ </p>
+
+ </section>
+ </body>
+</document>
Propchange: jakarta/cactus/trunk/cactus-site/src/site/xdoc/writing/howto_ejb_3.xml
------------------------------------------------------------------------------
svn:eol-style = native
Modified: jakarta/cactus/trunk/cactus-site/src/site/xdoc/writing/howto_ejb_j2eeri.xml
URL: http://svn.apache.org/viewvc/jakarta/cactus/trunk/cactus-site/src/site/xdoc/writing/howto_ejb_j2eeri.xml?rev=672783&r1=672782&r2=672783&view=diff
==============================================================================
--- jakarta/cactus/trunk/cactus-site/src/site/xdoc/writing/howto_ejb_j2eeri.xml (original)
+++ jakarta/cactus/trunk/cactus-site/src/site/xdoc/writing/howto_ejb_j2eeri.xml Mon Jun 30 07:40:15 2008
@@ -30,7 +30,11 @@
<body>
<section name="Forewords">
-
+ <p>
+ This document explains how to unit test EJBs version 2.0 with Cactus. If you want to
+ test EJB version 3.0 with Cactus you can follow <a href="/writing/howto_ejb_3.html">this article</a>, as well as have a look at the
+ sample applications that come with Cactus's distribution in <code>samples/ejb3</code>
+ </p>
<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.
---------------------------------------------------------------------
To unsubscribe, e-mail: cactus-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: cactus-dev-help@jakarta.apache.org