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
- An instance of the SOAtest/Virtualize server should be running. See Deploying the SOAtest and Virtualize Server WAR File.
- The example ParaBank project should be deployed. See Setting Up ParaBank.
- A data repository server should be deployed and configured to register with CTP. See Installing a Remote Data Repository Server.
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.
- Open the <SOATEST/VIRTUALIZE_INSTALL>/proxies directory
- Copy the ParasoftJDBCDriver.jar file to the <WORKSPACE>/ParaBank/WebContent/WEB-INF/lib directory.
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=
- In the Virtualize desktop, open the Java perspective then choose Run> Run Configurations.
- Select Apache Tomcat> ParaBank Tomcat 8.5 Server.
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
- 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:
- Open CTP and choose Environment Manager from the application menu.
- Click Add System in the toolbar and choose the Create an empty system option.
- Click Create and click in the edit (pencil) button next to the New System label.
- Rename your system “Parabank” and click the apply (checkmark) button to save your change.
- Drag a Database component into the diagram area and click the save button.
- Choose New Environment from the actions drop-down menu on the system page.
- Click the edit button for the new environment and name it “Silo 1”.
- 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.
- Hover your pointer over the top-right corner of the database component so that the options drop-down menu button appears.
- Click the drop-down menu and choose New Instance.
- Enter “Passthrough” in the Name field.
- Choose the HTTP option in the Real endpoints section and specify the host, port, and path to your application.
- Enable the JDBC Controller option and click Select a JDBC controller.
- 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.
- Click Finish and repeat steps 1-6 to configure a “Record” instance.
- 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.