WEB开发网
开发学院软件开发Java 用Cactus来测试J2ee应用 阅读

用Cactus来测试J2ee应用

 2010-03-19 00:00:00 来源:WEB开发网   
核心提示: UserManagerBean是一个session bean ,它主要是对user的管理,和客户端通讯,用Cactus来测试J2ee应用(4),其实就是session facade模式,代码里面有注释

UserManagerBean是一个session bean ,它主要是对user的管理,和客户端通讯,其实就是session facade模式。代码里面有注释,这里就不多叙述了。

ejb-jar.xml 部署文件描述

<?xml version="1.0" encoding="UTF-8"?> 
<!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN" 
"http://java.sun.com/dtd/ejb-jar_2_0.dtd"> 
<ejb-jar> 
  <enterprise-beans> 
    <session> 
      <display-name>UserManager</display-name> 
      <ejb-name>UserManager</ejb-name> 
      <local-home>usersystem.UserManagerLocalHome</local-home> 
      <local>usersystem.UserManagerLocal</local> 
      <ejb-class>usersystem.UserManagerBean</ejb-class> 
      <session-type>Stateless</session-type> 
      <transaction-type>Container</transaction-type> 
      <ejb-local-ref> 
        <description /> 
        <ejb-ref-name>User</ejb-ref-name> 
        <ejb-ref-type>Entity</ejb-ref-type> 
        <local-home>usersystem.UserHome</local-home> 
        <local>usersystem.User</local> 
        <ejb-link>User</ejb-link> 
      </ejb-local-ref> 
      <ejb-local-ref> 
        <description /> 
        <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> 

上一页  1 2 3 4 5 6 7 8 9  下一页

Tags:Cactus Jee

编辑录入:爽爽 [复制链接] [打 印]
    赞助商链接