Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "EJB Test Plan/Session Bean Wizard"

(Create Session Bean with Home and Components interfaces (EJB 2.x))
(Create Stateful Session Bean)
 
(8 intermediate revisions by the same user not shown)
Line 11: Line 11:
 
# Create One EJB Project 3.0 and add it to the EAR.  
 
# Create One EJB Project 3.0 and add it to the EAR.  
 
# Create a new Session Bean:
 
# Create a new Session Bean:
#* for Java package enter some String that starts with a number, or has some symbols (except _ ). There should be an error: Invalid Java package name…
 
 
#* enter "test" for Java package.
 
#* enter "test" for Java package.
#* for Class name enter some String that starts with a number, or has some symbols (except _ ). There should be an error: Invalid Java class name. Next and Finish buttons are disabled.
 
 
#* enter "TestBean" for Class name.
 
#* enter "TestBean" for Class name.
 
#* State type must be Stateless by default.
 
#* State type must be Stateless by default.
 
#* Check whether only "Create Business Interface > Local" is checked by default and leave it checked.
 
#* Check whether only "Create Business Interface > Local" is checked by default and leave it checked.
 
#* [[Image:Session_bean_01.png]]
 
#* [[Image:Session_bean_01.png]]
#* go to next page.
 
#* Check whether in Business Interfaces section only TestBeanLocal interface is shown.
 
#* Leave the Inherited abstract methods and Constructors from superclass checkboxes checked.
 
 
#* press Finish.
 
#* press Finish.
 +
#Check that Session Bean class and interface exist in the project file structure.
 +
#Verify that there is a node for the Deployment Descriptor and node for the Beans under the "Session Beans" node.
 +
#Check that under this node all bean classes and interfaces are listed.
 +
#Check if in the ‘ejbModule’ source folder there is the following annotation and the default constructor:
 +
 +
    package test;
 +
        import javax.ejb.Stateless;
 +
        /**
 +
        * Session Bean implementation class TestBean
 +
        */
 +
        @Stateless
 +
        public class TestBean implements TestBeanLocal {
 +
            /**
 +
            * Default constructor.
 +
            */
 +
            public TestBean() {
 +
              // TODO Auto-generated constructor stub
 +
            }
 +
        }
 +
 +
 +
 +
== Create Remote Session Bean ==
 +
 
#Create a new Stateless Session Bean:
 
#Create a new Stateless Session Bean:
 
#*enter "test" for Java package.
 
#*enter "test" for Java package.
#*enter "TestBean" for Class name. Check that there is an error: The class already exists in the package.
+
#*enter "TestBean1" for Class name.
#*enter "TestBean1" for name.
+
 
#*Check up Remote interface and uncheck Local interface.
 
#*Check up Remote interface and uncheck Local interface.
 +
#*Next
 +
#*Delete the name TestBean4 from the field Bean name. Error message is shown and Next and Finish buttons are disabled.
 +
#*Enter some String that starts with a number, or has some symbols (except _ ). There should be an error and Next and Finish buttons are disabled.
 +
#*Set Bean name: MyBean.
 +
#*Set Mapped name: ejb/MyBean.
 
#*Check whether in Business Interfaces section only TestBean1Remote interface is shown.
 
#*Check whether in Business Interfaces section only TestBean1Remote interface is shown.
 
#*press Finish.
 
#*press Finish.
 +
#Check if in the ‘ejbModule’ source folder the following code is generated:
 +
   
 +
    package test;
 +
      import javax.ejb.Stateless;
 +
      /**
 +
      * Session Bean implementation class TestBean1
 +
      */
 +
      @Stateless(name = "MyBean", mappedName = "ejb/MyBean")
 +
      public class TestBean1 implements TestBean1Remote {
 +
          /**
 +
            * Default constructor.
 +
          */
 +
          public TestBean1() {
 +
              // TODO Auto-generated constructor stub
 +
          }
 +
        }
 +
 +
== Create Session Bean with Remote and Local Interfaces ==
 +
 
#Create a new Stateless Session Bean :
 
#Create a new Stateless Session Bean :
 
#*enter "test" for Java package.  
 
#*enter "test" for Java package.  
Line 36: Line 78:
 
#*[[Image:Session_bean_02.png]]
 
#*[[Image:Session_bean_02.png]]
 
#*press Finish.
 
#*press Finish.
#Check that Session Bean classes and interfaces exist in the project file structure.
+
#Check if in the ‘ejbModule’ source folder the following code is generated:
#Verify that there is a node for the Deployment Descriptor and nodes for all the Beans under the "Session Beans" node.
+
 
#Check that under each node all bean classes and interfaces are listed.
+
    package test;
 +
      import javax.ejb.Stateless;
 +
      /**
 +
      * Session Bean implementation class TestBean1_2
 +
      */
 +
      @Stateless
 +
      public class TestBean1_2 implements TestBean1_2Remote, TestBean1_2Local {
 +
          /**
 +
          * Default constructor.  
 +
          */
 +
          public TestBean1_2() {
 +
              // TODO Auto-generated constructor stub
 +
          }
 +
      }
  
 
<< add more steps >>
 
<< add more steps >>
 +
 +
== Validate fields of Session Bean wizard ==
 +
 +
# Create a new Session Bean:
 +
#* for Java package enter some String that starts with a number, or has some symbols (except _ ). There should be an error: Invalid Java package name…
 +
#*Enter "test".
 +
#*for Class name enter some String that starts with a number, or has some symbols (except _ ). There should be an error: Invalid Java class name. Next and Finish buttons are disabled.
 +
#*enter "TestBean" for Class name. Check that there is an error: The class already exists in the package.
 +
#*Enter some valid name.
 +
#*Check up Remote and Local interfaces.
 +
#*Delete the names in the fields. Error message is shown and Next and Finish buttons are disabled.
 +
#*Set the same names in the Remote and Local Interfaces fields:
 +
#*[[Image:Session_bean_07.png]]
 +
#*go to next page
 +
#*Delete the name TestBean4 from the field Bean name. Error message is shown and Next and Finish buttons are disabled.
 +
#*Enter some String that starts with a number, or has some symbols (except _ ). There should be an error and Next and Finish buttons are disabled.
 +
#*Set Bean name: MyBean. There should be an error: Enterprise bean with the same Ejb Name already exists.
 +
#*[[Image:Session_bean_09.png]]
 +
#*Set Mapped name: ejb/MyBean.
  
 
== Create Session Bean with addition Business Interfaces ==
 
== Create Session Bean with addition Business Interfaces ==
Line 67: Line 141:
  
 
== Create Session Bean with Home and Components interfaces (EJB 2.x) ==
 
== Create Session Bean with Home and Components interfaces (EJB 2.x) ==
 +
 
#Create a new Stateless Session Bean :
 
#Create a new Stateless Session Bean :
 
#*enter "test" for Java package  
 
#*enter "test" for Java package  
Line 74: Line 149:
 
#*Check Local and Remote  
 
#*Check Local and Remote  
 
#*Leave the Inherited abstract methods and Constructors from superclass checkboxes checked.
 
#*Leave the Inherited abstract methods and Constructors from superclass checkboxes checked.
#*[[Image:Image.png]]
+
#*[[Image:Session_bean_04.png]]
 
#*Press Finish  
 
#*Press Finish  
 
#Check if in the ‘ejbModule’ source folder there are the following annotations:  
 
#Check if in the ‘ejbModule’ source folder there are the following annotations:  
Line 81: Line 156:
 
       @LocalHome(TestBean3LocalHome.class)
 
       @LocalHome(TestBean3LocalHome.class)
 
       @RemoteHome(TestBean3RemoteHome.class)
 
       @RemoteHome(TestBean3RemoteHome.class)
 +
 +
 +
<< add more steps >>
 +
 +
 +
 +
== Create Session Bean with Transaction Type Bean ==
 +
 +
#Create a new Stateless Session Bean :
 +
#*enter "test" for Java package
 +
#*enter "TestBean4" for Class name
 +
#*go to next page
 +
#*Select for Transaction Type : Bean.
 +
#*Leave the Inherited abstract methods and Constructors from superclass check boxes checked.
 +
#*Press Finish.
 +
#Check if in the ‘ejbModule’ source folder there are the following annotations:
 +
 +
      @Stateless
 +
      @TransactionManagement(TransactionManagementType.BEAN)
 +
 +
 +
 +
== Create Stateful Session Bean ==
 +
 +
#Create a new Session Bean :
 +
#*enter "test" for Java package.
 +
#*enter "TestBean5" for Class name.
 +
#*Set for State Type:  Stateful.
 +
#*go to next page.
 +
#*Set the Bean name: MyStatefulBean.
 +
#*Set Mapped name: ejb/MyStatefulBean.
 +
#*Leave the Inherited abstract methods and Constructors from superclass checkboxes checked.
 +
#*[[Image:Session_bean_06.png]]
 +
#*Press Finish.
 +
#Check if in the ‘ejbModule’ source folder there are the following annotations:
 +
 +
      @Stateful(name = "MyStatefulBean", mappedName = "ejb/MyStatefulBean")

Latest revision as of 03:05, 4 July 2008

Functional tests for the Session Bean wizard.

Prerequisites

  • Java EE 5 compatible runtime installed: JBoss, Glassfish, etc.
  • an EAR 5 project created.

Create Default Session Bean

  1. Open the Java EE perspective.
  2. Create One EJB Project 3.0 and add it to the EAR.
  3. Create a new Session Bean:
    • enter "test" for Java package.
    • enter "TestBean" for Class name.
    • State type must be Stateless by default.
    • Check whether only "Create Business Interface > Local" is checked by default and leave it checked.
    • Session bean 01.png
    • press Finish.
  4. Check that Session Bean class and interface exist in the project file structure.
  5. Verify that there is a node for the Deployment Descriptor and node for the Beans under the "Session Beans" node.
  6. Check that under this node all bean classes and interfaces are listed.
  7. Check if in the ‘ejbModule’ source folder there is the following annotation and the default constructor:
    package test;
       import javax.ejb.Stateless;
        /**
        * Session Bean implementation class TestBean
        */
       @Stateless
       public class TestBean implements TestBeanLocal {
           /**
           * Default constructor. 
           */
           public TestBean() {
              // TODO Auto-generated constructor stub
           }
       }


Create Remote Session Bean

  1. Create a new Stateless Session Bean:
    • enter "test" for Java package.
    • enter "TestBean1" for Class name.
    • Check up Remote interface and uncheck Local interface.
    • Next
    • Delete the name TestBean4 from the field Bean name. Error message is shown and Next and Finish buttons are disabled.
    • Enter some String that starts with a number, or has some symbols (except _ ). There should be an error and Next and Finish buttons are disabled.
    • Set Bean name: MyBean.
    • Set Mapped name: ejb/MyBean.
    • Check whether in Business Interfaces section only TestBean1Remote interface is shown.
    • press Finish.
  2. Check if in the ‘ejbModule’ source folder the following code is generated:
    package test;
      import javax.ejb.Stateless;
      /**
      * Session Bean implementation class TestBean1
      */
      @Stateless(name = "MyBean", mappedName = "ejb/MyBean")
      public class TestBean1 implements TestBean1Remote {
          /**
            * Default constructor. 
          */
          public TestBean1() {
              // TODO Auto-generated constructor stub
          }
       }

Create Session Bean with Remote and Local Interfaces

  1. Create a new Stateless Session Bean :
    • enter "test" for Java package.
    • enter "TestBean1_2" for Class name.
    • Check up both interfaces.
    • Press Next and check whether the names of the both interfaces are shown.
    • Session bean 02.png
    • press Finish.
  2. Check if in the ‘ejbModule’ source folder the following code is generated:
    package test;
      import javax.ejb.Stateless;
      /**
      * Session Bean implementation class TestBean1_2
      */
      @Stateless
      public class TestBean1_2 implements TestBean1_2Remote, TestBean1_2Local {
         /**
         * Default constructor. 
         */
         public TestBean1_2() {
             // TODO Auto-generated constructor stub
         }
      }

<< add more steps >>

Validate fields of Session Bean wizard

  1. Create a new Session Bean:
    • for Java package enter some String that starts with a number, or has some symbols (except _ ). There should be an error: Invalid Java package name…
    • Enter "test".
    • for Class name enter some String that starts with a number, or has some symbols (except _ ). There should be an error: Invalid Java class name. Next and Finish buttons are disabled.
    • enter "TestBean" for Class name. Check that there is an error: The class already exists in the package.
    • Enter some valid name.
    • Check up Remote and Local interfaces.
    • Delete the names in the fields. Error message is shown and Next and Finish buttons are disabled.
    • Set the same names in the Remote and Local Interfaces fields:
    • Session bean 07.png
    • go to next page
    • Delete the name TestBean4 from the field Bean name. Error message is shown and Next and Finish buttons are disabled.
    • Enter some String that starts with a number, or has some symbols (except _ ). There should be an error and Next and Finish buttons are disabled.
    • Set Bean name: MyBean. There should be an error: Enterprise bean with the same Ejb Name already exists.
    • Session bean 09.png
    • Set Mapped name: ejb/MyBean.

Create Session Bean with addition Business Interfaces

  1. Create a new Stateless Session Bean :
    • enter "test" for Java package.
    • enter "TestBean2" for Class name.
    • go to next page.
    • add new Business Interfaces.
    • Select one Interface and check the radio button Local, press OK.
    • Select the new interface from the Business Interface and press Remove button.
    • Press Back, and then Next again and check that this interface is not listed.
    • add new Business Interfaces as Local.
    • Leave the Inherited abstract methods and Constructors from superclass check boxes checked.
    • Session bean 03.png
    • Press Finish.
  2. Check if in the ejbModule source folder class TestBean2 implements the interfaces:TestBean2Local and the added interface.
  3. Create a new Stateless Session Bean :
    • enter "test" for Java package.
    • enter "TestBean2_1" for Class name.
    • go to next page.
    • add new Business Interfaces as Remote.
    • Leave the Inherited abstract methods and Constructors from superclass check boxes checked.
  4. Check if in the ‘ejbModule’ source folder class TestBean2_1 implements the interfaces:TestBean2_1Local and the added interface.
  5. Check that inherited methods and constructors are created.

<< add more steps >>

Create Session Bean with Home and Components interfaces (EJB 2.x)

  1. Create a new Stateless Session Bean :
    • enter "test" for Java package
    • enter "TestBean3" for Class name
    • go to next page
    • Expand Home and Components interfaces (EJB 2.x)
    • Check Local and Remote
    • Leave the Inherited abstract methods and Constructors from superclass checkboxes checked.
    • Session bean 04.png
    • Press Finish
  2. Check if in the ‘ejbModule’ source folder there are the following annotations:
     @Stateless
     @LocalHome(TestBean3LocalHome.class)
     @RemoteHome(TestBean3RemoteHome.class)


<< add more steps >>


Create Session Bean with Transaction Type Bean

  1. Create a new Stateless Session Bean :
    • enter "test" for Java package
    • enter "TestBean4" for Class name
    • go to next page
    • Select for Transaction Type : Bean.
    • Leave the Inherited abstract methods and Constructors from superclass check boxes checked.
    • Press Finish.
  2. Check if in the ‘ejbModule’ source folder there are the following annotations:
      @Stateless
      @TransactionManagement(TransactionManagementType.BEAN)


Create Stateful Session Bean

  1. Create a new Session Bean :
    • enter "test" for Java package.
    • enter "TestBean5" for Class name.
    • Set for State Type: Stateful.
    • go to next page.
    • Set the Bean name: MyStatefulBean.
    • Set Mapped name: ejb/MyStatefulBean.
    • Leave the Inherited abstract methods and Constructors from superclass checkboxes checked.
    • Session bean 06.png
    • Press Finish.
  2. Check if in the ‘ejbModule’ source folder there are the following annotations:
      @Stateful(name = "MyStatefulBean", mappedName = "ejb/MyStatefulBean")

Back to the top