Definition

The GenericTemplateFileReceiver uses a template file which can be of any type (JSON, XML, CSV, etc.), consisting of a set of tags that are defined as placeholders which can be replaced by GenRocket generated test data during the generation process.


Parameters

The GenericTemplateFileReceiver requires that the following parameters are defined:

  • outputPath - Defines the path of the output directory.
  • outputSubDirectory - Defines the sub-directory within the output directory to store the generated output file.
  • outputName - Defines the name of the output file.
  • templatePath - Defines the location of the template file.
  • templateSubDirectory - Defines the sub-directory location within the template directory to read the template file.
  • templateName - Defines the name of the template file.
  • filesPerDirectory - Defines the number of output files to be created per directory.
  • modifyFile - If set to True, the GenericTemplateFileReceiver will read each file per loopCount from the Output path and update the tags present in the file with attribute values and, if set to False, the receiver will create a new file at the output location by reading a default Template file from the Template path.


Template File - Example

1) The following is an example of JSON template file containing the set of tags; these set of tags represent GenRocket Domain Attribute name enclosed with '@' as a placeholders. Here, these four tags- @id@, @firstName@, @username@, @password@ are defined which will be replaced by a generated value from a GenRocket Domain containing Attributes matching the names of each tag.


  [
    {
      "id" : "@User.id@",
      "firstName" : "@firstName@",
      "lastName" : "Abell",
      "middleInitial" : "D",
      "username" : "@username@",
      "password" : "@password@"
    }
  ]


2) The following is an example of XML template file containing the set of tags; these set of tags represent GenRocket Domain Attribute name enclosed with '@' as a placeholders. Here, these three tags- @id@, @username@, @password@ are defined which will be replaced by a generated value from a GenRocket Domain containing Attributes matching the names of each tag.


<rows>
  <row id="@User.id@" firstName="Sharonda" lastName="Abell" middleInitial="D" username="@username@" password="@password@"/>
</rows>


Example Domain

The following is an example of GenRocket Domain containing the set of Attributes that matches with the tags defined within the template files.

 

Domain - User

  • Attributes 
    • id- RangeGen Generator 
      • startRange = 100
    • firstName- NameGen Generator
    • lastName- NameGen Generator
    • middleInitial- AlphabetGen Generator
    • username- UsernameGen Generator
    • password- EncryptGen Generator



Example Scenario

If the example Scenario were to specify its loopCount equal to 2, then two rows data would be replicated to a two new files consisting of each row data per file.  The resulting file will contain the following set of values (the data values may be different).


1) Resulting JSON format files.


  • File #1 (Result-1.json):
  [
    {
      "id" : "100",
      "firstName" : "Kristina",
      "lastName" : "Abell",
      "middleInitial" : "D",
      "username" : "user100",
      "password" : "AD57366865126E55649ECB23AE1D48887544976EFEA46A48EB5D85A6EEB4D306"
    }
  ]


  • File #2 (Result-2.json):
  [
    {
      "id" : "101",
      "firstName" : "Angel",
      "lastName" : "Abell",
      "middleInitial" : "D",
      "username" : "user101",
      "password" : "16DC368A89B428B2485484313BA67A3912CA03F2B2B42429174A4F8B3DC84E44"
    }
  ]


2) Resulting XML format files.


  • File #1 (Result-1.xml):
<rows>
  <row id="100" firstName="Sharonda" lastName="Abell" middleInitial="D" username="user100" password="AD57366865126E55649ECB23AE1D48887544976EFEA46A48EB5D85A6EEB4D306"/>
</rows>


  • File #2 (Result-2.xml):
<rows>
  <row id="101" firstName="Sharonda" lastName="Abell" middleInitial="D" username="user101" password="16DC368A89B428B2485484313BA67A3912CA03F2B2B42429174A4F8B3DC84E44"/>
</rows>