Setup and Configuration
This chapter describes how to set up the JAX-RS 1.1 TCK and JavaTest harness software. Before proceeding with the instructions in this chapter, be sure to install all required software, as described in Chapter 3, Installation.
After completing the instructions in this chapter, proceed to Chapter 5, Executing Tests for instructions on running the JAX-RS 1.1 TCK.
This chapter includes the following topics:
4.1 Configuring Your Environment to Run the JAX-RS 1.1 TCK Against the Sun Reference Implementation
After configuring your environment as described in this section, continue with the instructions in 4.4 Using the JavaTest Harness Software.
Note -
In these instructions, variables in angle brackets need to be expanded for each platform. For example, <TS_HOME> becomes $TS_HOME on Solaris/Linux and %TS_HOME% on Windows. In addition, the forward slashes (/) used in all of the examples need to be replaced with backslashes (\) for Windows. Finally, be sure to use the appropriate separator for your operating system when specifying multiple path entries (; on Windows, : on UNIX/Linux).
On Windows, you must escape any backslashes with an extra backslash in path separators used in any of the following properties, or use forward slashes as a path separator instead.
To Configure Your Environment to Run the JAX-RS 1.1 TCK Against the Sun RI
- Set the following environment variables in your shell environment:
- JAVA_HOME to the directory in which Java SE 6 is installed
- TS_HOME to the directory in which the JAX-RS 1.1 TCK 1.1 software is installed
- ANT_HOME should not be set in your environment. If it is set, either unset it or make sure it is set to <TS_HOME>/tools/ant. The <TS_HOME>/bin/ant script automatically sets ANT_HOME if it is unset in the environment.
- Edit your <TS_HOME>/bin/ts.jte file and set the following environment variables:
- Set the webServerHost property to the name of the host on which Java
EE 6 RI is running.
The default setting is localhost.
- Set the webServerPort property to the port number of the host on which
Java EE 6 RI is running.
The default setting is 8080.
- Set the web.home property to the installation directory of Java EE 6 RI .
- Set the jaxrs.classes property to point to the classes or JAR for the
JSR 311 API.
The default setting for this property is ${web.home}/modules/jsr311-api.jar.
- Set the jaxrs_impl.classes and jaxrs_impl_lib properties to point to the Jersey RI.
The default setting for these properties is ${web.home}/modules/jersey-gf-bundle.jar .
- Set the servlet_adaptor property to point to the Servlet adaptor class for the
JAX-RS implementation.
The default setting for this property is com/sun/jersey/spi/container/servlet/ServletContainer.class, the servlet adaptor supplied in Jersey.
- Set the impl.vi property to the name of the Java EE 6
RI .
The relevant porting files are located under the $TS_HOME/bin/xml/impl/glassfish/ directory.
The default setting for this property is glassfish.
- Set the jaxrs_impl_name property to the name of the JAX-RS RI.
A file bearing this name has been created under $TS_HOME/bin/xml/impl/glassfish/jersey.xml with packaging instructions.
The default setting for this property is jersey.
- Set the impl.vi.deploy.dir property to point to the autodeploy directory of the Java
EE 6 RI .
The default setting for this property is ${web.home}/domains/domain1/autodpeloy.
- Set the servlet.classes property to point to the class files for the Servlet
APIs.
The default setting for this property is ${web.home}/modules/javax.servlet.jar.
- Verify that the tools.jar property is set to the location of the tools.jar file that is distributed with Java SE 6.
- Set the porting.ts.url.class.1 property to your porting implementation class that is used for obtaining URLs.
- Set the webServerHost property to the name of the host on which Java
EE 6 RI is running.
- Provide your own implementations of the porting package interfaces provided with the JAX-RS
1.1 TCK.
The porting interfaces are:
TSURLInterface.java — Obtains URL strings for web resources in an implementation-specific manner
API documentation for the TSURLInterface.java porting package interface is available in the <TS_HOME>/docs/api directory.
- If the JAX-RS 1.1 TCK test applications are published on a Servlet 3.0-compliant
Web container to certify the VI, the servlet_adaptor property needs to be set
in the ts.jte file, and VI-specific WAR files containing the Servlet information need
to be created for publishing.
The VI-specific WAR files should never override any existing files that come with the TCK. Refer to Appendix B, Packaging the JAX-RS 1.1 TCK Test Applications in Servlet-Compliant WAR Files With VI-Specific Information for more information.
- When creating VI-specific WAR files, deploying JAX-RS test applications, or running the JAX-RS
1.1 TCK, it is recommended that you create a porting file named $jaxrs_impl_name
under $TS_HOME/bin/xml/${impl_vi}.
Use the jersey.xml file as a reference.
4.2 Configuring Your Environment to Repackage and Run the JAX-RS 1.1 TCK Against the Vendor Implementation
After configuring your environment as described in this section, continue with the instructions in 4.4 Using the JavaTest Harness Software.
Note -
In these instructions, variables in angle brackets need to be expanded for each platform. For example, <TS_HOME> becomes $TS_HOME on Solaris/Linux and %TS_HOME% on Windows. In addition, the forward slashes (/) used in all of the examples need to be replaced with backslashes (\) for Windows. Finally, be sure to use the appropriate separator for your operating system when specifying multiple path entries (; on Windows, : on UNIX/Linux).
On Windows, you must escape any backslashes with an extra backslash in path separators used in any of the following properties, or use forward slashes as a path separator instead.
To Configure Your Environment to Repackage and Run the JAX-RS 1.1 TCK Against the Vendor Implementation
Before You Begin
Decide against which JAX-RS implementation the tests will be run and determine to which Servlet–compliant Web server the JAX-RS TCK applications will be published.
Package the JAX-RS test applications for that JAX-RS implementation and Servlet–compliant Web server.
See Appendix B, Packaging the JAX-RS 1.1 TCK Test Applications in Servlet-Compliant WAR Files With VI-Specific Information for information about repackaging the JAX-RS test application.
- Set the following environment variables in your shell environment:
- JAVA_HOME to the directory in which Java SE 6 is installed
- TS_HOME to the directory in which the JAX-RS 1.1 TCK 1.1 software is installed
- ANT_HOME should not be set in your environment. If it is set, either unset it or make sure it is set to <TS_HOME>/tools/ant. The <TS_HOME>/bin/ant script automatically sets ANT_HOME if it is unset in the environment.
- Edit your <TS_HOME>/bin/ts.jte file and set the following environment variables:
- Set the webServerHost property to the name of the host on which your
Web server is running that is configured with the Vendor Implementation.
The default setting is localhost.
- Set the webServerPort property to the port number of the host on which
the Web server is running that is configured with the Vendor JAX-RS 1.1
Vendor Implementation.
The default setting is 8080.
- Set the web.home property to the installation directory of the Web server.
- Set the jaxrs.classes property to point to the classes or JAR for the
JSR 311 API.
The default setting for this property is ${web.home}/modules/jsr311-api.jar.
- Set the jaxrs_impl.classes and jaxrs_impl_lib properties to point to all classes/JARs for
the JSR 311 VI implementation and all dependent libraries.
The default setting for these properties is ${web.home}/modules/jersey-gf-bundle.jar .
- Set the servlet_adaptor property to point to the Servlet adaptor class for the
JAX-RS implementation.
The class must be located in the JAR file defined by the jaxrs_impl_lib property. The JAX-RS TCK test application is published on a Servlet-compliant Web container. By default, this property is set to com/sun/jersey/spi/container/servlet/ServletContainer.class, the servlet adaptor supplied in Jersey.
- Set the impl.vi property to the name of the Web server.
The relevant porting files are located under the $TS_HOME/bin/xml/impl/${impl.vi}/ directory.
The default setting for this property is glassfish.
- Set the jaxrs_impl_name property to the name of the JAX-RS implementation to be
tested.
The name of the property must be unique. A file bearing this name will be created under $TS_HOME/bin/xml/impl/${impl.vi}/${jaxrs_impl_name}.xml with packaging and/or deployment instructions.
The default setting for this property is jersey.
- Set the impl.vi.deploy.dir property to point to the autodeploy directory for the Web
server.
The default setting for this property is ${web.home}/domains/domain1/autodpeloy.
- Set the servlet.classes property to point to the class files for the Servlet
APIs.
The default setting for this property is ${web.home}/modules/javax.servlet.jar.
- Verify that the tools.jar property is set to the location of the tools.jar file that is distributed with Java SE 6.
- Set the porting.ts.url.class.1 property to your porting implementation class that is used for obtaining URLs.
- Set the webServerHost property to the name of the host on which your
Web server is running that is configured with the Vendor Implementation.
- Provide your own implementations of the porting package interfaces provided with the JAX-RS
1.1 TCK.
The porting interfaces are:
TSURLInterface.java — Obtains URL strings for web resources in an implementation-specific manner
API documentation for the TSURLInterface.java porting package interface is available in the <TS_HOME>/docs/api directory.
- If the JAX-RS 1.1 TCK test applications are published on a Servlet 3.0-compliant
Web container to certify the VI, the servlet_adaptor property needs to be set
in the ts.jte file, and VI-specific WAR files containing the Servlet information need
to be created for publishing.
The VI-specific WAR files should never override any existing files that come with the TCK. Refer to Appendix B, Packaging the JAX-RS 1.1 TCK Test Applications in Servlet-Compliant WAR Files With VI-Specific Information for more information.
- When creating VI-specific WAR files, deploying JAX-RS test applications, or running the JAX-RS
1.1 TCK, it is recommended that you create a porting file named $jaxrs_impl_name
under $TS_HOME/bin/xml/${impl_vi}.
Use the jersey.xml file as a reference.
4.3 Publishing the JAX-RS 1.1 TCK Test Applications
The JAX-RS 1.1 TCK provides an automatic way of deploying both the prebuilt and Vendor-built archives to the configured web container(s) via deployment handlers.
The handler file (<TS_HOME>/bin/xml/impl/glassfish/jersey.xml is written to be used with Jersey and Java EE 6 RI . If the Vendor chooses not to use Java EE 6 RI to run with their implementation but still chooses to publish to a Servlet-compliant Web container, then a VI-specific JAX-RS 1.1 TCK tests Web archive needs to be created. This archive contains the VI-specific servlet class, and the Vendor should create their own version handler file to provide this functionality. It is recommended that the handler file be named ${jaxrs_impl_name} and be located in $TS_HOME/bin/xml/${impl.vi}/${jaxrs_impl_name}. Refer to Appendix B, Packaging the JAX-RS 1.1 TCK Test Applications in Servlet-Compliant WAR Files With VI-Specific Information for more information.
This section describes the various commands used for deploying the classes or WAR files to the configured web container.
4.3.1 Generic Deployment Command Scenarios
You can deploy all JAX-RS WAR files to Java EE 6 RI or the Web server chosen by a Vendor, deploy just a single test directory, or deploy of subset of test directories.
To Deploy all the WAR Files From the <TS_HOME>/dist to a Web Server
- Enter the following command:
<TS_HOME>/bin/ant deploy.all
To Deploy a Single Test Directory
- Enter the following commands:
cd <TS_HOME>/src/com/sun/ts/tests/jaxrs/api/rs/getTest <TS_HOME>/bin/ant deploy
To Deploy a Subset of Test Directories
- Enter the following commands:
cd <TS_HOME>/src/com/sun/ts/tests/jaxrs/api <TS_HOME>/bin/ant deploy
4.3.2 Deploying the JAX-RS 1.1 TCK Prebuilt Archives
This section explains issues regarding the deployment of the JAX-RS 1.1 TCK prebuilt archives. Before conducting any deployment, ensure that your environment has been configured by following the instructions in either 4.1 Configuring Your Environment to Run the JAX-RS 1.1 TCK Against the Sun Reference Implementation or 4.2 Configuring Your Environment to Repackage and Run the JAX-RS 1.1 TCK Against the Vendor Implementation.
The <TS_HOME>/dist directory contains all WAR files for the JAX-RS 1.1 TCK tests that have been compiled and packaged using the Sun Reference Implementation for deployment on a Servlet-compliant Web container, Java EE 6 RI , using the standard Web Archive (WAR) format.
These WAR files contain only Jersey, a Java EE 6 RI -specfic servlet adaptor, and are tailored to run against the Sun Reference Implementation. These WAR files allow you to deploy (without any additional setup or modification) against the Sun Reference Implementation to test the various features and functionality of this implementation.
To deploy the JAX-RS 1.1 TCK tests, use either the deploy or deploy.all batch command as described in 4.3.1 Generic Deployment Command Scenarios.
4.3.3 Deploying the JAX-RS 1.1 TCK Test Applications Against the Vendor Implementation
This section describes how to deploy the JAX-RS 1.1 TCK test applications against the Vendor Implementation and vendor's choice of Web server. Before conducting the deployment, ensure that you have followed the instructions in 4.2 Configuring Your Environment to Repackage and Run the JAX-RS 1.1 TCK Against the Vendor Implementation. Vendors can deploy JAX-RS 1.1 TCK tests in either Java class or WAR format. All test resource classes are located under $TS_HOME/classes. All test resources packaged in WAR files are located under $TS_HOME/dist.
If a vendor chooses to deploy WAR files on a Servlet–compliant Web container other than Java EE 6 RI , it is necessary to build test WAR files that contain the VI's servlet class and servlet class property in the web.xml deployment descriptor, as specified in the JAX-RS specification. The JAX-RS 1.1 TCK comes with a web.xml.template file for each test, which contains all information except the servlet class. The JAX-RS 1.1 TCK also comes with a tool to replace the RI or VI's servlet adaptor class name in the web.xml.template. Refer to Appendix B, Packaging the JAX-RS 1.1 TCK Test Applications in Servlet-Compliant WAR Files With VI-Specific Information for more information about repackaging the JAX-RS TCK tests.
To deploy a resource class in class file format, a vendor must create a handler file that supports deploy options as described in 4.3.1 Generic Deployment Command Scenarios. All tests with resource classes have a ${resource.classes} property set in each test's individual build.xml file; this value contains all resource classes in the test.
To deploy the tests, the vendor should perform a deployment using either the deploy or deploy.all batch command, as described in 4.3.1 Generic Deployment Command Scenarios.
4.4 Using the JavaTest Harness Software
There are two general ways to run the JAX-RS 1.1 TCK test suite using the JavaTest harness software:
Through the JavaTest GUI; if using this method, please continue on to 4.5 Using the JavaTest Harness Configuration GUI.
In JavaTest batch mode, from the command line in your shell environment; if using this method, please proceed directly to Chapter 5, Executing Tests.
4.5 Using the JavaTest Harness Configuration GUI
You can use the JavaTest harness GUI to modify general test settings and to quickly get started with the default JAX-RS 1.1 TCK test environment. This section covers the following topics:
Note - It is only necessary to proceed with this section if you want to run the JavaTest harness in GUI mode. If you plan to run the JavaTest harness in command-line mode, skip the remainder of this chapter, and continue with Chapter 5, Executing Tests.
4.5.1 Configuration GUI Overview
In order for the JavaTest harness to execute the test suite, it requires information about how your computing environment is configured. The JavaTest harness requires two types of configuration information:
Test environment — This is data used by the tests. For example, the path to the Java runtime, how to start the product being tested, network resources, and other information required by the tests in order to run. This information does not change frequently and usually stays constant from test run to test run.
Test parameters — This is information used by the JavaTest harness to run the tests. Test parameters are values used by the JavaTest harness that determine which tests in the test suite are run, how the tests should be run, and where the test reports are stored. This information often changes from test run to test run.
The first time you run the JavaTest harness software, you are asked to specify the test suite and work directory that you want to use. (These parameters can be changed later from within the JavaTest harness GUI.)
Once the JavaTest harness GUI is displayed, whenever you choose Run Tests->Start to begin a test run, the JavaTest harness determines whether all of the required configuration information has been supplied:
If the test environment and parameters have been completely configured, the test run starts immediately.
If any required configuration information is missing, the configuration editor displays a series of questions asking you the necessary information. This is called the configuration interview . When you have entered the configuration data, you are asked if you wish to proceed with running the test.
4.5.2 Starting the Configuration GUI
Before you start the JavaTest harness software, you must have a valid test suite and Java SE 6 installed on your system.
The JAX-RS 1.1 TCK includes an Ant script that is used to execute the JavaTest harness from the <TS_HOME> directory. Using this Ant script to start the JavaTest harness is part of the procedure described in 4.5.3 The Configuration Interview.
When you execute the JavaTest harness software for the first time, the JavaTest harness displays a Welcome dialog box that guides you through the initial startup configuration.
If it is able to open a test suite, the JavaTest harness displays a Welcome to JavaTest dialog box that guides you through the process of either opening an existing work directory or creating a new work directory as described in the JavaTest online help.
If the JavaTest harness is unable to open a test suite, it displays a Welcome to JavaTest dialog box that guides you through the process of opening both a test suite and a work directory as described in the JavaTest documentation.
After you specify a work directory, you can use the Test Manager to configure and run tests as described in 4.5.3 The Configuration Interview.
4.5.3 The Configuration Interview
The answers you give to some of the configuration interview questions are specific to your site. For example, the name of the host on which the JavaTest harness is running. Other configuration parameters can be set however you wish. For example, where you want test report files to be stored.
To Configure the JavaTest Harness to Run the JAX-RS 1.1 TCK Tests
Note that you only need to complete all these steps the first time you start the JavaTest test harness. After you complete these steps, you can either run all of the tests by completing the steps in 5.2 Starting JavaTest or run a subset of the tests by completing the steps in 5.3 Running a Subset of the Tests.
- Change to the <TS_HOME>/bin directory and start the JavaTest test harness:cd <TS_HOME>/bin <TS_HOME>/bin/ant gui
If the Welcome Screen does not appear do the following, otherwise skip to next step.
- Click File->Open Quick Start Wizard.
The Welcome screen displays.
- Click Start a new test run, and then click Next.
You are prompted to Create a new configuration or use a configuration template.
- Select Create a new configuration, and then click Next.
You are prompted to select a test suite.
- Accept the default suite (<TS_HOME>/src), and then click Next.
You are prompted to specify a work directory to use to store your test results.
- Type a work directory name or use the Browse button to select a
work directory, and then click Next.
You are prompted to start the configuration editor or start a test run. At this point, the JAX-RS 1.1 TCK is configured to run the default test suite.
- Uncheck the Start the configuration editor option, and then click Finish.
- Click Run Tests->Start.
The JavaTest harness starts running the tests.
- To Reconfigure the JavaTest test harness, click Configuration->New Configuration or Configuration->Change Configuration.
- Click Report->Create Report.
- Specify the directory in which the JavaTest test harness will write the report,
and then click OK.
A report is created, and you are asked whether you want to view it.
- Click Yes to view the report.
4.5.4 Modifying the Default Test Configuration
The JavaTest GUI enables you to configure numerous test options. These options are divided into two general dialog box groups:
Group 1 — Available from the JavaTest Configure->Change Configuration submenus, the following options are displayed in a tabbed dialog box:
Tests to Run
Exclude List
Keywords
Prior Status
Test Environment
Concurrency
Timeout Factor
Group 2 — Available from the JavaTest Configure->Change Configuration->Other Values submenu, or by pressing Ctrl+E, the following options are displayed in a paged dialog box:
Environment Files
Test Environment
Specify Tests to Run
Specify an Exclude List
Note that there is some overlap between the functions in these two dialog boxes; for those functions use the dialog that is most convenient for you. Please refer to the JavaTest Harness documentation or the online help for complete information about these various options.