In this chapter, we’ll discuss how to get data into the testing infrastructure. We will use an instance of the Parabank example application shipped with Parasoft SOAtest and Virtualize and add a proxy to the application configuration so that we can capture the data to a data repository.  

In this section:

Prerequisities

Deploying the ParasoftJDBC Driver  

We’ll start by deploying the ParasoftJDBC driver to Parabank and configuring a connection to the SOAtest/Virtualizer server. The Parasoft JDBC driver is a special JDBC driver that can act as a man-in-the-middle between the application and its regular JDBC driver. See About the Parasoft JDBC Driver to learn. 

  1. Open the <SOATEST/VIRTUALIZE_INSTALL>/proxies directory
  2. Copy the ParasoftJDBCDriver.jar file to the <WORKSPACE>/ParaBank/WebContent/WEB-INF/lib directory.
     
  3. Open the ParaBank/src/jdbc.properties file and specify the following settings:

    jdbc.driverClassName=com.parasoft.xtest.jdbc.virt.driver.JDBCProxyDriver 
    jdbc.url=jdbc:parasoft:proxydriver:org.hsqldb.jdbcDriver:@jdbc:hsqldb:hsql://localhost/parabank 
    jdbc.username=sa 
    jdbc.password= 

     

  4. In the Virtualize desktop, open the Java perspective then choose  Run> Run Configurations
  5. Select  Apache Tomcat> ParaBank Tomcat 8.5 Server
  6. Under the  Arguments  tab, add the following Parasoft JDBC Driver flags to what is already listed in the VM arguments section:

    -Dparasoft.virtualize.server.url=http://localhost:9080 -Dparasoft.virtualize.group.id=parabank 
     -Dparasoft.virtualize.driver.register.jdbcproxydriver.in.drivermanager=true -Dparasoft.virtualize.driver.proxy.direct=true 

     

  7. Restart the ParaBank server with the updated run configuration. You can open the console view in Virtualize desktop and log in and out of the ParaBank to verify that the proxy is working.

If you are applying this tutorial to your own project, the documentation includes instructions on how to deploy the Parasoft JDBC Driver to several application. See Using the Parasoft JDBC Driver.

Recording Database Queries 

In this step, we will record a database query and use it to create a virtual asset. Recording a database query will not add data to a data repository. An action, such as sending a message to virtual asset connected to the repository, must be taken in order to capture the data. You can perform this step in the Virtualize desktop or in CTP. We will use CTP in this tutorial, which requires some additional configuration. 

Creating an Environment 

We’ll create a new system, environment, and database component in CTP. A system is a representation of your development infrastructure. A system contains one or more representations of your environments, such as "regression testing", "integration testing", etc. Additionally, you can create several instances of an environment to meet your testing needs.

A system is a palette that is populated with several components, such as databases, servers, clients, etc. An instance of each component contains configurations used within specific environments. A realistic system would contain several components, but we will only use the database component to illustrate the workflow:

  1. Open CTP and choose Environment Manager from the application menu.
  2. Click Add System in the toolbar and choose the Create an empty system option.
  3. Click Create and click in the edit (pencil) button next to the New System label.
  4. Rename your system “Parabank” and click the apply (checkmark) button to save your change.
  5. Drag a Database component into the diagram area and click the save button.
  6. Choose New Environment from the actions drop-down menu on the system page.
     
  7. Click the edit button for the new environment and name it “Silo 1”.
  8. Save the environment.

You should now a have a system called Parabank that consists of a single database. The system contains the Silo 1 environment. We will next add multiple instances of the database component to configure different states.

Adding Database Component Instances to the Environment 

A component is a type of object that can appear in your environments. You have to add instances of the component that perform specific functions for them to be useful. 

  1. Hover your pointer over the top-right corner of the database component so that the options drop-down menu button appears.
  2. Click the drop-down menu and choose New Instance.
  3. Enter “Passthrough” in the Name field.
  4. Choose the HTTP option in the Real endpoints section and specify the host, port, and path to your application.
  5. Enable the JDBC Controller option and click Select a JDBC controller. 
  6. Choose the “parabank” controller and specify Passthrough as the mode. You can leave the default for all other configurations in this section. Refer to XREF LINK for additional information about these settings. 
  7. Click Finish and repeat steps 1-6 to configure a “Record” instance.
  8. Click Finish after configuring the Record instance. 

You now have a passthrough mode and a record mode configured for the database component. The next step is to enable recording and capture a query.


  • No labels