TS 73 RESTWebServices

RESTful Web Services Specification

Author: Jiří Skřivánek
Version: NetBeans 7.3.1
Last update: 16-th May 2013
Bugzilla: webservices/REST
Introduction: This test specification is focused on testing RESTful web services support in NetBeans IDE. Big part of functionality is covered by automated tests described in WSTests. This should be also updated TS_60_RESTSupport or added to this test specification.

Here is description of REST support logic in NetBeans 7.3.1 by David Konecny. First, we are distinguishing two paths in the code:

  1. JAX-RS 2.0
  2. everything else

When #1 is used? If project EE level is 7 or if project classpath or server classpath contains JAX-RS 2.0. That means for example that EE5 project for GF 4.0 fits into #1.

From UI point of view #1 does not have any extra UI - we always generate JAX-RS 2.0 compliant code. In #2 case though user has to decide whether they want to use Jersey or just JAX-RS 1.0 (web.xml or ApplicationConfig.java generated) - in this case few wizards have extra UI to tick 'Use Jersey' box. In the past there used to be a third UI case where a special "Configure REST" dialog was shown - I removed that code and now it is handled as #2 above.

Contents


Test suite: Jersey Configuration

  1. Create Jersey Web Service - TODO - review with NetBeans 7.3.1
    1. Create new web project with GlassFish server
    2. Open new file wizard and select Web Services|RESTful Web Services from Patterns
    3. Click Next and click Next again to confirm Simple Root Resource
    4. Insert arbitrary Resource Package
    5. Change MIME Type to text/plain
    6. Check Use Jersey specific features check box
    7. Click Finish
    8. Replace content in getText method with
      return "Hello";
    9. Expand Libraries node in Projects view and check there is 8 jars including jackson*.jar/jersey*.jar and others
    10. Open project Properties, select Libraries categoty and verify that Package check box is not selected because those jars are bundled with target server
    11. Open Configuration Files|web.xml and check there is Jersey POJOMappingFeature set like this
      <init-param>
      <param-name>com.sun.jersey.api.json.POJOMappingFeature</param-name>
      <param-value>true</param-value>
      </init-param>
    12. Right-click project node and choose Deploy
    13. Right-click RESTful Web Services|GenericResource and chooose Test Resource Uri
    14. Check browser is opened and result of web service is shown
  2. Convert Method to Asynchronous
    1. Open GenericResource.java
    2. Right-click at getText method and choose Insert Code...|Convert Method to Asynchronous...
    3. Verify code is changed to asynchronous call
    4. Right-click again at getText method and choose Insert Code...|Convert Method to Asynchronous...
    5. Verify nothing has changed, IDE beeps and warning is displayed at status bar
    6. Right-click RESTful Web Services|GenericResource and chooose Test Resource Uri
    7. Check browser is opened and result of web service is shown
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