com.bitmechanic.maxq.generator
Class TemplateCodeGenerator

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

public class TemplateCodeGenerator
extends java.lang.Object
implements IScriptGenerator

Template based code generator.

Version:
$Id: TemplateCodeGenerator.java,v 1.2 2005/05/04 12:46:17 rkrzewsk Exp $
Author:
Rafal Krzewski, MaxQ community

Field Summary
 
Fields inherited from interface com.bitmechanic.maxq.generator.IScriptGenerator
EOL
 
Constructor Summary
TemplateCodeGenerator(IScriptAdapter script)
          Creates new TempateCodeGenerator instance.
 
Method Summary
 void close()
          Called when a generator is no longer needed.
 void doLoad()
          Called after a new script has been loaded from file.
 void doNew()
          Called when a new script needs to be begun.
 void doSave(java.lang.String path, java.lang.String name)
          Notifies the generator that the script is about to be saved.
 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.
static java.lang.String getGeneratorDescription()
          Returns brief description of the generator.
 java.lang.String[] getValidFileExtensions()
          Returns an array of valid file extensions for the type of code generator in use.
 java.lang.String parseTestName()
          Parses the name of the test out of the script.
 void processRequest(HttpRequestHeader header, byte[] body)
          
 void processResponse(HttpRequestHeader header, byte[] body)
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TemplateCodeGenerator

public TemplateCodeGenerator(IScriptAdapter script)
Creates new TempateCodeGenerator instance.

Parameters:
script - the script adapter.
Method Detail

getGeneratorDescription

public static java.lang.String getGeneratorDescription()
Returns brief description of the generator.

Returns:
brief description of the generator.

getValidFileExtensions

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

Specified by:
getValidFileExtensions in interface IScriptGenerator
Returns:
array of valid file extentions

parseTestName

public java.lang.String parseTestName()
Parses the name of the test out of the script.

Specified by:
parseTestName in interface IScriptGenerator
Returns:
test name if test has been loaded or saved. Empty otherwise.

doStartRecording

public void doStartRecording()
Called before any processRequest() calls.

Specified by:
doStartRecording in interface IScriptGenerator

doStopRecording

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

Specified by:
doStopRecording in interface IScriptGenerator

doNew

public void doNew()
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.

Specified by:
doNew in interface IScriptGenerator

doSave

public void doSave(java.lang.String path,
                   java.lang.String name)
Notifies the generator that the script is about to be saved. This gives it the opportunity to patch the script to include the new filename.

Specified by:
doSave in interface IScriptGenerator

doLoad

public void doLoad()
Called after a new script has been loaded from file.

Specified by:
doLoad in interface IScriptGenerator

close

public void close()
Called when a generator is no longer needed.

Specified by:
close in interface IScriptGenerator

processRequest

public void processRequest(HttpRequestHeader header,
                           byte[] body)
                    throws java.lang.Exception

Specified by:
processRequest in interface ProxyServer.Observer
Throws:
java.lang.Exception

processResponse

public void processResponse(HttpRequestHeader header,
                            byte[] body)
                     throws java.lang.Exception

Specified by:
processResponse in interface ProxyServer.Observer
Throws:
java.lang.Exception