9. Operational Test Data with Data Production Libraries (DPLs)
PushToTest TestMaker's Data Product Library (DPL) is a powerful system to deliver operational data to tests at test runtime. For instance, a test of an on-line registration service stores name and password values in a database and uses a DPL to access the database as the test operates. In a second instance, a test of a reporting service uses a DPL to access a comma-separated-value (CSV) file of acceptable responses to validate service responses.
Operational Test Data with Data Production Libraries (DPLs)
PushToTest TestMaker's Data Product Library (DPL) is a powerful system to deliver operational data to tests at test runtime. For instance, a test of an on-line registration service stores name and password values in a database and uses a DPL to access the database as the test operates. In a second instance, a test of a reporting service uses a DPL to access a comma-separated-value (CSV) file of acceptable responses to validate service responses.
Overview
This section contains the following sections:
Comma Separated Value (CSV) Operational Data For Tests
Relational Data (RDBMS) Operational Data For Tests
Sharing and Reusing Operational Data Between Tests
Original Operational Data For Tests Using Lingo
TestMaker implements an extensible DPL framework to provide operational test data to test script runners at test runtime. The DPL framework is general in that data may be input from a variety of sources, including a relational database, comma-separated-value file, Web service, and data generator. TestMaker comes with pre-built DPLs and makes it easy for Java developers to add their own custom DPLs.
DPLs work in conjunction with script runners at test runtime. TestScenarios define the DPL and script runner interaction. The TestMaker Tutorials give instructions on using the pre-built DPLs.
Here is a quick summary:
1. In a TestScenario establish a new DPL in the <DataSources>
<DataSources>
<dpl name="mydpl" type="HashDPL">
<argument name="file" dpl="rsc" value="getDataByIndex" index="0"/>
</dpl>
</DataSources>
2. Identify the source of the DPL data in the <Resources> section.
<resources>
<data path="data.csv"/>
<testgen4web path="BrewBizWeb.testgen4web"/></resources>
3. Add an <argument> to pass-in the DPL data.
<run name="testweb" testclass="BrewBizWeb.testgen4web" method="testgen4web" langtype="testgen4web">
<argument dpl="mydpl" name="DPL_Properties" value="getData"/>
</run>
In the above example the testgen4web script runner looks into the TestGen4Web test and replaces values from the data.csv file. The DPL uses the first row in the CSV file to identify field mapping names.

The TestGen4Web, Selenium, and soapUI script runners provide support for the HashDPL data mapping from CSV files. Script runners for Java, Jython, JRuby, Groovy and the other support scripting languages receive DPL data in a dictionary structure. For example, the following shows the output of a TestGen4Web test transformed to Jython:
def applyValues(self,actions,DPLvalues):
''' Assigns the values included in the DPL to the Testgen4web code '''
if DPLvalues != None:
map = HashMap()
try:
dpl = map.getClass().equals(map.getClass(),DPLvalues.getClass());
except:
dpl = 0;
if dpl:
for i in range (0,len(actions)):
if DPLvalues.containsKey(actions[i].value):
actions[i].value = DPLvalues.get(actions[i].value)
else:
for i in range(0,len(DPLvalues)):
if len(DPLvalues) > i and DPLvalues[i] != None and DPLvalues[i] != "":
actions[i].value = DPLvalues[i]
def run(self,file,DPLvalues=None):
''' Run the test '''
...
self.applyValues(self.actions,DPLvalues)
Lastly, DPLs have the ability to share data from one test to the next. For example, TheLocker DPL takes the results from a test step authored in soapUIas input to a second test step authored in TestGen4Web. The EndToEnd Tutorial gives an example of DPL data sharing between test steps.
Recipes
Comma Separated Value (CSV) Operational Data For Tests

Comma separated value (CSV) files contain data formatted into rows, where each row is on a single line and contains one or more fields separated by commas. The CSV Data Production Library (DPL) reads rows of data from a CSV file and passes the data to a test script as string arrays.
Consider the following example data:
Name,Age,Eye Color,Hair Color
Pepe,24,black,red
Heriberto,56,black,blue
Austelina,77,black,yellow
Configure the HashDPL in the <resources> section of a TestScenario document by defining its parameters including programs, Java classes, modules, and scripts. This example identifies a Java resource (print.jar) and a CSV data file (csv.txt):
<resources>
<data path="./example_agents/dplCSVExample/csv.txt"/>
<jar path="./example_agents/dplCSVExample/print.jar"/>
</resources>
TestMaker is a distributed environment and the files identified in the <resources> section are distributed to the TestNodes. When using a HashDPL, test scripts do not access data through a direct path, for example a local directory (/usr/local/csv.txt or c:\documents\csv.txt), instead your TestScenario identifies a DPL and the DPL provides the data to the script. Here is an example:
<DataSources>
<dpl name="csv" type="HashDPL">
<argument name="file" dpl="rsc" value="getDataByIndex" index="0"/>
</dpl>
</DataSources>
The <DataSources> and <dpl> elements identify the HashDPL type, a DPL resource name, and specifies the index to the first row of data.
As an example of how this works, this <messagesizes> element (<messagesizes> is synonymous with <dataindexes> in TestMaker 5.2 and later,) from the example TestScenario document (testDPLCVS.xml), defines a load test to check a service with three different message sizes.
<messagesizes>
<messagesize value="0"/>
<messagesize value="1"/>
<messagesize value="2"/>
</messagesizes>
The message size values are index values meaning the message size value 0 tells the DPL to use the first row of data in a CSV file.
Following are some example <run> element definitions.
This definition uses the DPL to get the next row of data; when the end of the file is reached, getNextData moves the DPL to the beginning of the file:
<run name="CVS" testclass="com.examples.print" method="print" langtype="java">
<argument name="arg" dpl="csv" value="getNextData"/>
</run>
This definition uses the DPL to get a specific row of data, the first row (index="0"):
<run name="CVS" testclass="com.examples.print" method="print" langtype="java">
<argument name="arg" dpl="csv" value="getDataByIndex" index="0" />
</run>
This definition uses the DPL to get the row of data defined by the <messagesize> value for the test-use-case during a load test:
<run name="CVS" testclass="com.examples.print" method="print" langtype="java">
<argument name="arg" dpl="csv" value="getDataByIndex" index="messagesize"/>
</run>
See an example of the above recipe in the Web Application Tutorial.
Relational Data (RDBMS) Operational Data For Tests

Relational Database Management Systems (RDBMS) store data in a relational model of tables, rows, and columns. The Structured Query Language (SQL) provides a syntax for defining views of the relational model. The Data Production Library (DPL) generates data from a relational database and passes the data to a test at runtime.
Note: The following presents an example found in testmaker_home/example_agents/MYSQLExample.
The RDBMS DPL has five configuration parameters:
Connector: The JDBC type to connect to the database. TestMaker does not provide a JDBC driver since databases provide JDBC connectors by implementing the java.sql.Driver interface. In the example given, the driver class used is the com.mysql.jdbc.Driver from the MySQL database.
URL: The URL of the database.
Logging: The account username for database access.
Password: The account password for database access.
Query: The query for the database. The query is done one time with the result stored for further use.
Here is the configuration syntax:
<DataSources>
<dpl name=" rdbms" type="RDBMSDPL">
<argument name="connector" value="com.mysql.jdbc.Driver" />
<argument name="url" value="jdbc:mysql://localhost/tmstatus" />
<argument name="login" value="userlogging" />
<argument name="password" value="12345" />
<argument name="query" value="select * from scenario" />
</dpl>
</DataSources>
That definition mapped in Java code:
RDBMSDPL rdbms = new RDBMSDPL();
rdbms.setup(com.mysql.jdbc.Driver”,
"jdbc:mysql://localhost/tmstatus",
" userlogging ",
"12345",
“select * from scenario”);
Given a table called "person" in a SQL database called "tmstatus":
Name Age Eye Color Hair Color
Pepe 24 Black red
Heriberto 56 Black blue
Austelina 77 Black yellow
The syntax to access a data row using the RDBMS DPL:
<run name="CSV example 1" testclass="simple.print" method="print" langtype="java">
argument name="arrayString" dpl=" rdbms" value=" getDataByIndex" index="0"/>
</run>
<run name="CSV example 1" testclass="simple.print" method="print" langtype="java">
argument name="arrayString" dpl=" rdbms value=" getDataByIndex" index="1"/>
</run>
<run name="CSV example 2" testclass="simple.print" method="print" langtype="java">
argument name="arrayString" dpl=" rdbmss value=" getDataByIndex" index="0"/>
</run>
Those definitions mapped in Java code:
simple.print spr = new simple.print ();
spr.print (new String[] { “Name”, “age”, “eye color”, “hair color” };
spr.print (new String[] { “Pepe”, “24”, “black”, “red” };
simple.print spr2 = new simple.print ();
spr2.print (new String[] { “Name”, “age”, “eye color”, “hair color” };
See an example of the above recipe in the Web Application Tutorial.
Sharing and Reusing Operational Data Between Tests

Tests share data using HashDPL and TheLocker DPL. For example:
<!-- Run a soapUI test of the SOAP-based Web Service interface -->
<!-- Use CSV data from the DPL in the soapUI test -->
<run name="BrewBizService" testclass="TestSuite" method="TestCase" langtype="soapui">
<argument dpl="mydpl" name="DPL_Properties" value="getData"/>
</run>
<!-- Run a TestGen4Web test of a Web application -->
<!-- Use CSV data from the DPL in the TestGen4Web test -->
<run name="testweb" testclass="BrewBizWeb.testgen4web" method="testgen4web" langtype="testgen4web">
<argument dpl="mydpl" name="DPL_Properties" value="getData" />
</run>
See an example of the above recipe in the EndToEnd Test Tutorial.
Original Operational Data For Tests Using Lingo

DPLs can create their own operational test data. For example, the Lingo DPL creates pseudo random gibberish text that is handy for testing. To help understand how to create DPLs, here is the source code for the Lingo DPL:
package com.pushtotest.tool.dpl.provided;
import com.pushtotest.tool.dpl.DataProduction;
import com.pushtotest.tool.util.Lingo;
import java.util.Vector;
import java.util.Random;
import java.util.Date;
/**
* DPL that provides Dummy text of the type "Lorem ipsum.."
* @author wmartinez
*/
public class LingoDPL implements DataProduction{
private Random myRandom = new Random(new Date().getTime());
private Vector vPayloads = new Vector();
private Lingo lingoGen = new Lingo();
private int iPosition = 0;
/** Creates a new instance of LingoDPL */
public LingoDPL() {
}
public void setup() {
// Default of Lingo default size
vPayloads.add(lingoGen.getMessage());
}
public void setup(int messSize) {
// Creates only one message of messSize
vPayloads.add(lingoGen.getMessage(messSize));
}
public void setup(String[] arguments) {
// arguments contains a list of sizes in string form
for (String sSize: arguments) {
int iSize = Integer.parseInt(sSize);
vPayloads.add(lingoGen.getMessage(iSize));
}
}
public Object getData() {
return vPayloads.get(iPosition);
}
public Object getRandomData() {
return vPayloads.get(myRandom.nextInt(vPayloads.size()));
}
public Object getNextData() {
Object sToReturn = vPayloads.get(iPosition++);
if (iPosition == vPayloads.size()){
iPosition = 0;
}
return sToReturn;
}
public Object getDataByIndex(int index) {
if (index >= vPayloads.size())
index = vPayloads.size()-1;
return vPayloads.get(index);
}
public void tearDown() {
vPayloads.clear();
}
}
See an example of the above recipe in the Web Application Tutorial.
Multiple DPLs
Multiple DPLs may be used in one TestScenario, as this example where the <resource> element identifies two data files:
<resources>
<data path="./example_agents/dplCSVExample/csv.txt"/>
<data path="./example_agents/dplCSVExample/otherFile.txt"/>
</resources>
To access the first file (csv.txt):
<argument name="firstfile" dpl="rsc" value="getDataByIndex" index="0"/>
To access the second file (otherFile):
<argument name="secondfile" dpl="rsc" value="getDataByIndex" index="1"/>
To use the CSV DPL, the DPL must created:
<DataSources>
<dpl name="csv" type="CSVDPL">
<argument name="file" dpl="rsc" value="getDataByIndex" index="0"/>
</dpl>
</DataSources>
That definition mapped in Java code:
CSVDPL cvs = new CSVDPL();
Cvs.setup(“/remote_resource_path/cvs.txt”);
This is the definition to access a data row from the CSVDPL:
<run name="CSV example 1" testclass="simple.print" method="print" langtype="java">
argument name="arrayString" dpl="csv" value=" getDataByIndex" index="0"/>
</run>
<run name="CSV example 1" testclass="simple.print" method="print" langtype="java">
argument name="arrayString" dpl="csv" value=" getDataByIndex" index="1"/>
</run>
<run name="CSV example 2" testclass="simple.print" method="print" langtype="java">
argument name="arrayString" dpl="csv" value=" getDataByIndex" index="0"/>
</run>
That definition mapped in Java code:
simple.print spr = new simple.print();
spr.print (new String[] { “Name”, “age” , “eye color”, “hair color” };
spr.print (new String[] { “Pepe”, “24”, “black”, “red” };
simple.print spr2 = new simple.print ();
spr2.print (new String[] { “Name”, “age”, “eye color”, “hair color” };
Creating Your Own DPL
PushToTest TestMaker's Data Product Library (DPL) is a powerful system to deliver data to tests at runtime. For instance, a test of an on-line registration service stores name and password values in a database and uses a DPL to access the database as the test operates. In a second instance, a test of a reporting service uses a DPL to access a comma-separated-value (CSV) file of acceptable responses to validate service responses.
Creating your own DPL requires Java programming skills and a familiarity with the DPL abstract class definition. Implementing a DPL requires a Java class to implement the standard DPL methods including getNextData, getDataByIndex, and more (example DPL source code and resources can be found in testmaker_home/example_agents/dplExample).
Once you define and compile a custom DPL, use the <DataSources> in a TestScenario document to identify your custom DPL. You may even pass parameters to your DPL at runtime. This TestScenario excerpt shows how to do this:
<DataSources>
<dplDefType name="SimpleDPL" library="./example_agents/dplExample/dplSimple.jar"
lang="java" classname="com.dpl.SimpleDPL"/>
<dpl name="lingo" type="LingoDPL"/>
<dpl name="simple" type="SimpleDPL">
<argument name="argrun2" value="Data"/>
</dpl>
<dpl name="simple" type="SimpleDPL">
<argument name="argrun2" dpl="lingo" value="getNextData"/>
</dpl>
</DataSources>
![]() |
Additional documentation, product downloads and updates are at www.PushToTest.com. While the PushToTest testMaker software is distributed under an open-source license, the documenation remains (c) 2008 PushToTest. All rights reserved. PushToTest is a trademark of the PushToTest company. |

