您的位置:软件测试 > 开源软件测试 > 开源单元测试工具 > Cactus
用Cactus来测试J2ee应用
作者:网络转载 发布时间:[ 2012/11/29 14:52:41 ] 推荐标签:

<ejb-ref-name>UserInfo</ejb-ref-name>
<ejb-ref-type>Entity</ejb-ref-type>
<local-home>usersystem.UserInfoHome</local-home>
<local>usersystem.UserInfo</local>
<ejb-link>UserInfo</ejb-link>
</ejb-local-ref>
</session>
<entity>
<display-name>User</display-name>
<ejb-name>User</ejb-name>
<local-home>usersystem.UserHome</local-home>
<local>usersystem.User</local>
<ejb-class>usersystem.UserBean</ejb-class>
<persistence-type>Container</persistence-type>
<prim-key-class>java.lang.String</prim-key-class>
<reentrant>False</reentrant>
<cmp-version>2.x</cmp-version>
<abstract-schema-name>User</abstract-schema-name>
<cmp-field>
<field-name>name</field-name>
</cmp-field>
<cmp-field>
<field-name>password</field-name>
</cmp-field>
<primkey-field>name</primkey-field>
<query>
<query-method>
<method-name>findAll</method-name>
<method-params />
</query-method>
<ejb-ql>select Object(theUser) from User as theUser</ejb-ql>
</query>
</entity>
<entity>
<display-name>UserInfo</display-name>
<ejb-name>UserInfo</ejb-name>
<local-home>usersystem.UserInfoHome</local-home>
<local>usersystem.UserInfo</local>
<ejb-class>usersystem.UserInfoBean</ejb-class>
<persistence-type>Container</persistence-type>
<prim-key-class>java.lang.String</prim-key-class>
<reentrant>False</reentrant>
<cmp-version>2.x</cmp-version>
<abstract-schema-name>UserInfo</abstract-schema-name>
<cmp-field>
<field-name>name</field-name>
</cmp-field>
<cmp-field>
<field-name>email</field-name>
</cmp-field>
<cmp-field>
<field-name>address</field-name>
</cmp-field>
<cmp-field>
<field-name>tel</field-name>

</cmp-field>
<primkey-field>name</primkey-field>
</entity>
</enterprise-beans>
<relationships>
<ejb-relation>
<ejb-relation-name>userInfo-user</ejb-relation-name>
<ejb-relationship-role>
<description>userInfo</description>
<ejb-relationship-role-name>UserInfoRelationshipRole</ejb-relationship-role-name>
<multiplicity>One</multiplicity>
<cascade-delete />
<relationship-role-source>
<description>userInfo</description>
<ejb-name>UserInfo</ejb-name>
</relationship-role-source>
<cmr-field>
<description>user</description>
<cmr-field-name>user</cmr-field-name>
</cmr-field>
</ejb-relationship-role>
<ejb-relationship-role>
<description>user</description>
<ejb-relationship-role-name>UserRelationshipRole</ejb-relationship-role-name>
<multiplicity>One</multiplicity>
<relationship-role-source>
<description>user</description>
<ejb-name>User</ejb-name>
</relationship-role-source>
<cmr-field>
<description>userInfo</description>
<cmr-field-name>userInfo</cmr-field-name>
</cmr-field>
</ejb-relationship-role>
</ejb-relation>
</relationships>
<assembly-descriptor>
<container-transaction>
<method>
<ejb-name>User</ejb-name>
<method-name>*</method-name>
</method>
<trans-attribute>Required</trans-attribute>
</container-transaction>
<container-transaction>
<method>
<ejb-name>UserManager</ejb-name>
<method-name>*</method-name>
</method>
<trans-attribute>Required</trans-attribute>
</container-transaction>
<container-transaction>
<method>
<ejb-name>UserInfo</ejb-name>
<method-name>*</method-name>
</method>
<trans-attribute>Required</trans-attribute>
</container-transaction>
</assembly-descriptor>
</ejb-jar>

接下来是访问EJB的客户端,我们用了一个servlet.

ManaServlet.java
package usersystem.servlet;

import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;

import usersystem.*;
import javax.naming.*;
import javax.ejb.*;
import javax.ejb.*;
import javax.ejb.*;

/**
* <p>Title: </p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2002</p>
* <p>Company: </p>
* @author unascribed
* @version 1.0
*/

public class ManaServlet extends HttpServlet {
static final private String CONTENT_TYPE = "text/html; charset=GBK";
private UserManagerLocalHome h=null;
private UserManagerLocal uml=null;

public void init() throws ServletException{

上一页12345下一页
软件测试工具 | 联系我们 | 投诉建议 | 诚聘英才 | 申请使用列表 | 网站地图
沪ICP备07036474 2003-2017 版权所有 上海泽众软件科技有限公司 Shanghai ZeZhong Software Co.,Ltd