Jump to: navigation, search

Difference between revisions of "WTP JEE5 Test Scenarios"

Line 9: Line 9:
 
This use case is the most basic Web application scenario that involves creating the Web module, targeting it to a JEE5 runtime, and testing it using Run As> Run on Server
 
This use case is the most basic Web application scenario that involves creating the Web module, targeting it to a JEE5 runtime, and testing it using Run As> Run on Server
  
# Go to Installed Runtimes and add Tomcat 6 as a runtime.
+
* Go to Installed Runtimes and add Tomcat 6 as a runtime.
# Create a new Dynamic Web Project named HelloWorldWeb, select Tomcat 6 as the target runtime
+
* Create a new Dynamic Web Project named HelloWorldWeb, select Tomcat 6 as the target runtime
 
   [[Image:WtpJEE5UC1DynamicWebProj.gif]]
 
   [[Image:WtpJEE5UC1DynamicWebProj.gif]]
# Select Dynamic Web Module 2.5, and Java 5 as facets, click next to accept defaults.  A new Web 2.5 project is created.
+
* Select Dynamic Web Module 2.5, and Java 5 as facets, click next to accept defaults.  A new Web 2.5 project is created.
# CURRENT I-BUILD NO WEB:XML CREATED.  CAN ADD ONE MANUALLY
+
  [[Image:WTPJEE5UC1Facets.gif]]
 +
* CURRENT I-BUILD NO WEB:XML CREATED.  CAN ADD ONE MANUALLY
 
     <?xml version="1.0" encoding="UTF-8"?>
 
     <?xml version="1.0" encoding="UTF-8"?>
 
     <web-app xmlns="http://java.sun.com/xml/ns/javaee" version="2.5"
 
     <web-app xmlns="http://java.sun.com/xml/ns/javaee" version="2.5"
Line 28: Line 29:
 
       </welcome-file-list>
 
       </welcome-file-list>
 
     </web-app>
 
     </web-app>
# Add a new JSP file called test.jsp with the following content:
+
* Add a new JSP file called test.jsp with the following content:
 
     <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
 
     <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
 
         pageEncoding="ISO-8859-1"%>
 
         pageEncoding="ISO-8859-1"%>
Line 40: Line 41:
 
     <body>
 
     <body>
 
         Hello World!
 
         Hello World!
 
 
     </body>
 
     </body>
 
     </html>
 
     </html>
  
# Right click test.jsp, Choose Run As:  Run on Server, select Tomcat 6 as the server
+
* Right click test.jsp, Choose Run As:  Run on Server, select Tomcat 6 as the server
 
   (RUN AS RUN ONE SERVER DOES NOT WORK FOR WEB 2.5 ON LATEST I-BUILD)
 
   (RUN AS RUN ONE SERVER DOES NOT WORK FOR WEB 2.5 ON LATEST I-BUILD)
 
       [[Image:WTPJEE5UC1ServerError.gif]]
 
       [[Image:WTPJEE5UC1ServerError.gif]]
 +
 +
* Tomcat 6 starts and results are displayed
 +
 +
== COMBINED SCENARIO ==
 +
The second scenario is a test of EJB 3.0 and EAR 5.  Since EJBs are meaningless without a client, this use case involves creating an EJB 3.0 stateless session bean, that uses JPA 1.0 to map a simple class.  A web application using JSF is the EJB client.  Whole application is packaged as an EAR.
 +
 +
=== SIMPLE SESSION EJB 3.0/JPA 1.0 ===
 +
This use case is the most creates a simple POJO mapped using JPA 1.0.  A stateless session references the entity manager to query the DB.  The EJB jar is packaged in an EAR module
 +
* Go to Installed Runtimes and add Glassfish as a runtime.
 +
* Create a new EJB 3.0 Project, with JPA 1.0 facet named HelloWorldEJB, select Glassfish as the target runtime.
 +
* Make sure that  HelloWorldEJB is added to HelloWorldEAR.
 +
* Use the data tools to create a connection to the new Derby database named myderbydb.
 +
* Create a connection to it and create a new table using the following script:
 +
    CREATE TABLE HELLOWORLD (
 +
      `ID` varchar(10) NOT NULL,
 +
      `MESSAGE` varchar(50) NOT NULL,
 +
      `LANGUAGE` varchar(50) NOT NULL,
 +
      PRIMARY KEY  (`ID`)
 +
    );
 +
* Add a few rows of data such as
 +
    1 Hello World! en
 +
    2 Merhaba Dünya tr
 +
* Create a package called demo and add the following class which is JPA mapped
 +
    package demo;
 +
 +
    import java.io.Serializable;
 +
 +
    @Entity
 +
    public class HelloWorld implements Serializable{
 +
 +
private static final long serialVersionUID = 1L;
 +
 +
@Id
 +
private String id;
 +
private String message;
 +
private String language;
 +
 +
public HelloWorld() {
 +
}
 +
 +
      public String getId() {
 +
        ...

Revision as of 14:12, 26 March 2007

WTP 2.0 JEE 5 Use Cases

These scenarios are created to test the basic functionality that we would expect from WTP 2.0 to support JEE5. Please note that NO wizards are used other than the ones needed to create the servers, projects and add the necessary facets to these projects. The idea is if we are provided with valid JEE5 module and components (such as EJBs, JPA, Servlets, JSPs, etc), WTP 2.0 should support it. This includes Web, EJB, and EAR and Run As> Run on Server support. Of course this involves basic models for deployment descriptors (sans Annotation injections). Annotation support will only include that provided by JDT.

If you have questions, comments, etc., about these use cases, send a note to the WTP Dev List or contact me, Naci Dai.

SIMPLE WEB APPLICATION USE CASE

This use case is the most basic Web application scenario that involves creating the Web module, targeting it to a JEE5 runtime, and testing it using Run As> Run on Server

  • Go to Installed Runtimes and add Tomcat 6 as a runtime.
  • Create a new Dynamic Web Project named HelloWorldWeb, select Tomcat 6 as the target runtime
  WtpJEE5UC1DynamicWebProj.gif
  • Select Dynamic Web Module 2.5, and Java 5 as facets, click next to accept defaults. A new Web 2.5 project is created.
  WTPJEE5UC1Facets.gif
  • CURRENT I-BUILD NO WEB:XML CREATED. CAN ADD ONE MANUALLY
    <?xml version="1.0" encoding="UTF-8"?>
    <web-app xmlns="http://java.sun.com/xml/ns/javaee" version="2.5"
     metadata-complete="true">

     <display-name>MyJEE5Web</display-name>
     <welcome-file-list>
      <welcome-file>index.html</welcome-file>
      <welcome-file>index.htm</welcome-file>
      <welcome-file>index.jsp</welcome-file>
      <welcome-file>default.html</welcome-file>
      <welcome-file>default.htm</welcome-file>
      <welcome-file>default.jsp</welcome-file>
     </welcome-file-list>
    </web-app>
  • Add a new JSP file called test.jsp with the following content:
    <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
        pageEncoding="ISO-8859-1"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"       
      "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>Insert title here</title>
    </head>
    <body>
       Hello World!
    </body>
    </html>
  • Right click test.jsp, Choose Run As: Run on Server, select Tomcat 6 as the server
 (RUN AS RUN ONE SERVER DOES NOT WORK FOR WEB 2.5 ON LATEST I-BUILD)
     WTPJEE5UC1ServerError.gif
  • Tomcat 6 starts and results are displayed

COMBINED SCENARIO

The second scenario is a test of EJB 3.0 and EAR 5. Since EJBs are meaningless without a client, this use case involves creating an EJB 3.0 stateless session bean, that uses JPA 1.0 to map a simple class. A web application using JSF is the EJB client. Whole application is packaged as an EAR.

SIMPLE SESSION EJB 3.0/JPA 1.0

This use case is the most creates a simple POJO mapped using JPA 1.0. A stateless session references the entity manager to query the DB. The EJB jar is packaged in an EAR module

  • Go to Installed Runtimes and add Glassfish as a runtime.
  • Create a new EJB 3.0 Project, with JPA 1.0 facet named HelloWorldEJB, select Glassfish as the target runtime.
  • Make sure that HelloWorldEJB is added to HelloWorldEAR.
  • Use the data tools to create a connection to the new Derby database named myderbydb.
  • Create a connection to it and create a new table using the following script:
   CREATE TABLE HELLOWORLD (
     `ID` varchar(10) NOT NULL,
     `MESSAGE` varchar(50) NOT NULL,
     `LANGUAGE` varchar(50) NOT NULL,
      PRIMARY KEY  (`ID`)
   );
  • Add a few rows of data such as
   1 Hello World! en
   2 Merhaba Dünya tr
  • Create a package called demo and add the following class which is JPA mapped
   package demo;
   import java.io.Serializable;
   @Entity
   public class HelloWorld implements Serializable{

private static final long serialVersionUID = 1L;

@Id private String id; private String message; private String language;

public HelloWorld() { }

      public String getId() {
        ...