com.bitmechanic.maxq.generator
Class CompactGenerator

java.lang.Object
  extended by com.bitmechanic.maxq.generator.AbstractCodeGenerator
      extended by com.bitmechanic.maxq.generator.CompactGenerator
All Implemented Interfaces:
IScriptGenerator, ProxyServer.Observer, java.lang.Runnable

public class CompactGenerator
extends AbstractCodeGenerator

This class generates scripts in the format required by the CompactTest base class.

IScriptGenerator is too finely grained for our needs so this class is more complicated than it needs to be.

This class improves upon JythonCodeGenerator as follows: - It produces more concise scripts (thanks to a more sophisticated base class). The script will contain only _what_ was recorded, not _how_ to test/playback. - You can restart recording on an existing script.


Field Summary
 
Fields inherited from class com.bitmechanic.maxq.generator.AbstractCodeGenerator
assertNumber, END_STATEMENT, headersExist, jtidyConfigFile
 
Fields inherited from interface com.bitmechanic.maxq.generator.IScriptGenerator
EOL
 
Constructor Summary
CompactGenerator(IScriptAdapter adapter)
           
 
Method Summary
 void doAssertResponse(java.lang.String code)
           
 void doBodyParameterList(Param[] params)
           
 void doCallUrl(java.lang.String url, java.lang.String method, java.lang.String data, java.lang.String contentLength)
           
 void doEndTransaction()
          Called after all other calls for a particular transaction (request + response).
 void doHeaders(HeaderValue[] headers)
           
 void doNew()
          Called when a new script needs to be begun.
 void doParameterList(Param[] params)
          Implementer must add script code for the parameters provided.
 void doQueryStringParameterList(Param[] params)
           
 void doResponseForFile()
           
 void doResponseForStdOut(java.lang.String url)
           
 void doSetCharset(java.lang.String cs)
          Called when the character set for POST requests changes.
 void doSetData(java.lang.String data)
           
 void doStartRecording()
          Called before any processRequest() calls.
 void doStopRecording()
          Called after the last processResponse() call, but may be followed by another doStartRecording() to start the process over again.
 void doTestUrlMessage(java.lang.String url)
           
 void doTidyCode(java.lang.String url)
           
static java.lang.String getGeneratorDescription()
           
 java.lang.String[] getValidFileExtensions()
          Returns an array of valid file extensions for the type of code generator in use.
 void setStruts(boolean struts)
          Called if the processResponse find that the response contains the Struts token
 
Methods inherited from class com.bitmechanic.maxq.generator.AbstractCodeGenerator
close, doLoad, doSave, getDefaultTestName, getScript, getScriptAdapter, getTestName, getTestPath, getTimeElapsedSinceLastestRequest, insert, isCpRspToFile, isCpRspToStdout, isFirstRequest, parseTestName, processRequest, processResponse, run, setDefaultTestName, setTestName, setTestPath
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CompactGenerator

public CompactGenerator(IScriptAdapter adapter)
Method Detail

setStruts

public void setStruts(boolean struts)
Description copied from class: AbstractCodeGenerator
Called if the processResponse find that the response contains the Struts token

Specified by:
setStruts in class AbstractCodeGenerator

getGeneratorDescription

public static java.lang.String getGeneratorDescription()

doNew

public void doNew()
Description copied from interface: IScriptGenerator
Called when a new script needs to be begun. This will not be called when an existing script is loaded from file.

The script should output its full class name during this call to ensure that its generator can be recognised if it is saved and reloaded.


doStartRecording

public void doStartRecording()
Description copied from interface: IScriptGenerator
Called before any processRequest() calls.


doStopRecording

public void doStopRecording()
Description copied from interface: IScriptGenerator
Called after the last processResponse() call, but may be followed by another doStartRecording() to start the process over again.


getValidFileExtensions

public java.lang.String[] getValidFileExtensions()
Description copied from interface: IScriptGenerator
Returns an array of valid file extensions for the type of code generator in use.

Returns:
array of valid file extentions

doParameterList

public void doParameterList(Param[] params)
Description copied from class: AbstractCodeGenerator
Implementer must add script code for the parameters provided. This will only be called if there is at least one parameter.

Specified by:
doParameterList in class AbstractCodeGenerator
Parameters:
params - Query string and body parameters, without distinction.

doCallUrl

public void doCallUrl(java.lang.String url,
                      java.lang.String method,
                      java.lang.String data,
                      java.lang.String contentLength)
Specified by:
doCallUrl in class AbstractCodeGenerator

doAssertResponse

public void doAssertResponse(java.lang.String code)
Specified by:
doAssertResponse in class AbstractCodeGenerator

doEndTransaction

public void doEndTransaction()
                      throws Utils.UserException
Description copied from class: AbstractCodeGenerator
Called after all other calls for a particular transaction (request + response).

Specified by:
doEndTransaction in class AbstractCodeGenerator
Throws:
Utils.UserException

doSetCharset

public void doSetCharset(java.lang.String cs)
                  throws Utils.UserException
Description copied from class: AbstractCodeGenerator
Called when the character set for POST requests changes.

Specified by:
doSetCharset in class AbstractCodeGenerator
Throws:
Utils.UserException

doHeaders

public void doHeaders(HeaderValue[] headers)
Specified by:
doHeaders in class AbstractCodeGenerator

doTestUrlMessage

public void doTestUrlMessage(java.lang.String url)
Specified by:
doTestUrlMessage in class AbstractCodeGenerator

doSetData

public void doSetData(java.lang.String data)
Specified by:
doSetData in class AbstractCodeGenerator

doTidyCode

public void doTidyCode(java.lang.String url)
Specified by:
doTidyCode in class AbstractCodeGenerator

doResponseForStdOut

public void doResponseForStdOut(java.lang.String url)
Specified by:
doResponseForStdOut in class AbstractCodeGenerator

doResponseForFile

public void doResponseForFile()
Specified by:
doResponseForFile in class AbstractCodeGenerator

doQueryStringParameterList

public void doQueryStringParameterList(Param[] params)
                                throws Utils.UserException
Specified by:
doQueryStringParameterList in class AbstractCodeGenerator
Parameters:
params - Query string parameters.
Throws:
Utils.UserException

doBodyParameterList

public void doBodyParameterList(Param[] params)
                         throws Utils.UserException
Specified by:
doBodyParameterList in class AbstractCodeGenerator
Parameters:
params - Body parameters.
Throws:
Utils.UserException