| DPL Goal | DPL Package Name | Description |
| Lingo DPL, creates pseudo English-like text words and sentences | com.pushtotest.tool.dpl.provided.LingoDPL | Input the number of gibberish words |
| Comma separated value (CSV) file DPL | CSVDPL | Input the path to the CSV file. |
| Relational Database Management System (RDBMS) DPL | RDBMSDPL | Input the URI to the datasource, ID, password, and SQL |
from com.pushtotest.tool.protocolhandler import ProtocolHandler, HTTPProtocol
from com.pushtotest.tool.response import Response
import junit
# Base class of functions that support this test agent
# find this in testmaker_home/lib/agentbase.py
import agentbase
class DPLExample( agentbase.agentbase, junit.framework.TestCase ):
'''
Base class implements abstract methods need by recorded test agent script.
'''
def __init__( self, debuglevel = 0, logto="console", follow_redirects=0, \
successcodes='20.|300|301|302|303|304|307|401|403|408|41.',
\
logpath="log.txt",
sleeptime_min=0, sleeptime_max=0, imagesleeptime=0, \
loadimgtags
= "1", imagecache = "1", agentname="test", openlog=1 ):
''' Initialize this test '''
# Call the agentbase superclass's init method
agentbase.agentbase.__init__( self, debuglevel, logto, follow_redirects, \
successcodes,
logpath, sleeptime_min, sleeptime_max, imagesleeptime, \
loadimgtags,
imagecache, agentname, openlog )
junit.framework.TestCase.__init__(self, agentname)
def setUp( self ):
''' Add any needed set-up code here. '''
self.log( 1, "test: setUp" )
self.config()
def runTest( self, dpl_provided_argument_value ):
''' Run the test '''
self.log( 1, "test: runTest" )
self.params = [ [ '''testinput''', dpl_provided_argument_value ] ]
self.get(
'''http://examples.pushtotest.com/responder/htmlresponder''',
self.params)
def tearDown( self ):
''' Add any needed code to end the test here. '''
self.log( 1, "test: tearDown" )
<DataSources>
<dpl name="lingo" type="LingoDPL">
<argument dpl="lingo" value="1"/>
</dpl>
</DataSources>
<resources>
<module name="DPLExample" path="./example_agents/dplExample/DPLExample.py"/>
</resources>
<run name="test1" testclass="DPLExample" method="runTest" langtype="jython">
<argument name="argrun2" dpl="lingo" value="getNextData"/>
</run>
<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>
Name,Age,Eye Color,Hair Color
Pepe,24,black,red
Heriberto,56,black,blue
Austelina,77,black,yellow
| Name | Age | Eye Color | Hair Color |
| Pepe | 24 | Black | red |
| Heriberto | 56 | Black | blue |
| Austelina | 77 | Black | yellow |
<resources>
<data path="./example_agents/dplCSVExample/csv.txt"/>
<jar path="./example_agents/dplCSVExample/print.jar"/>
</resources>
<DataSources>
<dpl name="csv" type="CSVDPL">
<argument
name="file" dpl="rsc" value="getDataByIndex" index="0"/>
</dpl>
</DataSources>
<messagesizes>
<messagesize value="0"/>
<messagesize value="1"/>
<messagesize value="2"/>
</messagesizes>
<run name="CVS" testclass="com.examples.print" method="print" langtype="java">
<argument name="arg" dpl="csv" value="getNextData"/>
</run>
<run name="CVS" testclass="com.examples.print" method="print" langtype="java">
<argument name="arg" dpl="csv" value="getDataByIndex" index="0" />
</run>
<run name="CVS" testclass="com.examples.print" method="print" langtype="java">
<argument name="arg" dpl="csv" value="getDataByIndex" index="messagesize"/>
</run>
<resources>
<data path="./example_agents/dplCSVExample/csv.txt"/>
<data path="./example_agents/dplCSVExample/otherFile.txt"/>
</resources>
<argument name="firstfile" dpl="rsc" value="getDataByIndex" index="0"/>
<argument name="secondfile" dpl="rsc" value="getDataByIndex" index="1"/>
<DataSources>
<dpl name="csv" type="CSVDPL">
<argument name="file" dpl="rsc" value="getDataByIndex" index="0"/>
</dpl>
</DataSources>
CSVDPL cvs = new CSVDPL();
Cvs.setup(“/remote_resource_path/cvs.txt”);
<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>
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” };
<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>
RDBMSDPL rdbms = new RDBMSDPL();
rdbms.setup(com.mysql.jdbc.Driver”,
"jdbc:mysql://localhost/tmstatus",
" userlogging ",
"12345",
“select * from scenario”);
| Name | Age | Eye Color | Hair Color |
| Pepe | 24 | Black | red |
| Heriberto | 56 | Black | blue |
| Austelina | 77 | Black | yellow |
<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>
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” };
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();
}
}
|