STS 74 JavaEE

Revision as of 13:58, 17 July 2013 by Stezeb (Talk | contribs)

Java EE Sanity Test Specification for NetBeans 7.4

Author: Štěpán Žebra
Version: 1.0
Last update: 17.7.2013
Introduction: Purpose of this test specification is to try various technologies and go through the whole development cycle. It can be used for Ant based and Maven projects. If there are differences the test case is divided into two tracks.
Comments: This document is heavily based on TS_72_JavaEE_Sanity which is now obsolete. Test scenarios are based on


Test suite: Create Java EE 7 Application

Purpose: Create web applications with web services.
Setup: Install GlassFish server version 4.0 and register it in Tools | Servers in the IDE.

  1. Create Web Service project
Ant Project Maven Project
  1. Create a new "Java Web / Web Application" project,
    • "Project Name": dukes-age,
    • "Server": GlassFish 4,
    • "Java EE Version": Java EE 7 Web.
  2. Delete index.html file.
  1. Create a new "Maven / Web Application" project,
    • "Project Name": dukes-age,
    • "Server": GlassFish 4,
    • "Java EE Version": Java EE 7 Web.
  2. Delete index.html file.
  • EXPECTED RESULT: Newly created project is visible in the "Projects" view.
  1. Create Web Service class
    1. Select the project root node in "Projects" view and push New File... toolbar button.
    2. Select "Web Services / RESTful Web Services from Patterns" and push Next >.
    3. Choose "Simple Root Resource" design pattern and push Next >.
    4. Set
      • "Resource Package": firstcup.webservice,
      • "Path": dukesAge,
      • "Class Name": DukesAgeResource,
      • "MIME Type": text/plain.
    5. Push the Finish button.
    • EXPECTED RESULT: and classes are created and opened in the editor.
  2. Implement Web Service class
    1. In the, remove the putText generated method.
    2. Replace the body of the getText generated method with:
      // Create a new Calendar for Duke's birthday
      Calendar dukesBirthday = new GregorianCalendar(1995, Calendar.MAY, 23);
      // Create a new Calendar for today
      Calendar now = Calendar.getInstance();
      // Subtract today's year from Duke's birth year, 1995
      int dukesAge = now.get(Calendar.YEAR) - dukesBirthday.get(Calendar.YEAR);
      dukesBirthday.add(Calendar.YEAR, dukesAge);
      // If today's date is before May 23, subtract a year from Duke's age
      if (now.before(dukesBirthday)) {
      // Return a String representation of Duke's age
      return Integer.toString(dukesAge);
    3. Reformat the class (Alt+Shift+F), fix imports (Ctrl+Shift+I) and save it.
    • EXPECTED RESULT: There isn't any visible error in the editor.
  3. Configure, Build and Deploy the Web Service Endpoint
    1. In "Projects" view and invoke pop-up menu on the "dukes-age" root node and select Properties.
    2. Select the "Run" category in the "Project Properties" manager.
    3. Set "Context Path" to: /DukesAgeService.
    4. Set "Relative URL" to: /webresources/dukesAge.
    5. Push the OK button.
    6. Run the "dukes-age" project.
    • EXPECTED RESULT: The dukes-age successfully deploys to the GlassFish server, web browser loads the URL of the DukesAgeResource path, a String representing Duke's age is returned.
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