Reading multiple datasets from a functional test script
You can use the dynamic find() API to read multiple datasets from a functional test script.
This sample code shows you how to read more than one dataset 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 dataset
firstdataset();
}
public void firstdataset(){
//Get a value from the first dataset at the Test Script Level.
String address = dpString("Address");
System.out.println(" -- Address from the 'script' associated dataset: " + address);
//Call the second dataset
Seconddataset();
}
public void Seconddataset() {
// Point to the dataset location that was created
java.io.File dpFile = new java.io.File(
(String) getOption(IOptionName.DATASTORE), "/UserDetails.rftdp");
// Load the dataset using FT IdatasetFactory
Idataset dataset_two = dpFactory().load(dpFile, true);
// Open the dataset using FT IdatasetFactory
IdatasetIterator dataset_Ite_2 = dpFactory().open(dataset_two, null);
// After it is opened, initilize the dataset to access the data
dataset_Ite_2.dpInitialize(dataset_two);
// Get a value from the second dataset, first record
String firstName = dataset_Ite_2.dpString("FirstName");
// Redirect the output to console or use logInfo method
System.out.println(" -- First Name from the Second dataset: "
+ firstName);
}
}