Creating a project

Creating a project is the first step to start working with HCL OneTest™ API. A project contains the basic settings used by tests. You can also find different interactive guides on the Home page that provide you with information on the common tasks that you can accomplish in HCL OneTest™ API.

Before you begin

  • You must have closed HCL Quality Server sessions that are running if any.
  • If HCL OneTest™ API is running and you have just completed the tasks in Creating and running a test, you probably have that project open. To create and run a stub with an HTTP/TCP Proxy, you must create a new project. Therefore, you must close the existing project by clicking File > Close project. This action closes the project and restarts HCL OneTest™ API.

About this task

After you restart HCL OneTest™ API, you must create a new project, provide a name for your project and save it on your local drive. The following instructions are applicable for the Windows OS.

Procedure

  1. In the startup window, select Create Project and click OK.
  2. Enter a name for the project in the Project Name field.
  3. Click Browse and select a location to save the project.

    If you do not browse and select a location, the project is saved in the default location, which is your home directory. For example, the default location is C:\Users\USER_ADMIN.

    Image of the new project window.

  4. Click Finish.

    The main function of HCL Quality Server is to be the communication hub between HCL OneTest™ API and the HTTP Proxy.

Results

The new project is created.

What to do next

You must start the Add Numbers server and client. See Starting Add Numbers server and client.

Starting Add Numbers server and client

You can by using the sample WSDL documents such as the Add Numbers server and client provided along with HCL OneTest™ API, run the scripts as part of your project and test the usage of a web service hosted on your local system.

Before you begin

You must have created a project as described in Creating a project. Your project must be open in HCL OneTest™ API.

About this task

HCL OneTest™ API contains some example APIs. In this example, you use AddNumbers, which has a WSDL document describing the API.

If you want to model a system that does not have a WSDL definition, you can use a Swagger file instead. See Creating and running a test.

Procedure

  1. In the local drive, go to install_location/HCLProducts/API/examples/addnumbers.
  2. Run the startup script.

    The Add Numbers server window is displayed.

  3. Click Start Service.

    This action starts the Add Numbers web service on the host.

    Make note of the Host Address and Port Number fields. You need them in the next steps.

  4. In the local drive, go to install_location/HCLProducts/API/examples/addnumbersclient.
  5. Run the startup script.
    Note: Ensure that the host and port fields match the values that you noted earlier from the Add Numbers Server window.
  6. Click the equal sign.

    The client application sends an HTTP SOAP request to the server application, which adds the two numbers and returns the result. The result is displayed on the Add Numbers Client window.

    Image of the Add Numbers Client window.

Results

You have successfully tested a web service hosted on your local system by using the sample WSDL.

What to do next

You must configure the client to use the created stub. See Configuring the Add Numbers client to use the stub (virtual service).

Configuring the Add Numbers client to use the stub (virtual service)

You can configure the client to use the created stub as a virtual service.

Before you begin

You must have completed creating the stub and run it.

About this task

To support HCL OneTest™ API Service Virtualization, you must configure HTTP clients to use the HCL OneTest™ API HTTP/TCP Proxy. You must configure the Add Numbers client application to use the HCL OneTest™ API proxy by using the standard Java proxy settings.

Note: Other than the port number, there is nothing specific in the proxy settings of HCL OneTest™ API. Any application that sends its traffic through standard HTTP proxies can have its HTTP dependencies virtualized by using the HCL OneTest™ API HTTP/TCP Proxy.

Procedure

  1. Close the Add Numbers Client window.
  2. Open the startup script located at install_location/HCLProducts/API/examples/addnumbersclient in a text editor.
  3. Edit the script as follows:
    • In Windows:
      1. Comment out the line %JAVA_HOME%\bin\java %NET_PROPS% %SSL_PROPS% -jar AddNumbersClient.jar by inserting @rem at the beginning.

        The edited entry appears as: @rem %JAVA_HOME%\bin\java %NET_PROPS% %SSL_PROPS% -jar AddNumbersClient.jar.

      2. Uncomment the line for connecting to a proxy as indicated by the other comments in the file. Ensure that this line includes the –Dhttp.proxyHost=localhost and -Dhttp.proxyPort=3128 arguments, which direct the application to use the proxy that is started by HCL OneTest™ API, the one that is running locally on port 3128.
    • In Linux:
      1. Comment out the line $_RUNJAVA" "${SSL[@]}" -jar "$_SCRIPTDIR/AddNumbersClient.jar.
      2. Uncomment the line for connecting to a proxy, as indicated by the other comments in the file. Ensure that this line includes the arguments -Dhttp.proxyHost=localhost and -Dhttp.proxyPort=3128, which direct the application to use the proxy that was started by HCL OneTest™ API, the one that is running locally on port 3128.
  4. Save and close the file.

Results

You have successfully configured the Add Numbers client to use the stub.

What to do next

You must verify if the Add Numbers client application is using the HTTP proxy. See Verifying that the Add Numbers client is sending traffic through the proxy.

Verifying that the Add Numbers client is sending traffic through the proxy

After you configure the Add Numbers client to use the stub, you must verify that the Add Numbers service is using the HTTP proxy to send traffic.

Before you begin

The Add Numbers client must be running. If it is not, go to install_location/HCLProducts/API/examples/addnumbersclient and run the startup script.

Procedure

  1. In the Add Numbers client application, click the equal sign.

    The result of the addition operation (133) is returned as in Starting Add Numbers server and client, indicating that the client application can still communicate with the server application.

  2. In a web browser, open HCL Quality Server by going to https://localhost:5443/RTCP.

    The HCL Quality Server Home page is displayed.

  3. Click the Infrastructure icon on the HCL Quality Server Home page to view the connected agents or proxies. Image of the HCL Quality Server Home page.

    Two entries are listed on the Infrastructure page, one for the HTTP/TCP Proxy’s HTTP and HTTPS proxy capability, and the other for the HTTP/TCP Proxy’s TCP proxy capability. You can view the requests received by the proxy from the Statistics panel. You can also view the activities that were logged from the Activity panel.

Results

You have verified that the Add Numbers client application is using the HTTP proxy.

What to do next

You must discover the endpoints that are in use by the Add Numbers client application. See Using topology discovery to discover the endpoints in use.

Using topology discovery to discover the endpoints in use

You must discover the endpoints that are in use by the Add Numbers client application by selecting the intercepts registered with HCL Quality Server.

Topology discovery is the process of observing and modeling the components of a system under test by using only real traffic that flows through the system. You can view the resources that the system calls and choose the ones to include in the system model within your project. You then use this model to make detailed recordings of interactions and create tests and virtual services from those recordings. Topology discovery, recording, and service virtualization all require the HTTP proxy. Therefore, if you configure the HTTP proxy for the client for any one of these tasks, you need not do anything separately for the other tasks.

Procedure

  1. Return to HCL OneTest™ API Home page, and on the toolbar, click Architecture School.
  2. Click the Topology Discovery tab.

    Image of the Topology Discovery tab.

  3. The Observation Points panel lists the Topology Discovery intercept types that are registered with HCL Quality Server. If the HTTP/TCP proxy has started you can see 1 against both HTTP and TCP. To discover the HTTP endpoints, select the check box next to the intercept type, HTTP.

    Image of the Observation Points window.

  4. Click Start discovery.

    This action starts topology discovery by using the selected intercept type. A progress bar titled Starting Discovery in QS is displayed.

  5. Return to the Add Numbers client application and click the equal sign.
  6. Return to HCL OneTest™ API. After a few seconds, you can see a new line being displayed in the Observed Resources panel, which describes the Add Numbers server endpoint to which the request was sent.
  7. Click the row to see the information about the request that was observed.

    In the Observed Resource Invocation Summary panel, the description shows HTTP web service request and that it had a SOAPAction value of Add. This view summarizes large numbers of endpoints and invocations. You can use it to observe all the activities in a large, complex system, and find the endpoints that you are interested in testing or virtualizing.

    Image of the Observed Resources window.

  8. Select the check box next to either the endpoint (in the top section) or the description (in the bottom section).
  9. On the toolbar in the Observed Resources panel, click Add selected observations to the system model.

    On the Existing resources page, none of the observations are currently represented in your system model. If you observe an already modeled system, with this action you could reuse the existing resources that were involved in any of the observations.

  10. Click Next.
  11. On the Parent assignment page, choose a name for the new component to contain the observed operations. As the application observed is called Add Numbers, enter the same name.

    Image of the Add resources to system model window.

  12. Click Next.
  13. On the Documentation page, you must enter the details about the resources that you are creating. The details could include what you were observing and why, and your intention for the resources you are creating. For example, I have observed the Add Numbers server endpoint, and am modelling it to create a stub to support testing of the Add Numbers client application.
  14. Click Next.
  15. On the Summary page, select what to do after the resources are created. The default options stop the discovery process because you are done with it and take you to the Logical View of the Architecture School perspective where you see the created resource.
  16. Retain the default options selected and click Finish.

    A warning message prompts you to edit the resources and configure the end points with details of security, if any of them use security.

    This prompt is given because secure information such as passwords and SSL keys cannot be observed. You must ignore the message because in this case, the Add Numbers server did not have any security enabled.

    In the Logical View, you can see the component named AddNumbers containing an operation named Add that you observed, along with the localhost 8088 HTTP transport that the operation used.

    Image of the AddNumbers component in the Logical View perspective.

Results

You have discovered the endpoints used by the HTTP proxy when running the Add Numbers client application.

What to do next

You must record an operation for a message-based stub for the Add Numbers client application. See Recording an operation.

Recording an operation

You can use the recording operation to create a message-based stub if you have access to a live system from which you can record events.

Before you begin

You must have completed discovering of the HTTP proxy endpoints.

About this task

You can record the traffic that is going through the proxy to and from the Add Numbers server and use the recorded messages to create a stub, which provides a virtual Add Numbers service.

At this stage, the Logical View of the Architecture School perspective shows the component named AddNumbers containing an operation named Add, along with an HTTP transport.

Procedure

  1. Click the service operation called Add, to select it.
  2. Click Add event monitors for the selected items on the toolbar.

    HCL OneTest™ API switches to the Recording Studio perspective and adds an Event monitor for the Add operation, which you can see in the Monitor Configuration panel.

    Image of the Events View window.

    1. You are prompted to add a monitor for the localhost 8088 HTTP transport. You use such a monitor to record traffic for all the operations on that transport apart from those for the Add operation.
    2. As you want to record traffic for the Add operation alone, you can leave all the options with their defaults and click OK.

      The Monitor Configuration panel shows one row, which in the Monitor Name column indicates the Add operation.

    3. To remove other monitors, select them and click the Delete the selected monitors icon.

      The recorded events are displayed in the Events View.

      Image of the Events View window.

  3. In the Events View toolbar, click the Start Recording icon.

    You see a progress dialog for a few seconds while the proxy is configured for recording.

  4. Return to the Add Numbers client application and click the equal sign. The numbers 88 and 45 are added. The response is the same as in Starting Add Numbers server and client.
  5. Click the equal sign a few more times, entering different numbers to be added each time and note the response.
  6. Return to HCL OneTest™ API.

    You can see a number of recorded events. Half of these are requests sent to the server, and the other half are responses received from the server.

    Click each one to see the contents of the message. In the request messages action, you see the numbers you entered into the client application, and in the response messages action, the result of each addition.

  7. Stop the recording by clicking the Pause icon on the Events View toolbar.

    You can find the two events that represent the request for 88+45 and its response of 133. These events are the first two events in the table.

  8. Select these two events in the Events View; to do so, click the first one, hold down the Shift key and click the second one.

    The descriptions of the events displayed are:
    POST /addNumbers and 200 – OK

  9. In the Events View toolbar, click the Create Stub from selected events icon.

    This action opens the Recorded Events wizard where you can use the selected events to create a stub. The Operation Assignment page shows the events and that operation they are related to.

    Image of the Recorded Events window.

  10. Click Next.

    On the Transaction Assignment page, you control which request is grouped with which reply. In this case, you have only one request and reply, so they are put together into Group# 1.

  11. Click Summary.
  12. Enter the stub name as 88 plus 45.
  13. Click Finish.

    The stub is opened in Test Factory.

    Image of the Stub window.

Results

You have recorded requests and responses from the Add Numbers server and used them to create a stub that can listen to the request for one of the operations you recorded and returns the result that you recorded from the server for that request.

What to do next

You can verify if the client receives responses from the stub when the server application is disabled. See Disabling the server application and verifying that the client receives response from the stub.

Disabling the server application and verifying that the client receives response from the stub

You can verify if the client receives a response from the stub when the Add Numbers server application is disabled. If responses are received then you can infer that the service performing the operation is a virtualized one.

About this task

This task is a continuation of what you accomplished in Recording an operation. At this stage, the stub named 88 plus 45 is open in the editor in the Test Factory perspective. In this section, you can verify that the Add Numbers client receives the result of the Add operation from the stub even when the Add Numbers server is not available.

Procedure

  1. Go to the Add Numbers server application and stop the server by clicking Stop Service.
  2. Go to the Add Numbers client application.
  3. Change the values in Add to 88 and 45 to match the input expected by the stub.
  4. Click the equal sign. The application displays an error message, because it cannot connect to the server application.
  5. Click OK.
  6. Return to HCL OneTest™ API.
  7. With the Stub editor open, click the Run icon on the toolbar.
  8. Return to the Add Numbers client application and click the equal sign.

    The application returns the result as 133, because this is the number that was configured in the stub. Instead of calling the Add Numbers server, the request was responded to by the stub, which can be used to test the client application while the server is unavailable or is still under development.

    When virtualizing a real system, you create a more complex stub that either eliminates the need for the real server to be running when testing is in progress, or that simulates a difficult-to-recreate scenario. For example, an error case from the server application to aid testing of how the client application deals with such cases. For references on creating more complex and flexible stubs, see What to do next.

    An option is to use a data source from which a stub can look up data based on the message it received. For instructions on how to create a data-driven stub, complete the following steps:

    1. In the HCL OneTest™ API Home page, click Help > Interactive Guides.
    2. Click Select an Interactive Guide.

      Image of the Interactive guides list.

    3. Select Data Sources > Create a Stub that uses data from an external source and click OK.

      Image of the Select an Interactive Guide window.

    4. Follow the steps in the Interactive Guides view.

Results

You have successfully created, run, and verified a virtual service (message-based stub) that uses an HTTP proxy as a transport for messages.

What to do next

For information on creating more complex and flexible stubs, see the following documentation:
  • To control what requests the stub must respond to, you can use the stub editor’s Input tab and The Field Editor. For instructions, see Input tab.
  • To control how the stub constructs responses, you can use the stub editors Activity tab and The Field Editor. For instructions, see Activity tab.
Feedback