Parameterization Introduction

You can parameterize applicable tools (e.g., SOAP/REST Clients, JSON/XML Assertors, Message Responders) to use values that are saved in:

CTP automatically adds repository data sources when creating tests or virtual assets from traffic. Additional data sources can be defined directly from CTP, or added in the SOAtest/Virtualize desktop UI. Data Bank tools can be created directly from CTP or added from the SOAtest/Virtualize desktop UI.

Adding and Configuring a Data Source

From CTP, you can add CSV, Excel, SQL Database, and Repository data sources to test suites and responder suites. You can view any data source added from the SOAtest/Virtualize desktop UI at the suite level (test suite or responder suite). Moreover, you can also modify settings for suite-level CSV, Excel, SQL Database, and Repository data sources added from the SOAtest/Virtualize desktop UI.

Adding a Data Source

To add a data source:
  1. In the left pane, select the test or responder suite where you want the new data source added.
  2. Choose the appropriate Add New Data Source command from the page-level action menu.
  3. (Optional) Modify the name of the newly created data source.
  4. Configure the data source as described below:
  5. Save the new data source configuration.
The new data source will be added to the selected test suite or responder suite.

Configuring a CSV Data Source

To configure a CSV data source:

  1. Use the Rows controls to indicate the range of rows you want to use. If you only want to use selected rows, click the Range button, then enter the desired range (assuming a one-based index) by typing values into the From and To fields. For example, to use only the first 10 rows, enter 1 in the From field and 10 in the To field. To use only the fifth row, enter 5 in the From field and 5 in the To field.
  2. For Filepath, specify the location of the CSV file you want to use. You can either click in the text field and select from the list of files already uploaded to the active workspace on this SOAtest/Virtualize server (using the process described in Uploading Files), or you can click Upload and add a file from your local system.
  3. For Separator, enter or select the type of separator that the file uses.
  4. For Quote, enter or select the type of quotes that the file uses.
  5. Modify additional options if desired:
    • Trim leading/trailing whitespace: Specifies whether or not to strip whitespace from the beginning and end of the value.
    • First row specifies column names:  Specifies whether or not to consider the first row of the CSV file as column names. If the first row specifies column names, the elements in Form XML will show the column names as the name of each value. If the first row does not specify column names, then the elements in Form XML will use "value" as the name of each value.

       

Configuring an Excel Data Source

To configure an Excel data source:

  1. Use the Rows controls to indicate the range of rows you want to use. If you only want to use selected rows, click the Range button, then enter the desired range (assuming a one-based index) by typing values into the From and To fields. For example, to use only the first 10 rows, enter 1 in the From field and 10 in the To field. To use only the fifth row, enter 5 in the From field and 5 in the To field.
  2. For Filepath, specify the location of the Excel file you want to use. You can either click in the text field and select from the list of files already uploaded to the active workspace on this SOAtest/Virtualize server (using the process described in Uploading Files), or you can click Upload and add a file from your local system.
  3. For Sheet, specify the sheet of the specified Excel file you would like to use.
  4. If you want SOAtest to limit the size of every column in the Excel data source to the size of the column with the least number of rows (in other words, if you want it to stop processing data when it encounters an empty cell), enable Stop processing the spreadsheet at the first empty row

Configuring a Repository Data Source

Parasoft’s Data Repository is designed to help teams define, extend, and review large and/or hierarchical data sets for use in Parasoft messaging tools. A repository data source is a "wrapper" for the repository data source that allows you to consume it in Parasoft messaging tools in the same manner as you would consume data from an Excel data sheet or CSV file.

To configure a repository data source:

  1. Use the Rows controls to indicate the range of rows you want to use. If you only want to use selected rows, click the Range button, then enter the desired range (assuming a one-based index) by typing values into the From and To fields. For example, to use only the first 10 rows, enter 1 in the From field and 10 in the To field. To use only the fifth row, enter 5 in the From field and 5 in the To field.

  2. Select a Repository server and enter the Repository name of the repository you want to use. You can specify the name of one of the repositories connected through TDA or you can specify a new repository. If the named repository does not yet exist, it will be created.
  3. Select a Connection mode and configure it accordingly:
    • Host/Port: Enter the Data Repository Server's host and port. To use SSL to connect to the server, enable Use SSL.
    • Connection String: Enter the MongoDB connection string. An example of a connection string that connects to a local server with SSL is shown below. See https://www.mongodb.com/docs/manual/reference/connection-string/ for more information about MongoDB connection strings.

      MongoDB Connection String Example
      mongodb://localhost:2424/?tls=true&tlsAllowInvalidHostnames=true

      If an authentication database is specified in the connection string, you should use the /defaultauthdb component; only use the ?authsource=defaultauthdb option if credentials are specified in the connection string.

  4. Enter the username and password for connecting to this Data Repository server.
    • If you chose Connection String as your connection mode, you have the option to specify credentials in either the connection string or in the Username and Password fields. If credentials are specified in both, those in the Username and Password fields will take precedence.
  5. Specify the data set to which this data source will connect. You can specify a data set that does not yet exist, however, that data set will need to exist (and contain data) by the time you start applying tools to use this data source. 
     

Creating a Repository Data Source for SQL Data Sets?

If you are creating a data source for use in Virtualize’s SQL Responder tool, be sure to change the Type setting from Data Set to SQL Data Set.

Configuring a SQL Correlation Data Source

Unlike other data sources, SQL correlation data sources allow you to disable caching so the virtual asset does not need to be redeployed in order to read new records. This makes it particularly suited for CRUD workflows. SQL Correlation Data Sources are only applicable to Service Virtualization, not API Testing.

You must specify the JDBC driver to connect to a database. See Configuring JDBC Drivers for details. 

  1. (Optional) Change the data source label in the Name field.
  2. For Database type, select the type of database you want to connect to. The driver for the specified database type must be available on your CLASSPATH.
     

    Using a different type of database

    If the database you want to use is not listed under Database type, select Custom. You can then specify a driver class in the Driver class field. Type the path to the appropriate JDBC driver class, including the package name.

  3. Specify the settings for that particular type of driver. Settings will vary from driver to driver.
  4. In the SQL Query field, enter a SQL statement that will be run to load data. This statement must specify a correlation key, which will be used for data source correlations within Message Responders in the Data Source correlations tab. The correlation key can be declared in the following format: DatabaseColumnName=:CorrelationKeyName. For example:

    SELECT * FROM Customer WHERE ID = :CustomerID;

    The above selects all columns in the rows from the Customer table where the ID column has the value specified by the correlation key "CustomerID".

  5. In the Correlation Keys table, click Add new correlation key (+ icon) to define the correlation keys used for data source correlations within Message Responders. The table will be automatically populated with any correlation keys declared in the SQL Query, though you might need to set the correct type for the key. Specify a sample value according to the selected type. For some databases, the sample value may need to be set to a valid database value to retrieve the expected database columns. Click Modify (pencil icon) for a correlation key to make changes.
    • Note that all correlation keys configured in the table must be configured in the data source correlation tab for Message Responders.
  6. If you want updates to the database to be immediately reflected in any deployed virtual assets that use that data, leave the Enable caching option disabled (it is disabled by default). When enabled, virtual assets will need to be redeployed in order for the changes to take effect at runtime. Enabling caching for load testing is recommended for performance optimization.

Configuring a SQL Data Source

A SQL data source pulls database data using a SQL query. To add a SQL data source:
  1. Use the Rows controls to indicate the range of rows you want to use. If you only want to use selected rows, click the Range button, then enter the desired range (assuming a one-based index) by typing values into the From and To fields. For example, to use only the first 10 rows, enter 1 in the From field and 10 in the To field. To use only the fifth row, enter 5 in the From field and 5 in the To field.
  2. Specify the database to which this data source will connect.
  3. For Database type, select the type of database you want to connect to. The driver for the specified database type must be available on your CLASSPATH.
     


    Using a different type of database

    If the database you want to use is not listed under Database type, select Custom. You can then specify a driver class in the Driver class field. Type the path to the appropriate JDBC driver class, including the package name.

  4. Specify the settings for that particular type of driver. Settings will vary from driver to driver.
  5. In the SQL Query area, type or copy the SQL query that expresses which data you want to use. A preview of the resulting data will be shown in the Columns area.
  6. (Optional) Enable Close connection if you want to close the connection to this database. It is recommended when you plan to use the data source only once, and it doesn't need to wait for another command. It is not recommended when you plan to have multiple data sources all connecting to the same database. In that case, all of the data sources can share a connection—and do not need to waste resources on a new connection each time.

     

Selecting a Data Source within a Test Scenario or Responder Suite

If multiple data sources are associated with a test scenario or responder suite, use the Data source drop-down menu to indicate which data source you want to use to parameterize the tool you’re configuring.
You do not need to select a data source here in order to use values stored in a Data Bank tool.

Specifying Parameterized Values

You can use the ${value} notation to reference data bank and data source values (as well as variables) that are defined for the test suite or responder suite.
To select from a list of applicable values, start typing ${ . This will open a widget listing all the available parameterization options.

Select one of the options in the list, and the parameterization will be automatically configured.
  • No labels