Class StandardGenerator
- All Implemented Interfaces:
- Serializable,- Generator
StandardGenerator will be the default generator used to pre-process logs. It uses JMeter classes to generate the .jmx file. The first version of the utility only generated the HTTP requests as XML, but it required users to copy and paste it into a blank jmx file. Doing that way isn't flexible and would require changes to keep the format in sync.
This version is a completely new class with a totally different implementation, since generating the XML is no longer handled by the generator. The generator is only responsible for handling the parsed results and passing it to the appropriate JMeter class.
 Notes:
 the class needs to first create a thread group and add it to the HashTree.
 Then the samplers should be added to the thread group. Listeners shouldn't be
 added and should be left up to the user. One option is to provide parameters,
 so the user can pass the desired listener to the tool.
- See Also:
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected Fileprotected Stringprotected OutputStreamprotected HTTPSamplerBase
- 
Constructor SummaryConstructorsConstructorDescriptionThe constructor is used by GUI and samplers to generate request objects.StandardGenerator(String file) 
- 
Method SummaryModifier and TypeMethodDescriptionvoidclose()close the generatorThe method is responsible for calling the necessary methods to generate a valid request.protected voidCreate the OutputStream to save the JMX file.voidreset()Reset the HTTPSampler to make sure it is a new instance.voidsave()save must be called to write the jmx file, otherwise it will not be saved.voidThe host is the name of the server.voidThis is the label for the request, which is used in the logs and results.voidThe method is the HTTP request method.voidSet the request parametersvoidThe path is the web page you want to test.voidsetPort(int port) The default port for HTTP is 80, but not all servers run on that port.voidsetQueryString(String querystring) Set the querystring for the request if the method is GET.voidsetSourceLogs(String sourcefile) The source logs is the location where the access log resides.voidThe target can be either a java.io.File or a Sampler.
- 
Field Details- 
SAMPLE
- 
OUTPUT
- 
FILENAME
- 
FILE
 
- 
- 
Constructor Details- 
StandardGeneratorpublic StandardGenerator()The constructor is used by GUI and samplers to generate request objects.
- 
StandardGenerator- Parameters:
- file- name of a file (TODO seems not to be used anywhere)
 
 
- 
- 
Method Details- 
initStreamprotected void initStream()Create the OutputStream to save the JMX file.
- 
closepublic void close()close the generator
- 
setHostThe host is the name of the server.
- 
setLabelThis is the label for the request, which is used in the logs and results.
- 
setMethodThe method is the HTTP request method. It's normally POST or GET.
- 
setParamsSet the request parameters
- 
setPathThe path is the web page you want to test.
- 
setPortpublic void setPort(int port) The default port for HTTP is 80, but not all servers run on that port.
- 
setQueryStringSet the querystring for the request if the method is GET.- Specified by:
- setQueryStringin interface- Generator
- Parameters:
- querystring- query string of the request
 
- 
setSourceLogsThe source logs is the location where the access log resides.- Specified by:
- setSourceLogsin interface- Generator
- Parameters:
- sourcefile- path to the access log file
 
- 
setTargetThe target can be either a java.io.File or a Sampler. We make it generic, so that later on we can use these classes directly from a HTTPSampler.
- 
generateRequestThe method is responsible for calling the necessary methods to generate a valid request. If the generator is used to pre-process access logs, the method wouldn't return anything. If the generator is used by a control element, it should return the correct Sampler class with the required fields set.- Specified by:
- generateRequestin interface- Generator
- Returns:
- prefilled sampler
 
- 
savepublic void save()save must be called to write the jmx file, otherwise it will not be saved.
- 
resetpublic void reset()Reset the HTTPSampler to make sure it is a new instance.The purpose of the reset is so Samplers can explicitly call reset to create a new instance of HTTPSampler. 
 
-