TS 71 EJB

EJB Support Test Specification

Author: Radim Roska, Jiri Skrivanek
Version: NetBeans 7.1
Last update: 29-th May 2012
Estimated time: 3 hours
Default IZ component(s): javaee/EJB, EJB Project, Persistence
Description: Test Specification for EJB support in the NetBeans IDE.

Contents


Test suite: Create EJB project

Purpose: Test of project creation - all next test suites should be repeated with all projects if not stated differently.
Setup: GlassFish application server (or another app server) must be registered in IDE.

  1. Create j2ee 1.4 EJB project
    1. file - new project - Java EE - EJB Module, next
    2. specify Java EE Version to J2EE 1.4, finish
    • EXPECTED RESULT: New empty EJB project is created. Check Configuration files node in Projects View for deployment descriptors ejb-jar.xml and glassfish-ejb-jar.xml. In project properties (right click on project in Projects view and click on properties) there is Source/Binary Format set to JDK 1.4
  2. Create Java EE 5 EJB project
    1. file - new project - Java EE - EJB Module, next
    2. specify Java EE Version to Java EE 5, finish
    • EXPECTED RESULT: New empty EJB project is created. In project properties there is Source/Binary Format set to JDK 5.
  3. Create Java EE 6 EJB project
    1. file - new project - Java EE - EJB Module, next
    2. specify Java EE Version to Java EE 6, finish
    • EXPECTED RESULT: New empty EJB project is created. In project properties there is Source/Binary Format set to JDK 6.


Test suite: Message-Driven Bean

  1. Create Message-Driven Bean (only for GlassFish)
    1. File - New File - Enterprise JavaBeans - Message-Driven Bean. Next.
    2. Specify package
    3. Create Project Destination (Add button, specify destination name and click OK).
    4. Finish.
    • EXPECTED RESULT: Bean is created and opened in editor.
      For j2ee 1.4 project check information about message driven bean in ejb-jar.xml. This means: open ejb-jar.xml, go to the Enterprise Beans section and go through Message Driven bean information - check Name, transaction type is Container, destination type corresponds to message destination you have created before. In XML view you can see another information like message-destination-link which is message destination name.
      For java EE 5 and 6 project ensure correct annotations are generated in created file.


Test suite: Entity Class

  1. Create Entity classes
    1. j2ee 1.4 project
      1. File - New File - Enterprise JavaBeans - Entity Bean. Next.
      2. Specify package name.
      3. Specify Persistence type : Container/Bean and Local/Remote Interface.
      4. Try to create Entity Class.
    2. java ee 5/6 project
      1. File - New File - Persistence - Entity Class. Next.
      2. Specify package name.
      3. If project does not contain Persistence Unit, click on Create Persistence Unit. Specify e.g. some sample data source.
    • EXPECTED RESULT: Entity Bean for 1.4 project is created, check ejb-jar.xml for information about this bean. Again go to the Enterprise Beans section and look for created Entity bean - check name and persistence type in general subsection. In subsection Enterprise Bean Implementation and Interfaces there are Bean Class and interfaces of this particular bean.
      Entity class for ee 5 project is created. persistence.xml is in Configuration Files
  2. Create Entity classes from Database
    1. In java EE 5/6 project open New File dialog
    2. Select Persistence - Entity Classes from database, Next.
    3. Specify some data source. For example jdbc/sample.
    4. Select some of available tables - lets say Customer. This will select Discount_code as well because its related table.
    5. Uncheck Include Related Tables. Next.
    6. Class names table is correct. Ensure Generate Named Query Annotations is checked. Finish.
    • EXPECTED RESULT: Entity class is created. It contains correct set of fields according to the CUSTOMER table. There is NamedQueries annotation with set of queries.
  3. Create CMP Entity Beans from Database
    1. In j2ee 1.4 project open New File dialog
    2. File - New File - Enterprise JavaBeans - CMP Entity Beans from Database
    3. Specify some data source. For example jdbc/sample.
    4. Select some of available tables - lets say Customer. This will select Discount_code as well because its related table.Next.
    5. Class names table is correct. Ensure Generate Finder Methods for CMP Fields and Add CMP and CMR fields to the Local interfaces. Finish.
    • EXPECTED RESULT: Entity Bean is created, i.e. Customer, CustomerLocal and CustomerLocalHome (if you've specified just local interface). Again check ejb-jar.xml as in 1st test case. New record should be in table in CMP Relationships view. You should see Customer-DiscountCode Relationship with n:1 cardinality


Test suite: Session Bean

Setup: Created EJB Project. Create Java project for remote interfaces.

  1. Create Session Bean
    1. File - new file - Enterprise JavaBeans - Session Bean. Next.
    2. Specify package name.
    3. Set Stateless/Stateful Session Type
    4. Check Remote/Local interface
    5. Finish.
    6. Follow this steps for j2ee 1.4 and java ee 5/6 projects.
    • EXPECTED RESULT: Session bean is created.
      For j2ee 1.4 check that for every bean 3/5 files are created - SessionBean class and 2 interfaces for each local/remote interface. Also check deployment descriptor - ejb-jar.xml. In Enterprise Beans find NewSessionSB and check stateless/statefull state, transaction type bean/container.
      For java ee 5/6 check that session bean is annotated with correct annotation (@Stateless/@Stateful). Remote/Local interface is created.
  2. Create Session Bean For Entity Classes (only JavaEE 5/6)
    1. File - new file - Persistence - Session Bean For Entity Classes. Next.
    2. Select some of Available Entity Classes. Next.
    3. Specify package name.
    4. Check Remote/Local interface
    5. Finish.
    • EXPECTED RESULT: CustomerFacade Session bean and Remote/Local interface are created.
      Class contain basic methods for table/entity manipulation.


Test suite: Timer Session Bean (only JavaEE 6)

  1. Create Timer Session Bean
    1. Open new file wizard (File|New File)
    2. Choose Enterprise JavaBeans, Timer Session Bean and click Next
    3. Specify package and click Finish
    4. Deploy project
    • EXPECTED RESULT: Bean is created and opened in editor. Every minute is printed message to the server console.


Test suite: Final test

Purpose: Ensure its correctly assembled

  1. Deploy projects
    1. In project view Deploy each ejb project
    • EXPECTED RESULT: Application servers have to start up (if not running) and in output window there must be no error. After successful deployment check in Services view application server node and look for EJB project node.


Not logged in. Log in, Register

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo