Setup and Configuration

## 4 Setup and Configuration

This chapter describes how to set up the JASPIC 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 JASPIC TCK.

### 4.1 Configuring Your Environment to Run the TCK Against the Reference Implementation

After configuring your environment as described in this section, continue with the instructions in Section 4.6, "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.

#### 4.1.2 To Configure Your Environment for the JASPIC TCK

This section describes how to configure your environment to run the JASPIC TCK tests.

Deploy the JASPIC TCK tests in the manner that your implementation requires, based on the type of profile.

If your implementation is Java EE-based, set the `platform.mode` property in the `ts.jte` file to `javaEE`.

If your implementation is not Java EE-based, set the `platform.mode` property in the `ts.jte` file to `standalone`.

1. Set the following environment variables in your shell environment:

   1. `JAVA_HOME` to the directory in which Java SE 8 is installed

   2. `TS_HOME` to the directory in which the JASPIC TCK 1.1 software is installed

   3. `PATH` to include the following directories: `JAVA_HOME/bin`, `JASPIC_HOME/bin`, and `<TS_HOME>/tools/ant/bin`

2. Edit your `<TS_HOME>/bin/ts.jte` file and set the following environment variables:

   1. `pathsep` to the type of path separator used by your operating system
      The default is `:` for Solaris/Linux. Windows users should change this value to `;`.

   2. Set the `jaspic.home` property to the root directory of implementation under test.

   3. Set the `orb.host` property to the name of the machine on which you are running the JASPIC TCK tests.

   4. Set the `orb.port` property to the port number of the machine on which you are running the JASPIC TCK tests.

   5. Set the `sigTestClasspath` property to point to the implementation classes that are to be validated for signature compliance. This classpath must also include any other classes that are referenced, implemented, or extended by your implementation .

   6. Set the `servlet.is.jsr115.compatible` property based on whether or not you are running the Servlet profile in a JSR 115–compatible container.

   7. Set the `soap.is.jsr115.compatible` property based on whether or not you are running the SOAP profile in a JSR 115–compatible container.

   8. Set the `log.file.location` property to the location where your implementation’s log files and the JASPIC log file will be written.

   9. Set the `logical.hostname.servlet` property to the logical host that will process Servlet requests.
      Servlet requests may be directed to a logical host using various physical or virtual host names or addresses. A message processing runtime may be composed of multiple logical hosts. This setting is required to properly identify the Servlet profile’s application context identifier hostname. If the logical host that will process Servlet requests does not exist, you can set this to the default hostname of your implementation’s Web server.

   10. Set the `logical.hostname.soap` property to the name of the logical host that will process SOAP requests.
       This hostname is used in the implementation runtime’s application context identifier in the SOAP profile.

   11. Set the `vendor.authconfig.factory` property to specify your `AuthConfigFactory` class.
       This property setting will be used by the JASPIC tests to register the test suite’s provider in your `AuthConfigFactory`.

3. Run `ant config.vi`.
   This task configures the implementation under test to run the JASPIC TCK tests by doing the following:

   1. Copies `jaspic.jar` and `tsharness.jar` to the lib extension directory (for example, `/glassfish/domains/domain1/lib/ext`)

   2. Set up users and passwords for your implementation.
      For the purpose of running the CTS test suite, these should be set as follows:

      User | Password | Groups
      --- | --- | ---
      `j2ee_vi` | `j2ee_vi` | `staff`
      `javajoe` | `javajoe` | `guest`
      `j2ee` | `j2ee` | `staff`, `mgr`, `asadmin`

      Also make sure the principal to role-mappings that are specified in the runtime XML files are properly mapped in your environment. Note that the principal-to-role mappings may vary for each application.

   3. Install the client-side certificate in the `trustStore` in your implementation.
      Certificates are located `<TS_HOME>/bin/certificates`.
      Use the certificate that suits your environment:

      - `cts_cert` - For importing the CTS client certificate into a `truststore`

      - `clientcert.jks` - Used by the J2SE runtime to identify the CTS client’s identity

      - `clientcert.p12` – Contains CTS client certificate in `pkcs12` format

   4. Append the file `<TS_HOME>/bin/server_policy.append` to the Java policy file or files on your implementation.
      This file contains the grant statements used by the test harness, signature tests, and API tests.

   5. Appends the file `<TS_HOME>/bin/client_policy.append` to the application client’s Java policy file, which is referenced in the `TestExecuteAppClient` section of the `ts.jte` file.

   6. Creates a JVM option that increases the MaxPermSize for your implementation.

4. Run `ant enable.jaspic`.
   This task performs the configuration necessary for adding the test suite’s `SPI Verifier(TSSV)` to your implementation. Specifically, `ant enable.jaspic` performs the following operations:

   1. Sets the `jvm` option `-Dlog.file.location` in your implementation.
      This is the location of the log file where the Test Suite SPI Verifier (TSSV) creates log messages, which will be used by the JASPIC TCK tests, to identify the test status.

   2. Sets the `jvm` option `-Dprovider.configuration.file` in your implementation.
      This option is used to identify the provider configuration file that will be used by `TSAuthConfigFactory` to load the providers required by the JASPIC TCK tests.

   3. Sets the `jvm` option `-Dschema.file.location=${schema.file.location}` in your implementation.
      This option is used to identify the location of the schema file that is used by the `Provider-Configuration.xml` file.

   4. Sets up your implementation to use the test suite’s `AuthConfigFactory`.
      This can be done in one of the following ways:

      - Copy `<TS_HOME>/bin/ts.java.security` to the location in your implementation where the security configuration files reside. For example, the GlassFish Server security configuration files are in the `<JAVAEE_HOME>glassfish/domains/domain1/config` directory. After the file has been copied, use the `-Djava.security.properties` JVM option to direct your implementation to use this security property file. For example, to direct GlassFish Server to use the `ts.java.security` file, you would use this JVM option:

            -Djava.security.properties=glassfish/domains/domain1/config/ts.java.security

      - Add the following lines as a single line to the `JAVA_HOME/jre/lib/security/java.security` file:

            authconfigprovider.factory=
            com.sun.ts.tests.jaspic.tssv.config.TSAuthConfigFactory

        Adding this property to the `java.security` file forces your implementation to load the test suite’s `AuthConfigFactory`.

   5. Copies the `TS_HOME/lib/tssv.jar` file to your implementation instance library directory.
      The `tssv.jar` file includes the class files necessary to load `TSAuthConfigFactory` and related classes.

   6. Copies the TSSV configuration files (`ProviderConfiguration.xml`, `provider-configuration.xsd`) to your implementation instance library directory.

   7. Deploys the JASPIC file processor, `com/sun/ts/tests/jaspic/util/jaspic_util_web.war`.

5. If necessary, provide your own implementations of the porting package interface provided with the JASPIC TCK.
   `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 documentation bundle in the `docs/api` directory.

### 4.2 Configuring Your Environment to Repackage and Run the TCK Against the Vendor Implementation

After configuring your environment as described in this section, continue with the instructions in Section 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.

With the JASPIC TCK, vendors can specify the level of JASPIC support with which they comply. For example, a vendor may be compliant with the Servlet Profile, the SOAP Profile, or another (possibly unknown) profile. If a vendor chooses not to pursue compliance with any profile, they have an option of meeting something called baseline compliance. This is the level of compliance that exists regardless of which profile is being tested.

When a vendor is vying for compliance against no profile and is trying to get baseline compliance certification only, they have to implement a porting package (for example, a customvehicle) and pass the baseline tests that are in the `TS_HOME/src/com/sun/ts/tests/jaspic/spi/baseline` directory.

The sections that follow explain how to create a custom vehicle and how to replace the default vehicle with a custom vehicle.

#### 4.2.1 To Create a Custom Vehicle

A custom vehicle must be created and used when JASPIC profile tests are run in an environment that does not contain a Web server. If your JASPIC profile implementation includes a Web server, you do not need to implement your own custom vehicle.

The custom vehicle exists, in stubbed out form, and must be implemented in a way that provides a wrapper in which JASPIC tests can execute. The default `jaspicservlet` vehicle is an example of a vehicle that wraps and executes tests in a Servlet container. The `jaspicservlet` vehicle source can be used a reference to help you implement your own custom vehicle. The `jaspicservlet` vehicle is in the `src/com/sun/ts/tests/common/vehicle/jaspicservlet` directory.

1. Use the stubbed-out `customvehicle` in the `src/com/sun/ts/tests/common/vehicle/customvehicle` directory as your starting point.

2. Modify the `CustomVehicleRunner` class, using other vehicles as references.
   The `bin/xml/ts.vehicles.xml` file includes a stubbed-out section for the `customvehicle`, which you can modify to build you own `customvehicle`.

3. Build the `customvehicle` you created.

4. Modify the `src/vehicle.properties` file so that it refers to `customvehicle` instead of `jaspicservlet`.
   The `vehicle.properties` file is used during runtime to indicate in which vehicle the tests should be executed.

5. Remove or rename the `src/testsuite.jtd` file.
   This allows the test harness to identify tests to be run in your `customvehicle`.

#### 4.2.2 To Replace the Default Vehicle With a Custom Vehicle

If your JASPIC server does not have web support, you will need to create your own vehicle. A vehicle is a wrapper that supports running tests in different server-side containers, such as servlet, JSP, and so on. The JASPIC TCK provides a default vehicle, `jaspicservlet`, which supports running the TCK tests in a JASPIC runtime that has a Servlet container. To support running tests in an environment other than a Servlet container, you need to implement your own vehicle, effectively replacing the default vehicle, `jaspicservlet`.

This TCK was designed so you could use `jaspicservlet` as a template for creating your own vehicle. The `jaspicservlet` vehicle is used to contain and execute your client-side tests in the connector runtime.

The `jaspicservlet` vehicle is located in the `<TS_HOME>/src/com/sun/ts/tests/common/vehicle/jaspicservlet` directory.

To run the tests in a vehicle other than `jaspicservlet`, you need to create a custom vehicle named `customvehicle`. See Section 4.2.1, "To Create a Custom Vehicle," for more information on this topic.

### 4.3 Publishing the Test Applications

Not needed for the JASPIC TCK.

### 4.4 Custom Configuration Handlers

Configuration handlers are used to configure and unconfigure a JASPIC 1.1 implementation during the certification process. These are similar to deployment handlers but used for configuration. A configuration handler is an Ant build file that contains at least the required targets listed below: * `config.vi` - to configure the vendor implementation * `clean.vi` - to unconfigure the vendor implementation

These targets are called from the `<TS_HOME>/bin/build.xml` file and call down into the implementation-specific configuration handlers.

To provide your own configuration handler, create a config.vi.xml file with the necessary configuration steps for your implementation and place the file under the `<TS_HOME>/bin/xml/impl/<your_impl>` directory.

For more information, see `<TS_HOME>/bin/xml/impl/glassfish/config.vi.xml`, the configuration file for the Java EE 8 RI.

### 4.5 Custom Deployment Handlers

Deployment handlers are used to deploy and undeploy the WAR files that contain the tests to be run during the certification process. A deployment handler is an Ant build file that contains at least the required targets listed in the table below.

The JASPIC TCK provides these deployment handlers: * `<TS_HOME>/bin/xml/impl/none/deploy.xml` * `<TS_HOME>/bin/xml/impl/glassfish/deploy.xml`

The `deploy.xml` files in each of these directories are used to control deployment to a specific container (no deployment, deployment to the GlassFish Web container, deployment to the Tomcat Web container) denoted by the name of the directory in which each `deploy.xml` file resides. The primary `build.xml` file in the `<TS_HOME>/bin` directory has a target to invoke any of the required targets (-deploy, -undeploy, -deploy.all, -undeploy.all).

#### 4.5.1 To Create a Custom Deployment Handler

To deploy tests to another JASPIC implementation, you must create a custom handler. 1. Create a new directory in the <TS_HOME>/bin/impl directory tree. For example, create the <TS_HOME>/bin/impl/my_deployment_handler directory. Replace my_deployment_handler with the value of the impl.vi property that you set in Step 5 of the configuration procedure described in Section 4.2, "Configuring Your Environment to Repackage and Run the TCK Against the Vendor Implementation".

1. Copy the deploy.xml file from the <TS_HOME>/bin/xml/impl/none directory to the directory that you created.

2. Modify the required targets in the deploy.xml file. This is what the deploy.xml file for the "none" deployment handler looks like.

       <project name="No-op Deployment" default="deploy">
           <!-- No-op deployment target -->
           <target name="-deploy">
               <echo message="No deploy target implemented for this deliverable"/>
           </target>
           <target name="-undeploy">
               <echo message="No undeploy target implemented for this deliverable"/>
           </target>
           <target name="-deploy.all">
               <echo message="No deploy target implemented for this deliverable"/>
           </target>
           <target name="-undeploy.all">
               <echo message="No undeploy target implemented for this deliverable"/>
           </target>
       </project>

   Although this example just echoes messages, it does include the four required Ant targets (-deploy, -undeploy, -deploy.all, -undeploy.all) that your custom deploy.xml file must contain. With this as your starting point, look at the required targets in the deploy.xml files in the tomcat and glassfish directories for guidance as you create the same targets for the Web container in which you will run your implementation of JASPIC.

The following Ant targets can be called from anywhere under the <TS_HOME>/src directory:

- `deploy`

- `undeploy`

- `deploy.all`

- `undeploy.all`

The deploy.all and undeploy.all targets can also be called from the <TS_HOME>/bin directory.

Note | The targets in the deploy.xml file are never called directly. They are called indirectly by the targets listed above.

### 4.6 Using the JavaTest Harness Software

There are two general ways to run the JASPIC TCK test suite using the JavaTest harness software:

- Through the JavaTest GUI; if using this method, please continue on to Section 4.7, "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.7 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 JASPIC TCK test environment. This section covers the following topics:

- Configuration GUI Overview

- Starting the Configuration GUI

- To Configure the JavaTest Harness to Run the JASPIC TCK Tests

- Modifying the Default Test Configuration

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.7.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 Start, then Run Tests 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.7.2 Starting the Configuration GUI

Before you start the JavaTest harness software, you must have a valid test suite and Java SE 8 installed on your system.

The JASPIC 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 Section 4.7.3, "To Configure the JavaTest Harness to Run the TCK Tests."

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 Section 4.7.3, "To Configure the JavaTest Harness to Run the TCK Tests."

#### 4.7.3 To Configure the JavaTest Harness to Run the TCK Tests

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.

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 Section 5.1, "Starting JavaTest," or run a subset of the tests by completing the steps in Section 5.2, "Running a Subset of the Tests."

1. Change to the `<TS_HOME>/bin` directory and start the JavaTest test harness:
   `cd <TS_HOME>/bin`
   `ant gui`

2. From the File menu, click Open Quick Start Wizard.
   The Welcome screen displays.

3. Select Start a new test run, and then click Next.
   You are prompted to create a new configuration or use a configuration template.

4. Select Create a new configuration, and then click Next.
   You are prompted to select a test suite.

5. 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.

6. 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 JASPIC TCK is configured to run the default test suite.

7. Deselect the Start the configuration editor option, and then click Finish.

8. Click Run Tests, then click Start.
   The JavaTest harness starts running the tests.

9. To reconfigure the JavaTest test harness, do one of the following:

   - Click Configuration, then click New Configuration.

   - Click Configuration, then click Change Configuration.

10. Click Report, and then click Create Report.

11. 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.

12. Click Yes to view the report.

#### 4.7.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 box that is most convenient for you. Please refer to the JavaTest Harness documentation or the online help for complete information about these various options.

Copyright © 2018, Oracle and/or its affiliates. All rights reserved.