Reading multiple datapools from a functional test script
You can use the dynamic find() API to read multiple datapools
from a functional test script.
This sample code shows you how to read more than one datapool from a functional test
script.
public class UserInformation extends UserInformationHelper {
/**
* Script Name : UserInformation Generated : Sep 6, 2011 3:57:48
* PM Description : Functional Test Script Original Host : WinNT Version
* 5.1 Build 2600 (S)
*
* @since 2011/09/06
* @author user1
*/
public void testMain(Object[] args) throws Exception {
//User defined function to load more then on DataPool
firstDataPool();
}
public void firstDataPool(){
//Get a value from the first datapool at the Test Script Level.
String address = dpString("Address");
System.out.println(" -- Address from the 'script' associated dataPool: " + address);
//Call the second datapool
SecondDataPool();
}
public void SecondDataPool() {
// Point to the datapool location that was created
java.io.File dpFile = new java.io.File(
(String) getOption(IOptionName.DATASTORE), "/UserDetails.rftdp");
// Load the datapool using FT IDataPoolFactory
IDatapool dataPool_two = dpFactory().load(dpFile, true);
// Open the datapool using FT IDataPoolFactory
IDatapoolIterator dataPool_Ite_2 = dpFactory().open(dataPool_two, null);
// After it is opened, initilize the datapool to access the data
dataPool_Ite_2.dpInitialize(dataPool_two);
// Get a value from the second datapool, first record
String firstName = dataPool_Ite_2.dpString("FirstName");
// Redirect the output to console or use logInfo method
System.out.println(" -- First Name from the Second DataPool: "
+ firstName);
}
}